data: saving graph nodes with short name only

This change saves only the short names in the node, getName() no only gives the short version. The fullName is assembled
from the parent nodes on demand using the getFullName() method.
This commit is contained in:
Eberhard Graether
2014-07-26 14:58:06 +02:00
parent 641acc2bde
commit 68c6ede244
9 changed files with 268 additions and 75 deletions
+46 -2
View File
@@ -46,6 +46,19 @@ const std::string& Node::getName() const
return m_name;
}
std::string Node::getFullName() const
{
Node* parent = getParentNode();
if (parent)
{
return parent->getFullName() + "::" + m_name;
}
else
{
return m_name;
}
}
const std::vector<Edge*>& Node::getEdges() const
{
return m_edges;
@@ -90,7 +103,7 @@ Edge* Node::findEdge(std::function<bool(Edge*)> func) const
return *it;
}
return NULL;
return nullptr;
}
Edge* Node::findEdgeOfType(Edge::EdgeType type) const
@@ -116,7 +129,28 @@ Edge* Node::findEdgeOfType(Edge::EdgeType type, std::function<bool(Edge*)> func)
return *it;
}
return NULL;
return nullptr;
}
Node* Node::findChildNode(std::function<bool(Node*)> func) const
{
std::vector<Edge*>::const_iterator it = find_if(m_edges.begin(), m_edges.end(),
[&func](Edge* e)
{
if (e->getType() == Edge::EDGE_MEMBER)
{
return func(e->getTo());
}
return false;
}
);
if (it != m_edges.end())
{
return (*it)->getTo();
}
return nullptr;
}
void Node::forEachEdge(std::function<void(Edge*)> func) const
@@ -137,6 +171,16 @@ void Node::forEachEdgeOfType(Edge::EdgeType type, std::function<void(Edge*)> fun
);
}
void Node::forEachChildNode(std::function<void(Node*)> func) const
{
forEachEdgeOfType(Edge::EDGE_MEMBER,
[func](Edge* e)
{
func(e->getTo());
}
);
}
bool Node::isNode() const
{
return true;