anatomist 6.0.4
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
41namespace anatomist
42{
43
44 class ObjectList;
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 & );
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;
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 & );
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:
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 Tree* optionTree() const;
229
230 protected:
232 typedef std::set<carto::shared_ptr<AObject> > datatype;
234 };
235
236
237 inline size_t ObjectList::size() const
238 {
239 return( _data.size() );
240 }
241
242
244 {
245 return( iterator( new ObjectListIterator( _data.begin() ) ) );
246 }
247
248
250 {
251 return( const_iterator( new const_ObjectListIterator( _data.begin() ) ) );
252 }
253
254
256 {
257 return( iterator( new ObjectListIterator( _data.end() ) ) );
258 }
259
260
262 {
263 return( const_iterator( new const_ObjectListIterator( _data.end() ) ) );
264 }
265
266
273
274
276 {
277 _data.insert( x );
278 _insertObject( x.get() );
279 }
280
281
283 {
284 // ajouter un test du type d'iterateur avant le casting brutal
285 datatype::iterator & it = ((ObjectListIterator&)i.subIterator())._dataIt;
286 _eraseObject( it->get() );
287 _data.erase( it );
288 }
289
290}
291
292
293#endif
T * iterator
const T * const_iterator
BaseIterator & subIterator()
Definition MObject.h:130
Base Anatomist object (abstract)
Definition Object.h:97
AIterator const_iterator
Definition MObject.h:239
AIterator iterator
Definition MObject.h:238
virtual void _eraseObject(AObject *o)
must be called by all subclasses if they reimplement erase()
virtual void _insertObject(AObject *o)
must be called by all subclasses in their insert() implementation
virtual AObject * operator*() const
Definition ObjectList.h:140
virtual carto::shared_ptr< AObject > smart() const
de-reference iterator to get the underlying smart pointer
Definition ObjectList.h:152
virtual ObjectListIterator & operator--()
Definition ObjectList.h:178
std::set< carto::shared_ptr< AObject > > datatype
Definition ObjectList.h:54
datatype::iterator _dataIt
Definition ObjectList.h:68
virtual ObjectListIterator & operator++()
Definition ObjectList.h:164
virtual bool operator!=(const BaseIterator &) const
Definition ObjectList.h:98
ObjectListIterator(const datatype::iterator &)
virtual BaseIterator * clone() const
Definition ObjectList.h:192
Multi-object : AObject containing children objects.
Definition ObjectList.h:208
virtual int MType() const
Precise type of multi-object.
Definition ObjectList.h:213
std::set< carto::shared_ptr< AObject > > datatype
Data storage type, to be redefined by children classes.
Definition ObjectList.h:232
virtual iterator begin()
Definition ObjectList.h:243
virtual Tree * optionTree() const
Menu tree for new options, see object/optionMatcher.h.
virtual iterator end()
Definition ObjectList.h:255
virtual void insert(AObject *)
Definition ObjectList.h:267
virtual bool CanRemove(AObject *obj)
virtual void erase(iterator &)
Definition ObjectList.h:282
static Tree * _optionTree
Definition ObjectList.h:228
virtual const_iterator find(const AObject *) const
virtual size_t size() const
Definition ObjectList.h:237
Referential: marker for transformations, with an associated color.
Definition Referential.h:56
virtual AObject * operator*() const
Definition ObjectList.h:146
virtual bool operator!=(const BaseIterator &) const
Definition ObjectList.h:105
std::set< carto::shared_ptr< AObject > > datatype
Definition ObjectList.h:78
virtual const_ObjectListIterator & operator--()
Definition ObjectList.h:185
datatype::const_iterator _dataIt
Definition ObjectList.h:92
const_ObjectListIterator(const datatype::const_iterator &)
virtual const_ObjectListIterator & operator++()
Definition ObjectList.h:171
virtual carto::shared_ptr< AObject > smart() const
de-reference iterator to get the underlying smart pointer
Definition ObjectList.h:158
virtual BaseIterator * clone() const
Definition ObjectList.h:198