data: removed Singleton from Dictionary and made it a member of SearchIndex

Dictionary never had a good reason of being a Singleton in the first place so this will avoid concurrency and
structural issues in the future.
This commit is contained in:
Eberhard Graether
2014-09-30 22:10:42 +02:00
parent 95ece9ef2e
commit 390df1db1f
13 changed files with 128 additions and 103 deletions
@@ -1,11 +1,8 @@
#include "data/graph/token_component/TokenComponentSignature.h"
#include "utility/text/Dictionary.h"
std::shared_ptr<TokenComponentSignature> TokenComponentSignature::create(const std::string& signature)
TokenComponentSignature::TokenComponentSignature(Id wordId)
: m_wordId(wordId)
{
return std::shared_ptr<TokenComponentSignature>(
new TokenComponentSignature(Dictionary::getInstance()->getWordId(signature)));
}
TokenComponentSignature::~TokenComponentSignature()
@@ -17,17 +14,12 @@ std::shared_ptr<TokenComponent> TokenComponentSignature::copy() const
return std::make_shared<TokenComponentSignature>(*this);
}
const std::string& TokenComponentSignature::getSignature() const
Id TokenComponentSignature::getWordId() const
{
return Dictionary::getInstance()->getWord(m_wordId);
return m_wordId;
}
bool TokenComponentSignature::operator==(const TokenComponentSignature& other) const
{
return m_wordId == other.m_wordId;
}
TokenComponentSignature::TokenComponentSignature(Id wordId)
: m_wordId(wordId)
{
}
@@ -1,9 +1,6 @@
#ifndef TOKEN_COMPONENT_SIGNATURE_H
#define TOKEN_COMPONENT_SIGNATURE_H
#include <memory>
#include <string>
#include "data/graph/token_component/TokenComponent.h"
#include "utility/types.h"
@@ -11,19 +8,16 @@ class TokenComponentSignature
: public TokenComponent
{
public:
static std::shared_ptr<TokenComponentSignature> create(const std::string& signature);
TokenComponentSignature(Id wordId);
virtual ~TokenComponentSignature();
virtual std::shared_ptr<TokenComponent> copy() const;
const std::string& getSignature() const;
Id getWordId() const;
bool operator==(const TokenComponentSignature& other) const;
private:
TokenComponentSignature(Id wordId);
const Id m_wordId;
};