1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2000-2013 by the OpenSG Forum *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, carsten_neumann@gmx.net *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
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. *
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. *
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. *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
37 \*---------------------------------------------------------------------------*/
39 /*****************************************************************************\
40 *****************************************************************************
42 ** This file is automatically generated. **
44 ** Any changes made to this file WILL be lost when it is **
45 ** regenerated, which can become necessary at any time. **
47 ** Do not change this file, changes should be done in the derived **
48 ** class StatisticsForeground!
50 *****************************************************************************
51 \*****************************************************************************/
57 #pragma warning(disable: 4355) // turn off 'this' : used in base member initializer list warning
58 #pragma warning(disable: 4290) // disable exception specification warning
61 #include "OSGConfig.h"
66 #include "OSGStatisticsForegroundBase.h"
67 #include "OSGStatisticsForeground.h"
69 #include <boost/bind.hpp>
73 /***************************************************************************\
75 \***************************************************************************/
77 /*! \class OSG::StatisticsForeground
78 StatisticsForeground is the base class for all foregrounds that process
79 statistics. Decendents of this class can be used to print or draw Statistics
80 elements on the rendered image.
82 The OSG::StatCollector that is used to collect the elements needs to be
83 attached to the foreground in the _sfCollection field and the list of
84 OSG::StatElemDesc IDs that should be displayed need to be selected with the
87 Statistics presentation is done as a foreground so it can be drawn on top of a
88 currently rendering scene. This does not mean you could not collect
89 statistics directly and present them to the user in another way such as a
92 The format of every element is given by a format string for every element that
93 is directly passed to OSG::StatElem::putToString(), so go there to see the
96 If no elementIDs are given all elements in the OSG::StatCollector are display,
97 using the default format.
100 /***************************************************************************\
101 * Field Documentation *
102 \***************************************************************************/
104 /*! \var Int32 StatisticsForegroundBase::_mfElementIDs
105 The StatElemDesc IDs to use. If not set, use all in the descriptor.
108 /*! \var StatCollectorP StatisticsForegroundBase::_sfCollector
109 The OSG::StatCollector that keeps the displayed statistics.
113 /***************************************************************************\
114 * FieldType/FieldTrait Instantiation *
115 \***************************************************************************/
117 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
118 PointerType FieldTraits
<StatisticsForeground
*, nsOSG
>::_type(
119 "StatisticsForegroundPtr",
121 StatisticsForeground::getClassType(),
125 OSG_FIELDTRAITS_GETTYPE_NS(StatisticsForeground
*, nsOSG
)
127 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField
,
128 StatisticsForeground
*,
131 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField
,
132 StatisticsForeground
*,
135 /***************************************************************************\
136 * Field Description *
137 \***************************************************************************/
139 void StatisticsForegroundBase::classDescInserter(TypeObject
&oType
)
141 FieldDescriptionBase
*pDesc
= NULL
;
144 pDesc
= new MFInt32::Description(
145 MFInt32::getClassType(),
147 "The StatElemDesc IDs to use. If not set, use all in the descriptor.\n",
148 ElementIDsFieldId
, ElementIDsFieldMask
,
150 (Field::MFDefaultFlags
| Field::FStdAccess
),
151 static_cast<FieldEditMethodSig
>(&StatisticsForeground::editHandleElementIDs
),
152 static_cast<FieldGetMethodSig
>(&StatisticsForeground::getHandleElementIDs
));
154 oType
.addInitialDesc(pDesc
);
156 pDesc
= new SFStatCollectorP::Description(
157 SFStatCollectorP::getClassType(),
159 "The OSG::StatCollector that keeps the displayed statistics.\n",
160 CollectorFieldId
, CollectorFieldMask
,
162 (Field::SFDefaultFlags
| Field::FStdAccess
),
163 static_cast<FieldEditMethodSig
>(&StatisticsForeground::editHandleCollector
),
164 static_cast<FieldGetMethodSig
>(&StatisticsForeground::getHandleCollector
));
166 oType
.addInitialDesc(pDesc
);
170 StatisticsForegroundBase::TypeObject
StatisticsForegroundBase::_type(
171 StatisticsForegroundBase::getClassname(),
172 Inherited::getClassname(),
176 reinterpret_cast<InitContainerF
>(&StatisticsForeground::initMethod
),
177 reinterpret_cast<ExitContainerF
>(&StatisticsForeground::exitMethod
),
178 reinterpret_cast<InitalInsertDescFunc
>(
179 reinterpret_cast<void *>(&StatisticsForeground::classDescInserter
)),
182 "<?xml version=\"1.0\"?>\n"
185 " name=\"StatisticsForeground\"\n"
186 " parent=\"Foreground\"\n"
187 " library=\"System\"\n"
188 " pointerfieldtypes=\"both\"\n"
189 " structure=\"abstract\"\n"
190 " systemcomponent=\"true\"\n"
191 " parentsystemcomponent=\"true\"\n"
192 " decoratable=\"false\"\n"
193 " docGroupBase=\"GrpSystemStatistics\"\n"
195 " StatisticsForeground is the base class for all foregrounds that process\n"
196 " statistics. Decendents of this class can be used to print or draw Statistics\n"
197 " elements on the rendered image.\n"
199 " The OSG::StatCollector that is used to collect the elements needs to be\n"
200 " attached to the foreground in the _sfCollection field and the list of\n"
201 " OSG::StatElemDesc IDs that should be displayed need to be selected with the\n"
202 " _mfElementIDs field.\n"
204 " Statistics presentation is done as a foreground so it can be drawn on top of a\n"
205 " currently rendering scene. This does not mean you could not collect\n"
206 " statistics directly and present them to the user in another way such as a\n"
207 " GUI or text output. \n"
209 " The format of every element is given by a format string for every element that\n"
210 " is directly passed to OSG::StatElem::putToString(), so go there to see the\n"
211 " possible options.\n"
213 " If no elementIDs are given all elements in the OSG::StatCollector are display,\n"
214 " using the default format.\n"
217 "\t name=\"elementIDs\"\n"
218 "\t type=\"Int32\"\n"
219 "\t cardinality=\"multi\"\n"
220 "\t visibility=\"external\"\n"
221 "\t access=\"public\"\n"
223 "\tThe StatElemDesc IDs to use. If not set, use all in the descriptor.\n"
226 "\t name=\"collector\"\n"
227 "\t type=\"StatCollectorP\"\n"
228 "\t cardinality=\"single\"\n"
229 "\t visibility=\"external\"\n"
230 "\t access=\"public\"\n"
232 " The OSG::StatCollector that keeps the displayed statistics.\n"
234 "</FieldContainer>\n",
235 "StatisticsForeground is the base class for all foregrounds that process\n"
236 "statistics. Decendents of this class can be used to print or draw Statistics\n"
237 "elements on the rendered image.\n"
239 "The OSG::StatCollector that is used to collect the elements needs to be\n"
240 "attached to the foreground in the _sfCollection field and the list of\n"
241 "OSG::StatElemDesc IDs that should be displayed need to be selected with the\n"
242 "_mfElementIDs field.\n"
244 "Statistics presentation is done as a foreground so it can be drawn on top of a\n"
245 "currently rendering scene. This does not mean you could not collect\n"
246 "statistics directly and present them to the user in another way such as a\n"
247 "GUI or text output. \n"
249 "The format of every element is given by a format string for every element that\n"
250 "is directly passed to OSG::StatElem::putToString(), so go there to see the\n"
251 "possible options.\n"
253 "If no elementIDs are given all elements in the OSG::StatCollector are display,\n"
254 "using the default format.\n"
257 /*------------------------------ get -----------------------------------*/
259 FieldContainerType
&StatisticsForegroundBase::getType(void)
264 const FieldContainerType
&StatisticsForegroundBase::getType(void) const
269 UInt32
StatisticsForegroundBase::getContainerSize(void) const
271 return sizeof(StatisticsForeground
);
274 /*------------------------- decorator get ------------------------------*/
277 MFInt32
*StatisticsForegroundBase::editMFElementIDs(void)
279 editMField(ElementIDsFieldMask
, _mfElementIDs
);
281 return &_mfElementIDs
;
284 const MFInt32
*StatisticsForegroundBase::getMFElementIDs(void) const
286 return &_mfElementIDs
;
290 SFStatCollectorP
*StatisticsForegroundBase::editSFCollector(void)
292 editSField(CollectorFieldMask
);
294 return &_sfCollector
;
297 const SFStatCollectorP
*StatisticsForegroundBase::getSFCollector(void) const
299 return &_sfCollector
;
307 /*------------------------------ access -----------------------------------*/
309 SizeT
StatisticsForegroundBase::getBinSize(ConstFieldMaskArg whichField
)
311 SizeT returnValue
= Inherited::getBinSize(whichField
);
313 if(FieldBits::NoField
!= (ElementIDsFieldMask
& whichField
))
315 returnValue
+= _mfElementIDs
.getBinSize();
317 if(FieldBits::NoField
!= (CollectorFieldMask
& whichField
))
319 returnValue
+= _sfCollector
.getBinSize();
325 void StatisticsForegroundBase::copyToBin(BinaryDataHandler
&pMem
,
326 ConstFieldMaskArg whichField
)
328 Inherited::copyToBin(pMem
, whichField
);
330 if(FieldBits::NoField
!= (ElementIDsFieldMask
& whichField
))
332 _mfElementIDs
.copyToBin(pMem
);
334 if(FieldBits::NoField
!= (CollectorFieldMask
& whichField
))
336 _sfCollector
.copyToBin(pMem
);
340 void StatisticsForegroundBase::copyFromBin(BinaryDataHandler
&pMem
,
341 ConstFieldMaskArg whichField
)
343 Inherited::copyFromBin(pMem
, whichField
);
345 if(FieldBits::NoField
!= (ElementIDsFieldMask
& whichField
))
347 editMField(ElementIDsFieldMask
, _mfElementIDs
);
348 _mfElementIDs
.copyFromBin(pMem
);
350 if(FieldBits::NoField
!= (CollectorFieldMask
& whichField
))
352 editSField(CollectorFieldMask
);
353 _sfCollector
.copyFromBin(pMem
);
360 /*------------------------- constructors ----------------------------------*/
362 StatisticsForegroundBase::StatisticsForegroundBase(void) :
369 StatisticsForegroundBase::StatisticsForegroundBase(const StatisticsForegroundBase
&source
) :
371 _mfElementIDs (source
._mfElementIDs
),
372 _sfCollector (source
._sfCollector
)
377 /*-------------------------- destructors ----------------------------------*/
379 StatisticsForegroundBase::~StatisticsForegroundBase(void)
384 GetFieldHandlePtr
StatisticsForegroundBase::getHandleElementIDs (void) const
386 MFInt32::GetHandlePtr
returnValue(
387 new MFInt32::GetHandle(
389 this->getType().getFieldDesc(ElementIDsFieldId
),
390 const_cast<StatisticsForegroundBase
*>(this)));
395 EditFieldHandlePtr
StatisticsForegroundBase::editHandleElementIDs (void)
397 MFInt32::EditHandlePtr
returnValue(
398 new MFInt32::EditHandle(
400 this->getType().getFieldDesc(ElementIDsFieldId
),
404 editMField(ElementIDsFieldMask
, _mfElementIDs
);
409 GetFieldHandlePtr
StatisticsForegroundBase::getHandleCollector (void) const
411 SFStatCollectorP::GetHandlePtr
returnValue(
412 new SFStatCollectorP::GetHandle(
414 this->getType().getFieldDesc(CollectorFieldId
),
415 const_cast<StatisticsForegroundBase
*>(this)));
420 EditFieldHandlePtr
StatisticsForegroundBase::editHandleCollector (void)
422 SFStatCollectorP::EditHandlePtr
returnValue(
423 new SFStatCollectorP::EditHandle(
425 this->getType().getFieldDesc(CollectorFieldId
),
429 editSField(CollectorFieldMask
);
435 #ifdef OSG_MT_CPTR_ASPECT
436 void StatisticsForegroundBase::execSyncV( FieldContainer
&oFrom
,
437 ConstFieldMaskArg whichField
,
438 AspectOffsetStore
&oOffsets
,
439 ConstFieldMaskArg syncMode
,
440 const UInt32 uiSyncInfo
)
442 StatisticsForeground
*pThis
= static_cast<StatisticsForeground
*>(this);
444 pThis
->execSync(static_cast<StatisticsForeground
*>(&oFrom
),
454 void StatisticsForegroundBase::resolveLinks(void)
456 Inherited::resolveLinks();
458 #ifdef OSG_MT_CPTR_ASPECT
459 AspectOffsetStore oOffsets
;
461 _pAspectStore
->fillOffsetArray(oOffsets
, this);
464 #ifdef OSG_MT_CPTR_ASPECT
465 _mfElementIDs
.terminateShare(Thread::getCurrentAspect(),