anatomist  5.0.5
3D neuroimaging data viewer
ObjectList.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_OBJECTLIST_H
36 #define ANA_MOBJECT_OBJECTLIST_H
37 
39 
40 
41 namespace anatomist
42 {
43 
44  class ObjectList;
45  class const_ObjectListIterator;
46  class Referential;
47  class Geometry;
48 
50  {
51  public:
52  friend class ObjectList;
53  friend class GLObjectList;
54  typedef std::set<carto::shared_ptr<AObject> > datatype;
55  ObjectListIterator( const datatype::iterator & );
56  virtual ~ObjectListIterator();
57  virtual BaseIterator* clone() const;
58  virtual bool operator != ( const BaseIterator & ) const;
59  virtual bool operator != ( const ObjectListIterator & ) const;
60  virtual bool operator != ( const const_ObjectListIterator & ) const;
61  virtual AObject* operator * () const;
63  virtual carto::shared_ptr<AObject> smart() const;
64  virtual ObjectListIterator & operator ++ ();
65  virtual ObjectListIterator & operator -- ();
66 
67  protected:
68  datatype::iterator _dataIt;
69 
70  private:
71  };
72 
73 
75  {
76  public:
77  friend class ObjectList;
78  typedef std::set<carto::shared_ptr<AObject> > datatype;
79  const_ObjectListIterator( const datatype::const_iterator & );
80  virtual ~const_ObjectListIterator();
81  virtual BaseIterator* clone() const;
82  virtual bool operator != ( const BaseIterator & ) const;
83  virtual bool operator != ( const ObjectListIterator & ) const;
84  virtual bool operator != ( const const_ObjectListIterator & ) const;
85  virtual AObject* operator * () const;
87  virtual carto::shared_ptr<AObject> smart() const;
90 
91  protected:
92  datatype::const_iterator _dataIt;
93 
94  private:
95  };
96 
97 
98  inline bool ObjectListIterator::operator != ( const BaseIterator & x ) const
99  {
100  return( x.operator != ( *this ) );
101  }
102 
103 
104  inline bool
106  {
107  return( x.operator != ( *this ) );
108  }
109 
110 
111  inline bool
113  {
114  return( _dataIt != x._dataIt );
115  }
116 
117 
118  inline bool
120  const
121  {
122  return( _dataIt != x._dataIt );
123  }
124 
125 
126  inline bool
128  {
129  return( true );
130  }
131 
132 
133  inline bool
135  {
136  return( true );
137  }
138 
139 
141  {
142  return( _dataIt->get() );
143  }
144 
145 
147  {
148  return( _dataIt->get() );
149  }
150 
151 
153  {
154  return( *_dataIt );
155  }
156 
157 
159  {
160  return( *_dataIt );
161  }
162 
163 
165  {
166  ++_dataIt;
167  return( *this );
168  }
169 
170 
172  {
173  ++_dataIt;
174  return( *this );
175  }
176 
177 
179  {
180  --_dataIt;
181  return( *this );
182  }
183 
184 
186  {
187  --_dataIt;
188  return( *this );
189  }
190 
191 
193  {
194  return( new ObjectListIterator( *this ) );
195  }
196 
197 
199  {
200  return( new const_ObjectListIterator( *this ) );
201  }
202 
203 
204 
207  class ObjectList : public MObject
208  {
209  public:
210  ObjectList();
211  virtual ~ObjectList();
212 
213  virtual int MType() const { return( AObject::LIST ); }
214 
215  virtual size_t size() const;
216  virtual iterator begin();
217  virtual const_iterator begin() const;
218  virtual iterator end();
219  virtual const_iterator end() const;
220  virtual void insert( AObject * );
221  virtual void insert( const carto::shared_ptr<AObject> & );
222  virtual const_iterator find( const AObject * ) const;
223  virtual void erase( iterator & );
224 
225  virtual bool CanRemove( AObject *obj );
226 
227  virtual bool render( PrimList &, const ViewState & );
228 
229  virtual Tree* optionTree() const;
230  static Tree* _optionTree;
231 
232  protected:
234  typedef std::set<carto::shared_ptr<AObject> > datatype;
235  datatype _data;
236  };
237 
238 
239  inline size_t ObjectList::size() const
240  {
241  return( _data.size() );
242  }
243 
244 
246  {
247  return( iterator( new ObjectListIterator( _data.begin() ) ) );
248  }
249 
250 
252  {
253  return( const_iterator( new const_ObjectListIterator( _data.begin() ) ) );
254  }
255 
256 
258  {
259  return( iterator( new ObjectListIterator( _data.end() ) ) );
260  }
261 
262 
264  {
265  return( const_iterator( new const_ObjectListIterator( _data.end() ) ) );
266  }
267 
268 
269  inline void ObjectList::insert( AObject * x )
270  {
271  _data.insert( carto::shared_ptr<AObject>(
273  _insertObject( x );
274  }
275 
276 
278  {
279  _data.insert( x );
280  _insertObject( x.get() );
281  }
282 
283 
285  {
286  // ajouter un test du type d'iterateur avant le casting brutal
287  datatype::iterator & it = ((ObjectListIterator&)i.subIterator())._dataIt;
288  _eraseObject( it->get() );
289  _data.erase( it );
290  }
291 
292 }
293 
294 
295 #endif
virtual BaseIterator * clone() const
Definition: ObjectList.h:192
virtual ObjectListIterator & operator++()
Definition: ObjectList.h:164
static Tree * _optionTree
Definition: ObjectList.h:230
ViewState holds information about how a view wants to see an object.
Definition: viewstate.h:66
virtual ObjectListIterator & operator--()
Definition: ObjectList.h:178
Base Anatomist object (abstract)
Definition: Object.h:95
Multi-object generic iterator.
Definition: MObject.h:114
std::list< carto::rc_ptr< GLItem > > PrimList
Definition: Object.h:72
virtual AObject * operator*() const
Definition: ObjectList.h:140
Multi-object : base abstract class for objects that contain others.
Definition: MObject.h:234
virtual const_ObjectListIterator & operator--()
Definition: ObjectList.h:185
virtual AObject * operator*() const
Definition: ObjectList.h:146
ObjectListIterator(const datatype::iterator &)
std::set< carto::shared_ptr< AObject > > datatype
Definition: ObjectList.h:54
virtual iterator end()
Definition: ObjectList.h:257
std::set< carto::shared_ptr< AObject > > datatype
Data storage type, to be redefined by children classes.
Definition: ObjectList.h:234
datatype::iterator _dataIt
Definition: ObjectList.h:68
virtual void insert(AObject *)
Definition: ObjectList.h:269
virtual bool operator!=(const BaseIterator &) const
Definition: ObjectList.h:98
std::set< carto::shared_ptr< AObject > > datatype
Definition: ObjectList.h:78
virtual BaseIterator * clone() const
Definition: ObjectList.h:198
datatype::const_iterator _dataIt
Definition: ObjectList.h:92
Multi-object : AObject containing children objects.
Definition: ObjectList.h:207
virtual size_t size() const
Definition: ObjectList.h:239
virtual carto::shared_ptr< AObject > smart() const
de-reference iterator to get the underlying smart pointer
Definition: ObjectList.h:152
virtual carto::shared_ptr< AObject > smart() const
de-reference iterator to get the underlying smart pointer
Definition: ObjectList.h:158
virtual int MType() const
Precise type of multi-object.
Definition: ObjectList.h:213
virtual iterator begin()
Definition: ObjectList.h:245
virtual void erase(iterator &)
Definition: ObjectList.h:284
virtual const_ObjectListIterator & operator++()
Definition: ObjectList.h:171
virtual bool operator!=(const BaseIterator &) const
Definition: ObjectList.h:105
BaseIterator & subIterator()
Definition: MObject.h:130