Files
Sourcetrail/src/lib/data/graph/Token.cpp
T
malte_langkabel e628241b02 data: database storage
* replaced storage by a new version that utilizes sqlite for persistence.
* added SqliteStorage to manage direct access to the database.
* added testsuit for sqlite.
* slimmed down the protected interface of the storage.
* changed tests in StorageTestSuit to avoid using protected methods of the storage.
* added functions to begin and commit a transaction to the storage.
* removed GraphFilterTestSuite.
* removed GraphFilterConductorTestSuite.
* added Node and Edge constructor that takes id as parameter
* added constructor for TokenComponentNameCached that accepts NameHierarchy as parameter
* added TokenLocation constructor that takes locationId as parameter.
* created respective construction functions in TokenLocatonLine, -File and -Collection.

fortune cookie message = Recognition will come from unexpected sources.
2015-08-25 18:07:02 +02:00

69 lines
1.1 KiB
C++

#include "data/graph/Token.h"
#include "data/location/TokenLocation.h"
#include "utility/logging/logging.h"
void Token::resetNextId()
{
s_nextId = 1;
}
Token::Token() // TODO: remove this constructor
: m_id(s_nextId++)
{
}
Token::Token(Id id)
: m_id(id)
{
}
Token::~Token()
{
}
Id Token::getId() const
{
return m_id;
}
const std::vector<Id>& Token::getLocationIds() const
{
return m_locationIds;
}
void Token::addLocationId(Id locationId)
{
m_locationIds.push_back(locationId);
}
void Token::removeLocationId(Id locationId)
{
for (std::vector<Id>::const_iterator it = m_locationIds.begin(); it != m_locationIds.end(); it++)
{
if (*it == locationId)
{
m_locationIds.erase(it);
return;
}
}
LOG_ERROR("Location Id was not referenced by this Token.");
}
Token::Token(const Token& other)
: m_id(other.m_id)
{
for (std::shared_ptr<TokenComponent> component: other.m_components)
{
addComponent(component->copy());
}
}
void Token::addComponent(std::shared_ptr<TokenComponent> component)
{
m_components.push_back(component);
}
Id Token::s_nextId = 1;