OpenADFortTk (including Open64 and OpenAnalysis references)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
DGraphInterface.hpp
Go to the documentation of this file.
1 
15 #ifndef DGraphInterface_H
16 #define DGraphInterface_H
17 
18 #include <cassert>
22 #include <string>
23 #include <fstream>
24 #include <iostream>
25 #include <set>
26 
27 namespace OA {
28  namespace DGraph {
29 
30  typedef enum {DEdgeOrg = 0, DEdgeRev = 1} DGraphEdgeDirection;
31 
32  class EdgeInterface;
33  class EdgesIteratorInterface;
34  class NodeInterface;
35  class NodesIteratorInterface;
36  class DGraphInterface;
37 
38  class NodeInterface : public virtual Annotation {
39  public:
40  //========================================================
41  // Information
42  //========================================================
43 
44  virtual ~NodeInterface() { }
45 
46  virtual unsigned int getId () const = 0;
47 
48  virtual int num_incoming () const = 0;
49 
50  virtual int num_outgoing () const = 0;
51 
53  virtual bool isAnEntry() const = 0;
54 
56  virtual bool isAnExit() const = 0;
57 
58 
59  //========================================================
60  // Iterators
61  //========================================================
63  getIncomingEdgesIterator() const =0;
64 
66  getOutgoingEdgesIterator() const =0;
67 
69  getSourceNodesIterator() const =0;
70 
72  getSinkNodesIterator() const =0;
73 
74 
75  //========================================================
76  // Comparison operators
77  //========================================================
78  virtual bool operator== (NodeInterface& other) = 0;
79  virtual bool operator< (NodeInterface& other) = 0;
80 
81  //========================================================
82  // Construction
83  //========================================================
84  virtual void addOutgoingEdge(OA_ptr<EdgeInterface>) = 0;
85  virtual void addIncomingEdge(OA_ptr<EdgeInterface>) = 0;
86  virtual void removeIncomingEdge(OA_ptr<EdgeInterface> e) = 0;
87  virtual void removeOutgoingEdge(OA_ptr<EdgeInterface> e) = 0;
88 
89 
90  //========================================================
91  // Output
92  //========================================================
93  virtual void dump(std::ostream& os) = 0;
94  };
95 
96  // lt_Node: function object that compares by node id. Useful for sorting.
98  public:
99  // return true if n1 < n2; false otherwise
100  virtual bool operator()(const OA_ptr<NodeInterface> n1,
101  const OA_ptr<NodeInterface> n2) const = 0;
102  };
103 
104  class EdgeInterface : public virtual Annotation {
105  public:
106 
107  virtual ~EdgeInterface() { }
108  //========================================================
109  // Information
110  //========================================================
111  virtual unsigned int getId () const = 0;
112  virtual OA_ptr<NodeInterface> getSource() const = 0;
113  virtual OA_ptr<NodeInterface> getSink() const = 0;
114 
115  //========================================================
116  // Comparison operators
117  //========================================================
118  virtual bool operator== (EdgeInterface& other) = 0;
119  virtual bool operator< (EdgeInterface& other) = 0;
120  //========================================================
121  // Output
122  //========================================================
123  virtual void dump(std::ostream& os) = 0;
124  };
125 
126 
127 
128  // lt_Edge: function object that compares by id. Useful for sorting.
130  public:
131  // return true if e1 < e2; false otherwise
132  virtual bool operator()(
133  const OA_ptr<EdgeInterface> e1,
134  const OA_ptr<EdgeInterface> e2) const = 0;
135  };
136 
137 
138 
140  public:
142  virtual OA_ptr<NodeInterface> current() const = 0;
143  virtual void operator++() = 0; // prefix
144  virtual void operator++(int) = 0; // postfix
145  virtual bool isValid() const = 0;
146  virtual void reset() = 0;
147  };
148 
150  public:
152  virtual OA_ptr<EdgeInterface> current() const = 0;
153  virtual void operator++() = 0; // prefix
154  virtual void operator++(int) = 0; // postfix
155  virtual bool isValid() const = 0;
156  virtual void reset() = 0;
157  };
158 
159 
160  class DGraphInterface : public virtual Annotation {
161  public:
162 
163  virtual ~DGraphInterface() { }
164 
165  virtual int getNumNodes () = 0;
166  virtual int getNumEdges () = 0;
167 
168 
169  //========================================================
170  // Iterators
171  //========================================================
173  getNodesIterator() const = 0;
174 
175 
177  getEntryNodesIterator() const =0;
178 
180  getExitNodesIterator() const =0;
181 
184  DGraphEdgeDirection pOrient) =0;
185 
186 
189 
190 
192  getEdgesIterator() const =0;
193 
194 
195 
196  //========================================================
197  // Construction
198  //========================================================
199  virtual void addNode(OA_ptr<NodeInterface> n) = 0;
200  virtual void addEdge(OA_ptr<EdgeInterface> e) = 0;
201 
202 
203  };
204 
205  }// End of namespace DGraph
206 } // End of namespace OA
207 
208 #endif