1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2008 by the OpenSG Forum *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
15 * This library is free software; you can redistribute it and/or modify it *
16 * under the terms of the GNU Library General Public License as published *
17 * by the Free Software Foundation, version 2. *
19 * This library is distributed in the hope that it will be useful, but *
20 * WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
22 * Library General Public License for more details. *
24 * You should have received a copy of the GNU Library General Public *
25 * License along with this library; if not, write to the Free Software *
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
37 \*---------------------------------------------------------------------------*/
39 #ifndef _OSGPOINTERMFIELDBASE_H_
40 #define _OSGPOINTERMFIELDBASE_H_
46 #include "OSGBaseDef.h"
47 #include "OSGMField.h"
48 #include "OSGFieldContainerFieldTraits.h"
52 class PointerMFieldBaseConstIterator
;
54 /*! \ingroup GrpBaseFieldContainerFields
55 \ingroup GrpLibOSGBase
58 class OSG_BASE_DLLMAPPING PointerMFieldBase
: public Field
60 /*========================== PUBLIC =================================*/
64 /*---------------------------------------------------------------------*/
65 /*! \name Public Types */
68 typedef Field Inherited
;
69 typedef PointerMFieldBase Self
;
72 typedef FieldContainer
* StoredType
;
73 typedef MFieldVector
<StoredType
> StorageType
;
74 typedef StorageType::const_iterator StorageConstIt
;
77 typedef PointerMFieldBaseConstIterator const_iterator
;
78 typedef std::reverse_iterator
<const_iterator
> const_reverse_iterator
;
80 typedef FieldContainer
* const const_value
;
81 typedef FieldContainer
* value_type
;
83 typedef StorageType::size_type size_type
;
84 typedef StorageType::difference_type difference_type
;
87 typedef FieldTraits
<FieldContainer
*, 0> MFieldTraits
;
90 typedef EditMFieldHandle
<Self
> EditHandle
;
91 typedef boost::shared_ptr
<EditHandle
> EditHandlePtr
;
93 typedef GetMFieldHandle
<Self
> GetHandle
;
94 typedef boost::shared_ptr
<GetHandle
> GetHandlePtr
;
96 /*---------------------------------------------------------------------*/
98 static const bool isSField
= false;
99 static const bool isMField
= true;
101 static const bool isPointerField
= true;
103 /*---------------------------------------------------------------------*/
104 /*! \name Class Get */
107 static const FieldType
&getClassType(void);
110 /*---------------------------------------------------------------------*/
111 /*! \name Binary Interface */
114 SizeT
getBinSize(void ) const;
116 void copyToBin (BinaryDataHandler
&pMem
) const;
119 /*---------------------------------------------------------------------*/
120 /*! \name Std Library Const Interface */
123 const_iterator
begin (void ) const;
124 const_iterator
end (void ) const;
126 const_reverse_iterator
rbegin (void ) const;
127 const_reverse_iterator
rend (void ) const;
129 value_type
front (void ) const;
130 value_type
back (void ) const;
132 bool empty (void ) const;
133 size_type
size (void ) const;
134 UInt32
size32 (void ) const;
135 size_type
max_size (void ) const;
136 size_type
capacity (void ) const;
138 difference_type
findIndex(const_value value
) const;
141 /*---------------------------------------------------------------------*/
142 /*! \name Index Operator */
145 value_type
operator[](const size_type index
) const;
146 value_type
at (const size_type index
) const;
149 /*---------------------------------------------------------------------*/
150 /*! \name Raw Store Access */
153 bool operator ==(const Self
&source
) const;
156 /*---------------------------------------------------------------------*/
160 void dump( UInt32 uiIndent
= 0,
161 const BitVector bvFlags
= 0) const;
164 /*---------------------------------------------------------------------*/
168 #ifdef OSG_MT_CPTR_ASPECT
169 void beginEdit (UInt32 uiAspect
,
170 AspectOffsetStore
&oOffsets
);
172 Self
*resolveShare (UInt32 uiAspect
,
173 AspectOffsetStore
&oOffsets
);
175 void terminateShare(UInt32 uiAspect
,
176 AspectOffsetStore
&oOffsets
);
178 bool isShared (void );
182 /*========================= PROTECTED ===============================*/
186 typedef StorageType::iterator iterator
;
187 typedef StorageType::iterator StorageIt
;
189 /*---------------------------------------------------------------------*/
193 static FieldType _fieldType
;
194 StorageType _ptrStore
;
197 /*---------------------------------------------------------------------*/
198 /*! \name Constructors */
201 PointerMFieldBase(void);
204 /*---------------------------------------------------------------------*/
205 /*! \name Destructor */
208 ~PointerMFieldBase(void);
211 /*---------------------------------------------------------------------*/
212 /*! \name Assignment */
215 void reserve(size_type newSize
);
218 /*---------------------------------------------------------------------*/
219 /*! \name Assignment */
222 void operator =(const Self
&source
);
225 /*---------------------------------------------------------------------*/
226 /*! \name Cast Store Access */
230 template <class TargetStoredTypeT
>
233 typedef MFieldVector
<TargetStoredTypeT
> type
;
236 template <class TargetStoredTypeT
>
237 typename rebindStore
<TargetStoredTypeT
>::type
&editStore(void);
239 template <class TargetStoredTypeT
>
240 typename rebindStore
<TargetStoredTypeT
>::type
const &getStore (void) const;
242 StorageType
&editRawStore(void);
243 StorageType
const &getRawStore (void) const;
246 /*========================== PRIVATE ================================*/
250 PointerMFieldBase(const Self
&obj
);
253 typedef PointerMFieldBase FieldContainerPtrMFieldBase
;
256 /*---------------------------------------------------------------------------*/
257 /* PointerMFieldBaseConstIterator */
258 /*---------------------------------------------------------------------------*/
260 /*! \ingroup GrpBaseFieldContainerFields
261 \ingroup GrpLibOSGBase
265 class OSG_BASE_DLLMAPPING PointerMFieldBaseConstIterator
:
266 protected PointerMFieldBase::StorageConstIt
268 /*========================== PUBLIC =================================*/
270 /*---------------------------------------------------------------------*/
271 /*! \name Public Types */
274 typedef PointerMFieldBaseConstIterator Self
;
275 typedef PointerMFieldBase::StorageConstIt Inherited
;
277 typedef PointerMFieldBase MFieldType
;
280 typedef MFieldType::StoredType StoredType
;
281 typedef MFieldType::StorageType StorageType
;
282 typedef MFieldType::StorageConstIt StorageConstIt
;
284 typedef MFieldType::const_value const_value
;
287 typedef Inherited::iterator_category iterator_category
;
288 typedef Inherited::difference_type difference_type
;
289 typedef Inherited::value_type value_type
;
290 typedef Inherited::pointer pointer
;
291 typedef Inherited::reference reference
;
293 #if defined(WIN32) && _SECURE_SCL == 1 && _MSC_VER < 1600
294 typedef Inherited::_Checked_iterator_base_type
295 _Checked_iterator_base_type
;
296 typedef Inherited::_Checked_iterator_category
297 _Checked_iterator_category
;
301 /*---------------------------------------------------------------------*/
302 /*! \name Constructors */
305 PointerMFieldBaseConstIterator( void );
306 PointerMFieldBaseConstIterator(const Self
&source
);
307 explicit PointerMFieldBaseConstIterator(const StorageConstIt
&storeIt
);
310 /*---------------------------------------------------------------------*/
311 /*! \name Destructor */
314 ~PointerMFieldBaseConstIterator(void);
317 /*---------------------------------------------------------------------*/
318 /*! \name Access Operators */
321 value_type
operator * ( void ) const;
322 value_type
operator [](const difference_type offset
) const;
325 /*---------------------------------------------------------------------*/
326 /*! \name Operators */
329 Self
& operator ++( void );
330 Self
operator ++( int );
332 Self
& operator --( void );
333 Self
operator --( int );
335 Self
& operator +=(const difference_type offset
);
336 Self
operator + (const difference_type offset
) const;
338 Self
& operator -=(const difference_type offset
);
339 Self
operator - (const difference_type offset
) const;
341 bool operator == (const Self
& rhs
) const;
342 bool operator != (const Self
& rhs
) const;
345 /*========================= PROTECTED ===============================*/
352 #include "OSGPointerMFieldBase.inl"
354 #endif // _OSGPOINTERMFIELDBASE_H_