fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / Base / FieldContainer / Node / OSGNodeCoreBase.cpp
blob3ff5b5ff3c8cc1d30fd548169987665d0f4a9082
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2000-2013 by the OpenSG Forum *
6 * *
7 * www.opensg.org *
8 * *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, carsten_neumann@gmx.net *
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 /*****************************************************************************\
40 *****************************************************************************
41 ** **
42 ** This file is automatically generated. **
43 ** **
44 ** Any changes made to this file WILL be lost when it is **
45 ** regenerated, which can become necessary at any time. **
46 ** **
47 ** Do not change this file, changes should be done in the derived **
48 ** class NodeCore!
49 ** **
50 *****************************************************************************
51 \*****************************************************************************/
53 #include <cstdlib>
54 #include <cstdio>
56 #ifdef WIN32
57 #pragma warning(disable: 4355) // turn off 'this' : used in base member initializer list warning
58 #pragma warning(disable: 4290) // disable exception specification warning
59 #endif
61 #include "OSGConfig.h"
65 #include "OSGFieldContainer.h" // Parents Class
67 #include "OSGNodeCoreBase.h"
68 #include "OSGNodeCore.h"
70 #include <boost/bind.hpp>
72 OSG_BEGIN_NAMESPACE
74 /***************************************************************************\
75 * Description *
76 \***************************************************************************/
78 /*! \class OSG::NodeCore
79 Abstract base type for all cores, which define the behavior (semantics) of
80 the node(s) they belong to.
83 /***************************************************************************\
84 * Field Documentation *
85 \***************************************************************************/
87 /*! \var FieldContainer * NodeCoreBase::_mfParents
88 Parents of this core. Cores can have more than one parent, i.e. in general
89 they may be used in more than one place in the scenegraph.
93 /***************************************************************************\
94 * FieldType/FieldTrait Instantiation *
95 \***************************************************************************/
97 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
98 PointerType FieldTraits<NodeCore *, nsOSG>::_type(
99 "NodeCorePtr",
100 "AttachmentContainerPtr",
101 NodeCore::getClassType(),
102 nsOSG);
103 #endif
105 OSG_FIELDTRAITS_GETTYPE_NS(NodeCore *, nsOSG)
107 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField,
108 NodeCore *,
109 nsOSG)
111 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField,
112 NodeCore *,
113 nsOSG)
115 DataType &FieldTraits< NodeCore *, nsOSG + 1 >::getType(void)
117 return FieldTraits<NodeCore *, nsOSG>::getType();
121 OSG_EXPORT_PTR_SFIELD(ChildPointerSField,
122 NodeCore *,
123 UnrecordedRefCountPolicy,
124 nsOSG + 1)
127 OSG_EXPORT_PTR_MFIELD(ChildPointerMField,
128 NodeCore *,
129 UnrecordedRefCountPolicy,
130 nsOSG + 1)
133 DataType &FieldTraits<NodeCore *, nsOSG + 2 >::getType(void)
135 return FieldTraits<NodeCore *, nsOSG>::getType();
139 OSG_SFIELDTYPE_INST(ParentPointerSField,
140 NodeCore *,
141 NoRefCountPolicy,
142 nsOSG + 2);
144 OSG_FIELD_DLLEXPORT_DEF3(ParentPointerSField,
145 NodeCore *,
146 NoRefCountPolicy,
147 nsOSG + 2)
150 OSG_MFIELDTYPE_INST(ParentPointerMField,
151 NodeCore *,
152 NoRefCountPolicy,
155 OSG_FIELD_DLLEXPORT_DEF3(ParentPointerMField,
156 NodeCore *,
157 NoRefCountPolicy,
161 /***************************************************************************\
162 * Field Description *
163 \***************************************************************************/
165 void NodeCoreBase::classDescInserter(TypeObject &oType)
167 FieldDescriptionBase *pDesc = NULL;
170 pDesc = new MFParentFieldContainerPtr::Description(
171 MFParentFieldContainerPtr::getClassType(),
172 "Parents",
173 "Parents of this core. Cores can have more than one parent, i.e. in general\n"
174 "they may be used in more than one place in the scenegraph.\n",
175 ParentsFieldId, ParentsFieldMask,
176 true,
177 (Field::MFDefaultFlags | Field::FStdAccess),
178 static_cast <FieldEditMethodSig>(&NodeCore::invalidEditField),
179 static_cast <FieldGetMethodSig >(&NodeCore::invalidGetField));
181 oType.addInitialDesc(pDesc);
185 NodeCoreBase::TypeObject NodeCoreBase::_type(
186 NodeCoreBase::getClassname(),
187 Inherited::getClassname(),
188 "NodeCore",
189 nsOSG, //Namespace
190 NULL,
191 reinterpret_cast<InitContainerF>(&NodeCore::initMethod),
192 reinterpret_cast<ExitContainerF>(&NodeCore::exitMethod),
193 reinterpret_cast<InitalInsertDescFunc>(
194 reinterpret_cast<void *>(&NodeCore::classDescInserter)),
195 false,
197 "<?xml version=\"1.0\" ?>\n"
198 "\n"
199 "<FieldContainer\n"
200 " name=\"NodeCore\"\n"
201 " parent=\"AttachmentContainer\"\n"
202 " library=\"Base\"\n"
203 " structure=\"abstract\"\n"
204 " group=\"NodeCore\"\n"
205 " pointerfieldtypes=\"both\"\n"
206 " parentFields=\"both\"\n"
207 " childFields=\"both\"\n"
208 " systemcomponent=\"true\"\n"
209 " parentsystemcomponent=\"true\"\n"
210 " isNodeCore=\"true\"\n"
211 " docGroupBase=\"GrpBaseFieldContainer\"\n"
212 " >\n"
213 " Abstract base type for all cores, which define the behavior (semantics) of\n"
214 " the node(s) they belong to.\n"
215 "\n"
216 " <Field\n"
217 " name=\"Parents\"\n"
218 " category=\"parentpointer\"\n"
219 " type=\"FieldContainer\"\n"
220 " cardinality=\"multi\"\n"
221 " access=\"none\"\n"
222 " visibility=\"internal\"\n"
223 " >\n"
224 " Parents of this core. Cores can have more than one parent, i.e. in general\n"
225 " they may be used in more than one place in the scenegraph.\n"
226 " </Field>\n"
227 "</FieldContainer>\n",
228 "Abstract base type for all cores, which define the behavior (semantics) of\n"
229 "the node(s) they belong to.\n"
232 /*------------------------------ get -----------------------------------*/
234 FieldContainerType &NodeCoreBase::getType(void)
236 return _type;
239 const FieldContainerType &NodeCoreBase::getType(void) const
241 return _type;
244 UInt32 NodeCoreBase::getContainerSize(void) const
246 return sizeof(NodeCore);
249 /*------------------------- decorator get ------------------------------*/
257 /*------------------------------ access -----------------------------------*/
259 SizeT NodeCoreBase::getBinSize(ConstFieldMaskArg whichField)
261 SizeT returnValue = Inherited::getBinSize(whichField);
263 if(FieldBits::NoField != (ParentsFieldMask & whichField))
265 returnValue += _mfParents.getBinSize();
268 return returnValue;
271 void NodeCoreBase::copyToBin(BinaryDataHandler &pMem,
272 ConstFieldMaskArg whichField)
274 Inherited::copyToBin(pMem, whichField);
276 if(FieldBits::NoField != (ParentsFieldMask & whichField))
278 _mfParents.copyToBin(pMem);
282 void NodeCoreBase::copyFromBin(BinaryDataHandler &pMem,
283 ConstFieldMaskArg whichField)
285 Inherited::copyFromBin(pMem, whichField);
287 if(FieldBits::NoField != (ParentsFieldMask & whichField))
289 editMField(ParentsFieldMask, _mfParents);
290 _mfParents.copyFromBin(pMem);
297 /*------------------------- constructors ----------------------------------*/
299 NodeCoreBase::NodeCoreBase(void) :
300 Inherited(),
301 _mfParents ()
305 NodeCoreBase::NodeCoreBase(const NodeCoreBase &source) :
306 Inherited(source),
307 _mfParents ()
312 /*-------------------------- destructors ----------------------------------*/
314 NodeCoreBase::~NodeCoreBase(void)
317 /*-------------------------------------------------------------------------*/
318 /* Parent linking */
320 bool NodeCoreBase::linkParent(
321 FieldContainer * const pParent,
322 UInt16 const childFieldId,
323 UInt16 const parentFieldId )
325 if(parentFieldId == ParentsFieldId)
327 FieldContainer * pTypedParent =
328 dynamic_cast< FieldContainer * >(pParent);
330 if(pTypedParent != NULL)
332 editMField(ParentsFieldMask, _mfParents);
334 _mfParents.push_back(pTypedParent, childFieldId);
336 return true;
339 return false;
342 return Inherited::linkParent(pParent, childFieldId, parentFieldId);
345 bool NodeCoreBase::unlinkParent(
346 FieldContainer * const pParent,
347 UInt16 const parentFieldId)
349 if(parentFieldId == ParentsFieldId)
351 FieldContainer * pTypedParent =
352 dynamic_cast< FieldContainer * >(pParent);
354 if(pTypedParent != NULL)
356 Int32 iParentIdx = _mfParents.findIndex(pTypedParent);
358 if(iParentIdx != -1)
360 editMField(ParentsFieldMask, _mfParents);
362 _mfParents.erase(iParentIdx);
364 return true;
367 SWARNING << "Child ([" << this
368 << "] id [" << this->getId()
369 << "] type [" << this->getType().getCName()
370 << "] parentFieldId [" << parentFieldId
371 << "]) - Parent ([" << pParent
372 << "] id [" << pParent->getId()
373 << "] type [" << pParent->getType().getCName()
374 << "]): link inconsistent!"
375 << std::endl;
377 return false;
380 return false;
383 return Inherited::unlinkParent(pParent, parentFieldId);
388 GetFieldHandlePtr NodeCoreBase::getHandleParents (void) const
390 MFParentFieldContainerPtr::GetHandlePtr returnValue;
392 return returnValue;
395 EditFieldHandlePtr NodeCoreBase::editHandleParents (void)
397 EditFieldHandlePtr returnValue;
399 return returnValue;
403 #ifdef OSG_MT_CPTR_ASPECT
404 void NodeCoreBase::execSyncV( FieldContainer &oFrom,
405 ConstFieldMaskArg whichField,
406 AspectOffsetStore &oOffsets,
407 ConstFieldMaskArg syncMode,
408 const UInt32 uiSyncInfo)
410 NodeCore *pThis = static_cast<NodeCore *>(this);
412 pThis->execSync(static_cast<NodeCore *>(&oFrom),
413 whichField,
414 oOffsets,
415 syncMode,
416 uiSyncInfo);
418 #endif
422 void NodeCoreBase::resolveLinks(void)
424 Inherited::resolveLinks();
430 OSG_END_NAMESPACE