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
+18 -5
View File
@@ -180,7 +180,7 @@ public:
TS_ASSERT_EQUALS(paramEdge->getTo()->getFullName(), "char");
TS_ASSERT(node->getComponent<TokenComponentSignature>());
TS_ASSERT_EQUALS(node->getComponent<TokenComponentSignature>()->getSignature(), "isTrue(char)");
TS_ASSERT_EQUALS(storage.getWord(node->getComponent<TokenComponentSignature>()->getWordId()), "isTrue(char)");
std::vector<TokenLocation*> locations = storage.getLocationsForId(id);
TS_ASSERT_EQUALS(locations.size(), 2);
@@ -214,7 +214,7 @@ public:
TS_ASSERT_EQUALS(paramEdge->getTo()->getFullName(), "bool");
TS_ASSERT(node->getComponent<TokenComponentSignature>());
TS_ASSERT_EQUALS(node->getComponent<TokenComponentSignature>()->getSignature(), "isMethod(bool)");
TS_ASSERT_EQUALS(storage.getWord(node->getComponent<TokenComponentSignature>()->getWordId()), "isMethod(bool)");
std::vector<TokenLocation*> locations = storage.getLocationsForId(id);
TS_ASSERT_EQUALS(locations.size(), 2);
@@ -511,17 +511,30 @@ private:
public:
Node* getNodeWithId(Id id) const
{
return dynamic_cast<Node*>(getTokenWithId(id));
return dynamic_cast<Node*>(getGraph().getTokenById(id));
}
Edge* getEdgeWithId(Id id) const
{
return dynamic_cast<Edge*>(getTokenWithId(id));
return dynamic_cast<Edge*>(getGraph().getTokenById(id));
}
std::vector<TokenLocation*> getLocationsForId(Id id) const
{
return getTokenLocationsForId(id);
const std::vector<Id>& locationIds = getGraph().getTokenById(id)->getLocationIds();
std::vector<TokenLocation*> result;
for (Id locationId : locationIds)
{
result.push_back(getTokenLocationCollection().findTokenLocationById(locationId));
}
return result;
}
const std::string& getWord(Id wordId) const
{
return getSearchIndex().getWord(wordId);
}
};