anatomist  5.1.2
3D neuroimaging data viewer
AGraphIterator.h
Go to the documentation of this file.
1 /* This software and supporting documentation are distributed by
2  * Institut Federatif de Recherche 49
3  * CEA/NeuroSpin, Batiment 145,
4  * 91191 Gif-sur-Yvette cedex
5  * France
6  *
7  * This software is governed by the CeCILL-B license under
8  * French law and abiding by the rules of distribution of free software.
9  * You can use, modify and/or redistribute the software under the
10  * terms of the CeCILL-B license as circulated by CEA, CNRS
11  * and INRIA at the following URL "http://www.cecill.info".
12  *
13  * As a counterpart to the access to the source code and rights to copy,
14  * modify and redistribute granted by the license, users are provided only
15  * with a limited warranty and the software's author, the holder of the
16  * economic rights, and the successive licensors have only limited
17  * liability.
18  *
19  * In this respect, the user's attention is drawn to the risks associated
20  * with loading, using, modifying and/or developing or reproducing the
21  * software by the user in light of its specific status of free software,
22  * that may mean that it is complicated to manipulate, and that also
23  * therefore means that it is reserved for developers and experienced
24  * professionals having in-depth computer knowledge. Users are therefore
25  * encouraged to load and test the software's suitability as regards their
26  * requirements in conditions enabling the security of their systems and/or
27  * data to be ensured and, more generally, to use and operate it in the
28  * same conditions as regards security.
29  *
30  * The fact that you are presently reading this means that you have had
31  * knowledge of the CeCILL-B license and that you accept its terms.
32  */
33 
34 
35 #ifndef ANA_GRAPH_AGRAPHITERATOR_H
36 #define ANA_GRAPH_AGRAPHITERATOR_H
37 
38 
41 #include <graph/graph/graph.h>
42 
43 
44 namespace anatomist
45 {
46 
47  class AGraph;
48  class AGraphIterator;
49  class const_AGraphIterator;
50 
51  //
52  // class AGraphIterator
53  //
55  {
56  public:
57  friend class AGraph;
58  friend class const_AGraphIterator;
59  typedef std::set<carto::shared_ptr<AObject> > datatype;
60 
61  AGraphIterator( const datatype::iterator& thing );
62  AGraphIterator( const AGraphIterator& other );
63  virtual ~AGraphIterator();
64 
65  virtual BaseIterator* clone() const;
66  virtual bool operator != ( const BaseIterator& other ) const;
67  virtual bool operator != ( const AGraphIterator& other ) const;
68  virtual bool operator != ( const const_AGraphIterator& other ) const;
69  virtual AObject* operator * () const;
70  virtual AGraphIterator& operator ++ ();
71  virtual AGraphIterator& operator -- ();
72 
73  protected:
74  datatype::iterator _dataIt;
75  };
76 
77 
78  //
79  // class const_AGraphIterator
80  //
82  {
83  public:
84  friend class AGraph;
85  friend class AGraphIterator;
86  typedef std::set<carto::shared_ptr<AObject> > datatype;
87 
88  const_AGraphIterator( const datatype::const_iterator& thing );
91 
92  virtual BaseIterator* clone() const;
93  virtual bool operator != ( const BaseIterator& other ) const;
94  virtual bool operator != ( const const_AGraphIterator& other) const;
95  virtual bool operator != ( const AGraphIterator& other) const;
96  virtual AObject* operator * () const;
99 
100  protected:
101  datatype::const_iterator _dataIt;
102  };
103 
104 
105 //
106 // AGraphIterator methods
107 //
108 inline
110 ( const AGraphIterator::datatype::iterator& thing )
111  : BaseIterator(), _dataIt( thing )
112 {
113 }
114 
115 
116 inline
118  : BaseIterator(), _dataIt( other._dataIt )
119 {
120 }
121 
122 
123 inline
125 {
126  return new AGraphIterator( *this );
127 }
128 
129 
130 inline
131 bool AGraphIterator::operator !=
132 ( const BaseIterator& other ) const
133 {
134  return other.operator != ( *this );
135 }
136 
137 
138 inline
139 bool AGraphIterator::operator !=
140 ( const AGraphIterator& other ) const
141 {
142  return _dataIt != other._dataIt;
143 }
144 
145 
146 inline
147 bool AGraphIterator::operator !=
148 ( const const_AGraphIterator& other ) const
149 {
150  return _dataIt != other._dataIt;
151 }
152 
153 
154 inline
156 {
157  return _dataIt->get();
158 }
159 
160 
161 inline
163 {
164  ++_dataIt;
165  return *this;
166 }
167 
168 
169 inline
171 {
172  --_dataIt;
173  return *this;
174 }
175 
176 
177 //
178 // const_AGraphIterator methods
179 //
180 inline
182 ( const const_AGraphIterator::datatype::const_iterator& thing )
183  : BaseIterator(), _dataIt( thing )
184 {
185 }
186 
187 
188 inline
190  : BaseIterator(), _dataIt( other._dataIt )
191 {
192 }
193 
194 
195 inline
197 {
198  return new const_AGraphIterator( *this );
199 }
200 
201 
202 inline
203 bool const_AGraphIterator::operator !=
204 ( const BaseIterator& other ) const
205 {
206  return other.operator != ( *this );
207 }
208 
209 
210 inline
211 bool const_AGraphIterator::operator !=
212 ( const const_AGraphIterator& other ) const
213 {
214  return _dataIt != other._dataIt;
215 }
216 
217 
218 inline
219 bool const_AGraphIterator::operator !=
220 ( const AGraphIterator& other ) const
221 {
222  return _dataIt != other._dataIt;
223 }
224 
225 
226 inline
228 {
229  return _dataIt->get();
230 }
231 
232 
233 inline
235 {
236  ++_dataIt;
237  return *this;
238 }
239 
240 
241 inline
242 const_AGraphIterator& const_AGraphIterator::operator --
243 ()
244 {
245  --_dataIt;
246  return *this;
247 }
248 
249 }
250 
251 
252 #endif
datatype::iterator _dataIt
virtual AGraphIterator & operator++()
virtual AObject * operator*() const
virtual bool operator!=(const BaseIterator &other) const
AGraphIterator(const datatype::iterator &thing)
virtual BaseIterator * clone() const
virtual AGraphIterator & operator--()
std::set< carto::shared_ptr< AObject > > datatype
AGraph object class.
Definition: Graph.h:57
Base Anatomist object (abstract)
Definition: Object.h:96
virtual BaseIterator * clone() const
virtual const_AGraphIterator & operator++()
virtual bool operator!=(const BaseIterator &other) const
datatype::const_iterator _dataIt
std::set< carto::shared_ptr< AObject > > datatype
virtual const_AGraphIterator & operator--()
const_AGraphIterator(const datatype::const_iterator &thing)
virtual AObject * operator*() const