fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / System / Window / Base / OSGCameraDecoratorBase.cpp
blob977cb8cb3522873099a503d79d08330b8a2bbe09
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 CameraDecorator!
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 "OSGNode.h" // Beacon Class
67 #include "OSGCameraDecoratorBase.h"
68 #include "OSGCameraDecorator.h"
70 #include <boost/bind.hpp>
72 OSG_BEGIN_NAMESPACE
74 /***************************************************************************\
75 * Description *
76 \***************************************************************************/
78 /*! \class OSG::CameraDecorator
79 The Camera base class, see \ref PageSystemWindowCamera for a description.
81 The only common fields are _sfNear and _sfFar.
84 /***************************************************************************\
85 * Field Documentation *
86 \***************************************************************************/
88 /*! \var CameraPtr CameraDecoratorBase::_sfDecoratee
89 The object being decorated
92 /***************************************************************************\
93 * FieldType/FieldTrait Instantiation *
94 \***************************************************************************/
96 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
97 PointerType FieldTraits<CameraDecorator *, nsOSG>::_type(
98 "CameraDecoratorPtr",
99 "CameraPtr",
100 CameraDecorator::getClassType(),
101 nsOSG);
102 #endif
104 OSG_FIELDTRAITS_GETTYPE_NS(CameraDecorator *, nsOSG)
106 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField,
107 CameraDecorator *,
108 nsOSG)
110 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField,
111 CameraDecorator *,
112 nsOSG)
114 /***************************************************************************\
115 * Field Description *
116 \***************************************************************************/
118 void CameraDecoratorBase::classDescInserter(TypeObject &oType)
120 FieldDescriptionBase *pDesc = NULL;
122 pDesc = new SFUnrecCameraPtr::Description(
123 SFUnrecCameraPtr::getClassType(),
124 "decoratee",
125 "undocumented decoratee",
126 DecorateeFieldId, DecorateeFieldMask,
127 false,
128 (Field::SFDefaultFlags | Field::FStdAccess),
129 static_cast<FieldEditMethodSig>(&CameraDecorator::editHandleDecoratee),
130 static_cast<FieldGetMethodSig >(&CameraDecorator::getHandleDecoratee ));
132 oType.addInitialDesc(pDesc);
136 CameraDecoratorBase::TypeObject CameraDecoratorBase::_type(
137 CameraDecoratorBase::getClassname(),
138 Inherited::getClassname(),
139 "NULL",
140 nsOSG, //Namespace
141 NULL,
142 reinterpret_cast<InitContainerF>(&CameraDecorator::initMethod),
143 reinterpret_cast<ExitContainerF>(&CameraDecorator::exitMethod),
144 reinterpret_cast<InitalInsertDescFunc>(
145 reinterpret_cast<void *>(&CameraDecorator::classDescInserter)),
146 false,
148 "<?xml version=\"1.0\" ?>\n"
149 "\n"
150 "<FieldContainer\n"
151 " name=\"Camera\"\n"
152 " parent=\"AttachmentContainer\"\n"
153 " library=\"System\"\n"
154 " structure=\"abstract\"\n"
155 " pointerfieldtypes=\"both\"\n"
156 " systemcomponent=\"true\"\n"
157 " parentsystemcomponent=\"true\"\n"
158 " decoratable=\"true\"\n"
159 " decorateeFieldFlags=\"SFDefaultFlags | Field::FStdAccess\"\n"
160 " docGroupBase=\"GrpSystemWindow\"\n"
161 " >\n"
162 "\n"
163 " The Camera base class, see \\ref PageSystemWindowCamera for a description.\n"
164 "\n"
165 " The only common fields are _sfNear and _sfFar.\n"
166 "\n"
167 " <Field\n"
168 "\t name=\"beacon\"\n"
169 "\t type=\"Node\"\n"
170 " category=\"weakpointer\"\n"
171 "\t cardinality=\"single\"\n"
172 "\t visibility=\"external\"\n"
173 "\t >\n"
174 "\tThe object that define's the camera's coordinate system. The camera is\n"
175 "\t positioned at the origin of the system and looks down the negative z-axis\n"
176 "\t (OpenGL-style). \n"
177 " </Field>\n"
178 " <Field\n"
179 "\t name=\"near\"\n"
180 "\t type=\"Real32\"\n"
181 "\t cardinality=\"single\"\n"
182 "\t visibility=\"external\"\n"
183 "\t >\n"
184 "\tThe near distance of the camera.\n"
185 " </Field>\n"
186 " <Field\n"
187 "\t name=\"far\"\n"
188 "\t type=\"Real32\"\n"
189 "\t cardinality=\"single\"\n"
190 "\t visibility=\"external\"\n"
191 "\t >\n"
192 "\tThe far distance of the camera.\n"
193 " </Field>\n"
194 "</FieldContainer>\n",
195 "The Camera base class, see \\ref PageSystemWindowCamera for a description.\n"
196 "\n"
197 "The only common fields are _sfNear and _sfFar.\n"
200 /*------------------------------ get -----------------------------------*/
202 FieldContainerType &CameraDecoratorBase::getType(void)
204 return _type;
207 const FieldContainerType &CameraDecoratorBase::getType(void) const
209 return _type;
212 UInt32 CameraDecoratorBase::getContainerSize(void) const
214 return sizeof(CameraDecorator);
217 /*------------------------- decorator get ------------------------------*/
219 const SFUnrecCameraPtr *CameraDecoratorBase::getSFDecoratee(void) const
221 return &_sfDecoratee;
224 //! Get the CameraDecorator::_sfBeacon field.
225 const SFWeakNodePtr *CameraDecoratorBase::getSFBeacon(void) const
227 if(_sfDecoratee.getValue() != NULL)
229 return getDecoratee()->getSFBeacon();
231 else
233 return NULL;
236 //! Get the CameraDecorator::_sfBeacon field.
237 SFWeakNodePtr *CameraDecoratorBase::editSFBeacon(void)
239 if(_sfDecoratee.getValue() != NULL)
241 return getDecoratee()->editSFBeacon();
243 else
245 return NULL;
249 SFReal32 *CameraDecoratorBase::editSFNear(void)
251 if(_sfDecoratee.getValue() != NULL)
253 return getDecoratee()->editSFNear();
255 else
257 return NULL;
261 const SFReal32 *CameraDecoratorBase::getSFNear(void) const
263 if(_sfDecoratee.getValue() != NULL)
265 return getDecoratee()->getSFNear();
267 else
269 return NULL;
273 SFReal32 *CameraDecoratorBase::editSFFar(void)
275 if(_sfDecoratee.getValue() != NULL)
277 return getDecoratee()->editSFFar();
279 else
281 return NULL;
285 const SFReal32 *CameraDecoratorBase::getSFFar(void) const
287 if(_sfDecoratee.getValue() != NULL)
289 return getDecoratee()->getSFFar();
291 else
293 return NULL;
302 /*------------------------------ access -----------------------------------*/
304 SizeT CameraDecoratorBase::getBinSize(ConstFieldMaskArg whichField)
306 SizeT returnValue = Inherited::getBinSize(whichField);
308 if(FieldBits::NoField != (DecorateeFieldMask & whichField))
310 returnValue += _sfDecoratee.getBinSize();
313 return returnValue;
316 void CameraDecoratorBase::copyToBin(BinaryDataHandler &pMem,
317 ConstFieldMaskArg whichField)
319 Inherited::copyToBin(pMem, whichField);
321 if(FieldBits::NoField != (DecorateeFieldMask & whichField))
323 _sfDecoratee.copyToBin(pMem);
327 void CameraDecoratorBase::copyFromBin(BinaryDataHandler &pMem,
328 ConstFieldMaskArg whichField)
330 Inherited::copyFromBin(pMem, whichField);
332 if(FieldBits::NoField != (DecorateeFieldMask & whichField))
334 editSField(DecorateeFieldMask);
335 _sfDecoratee.copyFromBin(pMem);
342 /*------------------------- constructors ----------------------------------*/
344 CameraDecoratorBase::CameraDecoratorBase(void) :
345 Inherited(),
346 _sfDecoratee()
350 CameraDecoratorBase::CameraDecoratorBase(const CameraDecoratorBase &source) :
351 Inherited(source),
352 _sfDecoratee(source._sfDecoratee)
357 /*-------------------------- destructors ----------------------------------*/
359 CameraDecoratorBase::~CameraDecoratorBase(void)
363 void CameraDecoratorBase::onCreate(const CameraDecorator *source)
365 Inherited::onCreate(source);
367 if(source != NULL)
369 CameraDecorator *pThis = static_cast<CameraDecorator *>(this);
371 pThis->setBeacon(source->getBeacon());
375 GetFieldHandlePtr CameraDecoratorBase::getHandleDecoratee (void) const
377 SFUnrecCameraPtr::GetHandlePtr returnValue(
378 new SFUnrecCameraPtr::GetHandle(
379 &_sfDecoratee,
380 this->getType().getFieldDesc(DecorateeFieldId),
381 const_cast<CameraDecoratorBase *>(this)));
383 return returnValue;
386 EditFieldHandlePtr CameraDecoratorBase::editHandleDecoratee(void)
388 SFUnrecCameraPtr::EditHandlePtr returnValue(
389 new SFUnrecCameraPtr::EditHandle(
390 &_sfDecoratee,
391 this->getType().getFieldDesc(DecorateeFieldId),
392 this));
394 returnValue->setSetMethod(boost::bind(&CameraDecorator::setDecoratee,
395 static_cast<CameraDecorator *>(this), _1));
397 editSField(DecorateeFieldMask);
399 return returnValue;
402 GetFieldHandlePtr CameraDecoratorBase::getHandleBeacon (void) const
404 SFWeakNodePtr::GetHandlePtr returnValue(
405 new SFWeakNodePtr::GetHandle(
406 &_sfBeacon,
407 this->getType().getFieldDesc(BeaconFieldId),
408 const_cast<CameraDecoratorBase *>(this)));
410 return returnValue;
413 EditFieldHandlePtr CameraDecoratorBase::editHandleBeacon (void)
415 SFWeakNodePtr::EditHandlePtr returnValue(
416 new SFWeakNodePtr::EditHandle(
417 &_sfBeacon,
418 this->getType().getFieldDesc(BeaconFieldId),
419 this));
421 returnValue->setSetMethod(
422 boost::bind(&CameraDecorator::setBeacon,
423 static_cast<CameraDecorator *>(this), _1));
425 editSField(BeaconFieldMask);
427 return returnValue;
430 GetFieldHandlePtr CameraDecoratorBase::getHandleNear (void) const
432 SFReal32::GetHandlePtr returnValue(
433 new SFReal32::GetHandle(
434 &_sfNear,
435 this->getType().getFieldDesc(NearFieldId),
436 const_cast<CameraDecoratorBase *>(this)));
438 return returnValue;
441 EditFieldHandlePtr CameraDecoratorBase::editHandleNear (void)
443 SFReal32::EditHandlePtr returnValue(
444 new SFReal32::EditHandle(
445 &_sfNear,
446 this->getType().getFieldDesc(NearFieldId),
447 this));
450 editSField(NearFieldMask);
452 return returnValue;
455 GetFieldHandlePtr CameraDecoratorBase::getHandleFar (void) const
457 SFReal32::GetHandlePtr returnValue(
458 new SFReal32::GetHandle(
459 &_sfFar,
460 this->getType().getFieldDesc(FarFieldId),
461 const_cast<CameraDecoratorBase *>(this)));
463 return returnValue;
466 EditFieldHandlePtr CameraDecoratorBase::editHandleFar (void)
468 SFReal32::EditHandlePtr returnValue(
469 new SFReal32::EditHandle(
470 &_sfFar,
471 this->getType().getFieldDesc(FarFieldId),
472 this));
475 editSField(FarFieldMask);
477 return returnValue;
481 #ifdef OSG_MT_CPTR_ASPECT
482 void CameraDecoratorBase::execSyncV( FieldContainer &oFrom,
483 ConstFieldMaskArg whichField,
484 AspectOffsetStore &oOffsets,
485 ConstFieldMaskArg syncMode,
486 const UInt32 uiSyncInfo)
488 CameraDecorator *pThis = static_cast<CameraDecorator *>(this);
490 pThis->execSync(static_cast<CameraDecorator *>(&oFrom),
491 whichField,
492 oOffsets,
493 syncMode,
494 uiSyncInfo);
496 #endif
500 void CameraDecoratorBase::resolveLinks(void)
502 static_cast<CameraDecorator *>(this)->setDecoratee(NULL);
504 Inherited::resolveLinks();
506 static_cast<CameraDecorator *>(this)->setBeacon(NULL);
511 /*------------------------------ get -----------------------------------*/
514 //! Get the value of the CameraDecorator::_sfBeacon field.
515 Node * CameraDecoratorBase::getBeacon(void) const
517 if(_sfDecoratee.getValue() != NULL)
519 return getDecoratee()->getBeacon();
521 else
523 return Inherited::getBeacon();
527 //! Set the value of the CameraDecorator::_sfBeacon field.
528 void CameraDecoratorBase::setBeacon(Node * const value)
530 if(_sfDecoratee.getValue() != NULL)
532 getDecoratee()->setBeacon(value);
534 else
536 Inherited::setBeacon(value);
540 //! Get the value of the CameraDecorator::_sfNear field.
541 Real32 &CameraDecoratorBase::editNear(void)
543 if(_sfDecoratee.getValue() != NULL)
545 return getDecoratee()->editNear();
547 else
549 return Inherited::editNear();
553 //! Get the value of the CameraDecorator::_sfNear field.
554 Real32 CameraDecoratorBase::getNear(void) const
556 if(_sfDecoratee.getValue() != NULL)
558 return getDecoratee()->getNear();
560 else
562 return Inherited::getNear();
567 //! Set the value of the CameraDecorator::_sfNear field.
568 void CameraDecoratorBase::setNear(const Real32 value)
570 if(_sfDecoratee.getValue() != NULL)
572 getDecoratee()->setNear(value);
574 else
576 Inherited::setNear(value);
580 //! Get the value of the CameraDecorator::_sfFar field.
581 Real32 &CameraDecoratorBase::editFar(void)
583 if(_sfDecoratee.getValue() != NULL)
585 return getDecoratee()->editFar();
587 else
589 return Inherited::editFar();
593 //! Get the value of the CameraDecorator::_sfFar field.
594 Real32 CameraDecoratorBase::getFar(void) const
596 if(_sfDecoratee.getValue() != NULL)
598 return getDecoratee()->getFar();
600 else
602 return Inherited::getFar();
607 //! Set the value of the CameraDecorator::_sfFar field.
608 void CameraDecoratorBase::setFar(const Real32 value)
610 if(_sfDecoratee.getValue() != NULL)
612 getDecoratee()->setFar(value);
614 else
616 Inherited::setFar(value);
621 OSG_END_NAMESPACE