changed: gcc8 base update
[opensg.git] / Source / Base / FieldContainer / Fields / MemObjPointerFields / OSGMemObjPointerMFieldBase.inl
blob907fa0bdf63ed051d5d56e39719fca9737679c08
1 /*---------------------------------------------------------------------------*\
2  *                                OpenSG                                     *
3  *                                                                           *
4  *                                                                           *
5  *           Copyright (C) 2008 by the OpenSG Forum                          *
6  *                                                                           *
7  *                            www.opensg.org                                 *
8  *                                                                           *
9  *   contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de          *
10  *                                                                           *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
13  *                                License                                    *
14  *                                                                           *
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.                               *
18  *                                                                           *
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.                          *
23  *                                                                           *
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.                 *
27  *                                                                           *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
30  *                                Changes                                    *
31  *                                                                           *
32  *                                                                           *
33  *                                                                           *
34  *                                                                           *
35  *                                                                           *
36  *                                                                           *
37 \*---------------------------------------------------------------------------*/
39 OSG_BEGIN_NAMESPACE
41 /*! \class MemObjPointerMFieldBase
43     \brief Base class of all fields that store MemoryObjectPtr.
44     
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
49     has to be used.
50  */
53 inline
54 SizeT MemObjPointerMFieldBase::getBinSize(void) const
56     return 
57         sizeof(UInt32) + // num elements
58         (_ptrStore.size() ? 
59          MFieldTraits::getBinSize(&(_ptrStore[0]), _ptrStore.size()) : 0);
63 inline
64 void MemObjPointerMFieldBase::copyToBin(BinaryDataHandler &pMem) const
66     UInt32 n = UInt32(_ptrStore.size());
68     pMem.putValue(n);
70     if(n != 0)
71     {
72         MFieldTraits::copyToBin(   pMem, 
73                                 &(_ptrStore[0]),
74                                   _ptrStore.size());
75     }
78 /*-------------------------------------------------------------------------*/
79 /* Std Library Const Interface                                             */
81 inline 
82 MemObjPointerMFieldBase::const_iterator 
83     MemObjPointerMFieldBase::begin(void) const
85     return _ptrStore.begin();
88 inline 
89 MemObjPointerMFieldBase::const_iterator MemObjPointerMFieldBase::end(void) const
91     return _ptrStore.end();
93     
94 inline 
95 MemObjPointerMFieldBase::const_reverse_iterator 
96     MemObjPointerMFieldBase::rbegin(void) const
98     return _ptrStore.rbegin();
101 inline 
102 MemObjPointerMFieldBase::const_reverse_iterator 
103     MemObjPointerMFieldBase::rend(void) const
105     return _ptrStore.rend();
108 inline 
109 MemObjPointerMFieldBase::value_type MemObjPointerMFieldBase::front(void) const
111     return _ptrStore.front();
114 inline 
115 MemObjPointerMFieldBase::value_type MemObjPointerMFieldBase::back(void) const
117     return _ptrStore.back();
120 inline 
121 bool MemObjPointerMFieldBase::empty(void) const
123     return _ptrStore.empty();
126 inline 
127 MemObjPointerMFieldBase::size_type MemObjPointerMFieldBase::size(void) const
129     return _ptrStore.size();
132 inline 
133 MemObjPointerMFieldBase::size_type MemObjPointerMFieldBase::max_size(void) const
135     return _ptrStore.max_size();
138 inline 
139 MemObjPointerMFieldBase::size_type MemObjPointerMFieldBase::capacity(void) const
141     return _ptrStore.capacity();
143     
144 inline
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())
151     {
152         return it - _ptrStore.begin();
153     }
154     else
155     {
156         return -1;
157     }
160 inline 
161 void MemObjPointerMFieldBase::reserve(size_type newSize)
163     return _ptrStore.reserve(newSize);
166 inline 
167 MemObjPointerMFieldBase::value_type 
168     MemObjPointerMFieldBase::operator[](size_type const index) const
170     return _ptrStore[index];
173 inline 
174 MemObjPointerMFieldBase::value_type 
175     MemObjPointerMFieldBase::at(size_type const index) const
177     return _ptrStore.at(index);
179     
180 inline
181 bool MemObjPointerMFieldBase::operator ==(const Self &source) const
183     return _ptrStore == source._ptrStore;
187 #ifdef OSG_MT_CPTR_ASPECT
188 inline
189 void MemObjPointerMFieldBase::beginEdit(UInt32              ,
190                                         AspectOffsetStore  &)
194 inline
195 MemObjPointerMFieldBase::Self *
196     MemObjPointerMFieldBase::resolveShare(UInt32              , 
197                                           AspectOffsetStore  &)
199     return NULL;
202 inline
203 void MemObjPointerMFieldBase::terminateShare(UInt32              , 
204                                              AspectOffsetStore  &)
206     
209 inline
210 bool MemObjPointerMFieldBase::isShared(void)
212     return false;
214 #endif
216 /*-------------------------------------------------------------------------*/
217 /* Constructors                                                            */
219 inline
220 MemObjPointerMFieldBase::MemObjPointerMFieldBase(void) :
221      Inherited(),
222     _ptrStore ()
226 /*-------------------------------------------------------------------------*/
227 /* Destructor                                                              */
229 inline
230 MemObjPointerMFieldBase::~MemObjPointerMFieldBase(void)
235 /*-------------------------------------------------------------------------*/
236 /* Raw Store Access                                                        */
238 inline 
239 MemObjPointerMFieldBase::StorageType &
240     MemObjPointerMFieldBase::editRawStore(void)
242     return _ptrStore;
245 inline 
246 MemObjPointerMFieldBase::StorageType const &
247     MemObjPointerMFieldBase::getRawStore(void) const
249     return _ptrStore;
252 /*-------------------------------------------------------------------------*/
253 /* Cast Store Access                                                       */
255 template <class TargetStoredTypeT> inline 
256 typename MemObjPointerMFieldBase::rebindStore<TargetStoredTypeT>::type &
257     MemObjPointerMFieldBase::editStore(void)
259     return
260         reinterpret_cast<typename rebindStore<TargetStoredTypeT>::type &>(
261             _ptrStore);
264 template <class TargetStoredTypeT> inline 
265 typename MemObjPointerMFieldBase::rebindStore<TargetStoredTypeT>::type const &
266     MemObjPointerMFieldBase::getStore(void) const
268     return
269         reinterpret_cast<typename rebindStore<TargetStoredTypeT>::type const &>(
270             _ptrStore);
273 OSG_END_NAMESPACE