Files
Sourcetrail/src/lib/data/graph/Token.cpp
T
Eberhard Graether 2044ff9723 data: cleaned up Graph classes
* removed self assignment of id from Token
* removed FilterableGraph interface from Graph
* creating Nodes and Edges on Graph with addNode and addGraph methods
* removed obsolete Aggregation edge filtering
* fixed clang warnings
* fixed memory leak for Node creation
2015-08-27 17:25:52 +02:00

57 lines
940 B
C++

#include "data/graph/Token.h"
#include "data/location/TokenLocation.h"
#include "utility/logging/logging.h"
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);
}