changed: gcc8 base update
[opensg.git] / Source / System / Dynamics / Animation / OSGAnimTemplateBase.cpp
blob1cae606d8d1084dd44e6171bdd312350655eb0f9
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 AnimTemplate!
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 "OSGAnimDataSource.h" // Sources Class
67 #include "OSGAnimTemplateBase.h"
68 #include "OSGAnimTemplate.h"
70 #include <boost/bind.hpp>
72 OSG_BEGIN_NAMESPACE
74 /***************************************************************************\
75 * Description *
76 \***************************************************************************/
78 /*! \class OSG::AnimTemplate
82 /***************************************************************************\
83 * Field Documentation *
84 \***************************************************************************/
86 /*! \var std::string AnimTemplateBase::_sfName
90 /*! \var AnimDataSource * AnimTemplateBase::_mfSources
94 /*! \var std::string AnimTemplateBase::_mfTargetIds
99 /***************************************************************************\
100 * FieldType/FieldTrait Instantiation *
101 \***************************************************************************/
103 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
104 PointerType FieldTraits<AnimTemplate *, nsOSG>::_type(
105 "AnimTemplatePtr",
106 "AttachmentContainerPtr",
107 AnimTemplate::getClassType(),
108 nsOSG);
109 #endif
111 OSG_FIELDTRAITS_GETTYPE_NS(AnimTemplate *, nsOSG)
113 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField,
114 AnimTemplate *,
115 nsOSG)
117 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField,
118 AnimTemplate *,
119 nsOSG)
121 /***************************************************************************\
122 * Field Description *
123 \***************************************************************************/
125 void AnimTemplateBase::classDescInserter(TypeObject &oType)
127 FieldDescriptionBase *pDesc = NULL;
130 pDesc = new SFString::Description(
131 SFString::getClassType(),
132 "name",
134 NameFieldId, NameFieldMask,
135 false,
136 (Field::FClusterLocal),
137 static_cast<FieldEditMethodSig>(&AnimTemplate::editHandleName),
138 static_cast<FieldGetMethodSig >(&AnimTemplate::getHandleName));
140 oType.addInitialDesc(pDesc);
142 pDesc = new MFUnrecAnimDataSourcePtr::Description(
143 MFUnrecAnimDataSourcePtr::getClassType(),
144 "sources",
146 SourcesFieldId, SourcesFieldMask,
147 false,
148 (Field::FStdAccess | Field::FClusterLocal),
149 static_cast<FieldEditMethodSig>(&AnimTemplate::editHandleSources),
150 static_cast<FieldGetMethodSig >(&AnimTemplate::getHandleSources));
152 oType.addInitialDesc(pDesc);
154 pDesc = new MFString::Description(
155 MFString::getClassType(),
156 "targetIds",
158 TargetIdsFieldId, TargetIdsFieldMask,
159 false,
160 (Field::FClusterLocal),
161 static_cast<FieldEditMethodSig>(&AnimTemplate::editHandleTargetIds),
162 static_cast<FieldGetMethodSig >(&AnimTemplate::getHandleTargetIds));
164 oType.addInitialDesc(pDesc);
168 AnimTemplateBase::TypeObject AnimTemplateBase::_type(
169 AnimTemplateBase::getClassname(),
170 Inherited::getClassname(),
171 "NULL",
172 nsOSG, //Namespace
173 NULL,
174 reinterpret_cast<InitContainerF>(&AnimTemplate::initMethod),
175 reinterpret_cast<ExitContainerF>(&AnimTemplate::exitMethod),
176 reinterpret_cast<InitalInsertDescFunc>(
177 reinterpret_cast<void *>(&AnimTemplate::classDescInserter)),
178 false,
180 "<?xml version=\"1.0\"?>\n"
181 "\n"
182 "<FieldContainer\n"
183 " name=\"AnimTemplate\"\n"
184 " parent=\"AttachmentContainer\"\n"
185 " library=\"Dynamics\"\n"
186 " pointerfieldtypes=\"both\"\n"
187 " structure=\"abstract\"\n"
188 " systemcomponent=\"true\"\n"
189 " parentsystemcomponent=\"true\"\n"
190 " decoratable=\"false\"\n"
191 " useLocalIncludes=\"false\"\n"
192 " isNodeCore=\"false\"\n"
193 " isBundle=\"false\"\n"
194 " parentFields=\"none\"\n"
195 " >\n"
196 " <Field\n"
197 " name=\"name\"\n"
198 " category=\"data\"\n"
199 " type=\"std::string\"\n"
200 " cardinality=\"single\"\n"
201 " visibility=\"external\"\n"
202 " access=\"public\"\n"
203 " fieldFlags=\"FClusterLocal\"\n"
204 " >\n"
205 " </Field>\n"
206 " <Field\n"
207 " name=\"sources\"\n"
208 " category=\"pointer\"\n"
209 " type=\"AnimDataSource\"\n"
210 " cardinality=\"multi\"\n"
211 " visibility=\"external\"\n"
212 " access=\"public\"\n"
213 " fieldFlags=\"FStdAccess, FClusterLocal\"\n"
214 " >\n"
215 " </Field>\n"
216 " <Field\n"
217 " name=\"targetIds\"\n"
218 " category=\"data\"\n"
219 " type=\"std::string\"\n"
220 " cardinality=\"multi\"\n"
221 " visibility=\"external\"\n"
222 " access=\"public\"\n"
223 " fieldFlags=\"FClusterLocal\"\n"
224 " >\n"
225 " </Field>\n"
226 "</FieldContainer>\n",
230 /*------------------------------ get -----------------------------------*/
232 FieldContainerType &AnimTemplateBase::getType(void)
234 return _type;
237 const FieldContainerType &AnimTemplateBase::getType(void) const
239 return _type;
242 UInt32 AnimTemplateBase::getContainerSize(void) const
244 return sizeof(AnimTemplate);
247 /*------------------------- decorator get ------------------------------*/
250 SFString *AnimTemplateBase::editSFName(void)
252 editSField(NameFieldMask);
254 return &_sfName;
257 const SFString *AnimTemplateBase::getSFName(void) const
259 return &_sfName;
263 //! Get the AnimTemplate::_mfSources field.
264 const MFUnrecAnimDataSourcePtr *AnimTemplateBase::getMFSources(void) const
266 return &_mfSources;
269 MFUnrecAnimDataSourcePtr *AnimTemplateBase::editMFSources (void)
271 editMField(SourcesFieldMask, _mfSources);
273 return &_mfSources;
275 AnimDataSource * AnimTemplateBase::getSources(const UInt32 index) const
277 return _mfSources[index];
280 MFString *AnimTemplateBase::editMFTargetIds(void)
282 editMField(TargetIdsFieldMask, _mfTargetIds);
284 return &_mfTargetIds;
287 const MFString *AnimTemplateBase::getMFTargetIds(void) const
289 return &_mfTargetIds;
295 void AnimTemplateBase::pushToSources(AnimDataSource * const value)
297 editMField(SourcesFieldMask, _mfSources);
299 _mfSources.push_back(value);
302 void AnimTemplateBase::assignSources (const MFUnrecAnimDataSourcePtr &value)
304 MFUnrecAnimDataSourcePtr::const_iterator elemIt =
305 value.begin();
306 MFUnrecAnimDataSourcePtr::const_iterator elemEnd =
307 value.end ();
309 static_cast<AnimTemplate *>(this)->clearSources();
311 while(elemIt != elemEnd)
313 this->pushToSources(*elemIt);
315 ++elemIt;
319 void AnimTemplateBase::removeFromSources(UInt32 uiIndex)
321 if(uiIndex < _mfSources.size())
323 editMField(SourcesFieldMask, _mfSources);
325 _mfSources.erase(uiIndex);
329 void AnimTemplateBase::removeObjFromSources(AnimDataSource * const value)
331 Int32 iElemIdx = _mfSources.findIndex(value);
333 if(iElemIdx != -1)
335 editMField(SourcesFieldMask, _mfSources);
337 _mfSources.erase(iElemIdx);
340 void AnimTemplateBase::clearSources(void)
342 editMField(SourcesFieldMask, _mfSources);
345 _mfSources.clear();
350 /*------------------------------ access -----------------------------------*/
352 SizeT AnimTemplateBase::getBinSize(ConstFieldMaskArg whichField)
354 SizeT returnValue = Inherited::getBinSize(whichField);
356 if(FieldBits::NoField != (NameFieldMask & whichField))
358 returnValue += _sfName.getBinSize();
360 if(FieldBits::NoField != (SourcesFieldMask & whichField))
362 returnValue += _mfSources.getBinSize();
364 if(FieldBits::NoField != (TargetIdsFieldMask & whichField))
366 returnValue += _mfTargetIds.getBinSize();
369 return returnValue;
372 void AnimTemplateBase::copyToBin(BinaryDataHandler &pMem,
373 ConstFieldMaskArg whichField)
375 Inherited::copyToBin(pMem, whichField);
377 if(FieldBits::NoField != (NameFieldMask & whichField))
379 _sfName.copyToBin(pMem);
381 if(FieldBits::NoField != (SourcesFieldMask & whichField))
383 _mfSources.copyToBin(pMem);
385 if(FieldBits::NoField != (TargetIdsFieldMask & whichField))
387 _mfTargetIds.copyToBin(pMem);
391 void AnimTemplateBase::copyFromBin(BinaryDataHandler &pMem,
392 ConstFieldMaskArg whichField)
394 Inherited::copyFromBin(pMem, whichField);
396 if(FieldBits::NoField != (NameFieldMask & whichField))
398 editSField(NameFieldMask);
399 _sfName.copyFromBin(pMem);
401 if(FieldBits::NoField != (SourcesFieldMask & whichField))
403 editMField(SourcesFieldMask, _mfSources);
404 _mfSources.copyFromBin(pMem);
406 if(FieldBits::NoField != (TargetIdsFieldMask & whichField))
408 editMField(TargetIdsFieldMask, _mfTargetIds);
409 _mfTargetIds.copyFromBin(pMem);
416 /*------------------------- constructors ----------------------------------*/
418 AnimTemplateBase::AnimTemplateBase(void) :
419 Inherited(),
420 _sfName (),
421 _mfSources (),
422 _mfTargetIds ()
426 AnimTemplateBase::AnimTemplateBase(const AnimTemplateBase &source) :
427 Inherited(source),
428 _sfName (source._sfName ),
429 _mfSources (),
430 _mfTargetIds (source._mfTargetIds )
435 /*-------------------------- destructors ----------------------------------*/
437 AnimTemplateBase::~AnimTemplateBase(void)
441 void AnimTemplateBase::onCreate(const AnimTemplate *source)
443 Inherited::onCreate(source);
445 if(source != NULL)
447 AnimTemplate *pThis = static_cast<AnimTemplate *>(this);
449 MFUnrecAnimDataSourcePtr::const_iterator SourcesIt =
450 source->_mfSources.begin();
451 MFUnrecAnimDataSourcePtr::const_iterator SourcesEnd =
452 source->_mfSources.end ();
454 while(SourcesIt != SourcesEnd)
456 pThis->pushToSources(*SourcesIt);
458 ++SourcesIt;
463 GetFieldHandlePtr AnimTemplateBase::getHandleName (void) const
465 SFString::GetHandlePtr returnValue(
466 new SFString::GetHandle(
467 &_sfName,
468 this->getType().getFieldDesc(NameFieldId),
469 const_cast<AnimTemplateBase *>(this)));
471 return returnValue;
474 EditFieldHandlePtr AnimTemplateBase::editHandleName (void)
476 SFString::EditHandlePtr returnValue(
477 new SFString::EditHandle(
478 &_sfName,
479 this->getType().getFieldDesc(NameFieldId),
480 this));
483 editSField(NameFieldMask);
485 return returnValue;
488 GetFieldHandlePtr AnimTemplateBase::getHandleSources (void) const
490 MFUnrecAnimDataSourcePtr::GetHandlePtr returnValue(
491 new MFUnrecAnimDataSourcePtr::GetHandle(
492 &_mfSources,
493 this->getType().getFieldDesc(SourcesFieldId),
494 const_cast<AnimTemplateBase *>(this)));
496 return returnValue;
499 EditFieldHandlePtr AnimTemplateBase::editHandleSources (void)
501 MFUnrecAnimDataSourcePtr::EditHandlePtr returnValue(
502 new MFUnrecAnimDataSourcePtr::EditHandle(
503 &_mfSources,
504 this->getType().getFieldDesc(SourcesFieldId),
505 this));
507 returnValue->setAddMethod(
508 boost::bind(&AnimTemplate::pushToSources,
509 static_cast<AnimTemplate *>(this), _1));
510 returnValue->setRemoveMethod(
511 boost::bind(&AnimTemplate::removeFromSources,
512 static_cast<AnimTemplate *>(this), _1));
513 returnValue->setRemoveObjMethod(
514 boost::bind(&AnimTemplate::removeObjFromSources,
515 static_cast<AnimTemplate *>(this), _1));
516 returnValue->setClearMethod(
517 boost::bind(&AnimTemplate::clearSources,
518 static_cast<AnimTemplate *>(this)));
520 editMField(SourcesFieldMask, _mfSources);
522 return returnValue;
525 GetFieldHandlePtr AnimTemplateBase::getHandleTargetIds (void) const
527 MFString::GetHandlePtr returnValue(
528 new MFString::GetHandle(
529 &_mfTargetIds,
530 this->getType().getFieldDesc(TargetIdsFieldId),
531 const_cast<AnimTemplateBase *>(this)));
533 return returnValue;
536 EditFieldHandlePtr AnimTemplateBase::editHandleTargetIds (void)
538 MFString::EditHandlePtr returnValue(
539 new MFString::EditHandle(
540 &_mfTargetIds,
541 this->getType().getFieldDesc(TargetIdsFieldId),
542 this));
545 editMField(TargetIdsFieldMask, _mfTargetIds);
547 return returnValue;
551 #ifdef OSG_MT_CPTR_ASPECT
552 void AnimTemplateBase::execSyncV( FieldContainer &oFrom,
553 ConstFieldMaskArg whichField,
554 AspectOffsetStore &oOffsets,
555 ConstFieldMaskArg syncMode,
556 const UInt32 uiSyncInfo)
558 AnimTemplate *pThis = static_cast<AnimTemplate *>(this);
560 pThis->execSync(static_cast<AnimTemplate *>(&oFrom),
561 whichField,
562 oOffsets,
563 syncMode,
564 uiSyncInfo);
566 #endif
570 void AnimTemplateBase::resolveLinks(void)
572 Inherited::resolveLinks();
574 static_cast<AnimTemplate *>(this)->clearSources();
576 #ifdef OSG_MT_CPTR_ASPECT
577 AspectOffsetStore oOffsets;
579 _pAspectStore->fillOffsetArray(oOffsets, this);
580 #endif
582 #ifdef OSG_MT_CPTR_ASPECT
583 _mfTargetIds.terminateShare(Thread::getCurrentAspect(),
584 oOffsets);
585 #endif
589 OSG_END_NAMESPACE