ui: graph edges clickable
The graph views edges are now clickable. On click the edge and its connected nodes will be displayed. fortune cookie message = Be prepared to accept an exciting opportunity in the future.
This commit is contained in:
@@ -24,6 +24,7 @@ QtGraphView::QtGraphView(ViewLayout* viewLayout)
|
||||
m_edgeColors.push_back(Vec4i(73, 155, 222, 255)); // type
|
||||
m_edgeColors.push_back(Vec4i(231, 65, 65, 255)); // return
|
||||
m_edgeColors.push_back(Vec4i(227, 180, 68, 255)); // parameter
|
||||
m_edgeColors.push_back(Vec4i(113, 96, 191, 255)); // inheritance
|
||||
}
|
||||
|
||||
QtGraphView::~QtGraphView()
|
||||
@@ -240,7 +241,7 @@ std::shared_ptr<QtGraphEdge> QtGraphView::createEdge(QGraphicsView* view, const
|
||||
|
||||
if(owner != NULL && target != NULL)
|
||||
{
|
||||
std::shared_ptr<QtGraphEdge> qtEdge = std::make_shared<QtGraphEdge>(owner, target);
|
||||
std::shared_ptr<QtGraphEdge> qtEdge = std::make_shared<QtGraphEdge>(owner, target, edge.tokenId);
|
||||
|
||||
switch(edge.edgeType)
|
||||
{
|
||||
@@ -259,6 +260,9 @@ std::shared_ptr<QtGraphEdge> QtGraphView::createEdge(QGraphicsView* view, const
|
||||
case Edge::EdgeType::EDGE_PARAMETER_TYPE_OF:
|
||||
qtEdge->setColor(m_edgeColors[4]);
|
||||
break;
|
||||
case Edge::EdgeType::EDGE_INHERITANCE:
|
||||
qtEdge->setColor(m_edgeColors[5]);
|
||||
break;
|
||||
default:
|
||||
qtEdge->setColor(Vec4i(0, 0, 0, 255));
|
||||
}
|
||||
|
||||
@@ -5,8 +5,9 @@
|
||||
|
||||
#include "component/view/graphElements/GraphNode.h"
|
||||
|
||||
QtGraphEdge::QtGraphEdge(const std::weak_ptr<GraphNode>& owner, const std::weak_ptr<GraphNode>& target)
|
||||
: m_owner(owner)
|
||||
QtGraphEdge::QtGraphEdge(const std::weak_ptr<GraphNode>& owner, const std::weak_ptr<GraphNode>& target, const Id id)
|
||||
: GraphEdge(id)
|
||||
, m_owner(owner)
|
||||
, m_target(target)
|
||||
, m_color(0, 0, 0, 0)
|
||||
{
|
||||
@@ -99,3 +100,9 @@ Vec4i QtGraphEdge::getColor() const
|
||||
{
|
||||
return m_color;
|
||||
}
|
||||
|
||||
void QtGraphEdge::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event)
|
||||
{
|
||||
MessageActivateToken message(m_tokenId);
|
||||
message.dispatch();
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
|
||||
#include "qgraphicsitem.h"
|
||||
|
||||
#include "utility/messaging/type/MessageActivateToken.h"
|
||||
|
||||
#include "component/view/graphElements/GraphEdge.h"
|
||||
|
||||
class GraphNode;
|
||||
@@ -14,7 +16,7 @@ class QtGraphEdge:
|
||||
public QGraphicsLineItem
|
||||
{
|
||||
public:
|
||||
QtGraphEdge(const std::weak_ptr<GraphNode>& owner, const std::weak_ptr<GraphNode>& target);
|
||||
QtGraphEdge(const std::weak_ptr<GraphNode>& owner, const std::weak_ptr<GraphNode>& target, const Id id);
|
||||
virtual ~QtGraphEdge();
|
||||
|
||||
virtual void ownerMoved();
|
||||
@@ -28,6 +30,8 @@ public:
|
||||
virtual void setColor(const Vec4i& color);
|
||||
virtual Vec4i getColor() const;
|
||||
|
||||
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event);
|
||||
|
||||
private:
|
||||
std::weak_ptr<GraphNode> m_owner;
|
||||
std::weak_ptr<GraphNode> m_target;
|
||||
|
||||
@@ -34,15 +34,23 @@ void GraphController::createDummyGraph(const Id activeId, const LayoutFunction l
|
||||
if (view != NULL)
|
||||
{
|
||||
std::vector<DummyNode> nodes;
|
||||
std::vector<DummyEdge> edges;
|
||||
|
||||
nodes.push_back(createDummyNode(activeId));
|
||||
|
||||
std::vector<DummyNode> neighbours = createNeighbourNodes(nodes[0]);
|
||||
nodes.insert(nodes.end(), neighbours.begin(), neighbours.end());
|
||||
if(m_graphAccess->checkTokenIsNode(activeId))
|
||||
{
|
||||
nodes.push_back(createDummyNode(activeId));
|
||||
std::vector<DummyNode> neighbours = createNeighbourNodes(nodes[0]);
|
||||
nodes.insert(nodes.end(), neighbours.begin(), neighbours.end());
|
||||
}
|
||||
else
|
||||
{
|
||||
std::pair<Id, Id> nodeIds = m_graphAccess->getNodesOfEdge(activeId);
|
||||
nodes.push_back(createDummyNode(nodeIds.first));
|
||||
nodes.push_back(createDummyNode(nodeIds.second));
|
||||
}
|
||||
|
||||
layoutFunction(nodes);
|
||||
|
||||
std::vector<DummyEdge> edges;
|
||||
edges = createEdges(nodes);
|
||||
|
||||
view->rebuildGraph(nodes, edges);
|
||||
@@ -62,13 +70,13 @@ DummyNode GraphController::createDummyNode(const Id nodeId)
|
||||
|
||||
Id GraphController::findTopLevelNode(const Id nodeId)
|
||||
{
|
||||
std::vector<std::pair<Id, Id>> memberEdges = m_graphAccess->getMemberEdgesOfNode(nodeId);
|
||||
std::vector<std::tuple<Id, Id, Id>> memberEdges = m_graphAccess->getMemberEdgesOfNode(nodeId);
|
||||
|
||||
for(unsigned int i = 0; i < memberEdges.size(); i++)
|
||||
{
|
||||
if(memberEdges[i].first != nodeId)
|
||||
if(std::get<0>(memberEdges[i]) != nodeId)
|
||||
{
|
||||
return findTopLevelNode(memberEdges[i].first);
|
||||
return findTopLevelNode(std::get<0>(memberEdges[i]));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,13 +90,12 @@ DummyNode GraphController::buildNodeTopDown(const Id nodeId)
|
||||
result.name = m_graphAccess->getNameForNodeWithId(nodeId);
|
||||
result.tokenId = nodeId;
|
||||
|
||||
std::vector<std::pair<Id, Id>> memberEdges = m_graphAccess->getMemberEdgesOfNode(nodeId);
|
||||
|
||||
std::vector<std::tuple<Id, Id, Id>> memberEdges = m_graphAccess->getMemberEdgesOfNode(nodeId);
|
||||
for(unsigned int i = 0; i < memberEdges.size(); i++)
|
||||
{
|
||||
if(memberEdges[i].second != nodeId)
|
||||
if(std::get<1>(memberEdges[i]) != nodeId)
|
||||
{
|
||||
result.subNodes.push_back(buildNodeTopDown(memberEdges[i].second));
|
||||
result.subNodes.push_back(buildNodeTopDown(std::get<1>(memberEdges[i])));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,12 +106,13 @@ std::vector<DummyNode> GraphController::createNeighbourNodes(const Id nodeId)
|
||||
{
|
||||
std::vector<DummyNode> result;
|
||||
|
||||
std::vector<std::pair<Id, Id>> edges;
|
||||
std::vector<std::pair<Id, Id>> callEdges = m_graphAccess->getCallEdgesOfNode(nodeId);
|
||||
std::vector<std::pair<Id, Id>> usageEdges = m_graphAccess->getUsageEdgesOfNode(nodeId);
|
||||
std::vector<std::pair<Id, Id>> typeOfEdges = m_graphAccess->getTypeOfEdgesOfNode(nodeId);
|
||||
std::vector<std::pair<Id, Id>> returnTypeEdges = m_graphAccess->getReturnTypeOfEdgesOfNode(nodeId);
|
||||
std::vector<std::pair<Id, Id>> parameterEdges = m_graphAccess->getParameterOfEdgesOfNode(nodeId);
|
||||
std::vector<std::tuple<Id, Id, Id>> edges;
|
||||
std::vector<std::tuple<Id, Id, Id>> callEdges = m_graphAccess->getCallEdgesOfNode(nodeId);
|
||||
std::vector<std::tuple<Id, Id, Id>> usageEdges = m_graphAccess->getUsageEdgesOfNode(nodeId);
|
||||
std::vector<std::tuple<Id, Id, Id>> typeOfEdges = m_graphAccess->getTypeOfEdgesOfNode(nodeId);
|
||||
std::vector<std::tuple<Id, Id, Id>> returnTypeEdges = m_graphAccess->getReturnTypeOfEdgesOfNode(nodeId);
|
||||
std::vector<std::tuple<Id, Id, Id>> parameterEdges = m_graphAccess->getParameterOfEdgesOfNode(nodeId);
|
||||
std::vector<std::tuple<Id, Id, Id>> inheritanceEdges = m_graphAccess->getInheritanceEdgesOfNode(nodeId);
|
||||
|
||||
if(callEdges.size() > 0)
|
||||
{
|
||||
@@ -126,16 +134,20 @@ std::vector<DummyNode> GraphController::createNeighbourNodes(const Id nodeId)
|
||||
{
|
||||
edges.insert(edges.end(), parameterEdges.begin(), parameterEdges.end());
|
||||
}
|
||||
if(inheritanceEdges.size() > 0)
|
||||
{
|
||||
edges.insert(edges.end(), inheritanceEdges.begin(), inheritanceEdges.end());
|
||||
}
|
||||
|
||||
for(unsigned int i = 0; i < edges.size(); i++)
|
||||
{
|
||||
if(edges[i].first == nodeId)
|
||||
if(std::get<0>(edges[i]) == nodeId)
|
||||
{
|
||||
result.push_back(createDummyNode(edges[i].second));
|
||||
result.push_back(createDummyNode(std::get<1>(edges[i])));
|
||||
}
|
||||
else
|
||||
{
|
||||
result.push_back(createDummyNode(edges[i].first));
|
||||
result.push_back(createDummyNode(std::get<0>(edges[i])));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,9 +190,23 @@ std::vector<DummyEdge> GraphController::createEdges(const std::vector<DummyNode>
|
||||
std::vector<DummyEdge> result;
|
||||
|
||||
std::unordered_set<Id> nodeIds; // to help discard edges that point to non-existing nodes in the sub-graph
|
||||
std::queue<DummyNode> nodeQueue;
|
||||
for(unsigned int i = 0; i < nodes.size(); i++)
|
||||
{
|
||||
nodeIds.insert(nodes[i].tokenId);
|
||||
nodeQueue.push(nodes[i]);
|
||||
}
|
||||
|
||||
while(nodeQueue.size() > 0)
|
||||
{
|
||||
DummyNode n = nodeQueue.front();
|
||||
nodeQueue.pop();
|
||||
|
||||
for(unsigned int i = 0; i < n.subNodes.size(); i++)
|
||||
{
|
||||
nodeQueue.push(n.subNodes[i]);
|
||||
}
|
||||
|
||||
nodeIds.insert(n.tokenId);
|
||||
}
|
||||
|
||||
std::set<DummyEdge> tmpEdges; // to make it easier to keep the edges unique
|
||||
@@ -211,31 +237,36 @@ std::set<DummyEdge> GraphController::getNeighbourEdgesOfNode(const DummyNode& no
|
||||
{
|
||||
std::set<DummyEdge> result;
|
||||
|
||||
std::vector<std::pair<Id, Id>> callEdges = m_graphAccess->getCallEdgesOfNode(node.tokenId);
|
||||
std::vector<std::pair<Id, Id>> usageEdges = m_graphAccess->getUsageEdgesOfNode(node.tokenId);
|
||||
std::vector<std::pair<Id, Id>> typeOfEdges = m_graphAccess->getTypeOfEdgesOfNode(node.tokenId);
|
||||
std::vector<std::pair<Id, Id>> returnTypeEdges = m_graphAccess->getReturnTypeOfEdgesOfNode(node.tokenId);
|
||||
std::vector<std::pair<Id, Id>> parameterEdges = m_graphAccess->getParameterOfEdgesOfNode(node.tokenId);
|
||||
std::vector<std::tuple<Id, Id, Id>> callEdges = m_graphAccess->getCallEdgesOfNode(node.tokenId);
|
||||
std::vector<std::tuple<Id, Id, Id>> usageEdges = m_graphAccess->getUsageEdgesOfNode(node.tokenId);
|
||||
std::vector<std::tuple<Id, Id, Id>> typeOfEdges = m_graphAccess->getTypeOfEdgesOfNode(node.tokenId);
|
||||
std::vector<std::tuple<Id, Id, Id>> returnTypeEdges = m_graphAccess->getReturnTypeOfEdgesOfNode(node.tokenId);
|
||||
std::vector<std::tuple<Id, Id, Id>> parameterEdges = m_graphAccess->getParameterOfEdgesOfNode(node.tokenId);
|
||||
std::vector<std::tuple<Id, Id, Id>> inheritanceEdges = m_graphAccess->getInheritanceEdgesOfNode(node.tokenId);
|
||||
|
||||
for(unsigned int i = 0; i < callEdges.size(); i++)
|
||||
{
|
||||
result.insert(DummyEdge(callEdges[i].first, callEdges[i].second, Edge::EdgeType::EDGE_CALL));
|
||||
result.insert(DummyEdge(std::get<0>(callEdges[i]), std::get<1>(callEdges[i]), std::get<2>(callEdges[i]), Edge::EdgeType::EDGE_CALL));
|
||||
}
|
||||
for(unsigned int i = 0; i < usageEdges.size(); i++)
|
||||
{
|
||||
result.insert(DummyEdge(usageEdges[i].first, usageEdges[i].second, Edge::EdgeType::EDGE_USAGE));
|
||||
result.insert(DummyEdge(std::get<0>(usageEdges[i]), std::get<1>(usageEdges[i]), std::get<2>(usageEdges[i]), Edge::EdgeType::EDGE_USAGE));
|
||||
}
|
||||
for(unsigned int i = 0; i < typeOfEdges.size(); i++)
|
||||
{
|
||||
result.insert(DummyEdge(typeOfEdges[i].first, typeOfEdges[i].second, Edge::EdgeType::EDGE_TYPE_OF));
|
||||
result.insert(DummyEdge(std::get<0>(typeOfEdges[i]), std::get<1>(typeOfEdges[i]), std::get<2>(typeOfEdges[i]), Edge::EdgeType::EDGE_TYPE_OF));
|
||||
}
|
||||
for(unsigned int i = 0; i < returnTypeEdges.size(); i++)
|
||||
{
|
||||
result.insert(DummyEdge(returnTypeEdges[i].first, returnTypeEdges[i].second, Edge::EdgeType::EDGE_RETURN_TYPE_OF));
|
||||
result.insert(DummyEdge(std::get<0>(returnTypeEdges[i]), std::get<1>(returnTypeEdges[i]), std::get<2>(returnTypeEdges[i]), Edge::EdgeType::EDGE_RETURN_TYPE_OF));
|
||||
}
|
||||
for(unsigned int i = 0; i < parameterEdges.size(); i++)
|
||||
{
|
||||
result.insert(DummyEdge(parameterEdges[i].first, parameterEdges[i].second, Edge::EdgeType::EDGE_PARAMETER_TYPE_OF));
|
||||
result.insert(DummyEdge(std::get<0>(parameterEdges[i]), std::get<1>(parameterEdges[i]), std::get<2>(parameterEdges[i]), Edge::EdgeType::EDGE_PARAMETER_TYPE_OF));
|
||||
}
|
||||
for(unsigned int i = 0; i < inheritanceEdges.size(); i++)
|
||||
{
|
||||
result.insert(DummyEdge(std::get<0>(inheritanceEdges[i]), std::get<1>(inheritanceEdges[i]), std::get<2>(inheritanceEdges[i]), Edge::EdgeType::EDGE_INHERITANCE));
|
||||
}
|
||||
|
||||
for(unsigned int i = 0; i < node.subNodes.size(); i++)
|
||||
|
||||
@@ -1,9 +1,15 @@
|
||||
#include "component/view/graphElements/GraphEdge.h"
|
||||
|
||||
GraphEdge::GraphEdge()
|
||||
GraphEdge::GraphEdge(const Id tokenId)
|
||||
: m_tokenId(tokenId)
|
||||
{
|
||||
}
|
||||
|
||||
GraphEdge::~GraphEdge()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
Id GraphEdge::getTokenId() const
|
||||
{
|
||||
return m_tokenId;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ class GraphNode;
|
||||
class GraphEdge
|
||||
{
|
||||
public:
|
||||
GraphEdge();
|
||||
GraphEdge(const Id tokenId);
|
||||
virtual ~GraphEdge();
|
||||
|
||||
virtual void ownerMoved() = 0;
|
||||
@@ -24,17 +24,23 @@ public:
|
||||
virtual std::weak_ptr<GraphNode> getOwner() = 0;
|
||||
virtual std::weak_ptr<GraphNode> getTarget() = 0;
|
||||
|
||||
Id getTokenId() const;
|
||||
|
||||
virtual void setColor(const Vec4i& color) = 0;
|
||||
virtual Vec4i getColor() const = 0;
|
||||
|
||||
protected:
|
||||
Id m_tokenId;
|
||||
};
|
||||
|
||||
// temporary data structure for (visual) graph creation process
|
||||
struct DummyEdge
|
||||
{
|
||||
public:
|
||||
DummyEdge(const Id o, const Id t, Edge::EdgeType type)
|
||||
DummyEdge(const Id o, const Id t, const Id tknId, Edge::EdgeType type)
|
||||
: ownerId(o)
|
||||
, targetId(t)
|
||||
, tokenId(tknId)
|
||||
, edgeType(type)
|
||||
{
|
||||
}
|
||||
@@ -73,6 +79,7 @@ public:
|
||||
|
||||
Id ownerId;
|
||||
Id targetId;
|
||||
Id tokenId;
|
||||
|
||||
Edge::EdgeType edgeType;
|
||||
};
|
||||
|
||||
+48
-12
@@ -289,9 +289,9 @@ std::vector<Id> Storage::getIdsOfNeighbours(const Id id) const
|
||||
return result;
|
||||
}
|
||||
|
||||
std::vector<std::pair<Id, Id>> Storage::getNeighbourEdgesOfNode(const Id id) const
|
||||
std::vector<std::tuple<Id, Id, Id>> Storage::getNeighbourEdgesOfNode(const Id id) const
|
||||
{
|
||||
std::vector<std::pair<Id, Id>> result;
|
||||
std::vector<std::tuple<Id, Id, Id>> result;
|
||||
|
||||
Node* node = m_graph.findNode([&](Node* node){
|
||||
return node->getId() == id;
|
||||
@@ -302,7 +302,7 @@ std::vector<std::pair<Id, Id>> Storage::getNeighbourEdgesOfNode(const Id id) con
|
||||
node->forEachEdge(
|
||||
[&result](Edge* e)
|
||||
{
|
||||
result.push_back(std::pair<Id, Id>(e->getFrom()->getId(), e->getTo()->getId()));
|
||||
result.push_back(std::tuple<Id, Id, Id>(e->getFrom()->getId(), e->getTo()->getId(), e->getId()));
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -310,36 +310,72 @@ std::vector<std::pair<Id, Id>> Storage::getNeighbourEdgesOfNode(const Id id) con
|
||||
return result;
|
||||
}
|
||||
|
||||
std::vector<std::pair<Id, Id>> Storage::getMemberEdgesOfNode(const Id id) const
|
||||
std::vector<std::tuple<Id, Id, Id>> Storage::getMemberEdgesOfNode(const Id id) const
|
||||
{
|
||||
return getEdgesOfTypeOfNode(id, Edge::EdgeType::EDGE_MEMBER);
|
||||
}
|
||||
|
||||
std::vector<std::pair<Id, Id>> Storage::getUsageEdgesOfNode(const Id id) const
|
||||
std::vector<std::tuple<Id, Id, Id>> Storage::getUsageEdgesOfNode(const Id id) const
|
||||
{
|
||||
return getEdgesOfTypeOfNode(id, Edge::EdgeType::EDGE_USAGE);
|
||||
}
|
||||
|
||||
std::vector<std::pair<Id, Id>> Storage::getCallEdgesOfNode(const Id id) const
|
||||
std::vector<std::tuple<Id, Id, Id>> Storage::getCallEdgesOfNode(const Id id) const
|
||||
{
|
||||
return getEdgesOfTypeOfNode(id, Edge::EdgeType::EDGE_CALL);
|
||||
}
|
||||
|
||||
std::vector<std::pair<Id, Id>> Storage::getTypeOfEdgesOfNode(const Id id) const
|
||||
std::vector<std::tuple<Id, Id, Id>> Storage::getTypeOfEdgesOfNode(const Id id) const
|
||||
{
|
||||
return getEdgesOfTypeOfNode(id, Edge::EdgeType::EDGE_TYPE_OF);
|
||||
}
|
||||
|
||||
std::vector<std::pair<Id, Id>> Storage::getReturnTypeOfEdgesOfNode(const Id id) const
|
||||
std::vector<std::tuple<Id, Id, Id>> Storage::getReturnTypeOfEdgesOfNode(const Id id) const
|
||||
{
|
||||
return getEdgesOfTypeOfNode(id, Edge::EdgeType::EDGE_RETURN_TYPE_OF);
|
||||
}
|
||||
|
||||
std::vector<std::pair<Id, Id>> Storage::getParameterOfEdgesOfNode(const Id id) const
|
||||
std::vector<std::tuple<Id, Id, Id>> Storage::getParameterOfEdgesOfNode(const Id id) const
|
||||
{
|
||||
return getEdgesOfTypeOfNode(id, Edge::EdgeType::EDGE_PARAMETER_TYPE_OF);
|
||||
}
|
||||
|
||||
std::vector<std::tuple<Id, Id, Id>> Storage::getInheritanceEdgesOfNode(const Id id) const
|
||||
{
|
||||
return getEdgesOfTypeOfNode(id, Edge::EdgeType::EDGE_INHERITANCE);
|
||||
}
|
||||
|
||||
std::pair<Id, Id> Storage::getNodesOfEdge(const Id id) const
|
||||
{
|
||||
std::pair<Id, Id> result;
|
||||
|
||||
Edge* edge = m_graph.findEdge([&](Edge* edge){
|
||||
return edge->getId() == id;
|
||||
});
|
||||
|
||||
if(edge != NULL)
|
||||
{
|
||||
result.first = edge->getFrom()->getId();
|
||||
result.second = edge->getTo()->getId();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
bool Storage::checkTokenIsNode(const Id id) const
|
||||
{
|
||||
Token* token = m_graph.findToken([&](Token* token){
|
||||
return token->getId() == id;
|
||||
});
|
||||
|
||||
if(token != NULL)
|
||||
{
|
||||
return token->isNode();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
TokenLocationCollection Storage::getTokenLocationsForTokenId(Id id) const
|
||||
{
|
||||
TokenLocationCollection ret;
|
||||
@@ -461,9 +497,9 @@ void Storage::log(std::string type, std::string str, const ParseLocation& locati
|
||||
LOG_INFO(info.str());
|
||||
}
|
||||
|
||||
std::vector<std::pair<Id, Id>> Storage::getEdgesOfTypeOfNode(const Id id, const Edge::EdgeType type) const
|
||||
std::vector<std::tuple<Id, Id, Id>> Storage::getEdgesOfTypeOfNode(const Id id, const Edge::EdgeType type) const
|
||||
{
|
||||
std::vector<std::pair<Id, Id>> result;
|
||||
std::vector<std::tuple<Id, Id, Id>> result;
|
||||
|
||||
Node* node = m_graph.findNode([&](Node* node){
|
||||
return node->getId() == id;
|
||||
@@ -476,7 +512,7 @@ std::vector<std::pair<Id, Id>> Storage::getEdgesOfTypeOfNode(const Id id, const
|
||||
{
|
||||
if(e->getType() == type)
|
||||
{
|
||||
result.push_back(std::pair<Id, Id>(e->getFrom()->getId(), e->getTo()->getId()));
|
||||
result.push_back(std::tuple<Id, Id, Id>(e->getFrom()->getId(), e->getTo()->getId(), e->getId()));
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
+13
-8
@@ -62,13 +62,18 @@ public:
|
||||
virtual std::string getNameForNodeWithId(Id id) const;
|
||||
virtual std::vector<std::string> getNamesForNodesWithNamePrefix(const std::string& prefix) const;
|
||||
virtual std::vector<Id> getIdsOfNeighbours(const Id id) const;
|
||||
virtual std::vector<std::pair<Id, Id>> getNeighbourEdgesOfNode(const Id id) const;
|
||||
virtual std::vector<std::pair<Id, Id>> getMemberEdgesOfNode(const Id id) const;
|
||||
virtual std::vector<std::pair<Id, Id>> getUsageEdgesOfNode(const Id id) const;
|
||||
virtual std::vector<std::pair<Id, Id>> getCallEdgesOfNode(const Id id) const;
|
||||
virtual std::vector<std::pair<Id, Id>> getTypeOfEdgesOfNode(const Id id) const;
|
||||
virtual std::vector<std::pair<Id, Id>> getReturnTypeOfEdgesOfNode(const Id id) const;
|
||||
virtual std::vector<std::pair<Id, Id>> getParameterOfEdgesOfNode(const Id id) const;
|
||||
virtual std::vector<std::tuple<Id, Id, Id>> getNeighbourEdgesOfNode(const Id id) const;
|
||||
virtual std::vector<std::tuple<Id, Id, Id>> getMemberEdgesOfNode(const Id id) const;
|
||||
virtual std::vector<std::tuple<Id, Id, Id>> getUsageEdgesOfNode(const Id id) const;
|
||||
virtual std::vector<std::tuple<Id, Id, Id>> getCallEdgesOfNode(const Id id) const;
|
||||
virtual std::vector<std::tuple<Id, Id, Id>> getTypeOfEdgesOfNode(const Id id) const;
|
||||
virtual std::vector<std::tuple<Id, Id, Id>> getReturnTypeOfEdgesOfNode(const Id id) const;
|
||||
virtual std::vector<std::tuple<Id, Id, Id>> getParameterOfEdgesOfNode(const Id id) const;
|
||||
virtual std::vector<std::tuple<Id, Id, Id>> getInheritanceEdgesOfNode(const Id id) const;
|
||||
|
||||
virtual std::pair<Id, Id> getNodesOfEdge(const Id id) const;
|
||||
|
||||
virtual bool checkTokenIsNode(const Id id) const;
|
||||
|
||||
// LocationAccess implementation
|
||||
virtual TokenLocationCollection getTokenLocationsForTokenId(Id locationId) const;
|
||||
@@ -84,7 +89,7 @@ private:
|
||||
|
||||
void log(std::string type, std::string str, const ParseLocation& location) const;
|
||||
|
||||
std::vector<std::pair<Id, Id>> getEdgesOfTypeOfNode(const Id id, const Edge::EdgeType type) const;
|
||||
std::vector<std::tuple<Id, Id, Id>> getEdgesOfTypeOfNode(const Id id, const Edge::EdgeType type) const;
|
||||
|
||||
Graph m_graph;
|
||||
TokenLocationCollection m_locationCollection;
|
||||
|
||||
@@ -18,13 +18,18 @@ public:
|
||||
virtual std::string getNameForNodeWithId(Id id) const = 0;
|
||||
virtual std::vector<std::string> getNamesForNodesWithNamePrefix(const std::string& prefix) const = 0;
|
||||
virtual std::vector<Id> getIdsOfNeighbours(const Id id) const = 0;
|
||||
virtual std::vector<std::pair<Id, Id>> getNeighbourEdgesOfNode(const Id id) const = 0;
|
||||
virtual std::vector<std::pair<Id, Id>> getMemberEdgesOfNode(const Id id) const = 0;
|
||||
virtual std::vector<std::pair<Id, Id>> getUsageEdgesOfNode(const Id id) const = 0;
|
||||
virtual std::vector<std::pair<Id, Id>> getCallEdgesOfNode(const Id id) const = 0;
|
||||
virtual std::vector<std::pair<Id, Id>> getTypeOfEdgesOfNode(const Id id) const = 0;
|
||||
virtual std::vector<std::pair<Id, Id>> getReturnTypeOfEdgesOfNode(const Id id) const = 0;
|
||||
virtual std::vector<std::pair<Id, Id>> getParameterOfEdgesOfNode(const Id id) const = 0;
|
||||
virtual std::vector<std::tuple<Id, Id, Id>> getNeighbourEdgesOfNode(const Id id) const = 0;
|
||||
virtual std::vector<std::tuple<Id, Id, Id>> getMemberEdgesOfNode(const Id id) const = 0;
|
||||
virtual std::vector<std::tuple<Id, Id, Id>> getUsageEdgesOfNode(const Id id) const = 0;
|
||||
virtual std::vector<std::tuple<Id, Id, Id>> getCallEdgesOfNode(const Id id) const = 0;
|
||||
virtual std::vector<std::tuple<Id, Id, Id>> getTypeOfEdgesOfNode(const Id id) const = 0;
|
||||
virtual std::vector<std::tuple<Id, Id, Id>> getReturnTypeOfEdgesOfNode(const Id id) const = 0;
|
||||
virtual std::vector<std::tuple<Id, Id, Id>> getParameterOfEdgesOfNode(const Id id) const = 0;
|
||||
virtual std::vector<std::tuple<Id, Id, Id>> getInheritanceEdgesOfNode(const Id id) const = 0;
|
||||
|
||||
virtual std::pair<Id, Id> getNodesOfEdge(const Id id) const = 0;
|
||||
|
||||
virtual bool checkTokenIsNode(const Id id) const = 0;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -67,72 +67,102 @@ std::vector<Id> GraphAccessProxy::getIdsOfNeighbours(const Id id) const
|
||||
return std::vector<Id>();
|
||||
}
|
||||
|
||||
std::vector<std::pair<Id, Id>> GraphAccessProxy::getNeighbourEdgesOfNode(const Id id) const
|
||||
std::vector<std::tuple<Id, Id, Id>> GraphAccessProxy::getNeighbourEdgesOfNode(const Id id) const
|
||||
{
|
||||
if (hasSubject())
|
||||
{
|
||||
return m_subject->getNeighbourEdgesOfNode(id);
|
||||
}
|
||||
|
||||
return std::vector<std::pair<Id, Id>>();
|
||||
return std::vector<std::tuple<Id, Id, Id>>();
|
||||
}
|
||||
|
||||
std::vector<std::pair<Id, Id>> GraphAccessProxy::getMemberEdgesOfNode(const Id id) const
|
||||
std::vector<std::tuple<Id, Id, Id>> GraphAccessProxy::getMemberEdgesOfNode(const Id id) const
|
||||
{
|
||||
if (hasSubject())
|
||||
{
|
||||
return m_subject->getMemberEdgesOfNode(id);
|
||||
}
|
||||
|
||||
return std::vector<std::pair<Id, Id>>();
|
||||
return std::vector<std::tuple<Id, Id, Id>>();
|
||||
}
|
||||
|
||||
std::vector<std::pair<Id, Id>> GraphAccessProxy::getUsageEdgesOfNode(const Id id) const
|
||||
std::vector<std::tuple<Id, Id, Id>> GraphAccessProxy::getUsageEdgesOfNode(const Id id) const
|
||||
{
|
||||
if (hasSubject())
|
||||
{
|
||||
return m_subject->getUsageEdgesOfNode(id);
|
||||
}
|
||||
|
||||
return std::vector<std::pair<Id, Id>>();
|
||||
return std::vector<std::tuple<Id, Id, Id>>();
|
||||
}
|
||||
|
||||
std::vector<std::pair<Id, Id>> GraphAccessProxy::getCallEdgesOfNode(const Id id) const
|
||||
std::vector<std::tuple<Id, Id, Id>> GraphAccessProxy::getCallEdgesOfNode(const Id id) const
|
||||
{
|
||||
if (hasSubject())
|
||||
{
|
||||
return m_subject->getCallEdgesOfNode(id);
|
||||
}
|
||||
|
||||
return std::vector<std::pair<Id, Id>>();
|
||||
return std::vector<std::tuple<Id, Id, Id>>();
|
||||
}
|
||||
|
||||
std::vector<std::pair<Id, Id>> GraphAccessProxy::getTypeOfEdgesOfNode(const Id id) const
|
||||
std::vector<std::tuple<Id, Id, Id>> GraphAccessProxy::getTypeOfEdgesOfNode(const Id id) const
|
||||
{
|
||||
if (hasSubject())
|
||||
{
|
||||
return m_subject->getTypeOfEdgesOfNode(id);
|
||||
}
|
||||
|
||||
return std::vector<std::pair<Id, Id>>();
|
||||
return std::vector<std::tuple<Id, Id, Id>>();
|
||||
}
|
||||
|
||||
std::vector<std::pair<Id, Id>> GraphAccessProxy::getReturnTypeOfEdgesOfNode(const Id id) const
|
||||
std::vector<std::tuple<Id, Id, Id>> GraphAccessProxy::getReturnTypeOfEdgesOfNode(const Id id) const
|
||||
{
|
||||
if (hasSubject())
|
||||
{
|
||||
return m_subject->getReturnTypeOfEdgesOfNode(id);
|
||||
}
|
||||
|
||||
return std::vector<std::pair<Id, Id>>();
|
||||
return std::vector<std::tuple<Id, Id, Id>>();
|
||||
}
|
||||
|
||||
std::vector<std::pair<Id, Id>> GraphAccessProxy::getParameterOfEdgesOfNode(const Id id) const
|
||||
std::vector<std::tuple<Id, Id, Id>> GraphAccessProxy::getParameterOfEdgesOfNode(const Id id) const
|
||||
{
|
||||
if (hasSubject())
|
||||
{
|
||||
return m_subject->getParameterOfEdgesOfNode(id);
|
||||
}
|
||||
|
||||
return std::vector<std::pair<Id, Id>>();
|
||||
return std::vector<std::tuple<Id, Id, Id>>();
|
||||
}
|
||||
|
||||
std::vector<std::tuple<Id, Id, Id>> GraphAccessProxy::getInheritanceEdgesOfNode(const Id id) const
|
||||
{
|
||||
if (hasSubject())
|
||||
{
|
||||
return m_subject->getInheritanceEdgesOfNode(id);
|
||||
}
|
||||
|
||||
return std::vector<std::tuple<Id, Id, Id>>();
|
||||
}
|
||||
|
||||
std::pair<Id, Id> GraphAccessProxy::getNodesOfEdge(const Id id) const
|
||||
{
|
||||
if (hasSubject())
|
||||
{
|
||||
return m_subject->getNodesOfEdge(id);
|
||||
}
|
||||
|
||||
return std::pair<Id, Id>();
|
||||
}
|
||||
|
||||
bool GraphAccessProxy::checkTokenIsNode(const Id id) const
|
||||
{
|
||||
if (hasSubject())
|
||||
{
|
||||
return m_subject->checkTokenIsNode(id);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -17,13 +17,18 @@ public:
|
||||
virtual std::string getNameForNodeWithId(Id id) const;
|
||||
virtual std::vector<std::string> getNamesForNodesWithNamePrefix(const std::string& prefix) const;
|
||||
virtual std::vector<Id> getIdsOfNeighbours(const Id id) const;
|
||||
virtual std::vector<std::pair<Id, Id>> getNeighbourEdgesOfNode(const Id id) const;
|
||||
virtual std::vector<std::pair<Id, Id>> getMemberEdgesOfNode(const Id id) const;
|
||||
virtual std::vector<std::pair<Id, Id>> getUsageEdgesOfNode(const Id id) const;
|
||||
virtual std::vector<std::pair<Id, Id>> getCallEdgesOfNode(const Id id) const;
|
||||
virtual std::vector<std::pair<Id, Id>> getTypeOfEdgesOfNode(const Id id) const;
|
||||
virtual std::vector<std::pair<Id, Id>> getReturnTypeOfEdgesOfNode(const Id id) const;
|
||||
virtual std::vector<std::pair<Id, Id>> getParameterOfEdgesOfNode(const Id id) const;
|
||||
virtual std::vector<std::tuple<Id, Id, Id>> getNeighbourEdgesOfNode(const Id id) const;
|
||||
virtual std::vector<std::tuple<Id, Id, Id>> getMemberEdgesOfNode(const Id id) const;
|
||||
virtual std::vector<std::tuple<Id, Id, Id>> getUsageEdgesOfNode(const Id id) const;
|
||||
virtual std::vector<std::tuple<Id, Id, Id>> getCallEdgesOfNode(const Id id) const;
|
||||
virtual std::vector<std::tuple<Id, Id, Id>> getTypeOfEdgesOfNode(const Id id) const;
|
||||
virtual std::vector<std::tuple<Id, Id, Id>> getReturnTypeOfEdgesOfNode(const Id id) const;
|
||||
virtual std::vector<std::tuple<Id, Id, Id>> getParameterOfEdgesOfNode(const Id id) const;
|
||||
virtual std::vector<std::tuple<Id, Id, Id>> getInheritanceEdgesOfNode(const Id id) const;
|
||||
|
||||
virtual std::pair<Id, Id> getNodesOfEdge(const Id id) const;
|
||||
|
||||
virtual bool checkTokenIsNode(const Id id) const;
|
||||
|
||||
private:
|
||||
GraphAccess* m_subject;
|
||||
|
||||
Reference in New Issue
Block a user