fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / Test / SystemLib / OSGFCDSParTestFCBase.cpp
blobf932330ccc518a61469a5567e8ea84687913405a
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2000-2006 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 /*****************************************************************************\
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 FCDSParTestFC!
49 ** **
50 *****************************************************************************
51 \*****************************************************************************/
53 #include <cstdlib>
54 #include <cstdio>
56 #include "OSGConfig.h"
60 #include "OSGFieldContainer.h" // Parent Class
62 #include "OSGFCDSParTestFCBase.h"
63 #include "OSGFCDSParTestFC.h"
65 #include <boost/bind.hpp>
67 #ifdef WIN32 // turn off 'this' : used in base member initializer list warning
68 #pragma warning(disable:4355)
69 #endif
71 OSG_BEGIN_NAMESPACE
73 /***************************************************************************\
74 * Description *
75 \***************************************************************************/
77 /*! \class OSG::FCDSParTestFC
81 /***************************************************************************\
82 * Field Documentation *
83 \***************************************************************************/
85 /*! \var FieldContainer * FCDSParTestFCBase::_sfParent
90 /***************************************************************************\
91 * FieldType/FieldTrait Instantiation *
92 \***************************************************************************/
94 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
95 PointerType FieldTraits<FCDSParTestFC *, nsOSG>::_type(
96 "FCDSParTestFCPtr",
97 "AttachmentContainerPtr",
98 FCDSParTestFC::getClassType(),
99 nsOSG);
100 #endif
102 OSG_FIELDTRAITS_GETTYPE_NS(FCDSParTestFC *, nsOSG)
104 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField,
105 FCDSParTestFC *,
106 nsOSG);
108 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField,
109 FCDSParTestFC *,
110 nsOSG);
112 DataType &FieldTraits< FCDSParTestFC *, nsOSG + 1 >::getType(void)
114 return FieldTraits<FCDSParTestFC *, nsOSG>::getType();
118 OSG_EXPORT_PTR_SFIELD(ChildPointerSField,
119 FCDSParTestFC *,
120 UnrecordedRefCountPolicy,
121 nsOSG + 1);
124 OSG_EXPORT_PTR_MFIELD(ChildPointerMField,
125 FCDSParTestFC *,
126 UnrecordedRefCountPolicy,
127 nsOSG + 1);
130 /***************************************************************************\
131 * Field Description *
132 \***************************************************************************/
134 void FCDSParTestFCBase::classDescInserter(TypeObject &oType)
136 FieldDescriptionBase *pDesc = NULL;
139 pDesc = new SFParentFieldContainerPtr::Description(
140 SFParentFieldContainerPtr::getClassType(),
141 "parent",
143 ParentFieldId, ParentFieldMask,
144 true,
145 (Field::SFDefaultFlags | Field::FStdAccess),
146 static_cast <FieldEditMethodSig>(&FCDSParTestFC::invalidEditField),
147 static_cast <FieldGetMethodSig >(&FCDSParTestFC::invalidGetField));
149 oType.addInitialDesc(pDesc);
153 FCDSParTestFCBase::TypeObject FCDSParTestFCBase::_type(
154 FCDSParTestFCBase::getClassname(),
155 Inherited::getClassname(),
156 "NULL",
157 nsOSG, //Namespace
158 reinterpret_cast<PrototypeCreateF>(&FCDSParTestFCBase::createEmptyLocal),
159 FCDSParTestFC::initMethod,
160 FCDSParTestFC::exitMethod,
161 reinterpret_cast<InitalInsertDescFunc>(&FCDSParTestFC::classDescInserter),
162 false,
164 "<?xml version=\"1.0\" ?>\n"
165 "\n"
166 "<FieldContainer\n"
167 "\tname=\"FCDSParTestFC\"\n"
168 "\tparent=\"AttachmentContainer\"\n"
169 "\tlibrary=\"System\"\n"
170 "\tstructure=\"concrete\"\n"
171 "\tpointerfieldtypes=\"both\"\n"
172 "\tsystemcomponent=\"true\"\n"
173 "\tparentsystemcomponent=\"true\"\n"
174 " isNodeCore=\"false\"\n"
175 " childFields=\"both\"\n"
176 ">\n"
177 "\t<Field\n"
178 "\t\tname=\"parent\"\n"
179 "\t\ttype=\"FieldContainer\"\n"
180 "\t\tcardinality=\"single\"\n"
181 "\t\tvisibility=\"internal\"\n"
182 "\t\taccess=\"none\"\n"
183 " category=\"parentpointer\"\n"
184 "\t>\n"
185 "\t</Field>\n"
186 "</FieldContainer>\n",
190 /*------------------------------ get -----------------------------------*/
192 FieldContainerType &FCDSParTestFCBase::getType(void)
194 return _type;
197 const FieldContainerType &FCDSParTestFCBase::getType(void) const
199 return _type;
202 UInt32 FCDSParTestFCBase::getContainerSize(void) const
204 return sizeof(FCDSParTestFC);
207 /*------------------------- decorator get ------------------------------*/
215 /*------------------------------ access -----------------------------------*/
217 SizeT FCDSParTestFCBase::getBinSize(ConstFieldMaskArg whichField)
219 SizeT returnValue = Inherited::getBinSize(whichField);
221 if(FieldBits::NoField != (ParentFieldMask & whichField))
223 returnValue += _sfParent.getBinSize();
226 return returnValue;
229 void FCDSParTestFCBase::copyToBin(BinaryDataHandler &pMem,
230 ConstFieldMaskArg whichField)
232 Inherited::copyToBin(pMem, whichField);
234 if(FieldBits::NoField != (ParentFieldMask & whichField))
236 _sfParent.copyToBin(pMem);
240 void FCDSParTestFCBase::copyFromBin(BinaryDataHandler &pMem,
241 ConstFieldMaskArg whichField)
243 Inherited::copyFromBin(pMem, whichField);
245 if(FieldBits::NoField != (ParentFieldMask & whichField))
247 editSField(ParentFieldMask);
248 _sfParent.copyFromBin(pMem);
252 //! create a new instance of the class
253 FCDSParTestFCTransitPtr FCDSParTestFCBase::createLocal(BitVector bFlags)
255 FCDSParTestFCTransitPtr fc;
257 if(getClassType().getPrototype() != NULL)
259 FieldContainerTransitPtr tmpPtr =
260 getClassType().getPrototype()-> shallowCopyLocal(bFlags);
262 fc = dynamic_pointer_cast<FCDSParTestFC>(tmpPtr);
265 return fc;
268 //! create a new instance of the class, copy the container flags
269 FCDSParTestFCTransitPtr FCDSParTestFCBase::createDependent(BitVector bFlags)
271 FCDSParTestFCTransitPtr fc;
273 if(getClassType().getPrototype() != NULL)
275 FieldContainerTransitPtr tmpPtr =
276 getClassType().getPrototype()-> shallowCopyDependent(bFlags);
278 fc = dynamic_pointer_cast<FCDSParTestFC>(tmpPtr);
281 return fc;
284 //! create a new instance of the class
285 FCDSParTestFCTransitPtr FCDSParTestFCBase::create(void)
287 FCDSParTestFCTransitPtr fc;
289 if(getClassType().getPrototype() != NULL)
291 FieldContainerTransitPtr tmpPtr =
292 getClassType().getPrototype()-> shallowCopy();
294 fc = dynamic_pointer_cast<FCDSParTestFC>(tmpPtr);
297 return fc;
300 FCDSParTestFC *FCDSParTestFCBase::createEmptyLocal(BitVector bFlags)
302 FCDSParTestFC *returnValue;
304 newPtr<FCDSParTestFC>(returnValue, bFlags);
306 returnValue->_pFieldFlags->_bNamespaceMask &= ~bFlags;
308 return returnValue;
311 //! create an empty new instance of the class, do not copy the prototype
312 FCDSParTestFC *FCDSParTestFCBase::createEmpty(void)
314 FCDSParTestFC *returnValue;
316 newPtr<FCDSParTestFC>(returnValue, Thread::getCurrentLocalFlags());
318 returnValue->_pFieldFlags->_bNamespaceMask &=
319 ~Thread::getCurrentLocalFlags();
321 return returnValue;
325 FieldContainerTransitPtr FCDSParTestFCBase::shallowCopyLocal(
326 BitVector bFlags) const
328 FCDSParTestFC *tmpPtr;
330 newPtr(tmpPtr, dynamic_cast<const FCDSParTestFC *>(this), bFlags);
332 FieldContainerTransitPtr returnValue(tmpPtr);
334 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~bFlags;
336 return returnValue;
339 FieldContainerTransitPtr FCDSParTestFCBase::shallowCopyDependent(
340 BitVector bFlags) const
342 FCDSParTestFC *tmpPtr;
344 newPtr(tmpPtr, dynamic_cast<const FCDSParTestFC *>(this), ~bFlags);
346 FieldContainerTransitPtr returnValue(tmpPtr);
348 tmpPtr->_pFieldFlags->_bNamespaceMask = bFlags;
350 return returnValue;
353 FieldContainerTransitPtr FCDSParTestFCBase::shallowCopy(void) const
355 FCDSParTestFC *tmpPtr;
357 newPtr(tmpPtr,
358 dynamic_cast<const FCDSParTestFC *>(this),
359 Thread::getCurrentLocalFlags());
361 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~Thread::getCurrentLocalFlags();
363 FieldContainerTransitPtr returnValue(tmpPtr);
365 return returnValue;
371 /*------------------------- constructors ----------------------------------*/
373 FCDSParTestFCBase::FCDSParTestFCBase(void) :
374 Inherited(),
375 _sfParent (NULL)
379 FCDSParTestFCBase::FCDSParTestFCBase(const FCDSParTestFCBase &source) :
380 Inherited(source),
381 _sfParent (NULL)
386 /*-------------------------- destructors ----------------------------------*/
388 FCDSParTestFCBase::~FCDSParTestFCBase(void)
391 /*-------------------------------------------------------------------------*/
392 /* Parent linking */
394 bool FCDSParTestFCBase::linkParent(
395 FieldContainer * const pParent,
396 UInt16 const childFieldId,
397 UInt16 const parentFieldId )
399 if(parentFieldId == ParentFieldId)
401 FieldContainer * pTypedParent =
402 dynamic_cast< FieldContainer * >(pParent);
404 if(pTypedParent != NULL)
406 FieldContainer *pOldParent =
407 _sfParent.getValue ();
409 UInt16 oldChildFieldId =
410 _sfParent.getParentFieldPos();
412 if(pOldParent != NULL)
414 pOldParent->unlinkChild(this, oldChildFieldId);
417 editSField(ParentFieldMask);
419 _sfParent.setValue(static_cast<FieldContainer *>(pParent), childFieldId);
421 return true;
424 return false;
427 return Inherited::linkParent(pParent, childFieldId, parentFieldId);
430 bool FCDSParTestFCBase::unlinkParent(
431 FieldContainer * const pParent,
432 UInt16 const parentFieldId)
434 if(parentFieldId == ParentFieldId)
436 FieldContainer * pTypedParent =
437 dynamic_cast< FieldContainer * >(pParent);
439 if(pTypedParent != NULL)
441 if(_sfParent.getValue() == pTypedParent)
443 editSField(ParentFieldMask);
445 _sfParent.setValue(NULL, 0xFFFF);
447 return true;
450 SWARNING << "Child ([" << this
451 << "] id [" << this->getId()
452 << "] type [" << this->getType().getCName()
453 << "] parentFieldId [" << parentFieldId
454 << "]) - Parent ([" << pParent
455 << "] id [" << pParent->getId()
456 << "] type [" << pParent->getType().getCName()
457 << "]): link inconsistent!"
458 << std::endl;
460 return false;
463 return false;
466 return Inherited::unlinkParent(pParent, parentFieldId);
471 GetFieldHandlePtr FCDSParTestFCBase::getHandleParent (void) const
473 SFParentFieldContainerPtr::GetHandlePtr returnValue;
475 return returnValue;
478 EditFieldHandlePtr FCDSParTestFCBase::editHandleParent (void)
480 EditFieldHandlePtr returnValue;
482 return returnValue;
486 #ifdef OSG_MT_CPTR_ASPECT
487 void FCDSParTestFCBase::execSyncV( FieldContainer &oFrom,
488 ConstFieldMaskArg whichField,
489 AspectOffsetStore &oOffsets,
490 ConstFieldMaskArg syncMode,
491 const UInt32 uiSyncInfo)
493 FCDSParTestFC *pThis = static_cast<FCDSParTestFC *>(this);
495 pThis->execSync(static_cast<FCDSParTestFC *>(&oFrom),
496 whichField,
497 oOffsets,
498 syncMode,
499 uiSyncInfo);
501 #endif
504 #ifdef OSG_MT_CPTR_ASPECT
505 FieldContainer *FCDSParTestFCBase::createAspectCopy(
506 const FieldContainer *pRefAspect) const
508 FCDSParTestFC *returnValue;
510 newAspectCopy(returnValue,
511 dynamic_cast<const FCDSParTestFC *>(pRefAspect),
512 dynamic_cast<const FCDSParTestFC *>(this));
514 return returnValue;
516 #endif
518 void FCDSParTestFCBase::resolveLinks(void)
520 Inherited::resolveLinks();
526 OSG_END_NAMESPACE