anatomist  5.1.2
3D neuroimaging data viewer
objectVector.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_MOBJECT_OBJECTVECTOR_H
36 #define ANA_MOBJECT_OBJECTVECTOR_H
37 
39 
40 namespace anatomist
41 {
42 
43  class ObjectVector;
44  class const_ObjectVectorIterator;
45  class Referential;
46  class Geometry;
47 
49  {
50  public:
51  friend class ObjectVector;
52  friend class GLObjectVector;
53  typedef std::list<carto::shared_ptr<AObject> > datatype;
54  ObjectVectorIterator( const datatype::iterator & );
56  virtual BaseIterator* clone() const;
57  virtual bool operator != ( const BaseIterator & ) const;
58  virtual bool operator != ( const ObjectVectorIterator & ) const;
59  virtual bool operator != ( const const_ObjectVectorIterator & ) const;
60  virtual AObject* operator * () const;
61  virtual carto::shared_ptr<AObject> smart() const;
64 
65  protected:
66  datatype::iterator _dataIt;
67 
68  private:
69  };
70 
71 
73  {
74  public:
75  friend class ObjectVector;
76  friend class GLObjectVector;
77  typedef std::list<carto::shared_ptr<AObject> > datatype;
78  const_ObjectVectorIterator( const datatype::const_iterator & );
80  virtual BaseIterator* clone() const;
81  virtual bool operator != ( const BaseIterator & ) const;
82  virtual bool operator != ( const ObjectVectorIterator & ) const;
83  virtual bool operator != ( const const_ObjectVectorIterator & ) const;
84  virtual AObject* operator * () const;
85  virtual carto::shared_ptr<AObject> smart() const;
88 
89  protected:
90  datatype::const_iterator _dataIt;
91 
92  private:
93  };
94 
95 
96  inline bool
98  {
99  return( x.operator != ( *this ) );
100  }
101 
102 
103  inline bool
105  {
106  return( x.operator != ( *this ) );
107  }
108 
109 
110  inline bool
112  {
113  return( _dataIt != x._dataIt );
114  }
115 
116 
117  inline bool
120  const
121  {
122  return( _dataIt != x._dataIt );
123  }
124 
125 
126  inline bool
128  const
129  {
130  return( true );
131  }
132 
133 
134  inline bool
136  const
137  {
138  return( true );
139  }
140 
141 
143  {
144  return( _dataIt->get() );
145  }
146 
147 
149  {
150  return( _dataIt->get() );
151  }
152 
153 
155  {
156  return( *_dataIt );
157  }
158 
159 
161  {
162  return( *_dataIt );
163  }
164 
165 
167  {
168  ++_dataIt;
169  return( *this );
170  }
171 
172 
175  {
176  ++_dataIt;
177  return( *this );
178  }
179 
180 
182  {
183  --_dataIt;
184  return( *this );
185  }
186 
187 
190  {
191  --_dataIt;
192  return( *this );
193  }
194 
195 
197  {
198  return( new ObjectVectorIterator( *this ) );
199  }
200 
201 
203  {
204  return( new const_ObjectVectorIterator( *this ) );
205  }
206 
207 
208 
211  class ObjectVector : public MObject
212  {
213  public:
215  virtual ~ObjectVector();
216 
217  virtual int MType() const { return( AObject::VECTOR ); }
218 
221  virtual size_t size() const;
222  virtual iterator begin();
223  virtual const_iterator begin() const;
224  virtual iterator end();
225  virtual const_iterator end() const;
226  virtual void insert( AObject * );
227  virtual void insert( AObject *, int pos );
228  virtual void insert( const carto::shared_ptr<AObject> &, int pos = -1 );
229  virtual const_iterator find( const AObject * ) const;
231  virtual void erase( iterator & );
233  virtual bool CanRemove( AObject *obj );
234 
235  virtual Tree* optionTree() const;
236  static Tree* _optionTree;
237 
238  protected:
239  typedef std::list<carto::shared_ptr<AObject> > datatype;
241  };
242 
243 
244  inline size_t ObjectVector::size() const
245  {
246  return( _data.size() );
247  }
248 
249 
251  {
252  return( iterator( new ObjectVectorIterator( _data.begin() ) ) );
253  }
254 
255 
257  {
258  return( const_iterator
259  ( new const_ObjectVectorIterator( _data.begin() ) ) );
260  }
261 
262 
264  {
265  return( iterator( new ObjectVectorIterator( _data.end() ) ) );
266  }
267 
268 
270  {
271  return( const_iterator( new const_ObjectVectorIterator( _data.end() ) ) );
272  }
273 
274 
275  inline void ObjectVector::insert( AObject * x )
276  {
279  _insertObject( x );
280  }
281 
282 }
283 
284 
285 #endif
T * iterator
const T * const_iterator
Multi-object generic iterator.
Definition: MObject.h:115
Base Anatomist object (abstract)
Definition: Object.h:96
Multi-object : base abstract class for objects that contain others.
Definition: MObject.h:235
AIterator const_iterator
Definition: MObject.h:239
AIterator iterator
Definition: MObject.h:238
virtual void _insertObject(AObject *o)
must be called by all subclasses in their insert() implementation
virtual carto::shared_ptr< AObject > smart() const
Definition: objectVector.h:154
virtual BaseIterator * clone() const
Definition: objectVector.h:196
ObjectVectorIterator(const datatype::iterator &)
virtual AObject * operator*() const
Definition: objectVector.h:142
virtual ObjectVectorIterator & operator--()
Definition: objectVector.h:181
datatype::iterator _dataIt
Definition: objectVector.h:66
std::list< carto::shared_ptr< AObject > > datatype
Definition: objectVector.h:53
virtual ObjectVectorIterator & operator++()
Definition: objectVector.h:166
virtual bool operator!=(const BaseIterator &) const
Definition: objectVector.h:97
it's a list, in fact...
Definition: objectVector.h:212
virtual iterator begin()
Definition: objectVector.h:250
virtual const_iterator find(const carto::shared_ptr< AObject > &) const
virtual size_t size() const
Definition: objectVector.h:244
std::list< carto::shared_ptr< AObject > > datatype
Definition: objectVector.h:239
virtual void insert(AObject *, int pos)
virtual Tree * optionTree() const
Menu tree for new options, see object/optionMatcher.h.
virtual void insert(const carto::shared_ptr< AObject > &, int pos=-1)
virtual bool CanRemove(AObject *obj)
virtual const_iterator find(const AObject *) const
virtual void insert(AObject *)
Definition: objectVector.h:275
virtual void erase(iterator &)
static Tree * _optionTree
Definition: objectVector.h:236
virtual iterator end()
Definition: objectVector.h:263
virtual int MType() const
Precise type of multi-object.
Definition: objectVector.h:217
virtual BaseIterator * clone() const
Definition: objectVector.h:202
const_ObjectVectorIterator(const datatype::const_iterator &)
virtual carto::shared_ptr< AObject > smart() const
Definition: objectVector.h:160
datatype::const_iterator _dataIt
Definition: objectVector.h:90
virtual AObject * operator*() const
Definition: objectVector.h:148
virtual const_ObjectVectorIterator & operator++()
Definition: objectVector.h:174
virtual bool operator!=(const BaseIterator &) const
Definition: objectVector.h:104
std::list< carto::shared_ptr< AObject > > datatype
Definition: objectVector.h:77
virtual const_ObjectVectorIterator & operator--()
Definition: objectVector.h:189
std::vector< Object > ObjectVector
Definition: objectVector.h:51