![]() |
Tulip
4.6.0
Better Visualization Through Research
|
00001 /* 00002 * 00003 * This file is part of Tulip (www.tulip-software.org) 00004 * 00005 * Authors: David Auber and the Tulip development Team 00006 * from LaBRI, University of Bordeaux 00007 * 00008 * Tulip is free software; you can redistribute it and/or modify 00009 * it under the terms of the GNU Lesser General Public License 00010 * as published by the Free Software Foundation, either version 3 00011 * of the License, or (at your option) any later version. 00012 * 00013 * Tulip is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00016 * See the GNU General Public License for more details. 00017 * 00018 */ 00019 ///@cond DOXYGEN_HIDDEN 00020 00021 #ifndef TULIP_GGRAPHITERATOR_H 00022 #define TULIP_GGRAPHITERATOR_H 00023 #include <tulip/Iterator.h> 00024 #include <tulip/memorypool.h> 00025 #include <set> 00026 00027 #include <tulip/MutableContainer.h> 00028 #include <tulip/Observable.h> 00029 #include <tulip/tulipconf.h> 00030 #include <iostream> 00031 00032 #ifndef DOXYGEN_NOTFOR_DEVEL 00033 namespace tlp { 00034 00035 class Graph; 00036 class GraphImpl; 00037 struct node; 00038 struct edge; 00039 class NodeIterator :public Iterator<node> { 00040 }; 00041 00042 class EdgeIterator :public Iterator<edge> { 00043 }; 00044 00045 #if !defined(NDEBUG) && !defined(_OPENMP) 00046 class NodeIteratorObserver :public NodeIterator, public Observable { 00047 private: 00048 // Observable interface 00049 void treatEvent(const Event&); 00050 }; 00051 00052 class EdgeIteratorObserver :public EdgeIterator, public Observable { 00053 private: 00054 // Observable interface 00055 void treatEvent(const Event&); 00056 }; 00057 #endif 00058 //=========================================================== 00059 ///Factorization of code for iterators 00060 class FactorNodeIterator 00061 #if defined(NDEBUG) || defined(_OPENMP) 00062 :public NodeIterator 00063 #else 00064 :public NodeIteratorObserver 00065 #endif 00066 { 00067 protected: 00068 Graph *_parentGraph; 00069 const MutableContainer<bool>& _filter; 00070 public: 00071 FactorNodeIterator(const Graph *sG,const MutableContainer<bool>& filter): 00072 _parentGraph(sG->getSuperGraph()), 00073 _filter(filter) 00074 {} 00075 }; 00076 00077 class FactorEdgeIterator 00078 #if defined(NDEBUG) || defined(_OPENMP) 00079 :public EdgeIterator 00080 #else 00081 :public EdgeIteratorObserver 00082 #endif 00083 { 00084 protected: 00085 Graph *_parentGraph; 00086 const MutableContainer<bool>& _filter; 00087 public: 00088 FactorEdgeIterator(const Graph *sG,const MutableContainer<bool>& filter): 00089 _parentGraph(sG->getSuperGraph()), 00090 _filter(filter) 00091 {} 00092 }; 00093 //============================================================ 00094 ///Node iterator for GraphView 00095 class SGraphNodeIterator:public FactorNodeIterator, public MemoryPool<SGraphNodeIterator> { 00096 private: 00097 const Graph* sg; 00098 Iterator<node> *it; 00099 node curNode; 00100 bool value; 00101 00102 public: 00103 SGraphNodeIterator(const Graph *sG, const MutableContainer<bool>& filter, 00104 bool value=true); 00105 ~SGraphNodeIterator(); 00106 node next(); 00107 bool hasNext(); 00108 protected: 00109 void prepareNext(); 00110 }; 00111 //============================================================ 00112 ///Out node iterator for GraphView 00113 class OutNodesIterator:public FactorNodeIterator, public MemoryPool<OutNodesIterator> { 00114 private: 00115 Iterator<edge> *it; 00116 #if !defined(NDEBUG) && !defined(_OPENMP) 00117 const Graph *sg; 00118 #endif 00119 public: 00120 OutNodesIterator(const Graph *sG, const MutableContainer<bool>& filter, node n); 00121 ~OutNodesIterator(); 00122 node next(); 00123 bool hasNext(); 00124 }; 00125 //============================================================ 00126 ///In node iterator for GraphView 00127 class InNodesIterator:public FactorNodeIterator, public MemoryPool<InNodesIterator> { 00128 private: 00129 Iterator<edge> *it; 00130 #if !defined(NDEBUG) && !defined(_OPENMP) 00131 const Graph *sg; 00132 #endif 00133 public: 00134 InNodesIterator(const Graph *sG, const MutableContainer<bool>& filter ,node n); 00135 ~InNodesIterator(); 00136 node next(); 00137 bool hasNext(); 00138 }; 00139 //============================================================ 00140 ///In Out node iterator for GraphView 00141 class InOutNodesIterator:public FactorNodeIterator, public MemoryPool<InOutNodesIterator> { 00142 private: 00143 Iterator<edge> *it; 00144 node n; 00145 #if !defined(NDEBUG) && !defined(_OPENMP) 00146 const Graph *sg; 00147 #endif 00148 public: 00149 InOutNodesIterator(const Graph *sG,const MutableContainer<bool>& filter,node n); 00150 ~InOutNodesIterator(); 00151 node next(); 00152 bool hasNext(); 00153 }; 00154 //============================================================= 00155 ///Edge iterator for GraphView 00156 class SGraphEdgeIterator:public FactorEdgeIterator, public MemoryPool<SGraphEdgeIterator> { 00157 private: 00158 const Graph* sg; 00159 Iterator<edge> *it; 00160 edge curEdge; 00161 bool value; 00162 00163 public: 00164 SGraphEdgeIterator(const Graph *sG, const MutableContainer<bool>& filter, 00165 bool value = true); 00166 ~SGraphEdgeIterator(); 00167 edge next(); 00168 bool hasNext(); 00169 protected: 00170 void prepareNext(); 00171 }; 00172 //============================================================ 00173 ///Out edge iterator for GraphView 00174 class OutEdgesIterator:public FactorEdgeIterator, public MemoryPool<OutEdgesIterator> { 00175 private: 00176 Iterator<edge> *it; 00177 edge curEdge; 00178 00179 public: 00180 OutEdgesIterator(const Graph *sG, const MutableContainer<bool>& filter, node n); 00181 ~OutEdgesIterator(); 00182 edge next(); 00183 bool hasNext(); 00184 protected: 00185 void prepareNext(); 00186 }; 00187 //============================================================ 00188 ///In edge iterator for GraphView 00189 class InEdgesIterator:public FactorEdgeIterator, public MemoryPool<InEdgesIterator> { 00190 private: 00191 Iterator<edge> *it; 00192 edge curEdge; 00193 00194 public: 00195 InEdgesIterator(const Graph *sG,const MutableContainer<bool>& filter,node n); 00196 ~InEdgesIterator(); 00197 edge next(); 00198 bool hasNext(); 00199 protected: 00200 void prepareNext(); 00201 }; 00202 //============================================================ 00203 ///In Out edge iterator for GraphView 00204 class InOutEdgesIterator:public FactorEdgeIterator, public MemoryPool<InOutEdgesIterator> { 00205 private: 00206 Iterator<edge> *it; 00207 edge curEdge; 00208 00209 public: 00210 InOutEdgesIterator(const Graph *sG, const MutableContainer<bool>& filter, node n); 00211 ~InOutEdgesIterator(); 00212 edge next(); 00213 bool hasNext(); 00214 protected: 00215 void prepareNext(); 00216 }; 00217 00218 //============================================================ 00219 //Iterator for the GraphImpl 00220 //============================================================ 00221 class GraphImplNodeIterator 00222 #if defined(NDEBUG) || defined(_OPENMP) 00223 :public NodeIterator, public MemoryPool<GraphImplNodeIterator> 00224 #else 00225 :public NodeIteratorObserver 00226 #endif 00227 { 00228 private: 00229 #if !defined(NDEBUG) && !defined(_OPENMP) 00230 GraphImpl *graph; 00231 #endif 00232 Iterator<node> *itId; 00233 public: 00234 GraphImplNodeIterator(const Graph *g, Iterator<node>* it); 00235 ~GraphImplNodeIterator(); 00236 node next(); 00237 bool hasNext(); 00238 }; 00239 //============================================================= 00240 ///Edge iterator for data sg 00241 class GraphImplEdgeIterator 00242 #if defined(NDEBUG) || defined(_OPENMP) 00243 :public EdgeIterator, public MemoryPool<GraphImplEdgeIterator> 00244 #else 00245 :public EdgeIteratorObserver 00246 #endif 00247 { 00248 private: 00249 #if !defined(NDEBUG) && !defined(_OPENMP) 00250 GraphImpl *graph; 00251 #endif 00252 Iterator<edge> *itId; 00253 public: 00254 GraphImplEdgeIterator(const Graph *g, Iterator<edge>* it); 00255 ~GraphImplEdgeIterator(); 00256 edge next(); 00257 bool hasNext(); 00258 }; 00259 //============================================================ 00260 00261 } 00262 #endif // DOXYGEN_NOTFOR_DEVEL 00263 #endif 00264 ///@endcond