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 \*---------------------------------------------------------------------------*/
41 /*! \class MemObjPointerMFieldBase
43 \brief Base class of all fields that store MemoryObjectPtr.
45 It provides the const parts of the std::vector interface, but the pointers
46 returned/accepted by these functions are always pointers to the base
47 class MemoryObject, not the derived type.
48 To access those as well as for write access one of the derived classes
54 SizeT MemObjPointerMFieldBase::getBinSize(void) const
57 sizeof(UInt32) + // num elements
59 MFieldTraits::getBinSize(&(_ptrStore[0]), _ptrStore.size()) : 0);
64 void MemObjPointerMFieldBase::copyToBin(BinaryDataHandler &pMem) const
66 UInt32 n = UInt32(_ptrStore.size());
72 MFieldTraits::copyToBin( pMem,
78 /*-------------------------------------------------------------------------*/
79 /* Std Library Const Interface */
82 MemObjPointerMFieldBase::const_iterator
83 MemObjPointerMFieldBase::begin(void) const
85 return _ptrStore.begin();
89 MemObjPointerMFieldBase::const_iterator MemObjPointerMFieldBase::end(void) const
91 return _ptrStore.end();
95 MemObjPointerMFieldBase::const_reverse_iterator
96 MemObjPointerMFieldBase::rbegin(void) const
98 return _ptrStore.rbegin();
102 MemObjPointerMFieldBase::const_reverse_iterator
103 MemObjPointerMFieldBase::rend(void) const
105 return _ptrStore.rend();
109 MemObjPointerMFieldBase::value_type MemObjPointerMFieldBase::front(void) const
111 return _ptrStore.front();
115 MemObjPointerMFieldBase::value_type MemObjPointerMFieldBase::back(void) const
117 return _ptrStore.back();
121 bool MemObjPointerMFieldBase::empty(void) const
123 return _ptrStore.empty();
127 MemObjPointerMFieldBase::size_type MemObjPointerMFieldBase::size(void) const
129 return _ptrStore.size();
133 MemObjPointerMFieldBase::size_type MemObjPointerMFieldBase::max_size(void) const
135 return _ptrStore.max_size();
139 MemObjPointerMFieldBase::size_type MemObjPointerMFieldBase::capacity(void) const
141 return _ptrStore.capacity();
145 MemObjPointerMFieldBase::difference_type
146 MemObjPointerMFieldBase::findIndex(const_value value) const
148 const_iterator it = std::find(_ptrStore.begin(), _ptrStore.end(), value);
150 if(it != _ptrStore.end())
152 return it - _ptrStore.begin();
161 void MemObjPointerMFieldBase::reserve(size_type newSize)
163 return _ptrStore.reserve(newSize);
167 MemObjPointerMFieldBase::value_type
168 MemObjPointerMFieldBase::operator[](size_type const index) const
170 return _ptrStore[index];
174 MemObjPointerMFieldBase::value_type
175 MemObjPointerMFieldBase::at(size_type const index) const
177 return _ptrStore.at(index);
181 bool MemObjPointerMFieldBase::operator ==(const Self &source) const
183 return _ptrStore == source._ptrStore;
187 #ifdef OSG_MT_CPTR_ASPECT
189 void MemObjPointerMFieldBase::beginEdit(UInt32 ,
195 MemObjPointerMFieldBase::Self *
196 MemObjPointerMFieldBase::resolveShare(UInt32 ,
203 void MemObjPointerMFieldBase::terminateShare(UInt32 ,
210 bool MemObjPointerMFieldBase::isShared(void)
216 /*-------------------------------------------------------------------------*/
220 MemObjPointerMFieldBase::MemObjPointerMFieldBase(void) :
226 /*-------------------------------------------------------------------------*/
230 MemObjPointerMFieldBase::~MemObjPointerMFieldBase(void)
235 /*-------------------------------------------------------------------------*/
236 /* Raw Store Access */
239 MemObjPointerMFieldBase::StorageType &
240 MemObjPointerMFieldBase::editRawStore(void)
246 MemObjPointerMFieldBase::StorageType const &
247 MemObjPointerMFieldBase::getRawStore(void) const
252 /*-------------------------------------------------------------------------*/
253 /* Cast Store Access */
255 template <class TargetStoredTypeT> inline
256 typename MemObjPointerMFieldBase::rebindStore<TargetStoredTypeT>::type &
257 MemObjPointerMFieldBase::editStore(void)
260 reinterpret_cast<typename rebindStore<TargetStoredTypeT>::type &>(
264 template <class TargetStoredTypeT> inline
265 typename MemObjPointerMFieldBase::rebindStore<TargetStoredTypeT>::type const &
266 MemObjPointerMFieldBase::getStore(void) const
269 reinterpret_cast<typename rebindStore<TargetStoredTypeT>::type const &>(