55#include <Inventor/errors/SoDebugError.h>
56#include <Inventor/fields/SoFieldData.h>
57#include <Inventor/threads/SbThreadLocalStorage.h>
58#include <Inventor/threads/SbThreadMutex.h>
59#include <Inventor/SbRenderEngineMode.h>
60#include <Inventor/SoDB.h>
71#define SO__NODE_CHECK_INIT(className) { \
72 if (classTypeId.isBad()) { \
73 SoDebugError::post("SO_NODE_CONSTRUCTOR", \
74 "Can't construct a node of type " \
75 SO__QUOTE(className) \
76 " until initClass() has been called"); \
77 className::initClass(); \
79 SoTypedObject::checkDatabase(SO__QUOTE(className), this, className::getClassTypeId(), classTypeId); \
82#define SO__NODE_CHECK_CONSTRUCT(where) { \
83 if (fieldData == NULL) { \
84 SoDebugError::post(where, \
85 "Instance not properly constructed.\n" \
86 "Did you forget to put SO_NODE_CONSTRUCTOR()" \
87 " in the constructor?"); \
88 fieldData = new SoFieldData(parentFieldData ? *parentFieldData : NULL); \
93#define SO__NODE_CHECK_INIT(className) { \
94 if (classTypeId.isBad()) { \
95 className::initClass(); \
99#define SO__NODE_CHECK_CONSTRUCT(where) { \
100 if (fieldData == NULL) { \
101 fieldData = new SoFieldData(parentFieldData ? *parentFieldData : NULL); \
118#define SO_NODE_ABSTRACT_HEADER(className) \
121 static SoType getClassTypeId() \
122 { return classTypeId; } \
124 virtual SoType getTypeId() const; \
128 {
return className::getClassRenderEngineMode(); } \ \
132 {
return s_renderEngineMode; } \
134 virtual SbBool getIsBuiltIn()
const ; \
135 virtual const SoFieldData *getFieldData()
const; \
137 static const SoFieldData **getFieldDataPtr(); \
140 static SoType classTypeId; \
141 static SbBool isBuiltIn; \
142 static SbBool firstInstance; \
143 static SoFieldData *fieldData; \
144 static const SoFieldData **parentFieldData; \
151#define SO_NODE_HEADER(className) \
152 SO_NODE_ABSTRACT_HEADER(className); \
153 static void *createInstance(SoType* dynamicType = NULL)
166#define SO__NODE_ABSTRACT_VARS(className) \
167 SbThreadMutex className::classMutex; \
168 SoType className::classTypeId; \
169 SbBool className::isBuiltIn = FALSE; \
170 SoFieldData *className::fieldData = NULL; \
171 const SoFieldData **className::parentFieldData = NULL; \
172 SbBool className::firstInstance = TRUE; \
173 SbRenderEngineMode className::s_renderEngineMode;
178#define SO__NODE_VARS(className) \
179 SO__NODE_ABSTRACT_VARS(className)
186#define SO__NODE_ABSTRACT_METHODS(className) \
189 className::getTypeId() const \
191 return classTypeId; \
194 const SoFieldData * \
195 className::getFieldData() const \
198 SO__NODE_CHECK_CONSTRUCT(SO__QUOTE(className)); \
199 SoFieldData * result = fieldData; \
200 classMutex.unlock(); \
204 SbBool className::getIsBuiltIn() const \
209 const SoFieldData **className::getFieldDataPtr() \
212 const SoFieldData **result = (const SoFieldData **)&fieldData; \
213 classMutex.unlock(); \
223#define SO__NODE_METHODS(className) \
225 SO__NODE_ABSTRACT_METHODS(className) \
228 className::createInstance(SoType *) \
230 return (void *)(new className); \
241#define SO_NODE_SOURCE(className) \
242 SO__NODE_VARS(className); \
243 SO__NODE_METHODS(className)
245#define SO_NODE_ABSTRACT_SOURCE(className) \
246 SO__NODE_ABSTRACT_VARS(className); \
247 SO__NODE_ABSTRACT_METHODS(className)
256#define SO_NODE_INIT_CLASS_CHECK_PARENT(className, parentClass) \
257 if (parentClass::getClassTypeId().isBad()) { \
258 SoDebugError::post( SO__QUOTE(className)"::initClass", \
259 SO__QUOTE(className)" initialized before parent class " \
260 SO__QUOTE(parentClass)"\n"); \
261 parentClass::initClass(); \
264#define SO_NODE_INIT_CLASS_CHECK_PARENT(className, parentClass) \
265 if (parentClass::getClassTypeId().isBad()) \
266 parentClass::initClass()
269#if defined(LIBRARYBUILD)
271#define SO_NODE_INIT_RENDERING_MODE(className, parentClass) \
272 className::getClassRenderEngineMode().setRenderMode(SbRenderEngineMode::OIV_OPENINVENTOR_RENDERING);\
273 if (parentClass::getClassRenderEngineMode().isChildrenInherit()) \
274 className::getClassRenderEngineMode().setChildrenInherit(parentClass::getClassRenderEngineMode().isChildrenInherit())
278#define SO_NODE_INIT_RENDERING_MODE(className, parentClass) \
279 if ( className::getClassRenderEngineMode().isNotDefined() ) \
281 if (parentClass::getClassRenderEngineMode().isChildrenInherit()) \
282 s_renderEngineMode = parentClass::getClassRenderEngineMode(); \
284 SbRenderEngineMode::postInitWarning( OIV_FUNCTION); \
288#define SO__NODE_INIT_CLASS_INTERNAL(className,classPrintName,parentClass) \
290 SO_NODE_INIT_RENDERING_MODE(className, parentClass); \
291 SO_NODE_INIT_CLASS_CHECK_PARENT(className, parentClass); \
292 classTypeId = SoType::createType( parentClass::getClassTypeId(), \
294 &className::createInstance, \
295 (short)SoNode::getNextActionMethodIndex()); \
296 if (parentFieldData == NULL) \
297 SoNode::incNextActionMethodIndex(); \
298 parentFieldData = parentClass::getFieldDataPtr(); \
301#define SO__NODE_INIT_CLASS(className,classPrintName,parentClass) \
302 SO__NODE_INIT_CLASS_INTERNAL(className,classPrintName,parentClass)
304#define SO__NODE_INIT_ABSTRACT_CLASS_INTERNAL(className,classPrintName,parentClass) \
306 SO_NODE_INIT_CLASS_CHECK_PARENT(className, parentClass); \
307 classTypeId = SoType::createType( parentClass::getClassTypeId(), \
310 (short)SoNode::getNextActionMethodIndex()); \
311 if (parentFieldData == NULL) \
312 SoNode::incNextActionMethodIndex(); \
313 parentFieldData = parentClass::getFieldDataPtr(); \
316#define SO__NODE_INIT_ABSTRACT_CLASS(className,classPrintName,parentClass) \
317 SO__NODE_INIT_ABSTRACT_CLASS_INTERNAL(className,classPrintName,parentClass)
320#define SO__NODE_EXIT_CLASS(className) \
321 if (! SoType::removeType(classTypeId.getName())) { \
322 SoDebugError::post(SO__QUOTE(className)"::exitClass", \
323 "Unable to remove type (%s) for this class. Check exitClass() " \
324 "method is implemented and is called only once.\n", \
325 classTypeId.getName().getString() ); \
329 classTypeId = SoType::badType(); \
330 if (fieldData != NULL) \
335 parentFieldData = NULL; \
336 firstInstance = TRUE; \
339#define SO__NODE_EXIT_CLASS(className) \
340 SoType::removeType(classTypeId.getName()); \
341 classTypeId = SoType::badType(); \
342 if (fieldData != NULL) \
347 parentFieldData = NULL; \
365#define SO_THREAD_NODE_INIT_CLASS(className,structName) \
367 SB_THREAD_INIT_CLASS(className,structName)
369#define SO_THREAD_NODE_EXIT_CLASS(className) \
371 SB_THREAD_EXIT_CLASS(className)
373#define LOCAL_THREAD_VAR(_className_, _structName_, _varName_) \
375 GET_THREAD_LOCAL_VAR(_className_, _structName_, _varName_)
377#define LOCAL_THREAD_STORAGE(_className_) \
379 GET_THREAD_LOCAL_STORAGE(_className_)
389#define SO_NODE_INIT_CLASS_INTERNAL(className,parentClass,parentPrintClass) \
391 SO_NODE_INIT_RENDERING_MODE(className, parentClass); \
392 SO_NODE_INIT_CLASS_CHECK_PARENT(className, parentClass); \
393 classTypeId = SoType::createType( SoType::fromName(parentPrintClass), \
394 SO__QUOTE(className), \
395 &className::createInstance, \
396 (short)SoNode::getNextActionMethodIndex()); \
397 if (parentFieldData == NULL) \
398 SoNode::incNextActionMethodIndex(); \
399 parentFieldData = parentClass::getFieldDataPtr(); \
402#define SO_NODE_INIT_CLASS(className,parentClass,parentPrintClass) \
404 SO_NODE_INIT_CLASS_INTERNAL(className,parentClass,parentPrintClass)
406#define SO_NODE_INIT_ABSTRACT_CLASS_INTERNAL(className, parentClass, parentPrintClass) \
408 SO_NODE_INIT_RENDERING_MODE(className,parentClass); \
409 SO_NODE_INIT_CLASS_CHECK_PARENT(className, parentClass); \
410 classTypeId = SoType::createType( SoType::fromName(parentPrintClass), \
411 SO__QUOTE(className), \
413 (short)SoNode::getNextActionMethodIndex()); \
414 if (parentFieldData == NULL) \
415 SoNode::incNextActionMethodIndex(); \
416 parentFieldData = parentClass::getFieldDataPtr(); \
419#define SO_NODE_INIT_ABSTRACT_CLASS(className, parentClass, parentPrintClass) \
421 SO_NODE_INIT_ABSTRACT_CLASS_INTERNAL(className,parentClass,parentPrintClass)
427#define SO_NODE_CONSTRUCTOR(className) \
428 SoBaseInitializer sbi(this); \
430 SO__NODE_CHECK_INIT(className); \
431 if (fieldData == NULL) \
432 fieldData = new SoFieldData(parentFieldData ? \
433 (SoFieldData *)*parentFieldData : \
434 (SoFieldData *)NULL); \
436 firstInstance = FALSE; \
443#define SO_NODE_IS_FIRST_INSTANCE() \
445 (firstInstance == TRUE)
466#define CHECK_FIELD_INIT(fieldName)
470#define CHECK_MFIELD_INIT(fieldName) \
471 if ( dynamic_cast<SoSField*>(&this->fieldName) != NULL) \
472 SoDebugError::post("SO_NODE_ADD_MFIELD","Used for a SoSFField.")
474#define CHECK_FIELD_INIT(fieldName)
475#define CHECK_MFIELD_INIT(fieldName)
478#define SO_NODE_ADD_FIELD(fieldName,defValue) { \
480 SO__NODE_CHECK_CONSTRUCT(__FILE__); \
482 fieldData->addField(this, SO__QUOTE(fieldName), \
484 this->fieldName.setValue defValue; \
485 this->fieldName.setContainer(this); \
486 this->fieldName.setFieldType(SoField::EXPOSED_FIELD); \
487 CHECK_FIELD_INIT(fieldName); \
488 classMutex.unlock(); \
496#define SO_NODE_ADD_NAMED_FIELD(fieldName,memberName,defValue) { \
498 SO__NODE_CHECK_CONSTRUCT(__FILE__); \
500 fieldData->addField(this, SO__QUOTE(fieldName), \
501 &this->memberName); \
502 this->memberName.setValue defValue; \
503 this->memberName.setContainer(this); \
504 this->memberName.setFieldType(SoField::EXPOSED_FIELD); \
505 classMutex.unlock(); \
524#define SO_NODE_ADD_MFIELD(fieldName) { \
526 SO__NODE_CHECK_CONSTRUCT(__FILE__); \
528 fieldData->addField(this, SO__QUOTE(fieldName), \
530 this->fieldName.setContainer(this); \
531 this->fieldName.setFieldType(SoField::EXPOSED_FIELD); \
532 CHECK_MFIELD_INIT(fieldName); \
533 classMutex.unlock(); \
552#define SO_NODE_ADD_PRIVATEFIELD(fieldName,defValue) { \
554 SO__NODE_CHECK_CONSTRUCT(__FILE__); \
556 fieldData->addField(this, SO__QUOTE(fieldName), &this->fieldName); \
557 this->fieldName.setValue defValue; \
558 this->fieldName.setContainer(this); \
559 this->fieldName.setFieldType(SoField::HIDDEN_FIELD); \
560 classMutex.unlock(); \
579#define SO_NODE_ADD_PRIVATEMFIELD(fieldName) { \
581 SO__NODE_CHECK_CONSTRUCT(__FILE__); \
583 fieldData->addField(this, SO__QUOTE(fieldName), \
585 this->fieldName.setContainer(this); \
586 this->fieldName.setFieldType(SoField::HIDDEN_FIELD); \
587 classMutex.unlock(); \
609#define SO_NODE_ADD_EXPOSEDFIELD(fieldName,defValue) { \
611 SO__NODE_CHECK_CONSTRUCT(__FILE__); \
613 fieldData->addField(this, SO__QUOTE(fieldName), \
615 this->fieldName.setValue defValue; \
616 this->fieldName.setContainer(this); \
617 this->fieldName.setFieldType(SoField::EXPOSED_FIELD); \
618 classMutex.unlock(); \
634#define SO_NODE_ADD_EVENTIN(fieldName) { \
636 SO__NODE_CHECK_CONSTRUCT(__FILE__); \
638 fieldData->addField(this, SO__QUOTE(fieldName), \
640 this->fieldName.setContainer(this); \
641 this->fieldName.setFieldType(SoField::EVENTIN_FIELD); \
642 classMutex.unlock(); \
658#define SO_NODE_ADD_EVENTOUT(fieldName, defValue) { \
660 SO__NODE_CHECK_CONSTRUCT(__FILE__); \
662 fieldData->addField(this, SO__QUOTE(fieldName), \
664 this->fieldName.setValue defValue; \
665 this->fieldName.setContainer(this); \
666 this->fieldName.setFieldType(SoField::EVENTOUT_FIELD); \
667 classMutex.unlock(); \
683#define SO_NODE_ADD_HIDDEN_FIELD(fieldName, defValue) { \
685 SO__NODE_CHECK_CONSTRUCT(__FILE__); \
687 fieldData->addField(this, SO__QUOTE(fieldName), \
689 this->fieldName.setValue defValue; \
690 this->fieldName.setContainer(this); \
691 this->fieldName.setFieldType(SoField::INTERNAL_FIELD); \
692 classMutex.unlock(); \
706#define SO_NODE_ADD_FIELD_EVENTIN(fieldName, defValue) { \
708 SO__NODE_CHECK_CONSTRUCT(__FILE__); \
710 fieldData->addField(this, SO__QUOTE(fieldName), \
712 this->fieldName.setValue defValue; \
713 this->fieldName.setContainer(this); \
714 this->fieldName.setFieldType(SoField::FIELD_EVENTIN_FIELD); \
715 classMutex.unlock(); \
740#define SO_NODE_DEFINE_ENUM_VALUE(enumType,enumValue) { \
742 SO__NODE_CHECK_CONSTRUCT(__FILE__); \
744 fieldData->addEnumValue(SO__QUOTE(enumType), \
745 SO__QUOTE(enumValue), \
747 classMutex.unlock(); \
774#define SO__NODE_DEFINE_ENUM_VALUE(enumType,enumValueName,enumValue) { \
776 SO__NODE_CHECK_CONSTRUCT(__FILE__); \
778 fieldData->addEnumValue(SO__QUOTE(enumType), \
781 classMutex.unlock(); \
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Render engine mo...
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Portable mutex c...
Stores runtime type information.