logic: refactored GraphAccess and GraphController to use single call that returns Graph
This change refactors the GraphController to use the GraphAccess only with a single call that returns a Graph. The Graph contains all information for visually representing the active Token with all parent and child nodes and edges. This reduces coupling of the data and logic tiers.
This commit is contained in:
@@ -1,14 +1,13 @@
|
||||
#ifndef GRAPH_ACCESS_H
|
||||
#define GRAPH_ACCESS_H
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "data/graph/Graph.h"
|
||||
#include "utility/types.h"
|
||||
|
||||
class Edge;
|
||||
class Token;
|
||||
|
||||
class GraphAccess
|
||||
{
|
||||
public:
|
||||
@@ -17,19 +16,8 @@ public:
|
||||
virtual Id getIdForNodeWithName(const std::string& name) const = 0;
|
||||
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::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;
|
||||
virtual std::shared_ptr<Graph> getGraphForActiveTokenIds(const std::vector<Id>& tokenIds) const = 0;
|
||||
|
||||
virtual std::vector<Id> getActiveTokenIdsForId(Id tokenId) const = 0;
|
||||
virtual std::vector<Id> getLocationIdsForTokenIds(const std::vector<Id>& tokenIds) const = 0;
|
||||
|
||||
@@ -57,114 +57,14 @@ std::vector<std::string> GraphAccessProxy::getNamesForNodesWithNamePrefix(const
|
||||
return std::vector<std::string>();
|
||||
}
|
||||
|
||||
std::vector<Id> GraphAccessProxy::getIdsOfNeighbours(const Id id) const
|
||||
std::shared_ptr<Graph> GraphAccessProxy::getGraphForActiveTokenIds(const std::vector<Id>& tokenIds) const
|
||||
{
|
||||
if (hasSubject())
|
||||
{
|
||||
return m_subject->getIdsOfNeighbours(id);
|
||||
return m_subject->getGraphForActiveTokenIds(tokenIds);
|
||||
}
|
||||
|
||||
return std::vector<Id>();
|
||||
}
|
||||
|
||||
std::vector<std::tuple<Id, Id, Id>> GraphAccessProxy::getNeighbourEdgesOfNode(const Id id) const
|
||||
{
|
||||
if (hasSubject())
|
||||
{
|
||||
return m_subject->getNeighbourEdgesOfNode(id);
|
||||
}
|
||||
|
||||
return std::vector<std::tuple<Id, Id, Id>>();
|
||||
}
|
||||
|
||||
std::vector<std::tuple<Id, Id, Id>> GraphAccessProxy::getMemberEdgesOfNode(const Id id) const
|
||||
{
|
||||
if (hasSubject())
|
||||
{
|
||||
return m_subject->getMemberEdgesOfNode(id);
|
||||
}
|
||||
|
||||
return std::vector<std::tuple<Id, Id, Id>>();
|
||||
}
|
||||
|
||||
std::vector<std::tuple<Id, Id, Id>> GraphAccessProxy::getUsageEdgesOfNode(const Id id) const
|
||||
{
|
||||
if (hasSubject())
|
||||
{
|
||||
return m_subject->getUsageEdgesOfNode(id);
|
||||
}
|
||||
|
||||
return std::vector<std::tuple<Id, Id, Id>>();
|
||||
}
|
||||
|
||||
std::vector<std::tuple<Id, Id, Id>> GraphAccessProxy::getCallEdgesOfNode(const Id id) const
|
||||
{
|
||||
if (hasSubject())
|
||||
{
|
||||
return m_subject->getCallEdgesOfNode(id);
|
||||
}
|
||||
|
||||
return std::vector<std::tuple<Id, Id, Id>>();
|
||||
}
|
||||
|
||||
std::vector<std::tuple<Id, Id, Id>> GraphAccessProxy::getTypeOfEdgesOfNode(const Id id) const
|
||||
{
|
||||
if (hasSubject())
|
||||
{
|
||||
return m_subject->getTypeOfEdgesOfNode(id);
|
||||
}
|
||||
|
||||
return std::vector<std::tuple<Id, Id, Id>>();
|
||||
}
|
||||
|
||||
std::vector<std::tuple<Id, Id, Id>> GraphAccessProxy::getReturnTypeOfEdgesOfNode(const Id id) const
|
||||
{
|
||||
if (hasSubject())
|
||||
{
|
||||
return m_subject->getReturnTypeOfEdgesOfNode(id);
|
||||
}
|
||||
|
||||
return std::vector<std::tuple<Id, Id, Id>>();
|
||||
}
|
||||
|
||||
std::vector<std::tuple<Id, Id, Id>> GraphAccessProxy::getParameterOfEdgesOfNode(const Id id) const
|
||||
{
|
||||
if (hasSubject())
|
||||
{
|
||||
return m_subject->getParameterOfEdgesOfNode(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;
|
||||
return std::make_shared<Graph>();
|
||||
}
|
||||
|
||||
std::vector<Id> GraphAccessProxy::getActiveTokenIdsForId(Id tokenId) const
|
||||
|
||||
@@ -16,19 +16,8 @@ public:
|
||||
virtual Id getIdForNodeWithName(const std::string& name) const;
|
||||
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::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;
|
||||
virtual std::shared_ptr<Graph> getGraphForActiveTokenIds(const std::vector<Id>& tokenIds) const;
|
||||
|
||||
virtual std::vector<Id> getActiveTokenIdsForId(Id tokenId) const;
|
||||
virtual std::vector<Id> getLocationIdsForTokenIds(const std::vector<Id>& tokenIds) const;
|
||||
|
||||
Reference in New Issue
Block a user