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 ProgramChunk!
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 "OSGProgramChunkBase.h"
67 #include "OSGProgramChunk.h"
69 #include <boost/bind.hpp>
73 /***************************************************************************\
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
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
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(
119 ProgramChunk::getClassType(),
123 OSG_FIELDTRAITS_GETTYPE_NS(ProgramChunk
*, nsOSG
)
125 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField
,
129 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField
,
133 /***************************************************************************\
134 * Field Description *
135 \***************************************************************************/
137 void ProgramChunkBase::classDescInserter(TypeObject
&oType
)
139 FieldDescriptionBase
*pDesc
= NULL
;
142 pDesc
= new SFString::Description(
143 SFString::getClassType(),
145 "The program source code.\n",
146 ProgramFieldId
, ProgramFieldMask
,
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(),
157 "Program Parameters\n",
158 ParamValuesFieldId
, ParamValuesFieldMask
,
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(),
169 "Symbolic names for the program parameters.\n",
170 ParamNamesFieldId
, ParamNamesFieldMask
,
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(),
181 "The OpenGL ID of the program.\n",
182 GLIdFieldId
, GLIdFieldMask
,
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(),
198 reinterpret_cast<InitContainerF
>(&ProgramChunk::initMethod
),
199 reinterpret_cast<ExitContainerF
>(&ProgramChunk::exitMethod
),
200 reinterpret_cast<InitalInsertDescFunc
>(
201 reinterpret_cast<void *>(&ProgramChunk::classDescInserter
)),
204 "<?xml version=\"1.0\"?>\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"
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"
221 " See \\ref PageSystemProgramChunk for a description.\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"
228 " name=\"program\"\n"
229 " type=\"std::string\"\n"
230 " cardinality=\"single\"\n"
231 " visibility=\"external\"\n"
232 " access=\"public\"\n"
234 "\tThe program source code.\n"
237 " name=\"paramValues\"\n"
239 " cardinality=\"multi\"\n"
240 " visibility=\"external\"\n"
241 " access=\"public\"\n"
243 "\tProgram Parameters\n"
246 " name=\"paramNames\"\n"
247 " type=\"std::string\"\n"
248 " cardinality=\"multi\"\n"
249 " visibility=\"external\"\n"
250 " access=\"public\"\n"
252 "\tSymbolic names for the program parameters.\n"
257 " cardinality=\"single\"\n"
258 " visibility=\"internal\"\n"
259 " access=\"protected\"\n"
260 " defaultValue=\"0\"\n"
261 " fieldFlags=\"FClusterLocal\"\n"
263 "\tThe OpenGL ID of the program.\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"
270 "See \\ref PageSystemProgramChunk for a description.\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)
285 const FieldContainerType
&ProgramChunkBase::getType(void) const
290 UInt32
ProgramChunkBase::getContainerSize(void) const
292 return sizeof(ProgramChunk
);
295 /*------------------------- decorator get ------------------------------*/
298 SFString
*ProgramChunkBase::editSFProgram(void)
300 editSField(ProgramFieldMask
);
305 const SFString
*ProgramChunkBase::getSFProgram(void) const
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
);
344 const SFUInt32
*ProgramChunkBase::getSFGLId(void) const
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();
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) :
444 ProgramChunkBase::ProgramChunkBase(const ProgramChunkBase
&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(
466 this->getType().getFieldDesc(ProgramFieldId
),
467 const_cast<ProgramChunkBase
*>(this)));
472 EditFieldHandlePtr
ProgramChunkBase::editHandleProgram (void)
474 SFString::EditHandlePtr
returnValue(
475 new SFString::EditHandle(
477 this->getType().getFieldDesc(ProgramFieldId
),
481 editSField(ProgramFieldMask
);
486 GetFieldHandlePtr
ProgramChunkBase::getHandleParamValues (void) const
488 MFVec4f::GetHandlePtr
returnValue(
489 new MFVec4f::GetHandle(
491 this->getType().getFieldDesc(ParamValuesFieldId
),
492 const_cast<ProgramChunkBase
*>(this)));
497 EditFieldHandlePtr
ProgramChunkBase::editHandleParamValues (void)
499 MFVec4f::EditHandlePtr
returnValue(
500 new MFVec4f::EditHandle(
502 this->getType().getFieldDesc(ParamValuesFieldId
),
506 editMField(ParamValuesFieldMask
, _mfParamValues
);
511 GetFieldHandlePtr
ProgramChunkBase::getHandleParamNames (void) const
513 MFString::GetHandlePtr
returnValue(
514 new MFString::GetHandle(
516 this->getType().getFieldDesc(ParamNamesFieldId
),
517 const_cast<ProgramChunkBase
*>(this)));
522 EditFieldHandlePtr
ProgramChunkBase::editHandleParamNames (void)
524 MFString::EditHandlePtr
returnValue(
525 new MFString::EditHandle(
527 this->getType().getFieldDesc(ParamNamesFieldId
),
531 editMField(ParamNamesFieldMask
, _mfParamNames
);
536 GetFieldHandlePtr
ProgramChunkBase::getHandleGLId (void) const
538 SFUInt32::GetHandlePtr
returnValue(
539 new SFUInt32::GetHandle(
541 this->getType().getFieldDesc(GLIdFieldId
),
542 const_cast<ProgramChunkBase
*>(this)));
547 EditFieldHandlePtr
ProgramChunkBase::editHandleGLId (void)
549 SFUInt32::EditHandlePtr
returnValue(
550 new SFUInt32::EditHandle(
552 this->getType().getFieldDesc(GLIdFieldId
),
556 editSField(GLIdFieldMask
);
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
),
581 void ProgramChunkBase::resolveLinks(void)
583 Inherited::resolveLinks();
585 #ifdef OSG_MT_CPTR_ASPECT
586 AspectOffsetStore oOffsets
;
588 _pAspectStore
->fillOffsetArray(oOffsets
, this);
591 #ifdef OSG_MT_CPTR_ASPECT
592 _mfParamValues
.terminateShare(Thread::getCurrentAspect(),
595 #ifdef OSG_MT_CPTR_ASPECT
596 _mfParamNames
.terminateShare(Thread::getCurrentAspect(),