changed: gcc8 base update
[opensg.git] / Source / System / State / ARBProgram / OSGProgramChunkBase.cpp
blob29288f390c5613d9abe758a5365d046ee36bf106
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 ProgramChunk!
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 "OSGProgramChunkBase.h"
67 #include "OSGProgramChunk.h"
69 #include <boost/bind.hpp>
71 OSG_BEGIN_NAMESPACE
73 /***************************************************************************\
74 * Description *
75 \***************************************************************************/
77 /*! \class OSG::ProgramChunk
78 The ProgramChunk is the base class for generic ASCII-based programs
79 inside OpenGL. For actual use see the derived VertexProgramChunk and
80 FragmentProgramChunk.
82 See \ref PageSystemProgramChunk for a description.
84 The ProgramChunk contains the source code of the program to use
85 (OSG::ProgramChunk::_sfProgram) and the local program parameters
86 (OSG::ProgramChunk::_mfParamValues). The parameters can have an associated
87 name (OSG::ProgramChunk::_mfParamNames).
90 /***************************************************************************\
91 * Field Documentation *
92 \***************************************************************************/
94 /*! \var std::string ProgramChunkBase::_sfProgram
95 The program source code.
98 /*! \var Vec4f ProgramChunkBase::_mfParamValues
99 Program Parameters
102 /*! \var std::string ProgramChunkBase::_mfParamNames
103 Symbolic names for the program parameters.
106 /*! \var UInt32 ProgramChunkBase::_sfGLId
107 The OpenGL ID of the program.
111 /***************************************************************************\
112 * FieldType/FieldTrait Instantiation *
113 \***************************************************************************/
115 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
116 PointerType FieldTraits<ProgramChunk *, nsOSG>::_type(
117 "ProgramChunkPtr",
118 "StateChunkPtr",
119 ProgramChunk::getClassType(),
120 nsOSG);
121 #endif
123 OSG_FIELDTRAITS_GETTYPE_NS(ProgramChunk *, nsOSG)
125 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField,
126 ProgramChunk *,
127 nsOSG)
129 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField,
130 ProgramChunk *,
131 nsOSG)
133 /***************************************************************************\
134 * Field Description *
135 \***************************************************************************/
137 void ProgramChunkBase::classDescInserter(TypeObject &oType)
139 FieldDescriptionBase *pDesc = NULL;
142 pDesc = new SFString::Description(
143 SFString::getClassType(),
144 "program",
145 "The program source code.\n",
146 ProgramFieldId, ProgramFieldMask,
147 false,
148 (Field::SFDefaultFlags | Field::FStdAccess),
149 static_cast<FieldEditMethodSig>(&ProgramChunk::editHandleProgram),
150 static_cast<FieldGetMethodSig >(&ProgramChunk::getHandleProgram));
152 oType.addInitialDesc(pDesc);
154 pDesc = new MFVec4f::Description(
155 MFVec4f::getClassType(),
156 "paramValues",
157 "Program Parameters\n",
158 ParamValuesFieldId, ParamValuesFieldMask,
159 false,
160 (Field::MFDefaultFlags | Field::FStdAccess),
161 static_cast<FieldEditMethodSig>(&ProgramChunk::editHandleParamValues),
162 static_cast<FieldGetMethodSig >(&ProgramChunk::getHandleParamValues));
164 oType.addInitialDesc(pDesc);
166 pDesc = new MFString::Description(
167 MFString::getClassType(),
168 "paramNames",
169 "Symbolic names for the program parameters.\n",
170 ParamNamesFieldId, ParamNamesFieldMask,
171 false,
172 (Field::MFDefaultFlags | Field::FStdAccess),
173 static_cast<FieldEditMethodSig>(&ProgramChunk::editHandleParamNames),
174 static_cast<FieldGetMethodSig >(&ProgramChunk::getHandleParamNames));
176 oType.addInitialDesc(pDesc);
178 pDesc = new SFUInt32::Description(
179 SFUInt32::getClassType(),
180 "GLId",
181 "The OpenGL ID of the program.\n",
182 GLIdFieldId, GLIdFieldMask,
183 true,
184 (Field::FClusterLocal),
185 static_cast<FieldEditMethodSig>(&ProgramChunk::editHandleGLId),
186 static_cast<FieldGetMethodSig >(&ProgramChunk::getHandleGLId));
188 oType.addInitialDesc(pDesc);
192 ProgramChunkBase::TypeObject ProgramChunkBase::_type(
193 ProgramChunkBase::getClassname(),
194 Inherited::getClassname(),
195 "NULL",
196 nsOSG, //Namespace
197 NULL,
198 reinterpret_cast<InitContainerF>(&ProgramChunk::initMethod),
199 reinterpret_cast<ExitContainerF>(&ProgramChunk::exitMethod),
200 reinterpret_cast<InitalInsertDescFunc>(
201 reinterpret_cast<void *>(&ProgramChunk::classDescInserter)),
202 false,
204 "<?xml version=\"1.0\"?>\n"
205 "\n"
206 "<FieldContainer\n"
207 " name=\"ProgramChunk\"\n"
208 " parent=\"StateChunk\"\n"
209 " library=\"State\"\n"
210 " pointerfieldtypes=\"both\"\n"
211 " structure=\"abstract\"\n"
212 " systemcomponent=\"true\"\n"
213 " parentsystemcomponent=\"true\"\n"
214 " decoratable=\"false\"\n"
215 " docGroupBase=\"GrpStateARBProgram\"\n"
216 " >\n"
217 " The ProgramChunk is the base class for generic ASCII-based programs\n"
218 " inside OpenGL. For actual use see the derived VertexProgramChunk and\n"
219 " FragmentProgramChunk.\n"
220 "\n"
221 " See \\ref PageSystemProgramChunk for a description.\n"
222 "\n"
223 " The ProgramChunk contains the source code of the program to use\n"
224 " (OSG::ProgramChunk::_sfProgram) and the local program parameters\n"
225 " (OSG::ProgramChunk::_mfParamValues). The parameters can have an associated\n"
226 " name (OSG::ProgramChunk::_mfParamNames).\n"
227 " <Field\n"
228 " name=\"program\"\n"
229 " type=\"std::string\"\n"
230 " cardinality=\"single\"\n"
231 " visibility=\"external\"\n"
232 " access=\"public\"\n"
233 " >\n"
234 "\tThe program source code.\n"
235 " </Field>\n"
236 " <Field\n"
237 " name=\"paramValues\"\n"
238 " type=\"Vec4f\"\n"
239 " cardinality=\"multi\"\n"
240 " visibility=\"external\"\n"
241 " access=\"public\"\n"
242 " >\n"
243 "\tProgram Parameters\n"
244 " </Field>\n"
245 " <Field\n"
246 " name=\"paramNames\"\n"
247 " type=\"std::string\"\n"
248 " cardinality=\"multi\"\n"
249 " visibility=\"external\"\n"
250 " access=\"public\"\n"
251 " >\n"
252 "\tSymbolic names for the program parameters.\n"
253 " </Field>\n"
254 " <Field\n"
255 " name=\"GLId\"\n"
256 " type=\"UInt32\"\n"
257 " cardinality=\"single\"\n"
258 " visibility=\"internal\"\n"
259 " access=\"protected\"\n"
260 " defaultValue=\"0\"\n"
261 " fieldFlags=\"FClusterLocal\"\n"
262 " >\n"
263 "\tThe OpenGL ID of the program.\n"
264 " </Field>\n"
265 "</FieldContainer>\n",
266 "The ProgramChunk is the base class for generic ASCII-based programs\n"
267 "inside OpenGL. For actual use see the derived VertexProgramChunk and\n"
268 "FragmentProgramChunk.\n"
269 "\n"
270 "See \\ref PageSystemProgramChunk for a description.\n"
271 "\n"
272 "The ProgramChunk contains the source code of the program to use\n"
273 "(OSG::ProgramChunk::_sfProgram) and the local program parameters\n"
274 "(OSG::ProgramChunk::_mfParamValues). The parameters can have an associated\n"
275 "name (OSG::ProgramChunk::_mfParamNames).\n"
278 /*------------------------------ get -----------------------------------*/
280 FieldContainerType &ProgramChunkBase::getType(void)
282 return _type;
285 const FieldContainerType &ProgramChunkBase::getType(void) const
287 return _type;
290 UInt32 ProgramChunkBase::getContainerSize(void) const
292 return sizeof(ProgramChunk);
295 /*------------------------- decorator get ------------------------------*/
298 SFString *ProgramChunkBase::editSFProgram(void)
300 editSField(ProgramFieldMask);
302 return &_sfProgram;
305 const SFString *ProgramChunkBase::getSFProgram(void) const
307 return &_sfProgram;
311 MFVec4f *ProgramChunkBase::editMFParamValues(void)
313 editMField(ParamValuesFieldMask, _mfParamValues);
315 return &_mfParamValues;
318 const MFVec4f *ProgramChunkBase::getMFParamValues(void) const
320 return &_mfParamValues;
324 MFString *ProgramChunkBase::editMFParamNames(void)
326 editMField(ParamNamesFieldMask, _mfParamNames);
328 return &_mfParamNames;
331 const MFString *ProgramChunkBase::getMFParamNames(void) const
333 return &_mfParamNames;
337 SFUInt32 *ProgramChunkBase::editSFGLId(void)
339 editSField(GLIdFieldMask);
341 return &_sfGLId;
344 const SFUInt32 *ProgramChunkBase::getSFGLId(void) const
346 return &_sfGLId;
354 /*------------------------------ access -----------------------------------*/
356 SizeT ProgramChunkBase::getBinSize(ConstFieldMaskArg whichField)
358 SizeT returnValue = Inherited::getBinSize(whichField);
360 if(FieldBits::NoField != (ProgramFieldMask & whichField))
362 returnValue += _sfProgram.getBinSize();
364 if(FieldBits::NoField != (ParamValuesFieldMask & whichField))
366 returnValue += _mfParamValues.getBinSize();
368 if(FieldBits::NoField != (ParamNamesFieldMask & whichField))
370 returnValue += _mfParamNames.getBinSize();
372 if(FieldBits::NoField != (GLIdFieldMask & whichField))
374 returnValue += _sfGLId.getBinSize();
377 return returnValue;
380 void ProgramChunkBase::copyToBin(BinaryDataHandler &pMem,
381 ConstFieldMaskArg whichField)
383 Inherited::copyToBin(pMem, whichField);
385 if(FieldBits::NoField != (ProgramFieldMask & whichField))
387 _sfProgram.copyToBin(pMem);
389 if(FieldBits::NoField != (ParamValuesFieldMask & whichField))
391 _mfParamValues.copyToBin(pMem);
393 if(FieldBits::NoField != (ParamNamesFieldMask & whichField))
395 _mfParamNames.copyToBin(pMem);
397 if(FieldBits::NoField != (GLIdFieldMask & whichField))
399 _sfGLId.copyToBin(pMem);
403 void ProgramChunkBase::copyFromBin(BinaryDataHandler &pMem,
404 ConstFieldMaskArg whichField)
406 Inherited::copyFromBin(pMem, whichField);
408 if(FieldBits::NoField != (ProgramFieldMask & whichField))
410 editSField(ProgramFieldMask);
411 _sfProgram.copyFromBin(pMem);
413 if(FieldBits::NoField != (ParamValuesFieldMask & whichField))
415 editMField(ParamValuesFieldMask, _mfParamValues);
416 _mfParamValues.copyFromBin(pMem);
418 if(FieldBits::NoField != (ParamNamesFieldMask & whichField))
420 editMField(ParamNamesFieldMask, _mfParamNames);
421 _mfParamNames.copyFromBin(pMem);
423 if(FieldBits::NoField != (GLIdFieldMask & whichField))
425 editSField(GLIdFieldMask);
426 _sfGLId.copyFromBin(pMem);
433 /*------------------------- constructors ----------------------------------*/
435 ProgramChunkBase::ProgramChunkBase(void) :
436 Inherited(),
437 _sfProgram (),
438 _mfParamValues (),
439 _mfParamNames (),
440 _sfGLId (UInt32(0))
444 ProgramChunkBase::ProgramChunkBase(const ProgramChunkBase &source) :
445 Inherited(source),
446 _sfProgram (source._sfProgram ),
447 _mfParamValues (source._mfParamValues ),
448 _mfParamNames (source._mfParamNames ),
449 _sfGLId (source._sfGLId )
454 /*-------------------------- destructors ----------------------------------*/
456 ProgramChunkBase::~ProgramChunkBase(void)
461 GetFieldHandlePtr ProgramChunkBase::getHandleProgram (void) const
463 SFString::GetHandlePtr returnValue(
464 new SFString::GetHandle(
465 &_sfProgram,
466 this->getType().getFieldDesc(ProgramFieldId),
467 const_cast<ProgramChunkBase *>(this)));
469 return returnValue;
472 EditFieldHandlePtr ProgramChunkBase::editHandleProgram (void)
474 SFString::EditHandlePtr returnValue(
475 new SFString::EditHandle(
476 &_sfProgram,
477 this->getType().getFieldDesc(ProgramFieldId),
478 this));
481 editSField(ProgramFieldMask);
483 return returnValue;
486 GetFieldHandlePtr ProgramChunkBase::getHandleParamValues (void) const
488 MFVec4f::GetHandlePtr returnValue(
489 new MFVec4f::GetHandle(
490 &_mfParamValues,
491 this->getType().getFieldDesc(ParamValuesFieldId),
492 const_cast<ProgramChunkBase *>(this)));
494 return returnValue;
497 EditFieldHandlePtr ProgramChunkBase::editHandleParamValues (void)
499 MFVec4f::EditHandlePtr returnValue(
500 new MFVec4f::EditHandle(
501 &_mfParamValues,
502 this->getType().getFieldDesc(ParamValuesFieldId),
503 this));
506 editMField(ParamValuesFieldMask, _mfParamValues);
508 return returnValue;
511 GetFieldHandlePtr ProgramChunkBase::getHandleParamNames (void) const
513 MFString::GetHandlePtr returnValue(
514 new MFString::GetHandle(
515 &_mfParamNames,
516 this->getType().getFieldDesc(ParamNamesFieldId),
517 const_cast<ProgramChunkBase *>(this)));
519 return returnValue;
522 EditFieldHandlePtr ProgramChunkBase::editHandleParamNames (void)
524 MFString::EditHandlePtr returnValue(
525 new MFString::EditHandle(
526 &_mfParamNames,
527 this->getType().getFieldDesc(ParamNamesFieldId),
528 this));
531 editMField(ParamNamesFieldMask, _mfParamNames);
533 return returnValue;
536 GetFieldHandlePtr ProgramChunkBase::getHandleGLId (void) const
538 SFUInt32::GetHandlePtr returnValue(
539 new SFUInt32::GetHandle(
540 &_sfGLId,
541 this->getType().getFieldDesc(GLIdFieldId),
542 const_cast<ProgramChunkBase *>(this)));
544 return returnValue;
547 EditFieldHandlePtr ProgramChunkBase::editHandleGLId (void)
549 SFUInt32::EditHandlePtr returnValue(
550 new SFUInt32::EditHandle(
551 &_sfGLId,
552 this->getType().getFieldDesc(GLIdFieldId),
553 this));
556 editSField(GLIdFieldMask);
558 return returnValue;
562 #ifdef OSG_MT_CPTR_ASPECT
563 void ProgramChunkBase::execSyncV( FieldContainer &oFrom,
564 ConstFieldMaskArg whichField,
565 AspectOffsetStore &oOffsets,
566 ConstFieldMaskArg syncMode,
567 const UInt32 uiSyncInfo)
569 ProgramChunk *pThis = static_cast<ProgramChunk *>(this);
571 pThis->execSync(static_cast<ProgramChunk *>(&oFrom),
572 whichField,
573 oOffsets,
574 syncMode,
575 uiSyncInfo);
577 #endif
581 void ProgramChunkBase::resolveLinks(void)
583 Inherited::resolveLinks();
585 #ifdef OSG_MT_CPTR_ASPECT
586 AspectOffsetStore oOffsets;
588 _pAspectStore->fillOffsetArray(oOffsets, this);
589 #endif
591 #ifdef OSG_MT_CPTR_ASPECT
592 _mfParamValues.terminateShare(Thread::getCurrentAspect(),
593 oOffsets);
594 #endif
595 #ifdef OSG_MT_CPTR_ASPECT
596 _mfParamNames.terminateShare(Thread::getCurrentAspect(),
597 oOffsets);
598 #endif
602 OSG_END_NAMESPACE