#ifndef GRAPH_H #define GRAPH_H #include #include #include #include #include "data/graph/Edge.h" #include "data/graph/Node.h" class Graph { public: Graph(); virtual ~Graph(); Node* getNode(const std::string& fullName) const; Edge* getEdge(Edge::EdgeType type, Node* from, Node* to) const; Node* getNodeById(Id id) const; Edge* getEdgeById(Id id) const; Token* getTokenById(Id id) const; Node* createNodeHierarchy(const std::string& fullName); Node* createNodeHierarchy(Node::NodeType type, const std::string& fullName); Node* createNodeHierarchyWithDistinctSignature(const std::string& fullName, const std::string& signature); Node* createNodeHierarchyWithDistinctSignature( Node::NodeType type, const std::string& fullName, const std::string& signature ); Edge* createEdge(Edge::EdgeType type, Node* from, Node* to); void removeNode(Node* node); void removeEdge(Edge* edge); Node* findNode(std::function func) const; Edge* findEdge(std::function func) const; Token* findToken(std::function func) const; void forEachNode(std::function func) const; void forEachEdge(std::function func) const; void forEachToken(std::function func) const; Node* addNodeAsPlainCopy(Node* node); Edge* addEdgeAsPlainCopy(Edge* edge); void clear(); protected: const std::map>& getNodes() const; const std::map>& getEdges() const; private: static const std::string DELIMITER; Node* getLastValidNode(std::deque* names) const; Node* insertNodeHierarchy(Node::NodeType type, std::deque names, Node* parentNode); Node* insertNode(Node::NodeType type, const std::string& name, Node* parentNode); Edge* insertEdge(Edge::EdgeType type, Node* from, Node* to); void removeEdgeInternal(Edge* edge); const std::string m_delimiter; std::map> m_nodes; std::map> m_edges; friend std::ostream& operator<<(std::ostream& ostream, const Graph& graph); }; std::ostream& operator<<(std::ostream& ostream, const Graph& graph); #endif // GRAPH_H