21 #ifndef TULIP_GGRAPHITERATOR_H 22 #define TULIP_GGRAPHITERATOR_H 23 #include <tulip/Iterator.h> 24 #include <tulip/memorypool.h> 27 #include <tulip/MutableContainer.h> 28 #include <tulip/Observable.h> 29 #include <tulip/tulipconf.h> 30 #include <tulip/StoredType.h> 41 class TLP_SCOPE NodeIterator :
public Iterator<node> {
44 class TLP_SCOPE EdgeIterator :
public Iterator<edge> {
47 #if !defined(NDEBUG) && !defined(_OPENMP) 48 class TLP_SCOPE NodeIteratorObserver :
public NodeIterator,
public Observable {
51 void treatEvent(
const Event&);
54 class TLP_SCOPE EdgeIteratorObserver :
public EdgeIterator,
public Observable {
57 void treatEvent(
const Event&);
62 class TLP_SCOPE FactorNodeIterator
63 #if defined(NDEBUG) || defined(_OPENMP)
66 :
public NodeIteratorObserver
72 FactorNodeIterator(
const Graph *sG):
73 _parentGraph(sG->getSuperGraph()) {
77 class TLP_SCOPE FactorEdgeIterator
78 #if defined(NDEBUG) || defined(_OPENMP)
81 :
public EdgeIteratorObserver
87 FactorEdgeIterator(
const Graph *sG):
88 _parentGraph(sG->getSuperGraph()) {
93 template<
typename VALUE_TYPE>
94 class SGraphNodeIterator:
public FactorNodeIterator,
public MemoryPool<SGraphNodeIterator<VALUE_TYPE> > {
100 const MutableContainer<VALUE_TYPE>& _filter;
105 curNode = it->
next();
107 if (_filter.get(curNode) == value)
116 SGraphNodeIterator(
const Graph *sG,
117 const MutableContainer<VALUE_TYPE>& filter,
118 typename tlp::StoredType<VALUE_TYPE>::ReturnedConstValue val) :FactorNodeIterator(sG), sg(sG), value(val), _filter(filter) {
120 #if !defined(NDEBUG) && !defined(_OPENMP) 121 sg->addListener(
this);
126 ~SGraphNodeIterator() {
127 #if !defined(NDEBUG) && !defined(_OPENMP) 128 sg->removeListener(
this);
133 assert(curNode.isValid());
142 return (curNode.isValid());
148 class TLP_SCOPE OutNodesIterator:
public FactorNodeIterator,
public MemoryPool<OutNodesIterator> {
151 #if !defined(NDEBUG) && !defined(_OPENMP) 155 OutNodesIterator(
const GraphView *sG, node n);
162 class InNodesIterator:
public FactorNodeIterator,
public MemoryPool<InNodesIterator> {
165 #if !defined(NDEBUG) && !defined(_OPENMP) 169 InNodesIterator(
const GraphView *sG, node n);
176 class TLP_SCOPE InOutNodesIterator:
public FactorNodeIterator,
public MemoryPool<InOutNodesIterator> {
180 #if !defined(NDEBUG) && !defined(_OPENMP) 184 InOutNodesIterator(
const GraphView *sG, node n);
185 ~InOutNodesIterator();
191 template<
typename VALUE_TYPE>
192 class SGraphEdgeIterator:
public FactorEdgeIterator,
public MemoryPool<SGraphEdgeIterator<VALUE_TYPE> > {
198 const MutableContainer<VALUE_TYPE>& _filter;
205 if (_filter.get(curEdge.id) == value)
214 SGraphEdgeIterator(
const Graph *sG,
215 const MutableContainer<VALUE_TYPE>& filter,
216 typename tlp::StoredType<VALUE_TYPE>::ReturnedConstValue val)
217 : FactorEdgeIterator(sG), sg(sG), value(val), _filter(filter) {
219 #if !defined(NDEBUG) && !defined(_OPENMP) 220 sg->addListener(
this);
226 ~SGraphEdgeIterator() {
227 #if !defined(NDEBUG) && !defined(_OPENMP) 228 sg->removeListener(
this);
234 assert(curEdge.isValid());
243 return (curEdge.isValid());
248 class TLP_SCOPE OutEdgesIterator:
public FactorEdgeIterator,
public MemoryPool<OutEdgesIterator> {
255 OutEdgesIterator(
const GraphView *sG, node n);
264 class TLP_SCOPE InEdgesIterator:
public FactorEdgeIterator,
public MemoryPool<InEdgesIterator> {
271 InEdgesIterator(
const GraphView *sG, node n);
280 class TLP_SCOPE InOutEdgesIterator:
public FactorEdgeIterator,
public MemoryPool<InOutEdgesIterator> {
287 InOutEdgesIterator(
const GraphView *sG, node n);
288 ~InOutEdgesIterator();
298 class TLP_SCOPE GraphNodeIterator
299 #if defined(NDEBUG) || defined(_OPENMP)
300 :
public NodeIterator,
public MemoryPool<GraphNodeIterator>
302 :
public NodeIteratorObserver
306 #if !defined(NDEBUG) && !defined(_OPENMP) 312 ~GraphNodeIterator();
318 class TLP_SCOPE GraphEdgeIterator
319 #if defined(NDEBUG) || defined(_OPENMP)
320 :
public EdgeIterator,
public MemoryPool<GraphEdgeIterator>
322 :
public EdgeIteratorObserver
326 #if !defined(NDEBUG) && !defined(_OPENMP) 332 ~GraphEdgeIterator();
virtual itType next()=0
Moves the Iterator on the next element.
Interface for Tulip iterators. Allows basic iteration operations only.
virtual bool hasNext()=0
Tells if the sequence is at its end.