changed: gcc8 base update
[opensg.git] / Source / System / Statistics / Base / OSGStatisticsForegroundBase.cpp
bloba0ee0f4731d6d193efa0fae78595150ae354e5bd
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 StatisticsForeground!
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"
66 #include "OSGStatisticsForegroundBase.h"
67 #include "OSGStatisticsForeground.h"
69 #include <boost/bind.hpp>
71 OSG_BEGIN_NAMESPACE
73 /***************************************************************************\
74 * Description *
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
85 _mfElementIDs field.
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
90 GUI or text output.
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
94 possible options.
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",
120 "ForegroundPtr",
121 StatisticsForeground::getClassType(),
122 nsOSG);
123 #endif
125 OSG_FIELDTRAITS_GETTYPE_NS(StatisticsForeground *, nsOSG)
127 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField,
128 StatisticsForeground *,
129 nsOSG)
131 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField,
132 StatisticsForeground *,
133 nsOSG)
135 /***************************************************************************\
136 * Field Description *
137 \***************************************************************************/
139 void StatisticsForegroundBase::classDescInserter(TypeObject &oType)
141 FieldDescriptionBase *pDesc = NULL;
144 pDesc = new MFInt32::Description(
145 MFInt32::getClassType(),
146 "elementIDs",
147 "The StatElemDesc IDs to use. If not set, use all in the descriptor.\n",
148 ElementIDsFieldId, ElementIDsFieldMask,
149 false,
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(),
158 "collector",
159 "The OSG::StatCollector that keeps the displayed statistics.\n",
160 CollectorFieldId, CollectorFieldMask,
161 false,
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(),
173 "NULL",
174 nsOSG, //Namespace
175 NULL,
176 reinterpret_cast<InitContainerF>(&StatisticsForeground::initMethod),
177 reinterpret_cast<ExitContainerF>(&StatisticsForeground::exitMethod),
178 reinterpret_cast<InitalInsertDescFunc>(
179 reinterpret_cast<void *>(&StatisticsForeground::classDescInserter)),
180 false,
182 "<?xml version=\"1.0\"?>\n"
183 "\n"
184 "<FieldContainer\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"
194 " >\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"
198 "\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"
203 "\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"
208 "\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"
212 "\n"
213 " If no elementIDs are given all elements in the OSG::StatCollector are display,\n"
214 " using the default format.\n"
215 "\n"
216 " <Field\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"
222 "\t >\n"
223 "\tThe StatElemDesc IDs to use. If not set, use all in the descriptor.\n"
224 " </Field>\n"
225 " <Field\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"
231 "\t >\n"
232 " The OSG::StatCollector that keeps the displayed statistics.\n"
233 " </Field>\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"
238 "\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"
243 "\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"
248 "\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"
252 "\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)
261 return _type;
264 const FieldContainerType &StatisticsForegroundBase::getType(void) const
266 return _type;
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();
322 return returnValue;
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) :
363 Inherited(),
364 _mfElementIDs (),
365 _sfCollector ()
369 StatisticsForegroundBase::StatisticsForegroundBase(const StatisticsForegroundBase &source) :
370 Inherited(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(
388 &_mfElementIDs,
389 this->getType().getFieldDesc(ElementIDsFieldId),
390 const_cast<StatisticsForegroundBase *>(this)));
392 return returnValue;
395 EditFieldHandlePtr StatisticsForegroundBase::editHandleElementIDs (void)
397 MFInt32::EditHandlePtr returnValue(
398 new MFInt32::EditHandle(
399 &_mfElementIDs,
400 this->getType().getFieldDesc(ElementIDsFieldId),
401 this));
404 editMField(ElementIDsFieldMask, _mfElementIDs);
406 return returnValue;
409 GetFieldHandlePtr StatisticsForegroundBase::getHandleCollector (void) const
411 SFStatCollectorP::GetHandlePtr returnValue(
412 new SFStatCollectorP::GetHandle(
413 &_sfCollector,
414 this->getType().getFieldDesc(CollectorFieldId),
415 const_cast<StatisticsForegroundBase *>(this)));
417 return returnValue;
420 EditFieldHandlePtr StatisticsForegroundBase::editHandleCollector (void)
422 SFStatCollectorP::EditHandlePtr returnValue(
423 new SFStatCollectorP::EditHandle(
424 &_sfCollector,
425 this->getType().getFieldDesc(CollectorFieldId),
426 this));
429 editSField(CollectorFieldMask);
431 return returnValue;
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),
445 whichField,
446 oOffsets,
447 syncMode,
448 uiSyncInfo);
450 #endif
454 void StatisticsForegroundBase::resolveLinks(void)
456 Inherited::resolveLinks();
458 #ifdef OSG_MT_CPTR_ASPECT
459 AspectOffsetStore oOffsets;
461 _pAspectStore->fillOffsetArray(oOffsets, this);
462 #endif
464 #ifdef OSG_MT_CPTR_ASPECT
465 _mfElementIDs.terminateShare(Thread::getCurrentAspect(),
466 oOffsets);
467 #endif
471 OSG_END_NAMESPACE