OpenASIP  2.0
Graph.hh
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2009 Tampere University.
3 
4  This file is part of TTA-Based Codesign Environment (TCE).
5 
6  Permission is hereby granted, free of charge, to any person obtaining a
7  copy of this software and associated documentation files (the "Software"),
8  to deal in the Software without restriction, including without limitation
9  the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  and/or sell copies of the Software, and to permit persons to whom the
11  Software is furnished to do so, subject to the following conditions:
12 
13  The above copyright notice and this permission notice shall be included in
14  all copies or substantial portions of the Software.
15 
16  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  DEALINGS IN THE SOFTWARE.
23  */
24 /**
25  * @file Graph.hh
26  *
27  * Declaration of prototype of base graph interface.
28  *
29  * @author Andrea Cilio 2005 (cilio-no.spam-cs.tut.fi)
30  * @author Vladimir Guzma 2006 (vladimir.guzma-no.spam-tut.fi)
31  * @note rating: red
32  */
33 
34 
35 #ifndef TTA_GRAPH_HH
36 #define TTA_GRAPH_HH
37 
38 #include "Exception.hh"
39 #include "TCEString.hh"
40 
41 #include <set>
42 
43 /**
44  * Graph base interface shared by all clients within the project.
45  *
46  * Templated interface with node and edge types as parameters. If an
47  * implementation of this interface deals with multiple types of nodes, all
48  * types must share a common base type. Ditto for edges.
49  */
50 template<typename GraphNode, typename GraphEdge>
51 class GraphBase {
52 public:
53  typedef std::set<GraphNode*, typename GraphNode::Comparator > NodeSet;
54  typedef std::set<GraphEdge*, typename GraphEdge::Comparator > EdgeSet;
55 
56  GraphBase() {}
57  virtual ~GraphBase() {}
58 
59  /// Node type of this graph (possibly, a base class).
60  typedef GraphNode Node;
61  /// Edge type of this graph (possibly, a base class).
62  typedef GraphEdge Edge;
63 
64  virtual int nodeCount() const = 0;
65  virtual int edgeCount() const = 0;
66 
67  virtual Node& node(const int index) const = 0;
68  virtual Edge& edge(const int index) const = 0;
69 
70  virtual int outDegree(const Node& node) const = 0;
71  virtual int inDegree(const Node& node) const = 0;
72 
73  virtual Edge& outEdge(const Node& node, const int index) const = 0;
74 
75  virtual Edge& inEdge(const Node& node, const int index) const = 0;
76 
77  virtual EdgeSet outEdges(const Node& node) const = 0;
78  virtual EdgeSet inEdges(const Node& node) const = 0;
79 
80  virtual Node& tailNode(const Edge& edge) const = 0;
81  virtual Node& headNode(const Edge& edge) const = 0;
82 
83  virtual bool hasEdge(
84  const Node& nTail,
85  const Node& nHead) const = 0;
86 
87  virtual EdgeSet connectingEdges(
88  const Node& nTail, const Node& nHead) const = 0;
89 
90  virtual TCEString dotString() const;
91  virtual void writeToDotFile(const TCEString& fileName) const;
92 
93  virtual void addNode(Node& node) = 0;
94 
95  virtual void removeNode(Node& node) = 0;
96 
97  virtual void removeEdge(Edge& e) = 0;
98 
99  virtual void connectNodes(
100  const Node& nTail, const Node& nHead, Edge& e) = 0;
101  virtual void disconnectNodes(const Node& nTail, const Node& nHead) = 0;
102  virtual const TCEString& name() const = 0;
103 protected:
104  virtual bool hasNode(const Node&) const = 0;
105 };
106 
107 #include "Graph.icc"
108 
109 #endif
GraphBase::dotString
virtual TCEString dotString() const
GraphBase::headNode
virtual Node & headNode(const Edge &edge) const =0
Exception.hh
GraphBase::outDegree
virtual int outDegree(const Node &node) const =0
GraphBase::tailNode
virtual Node & tailNode(const Edge &edge) const =0
GraphBase::hasEdge
virtual bool hasEdge(const Node &nTail, const Node &nHead) const =0
GraphBase::removeEdge
virtual void removeEdge(Edge &e)=0
GraphBase::GraphBase
GraphBase()
Definition: Graph.hh:56
GraphBase::removeNode
virtual void removeNode(Node &node)=0
MoveNode
Definition: MoveNode.hh:65
GraphBase::addNode
virtual void addNode(Node &node)=0
GraphBase::outEdges
virtual EdgeSet outEdges(const Node &node) const =0
GraphBase::inEdge
virtual Edge & inEdge(const Node &node, const int index) const =0
TCEString.hh
GraphBase::EdgeSet
std::set< GraphEdge *, typename GraphEdge::Comparator > EdgeSet
Definition: Graph.hh:54
GraphBase::connectNodes
virtual void connectNodes(const Node &nTail, const Node &nHead, Edge &e)=0
GraphBase::inDegree
virtual int inDegree(const Node &node) const =0
GraphBase::connectingEdges
virtual EdgeSet connectingEdges(const Node &nTail, const Node &nHead) const =0
GraphBase::name
virtual const TCEString & name() const =0
GraphBase::NodeSet
std::set< GraphNode *, typename GraphNode::Comparator > NodeSet
Definition: Graph.hh:53
GraphBase::inEdges
virtual EdgeSet inEdges(const Node &node) const =0
GraphBase::edgeCount
virtual int edgeCount() const =0
GraphBase::disconnectNodes
virtual void disconnectNodes(const Node &nTail, const Node &nHead)=0
GraphBase::writeToDotFile
virtual void writeToDotFile(const TCEString &fileName) const
GraphBase
Definition: Graph.hh:51
GraphBase::nodeCount
virtual int nodeCount() const =0
GraphBase::outEdge
virtual Edge & outEdge(const Node &node, const int index) const =0
GraphEdge
Definition: GraphEdge.hh:52
TCEString
Definition: TCEString.hh:53
GraphBase::edge
virtual Edge & edge(const int index) const =0
Graph.icc
DataDependenceEdge
Definition: DataDependenceEdge.hh:43
GraphBase::~GraphBase
virtual ~GraphBase()
Definition: Graph.hh:57
GraphBase::Node
GraphNode Node
Node type of this graph (possibly, a base class).
Definition: Graph.hh:60
GraphBase::node
virtual Node & node(const int index) const =0
GraphNode
Definition: GraphNode.hh:42
GraphBase::Edge
GraphEdge Edge
Edge type of this graph (possibly, a base class).
Definition: Graph.hh:62
GraphBase::hasNode
virtual bool hasNode(const Node &) const =0