21 #ifndef TULIP_BASICITERATORS_H 22 #define TULIP_BASICITERATORS_H 23 #include <tulip/Iterator.h> 24 #include <tulip/memorypool.h> 25 #include <tulip/MutableContainer.h> 35 class TLP_SCOPE NodeIterator :
public Iterator<node> {};
37 class TLP_SCOPE EdgeIterator :
public Iterator<edge> {};
41 class TLP_SCOPE FactorNodeIterator :
public NodeIterator {
45 void enableListening(
const Graph *sg);
46 void disableListening(
const Graph *sg);
49 FactorNodeIterator(
const Graph *sg) : _parentGraph(sg->getSuperGraph()), ito(nullptr) {}
52 class TLP_SCOPE FactorEdgeIterator :
public EdgeIterator {
54 const Graph *_parentGraph;
56 void enableListening(
const Graph *sg);
57 void disableListening(
const Graph *sg);
60 FactorEdgeIterator(
const Graph *sg) : _parentGraph(sg->getSuperGraph()), ito(nullptr) {}
66 template <
typename VALUE_TYPE>
67 class SGraphNodeIterator :
public FactorNodeIterator,
68 public MemoryPool<SGraphNodeIterator<VALUE_TYPE>> {
74 const MutableContainer<VALUE_TYPE> &_filter;
78 while (it->hasNext()) {
81 if (_filter.get(curNode) == value)
90 SGraphNodeIterator(
const Graph *sG,
const MutableContainer<VALUE_TYPE> &filter,
91 typename tlp::StoredType<VALUE_TYPE>::ReturnedConstValue val)
92 : FactorNodeIterator(sG), sg(sG), value(val), _filter(filter) {
99 ~SGraphNodeIterator()
override {
100 disableListening(sg);
104 node next()
override {
105 assert(curNode.isValid());
113 bool hasNext()
override {
114 return (curNode.isValid());
120 template <
typename VALUE_TYPE>
121 class SGraphEdgeIterator :
public FactorEdgeIterator,
122 public MemoryPool<SGraphEdgeIterator<VALUE_TYPE>> {
128 const MutableContainer<VALUE_TYPE> &_filter;
132 while (it->hasNext()) {
133 curEdge = it->next();
135 if (_filter.get(curEdge.id) == value)
144 SGraphEdgeIterator(
const Graph *sG,
const MutableContainer<VALUE_TYPE> &filter,
145 typename tlp::StoredType<VALUE_TYPE>::ReturnedConstValue val)
146 : FactorEdgeIterator(sG), sg(sG), value(val), _filter(filter) {
152 ~SGraphEdgeIterator()
override {
156 edge next()
override {
157 assert(curEdge.isValid());
165 bool hasNext()
override {
166 return (curEdge.isValid());