fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / Base / FieldContainer / Fields / PointerFields / OSGPointerSFieldCommon.inl
blob9d513ffdff89e8fa0a057529cd53987efa77e4af
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 PointerSFieldCommon
43  */
45 /*-------------------------------------------------------------------------*/
46 /* Constructors                                                            */
48 template <class AccessHandlerT, Int32 NamespaceI> inline
49 PointerSFieldCommon<AccessHandlerT,
50                     NamespaceI    >::PointerSFieldCommon(void) :
51     Inherited()
55 template <class AccessHandlerT, Int32 NamespaceI> inline
56 PointerSFieldCommon<AccessHandlerT,
57                     NamespaceI    >::PointerSFieldCommon(const Self &source) :
58     Inherited()
60     _fieldValue = source._fieldValue;
62     AccessHandler::onAdd(this, _fieldValue);
65 template <class AccessHandlerT, Int32 NamespaceI> inline
66 PointerSFieldCommon<AccessHandlerT,
67                     NamespaceI    >::PointerSFieldCommon(const_value value) :
68     Inherited()
70     _fieldValue = value;
72     AccessHandler::onAdd(this, _fieldValue);
75 /*-------------------------------------------------------------------------*/
76 /* Destructor                                                              */
78 template <class AccessHandlerT, Int32 NamespaceI> inline
79 PointerSFieldCommon<AccessHandlerT,
80                     NamespaceI    >::~PointerSFieldCommon(void)
82     AccessHandler::onSub(this, _fieldValue);
85 /*-------------------------------------------------------------------------*/
86 /* Store Interface                                                         */
88 /*-------------------------------------------------------------------------*/
89 /* Reading Values                                                          */
91 template <class AccessHandlerT, Int32 NamespaceI> inline 
92 typename PointerSFieldCommon<AccessHandlerT,
93                              NamespaceI    >::value_type 
94     PointerSFieldCommon<AccessHandlerT,
95                         NamespaceI    >::ptrStoreGet(void) const
97     return AccessHandler::validate(_fieldValue);
100 /*-------------------------------------------------------------------------*/
101 /* Changing Values                                                         */
103 template <class AccessHandlerT, Int32 NamespaceI> inline 
104 void PointerSFieldCommon<AccessHandlerT,
105                          NamespaceI     >::ptrStoreSet(const_value pNewObj)
107     AccessHandler::onReplace(this, _fieldValue, pNewObj);
108     
109     _fieldValue = pNewObj;
112 template <class AccessHandlerT, Int32 NamespaceI> inline 
113 void PointerSFieldCommon<AccessHandlerT,
114                          NamespaceI    >::ptrStoreClear(void)
116     AccessHandler::onSub(this, _fieldValue);
117     
118     _fieldValue = NULL;
121 template <class AccessHandlerT, Int32 NamespaceI> inline 
122 FieldDescriptionBase *
123     PointerSFieldCommon<AccessHandlerT,
124                         NamespaceI    >::createFieldDescription   (
125                             const Char8                *szFieldname,
126                                   UInt32                uiFieldFlags,
127                                   FieldEditMethod       fEditMethod,
128                                   FieldGetMethod        fGetMethod  )
130     return NULL;
133 template <class AccessHandlerT, Int32 NamespaceI> inline 
134 FieldDescriptionBase *
135     PointerSFieldCommon<AccessHandlerT,
136                         NamespaceI    >::createIdxFieldDescription(
137                             const Char8                *szFieldname,
138                                   UInt32                uiFieldFlags,
139                                   FieldIndexEditMethod  fEditMethod,
140                                   FieldIndexGetMethod   fGetMethod  )
142     return NULL;
145 /*-------------------------------------------------------------------------*/
146 /* Binary IO                                                               */
148         
149 template <class AccessHandlerT, Int32 NamespaceI> inline 
150 void PointerSFieldCommon<AccessHandlerT,
151                          NamespaceI    >::copyFromBin(BinaryDataHandler &pMem)
153     FieldContainer *pNewObj = NULL;
154     
155     PtrBaseTraitsType::copyFromBin  ( pMem, 
156                                       pNewObj   );
158     AccessHandler    ::onSyncReplace( this, 
159                                      _fieldValue, 
160                                       pNewObj   );
161     
162     _fieldValue = pNewObj;
165 /*-------------------------------------------------------------------------*/
166 /* MT Sync                                                                 */
168 #ifdef OSG_MT_CPTR_ASPECT
169 template <class AccessHandlerT, Int32 NamespaceI> inline 
170 void PointerSFieldCommon<AccessHandlerT,
171                          NamespaceI     >::syncWith(Self &source)
173     FieldContainer *pNewObj = Aspect::convertToCurrent(source.ptrStoreGet());
174     
175     AccessHandler::onSyncReplace( this, 
176                                  _fieldValue, 
177                                   pNewObj);
178     
179     _fieldValue = pNewObj;
181 #endif
183 OSG_END_NAMESPACE