changed: gcc8 base update
[opensg.git] / Source / Base / FieldContainer / Fields / MemObjPointerFields / OSGMemObjPointerSFieldCommon.inl
blobf971402cc6b9554ddc3a09f4b3a6fab59cd7909c
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 MemObjPointerSFieldCommon
43  */
45 /*-------------------------------------------------------------------------*/
46 /* Constructors                                                            */
48 template <class AccessHandlerT, Int32 NamespaceI> inline
49 MemObjPointerSFieldCommon<AccessHandlerT,
50                           NamespaceI    >::MemObjPointerSFieldCommon(void) :
51     Inherited()
55 template <class AccessHandlerT, Int32 NamespaceI> inline
56 MemObjPointerSFieldCommon<AccessHandlerT,
57                           NamespaceI    >::MemObjPointerSFieldCommon(
58                               const Self &source) :
59     Inherited()
61     _fieldValue = source._fieldValue;
63     AccessHandler::onAdd(this, _fieldValue);
66 template <class AccessHandlerT, Int32 NamespaceI> inline
67 MemObjPointerSFieldCommon<AccessHandlerT,
68                           NamespaceI    >::MemObjPointerSFieldCommon(
69                               const_value value) :
70     Inherited()
72     _fieldValue = value;
74     AccessHandler::onAdd(this, _fieldValue);
77 /*-------------------------------------------------------------------------*/
78 /* Destructor                                                              */
80 template <class AccessHandlerT, Int32 NamespaceI> inline
81 MemObjPointerSFieldCommon<AccessHandlerT,
82                           NamespaceI    >::~MemObjPointerSFieldCommon(void)
84     AccessHandler::onSub(this, _fieldValue);
87 /*-------------------------------------------------------------------------*/
88 /* Store Interface                                                         */
90 /*-------------------------------------------------------------------------*/
91 /* Reading Values                                                          */
93 template <class AccessHandlerT, Int32 NamespaceI> inline 
94 typename MemObjPointerSFieldCommon<AccessHandlerT,
95                                    NamespaceI    >::value_type 
96     MemObjPointerSFieldCommon<AccessHandlerT,
97                               NamespaceI    >::ptrStoreGet(void) const
99     return AccessHandler::validate(_fieldValue);
102 /*-------------------------------------------------------------------------*/
103 /* Changing Values                                                         */
105 template <class AccessHandlerT, Int32 NamespaceI> inline 
106 void MemObjPointerSFieldCommon<AccessHandlerT,
107                                NamespaceI    >::ptrStoreSet(const_value pNewObj)
109     AccessHandler::onReplace(this, _fieldValue, pNewObj);
110     
111     _fieldValue = pNewObj;
114 template <class AccessHandlerT, Int32 NamespaceI> inline 
115 void MemObjPointerSFieldCommon<AccessHandlerT,
116                                NamespaceI    >::ptrStoreClear(void)
118     AccessHandler::onSub(this, _fieldValue);
119     
120     _fieldValue = NULL;
124 /*-------------------------------------------------------------------------*/
125 /* Binary IO                                                               */
127         
128 template <class AccessHandlerT, Int32 NamespaceI> inline 
129 void MemObjPointerSFieldCommon<AccessHandlerT,
130                                NamespaceI    >::copyFromBin(
131                                    BinaryDataHandler &pMem)
133     MemoryObject *pNewObj = NULL;
134     
135     PtrBaseTraitsType::copyFromBin  ( pMem, 
136                                       pNewObj   );
138     AccessHandler    ::onSyncReplace( this, 
139                                      _fieldValue, 
140                                       pNewObj   );
141     
142     _fieldValue = pNewObj;
145 /*-------------------------------------------------------------------------*/
146 /* MT Sync                                                                 */
148 #ifdef OSG_MT_CPTR_ASPECT
149 template <class AccessHandlerT, Int32 NamespaceI> inline 
150 void MemObjPointerSFieldCommon<AccessHandlerT,
151                                NamespaceI     >::syncWith(Self &source)
153     MemoryObject *pNewObj = convertToCurrentAspect(source.ptrStoreGet());
154     
155     AccessHandler::onSyncReplace( this, 
156                                  _fieldValue, 
157                                   pNewObj);
158     
159     _fieldValue = pNewObj;
161 #endif
163 OSG_END_NAMESPACE