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 _OSGMEMOBJPOINTERMFIELDBASE_H_
40 #define _OSGMEMOBJPOINTERMFIELDBASE_H_
46 #include "OSGBaseDef.h"
47 #include "OSGMField.h"
48 #include "OSGMemoryObjectFieldTraits.h"
52 /*! \ingroup GrpBaseMemoryObjectsFields
53 \ingroup GrpLibOSGBase
56 class OSG_BASE_DLLMAPPING MemObjPointerMFieldBase
: public Field
58 /*========================== PUBLIC =================================*/
62 /*---------------------------------------------------------------------*/
63 /*! \name Public Types */
66 typedef Field Inherited
;
67 typedef MemObjPointerMFieldBase Self
;
70 typedef MemoryObject
* StoredType
;
71 typedef MFieldVector
<StoredType
> StorageType
;
73 typedef StorageType::const_iterator const_iterator
;
74 typedef StorageType::const_reverse_iterator const_reverse_iterator
;
76 typedef StorageType::const_iterator StorageConstIt
;
78 typedef MemoryObject
* const const_value
;
79 typedef MemoryObject
* value_type
;
81 typedef StorageType::size_type size_type
;
82 typedef StorageType::difference_type difference_type
;
85 typedef FieldTraits
<MemoryObject
*, 0> MFieldTraits
;
89 typedef EditMFieldHandle
<Self
> EditHandle
;
90 typedef boost::shared_ptr
<EditHandle
> EditHandlePtr
;
92 typedef GetMFieldHandle
<Self
> GetHandle
;
93 typedef boost::shared_ptr
<GetHandle
> GetHandlePtr
;
95 /*---------------------------------------------------------------------*/
97 static const bool isSField
= false;
98 static const bool isMField
= true;
100 static const bool isPointerField
= true;
102 /*---------------------------------------------------------------------*/
103 /*! \name Class Get */
106 static const FieldType
&getClassType(void);
109 /*---------------------------------------------------------------------*/
110 /*! \name Binary Interface */
113 SizeT
getBinSize(void ) const;
115 void copyToBin (BinaryDataHandler
&pMem
) const;
118 /*---------------------------------------------------------------------*/
119 /*! \name Std Library Const Interface */
122 const_iterator
begin (void ) const;
123 const_iterator
end (void ) const;
125 const_reverse_iterator
rbegin (void ) const;
126 const_reverse_iterator
rend (void ) const;
128 value_type
front (void ) const;
129 value_type
back (void ) const;
131 bool empty (void ) const;
132 size_type
size (void ) const;
133 size_type
max_size (void ) const;
134 size_type
capacity (void ) const;
136 difference_type
findIndex(const_value value
) const;
139 /*---------------------------------------------------------------------*/
140 /*! \name Index Operator */
143 value_type
operator[](const size_type index
) const;
144 value_type
at (const size_type index
) const;
147 /*---------------------------------------------------------------------*/
148 /*! \name Raw Store Access */
151 bool operator ==(const Self
&source
) const;
154 /*---------------------------------------------------------------------*/
158 void dump( UInt32 uiIndent
= 0,
159 const BitVector bvFlags
= 0) const;
162 /*---------------------------------------------------------------------*/
166 #ifdef OSG_MT_CPTR_ASPECT
167 void beginEdit (UInt32 uiAspect
,
168 AspectOffsetStore
&oOffsets
);
170 Self
*resolveShare (UInt32 uiAspect
,
171 AspectOffsetStore
&oOffsets
);
173 void terminateShare(UInt32 uiAspect
,
174 AspectOffsetStore
&oOffsets
);
176 bool isShared (void );
180 /*========================= PROTECTED ===============================*/
184 typedef StorageType::iterator iterator
;
185 typedef StorageType::iterator StorageIt
;
187 /*---------------------------------------------------------------------*/
191 static FieldType _fieldType
;
192 StorageType _ptrStore
;
195 /*---------------------------------------------------------------------*/
196 /*! \name Constructors */
199 MemObjPointerMFieldBase(void);
202 /*---------------------------------------------------------------------*/
203 /*! \name Destructor */
206 ~MemObjPointerMFieldBase(void);
209 /*---------------------------------------------------------------------*/
210 /*! \name Assignment */
213 void reserve(size_type newSize
);
216 /*---------------------------------------------------------------------*/
217 /*! \name Assignment */
220 void operator =(const Self
&source
);
223 /*---------------------------------------------------------------------*/
224 /*! \name Cast Store Access */
228 template <class TargetStoredTypeT
>
231 typedef MFieldVector
<TargetStoredTypeT
> type
;
234 template <class TargetStoredTypeT
>
235 typename rebindStore
<TargetStoredTypeT
>::type
&editStore(void);
237 template <class TargetStoredTypeT
>
238 typename rebindStore
<TargetStoredTypeT
>::type
const &getStore (void) const;
240 StorageType
&editRawStore(void);
241 StorageType
const &getRawStore (void) const;
244 /*========================== PRIVATE ================================*/
248 MemObjPointerMFieldBase(const Self
&obj
);
251 typedef MemObjPointerMFieldBase MemoryObjectPtrMFieldBase
;
255 #include "OSGMemObjPointerMFieldBase.inl"
257 #endif // _OSGMEMOBJPOINTERMFIELDBASE_H_