1#ifndef COIN_SOSUBELEMENT_H
2#define COIN_SOSUBELEMENT_H
48#include <Inventor/SbBasic.h>
49#include <Inventor/SbName.h>
50#include <Inventor/C/tidbits.h>
53#include <Inventor/elements/SoElement.h>
57#define SO_ELEMENT_ABSTRACT_HEADER(_class_) \
59 static SoType getClassTypeId(void); \
60 static int getClassStackIndex(void); \
68 static int classStackIndex; \
69 static SoType classTypeId; \
70 static void cleanupClass(void) { SoType::removeType(_class_::classTypeId.getName()); _class_::classTypeId STATIC_SOTYPE_INIT; }
74#define SO_ELEMENT_HEADER(_class_) \
75 SO_ELEMENT_ABSTRACT_HEADER(_class_); \
77 static void * createInstance(void)
81#define PRIVATE_SOELEMENT_VARIABLES(_class_) \
82int _class_::classStackIndex; \
83SoType _class_::classTypeId STATIC_SOTYPE_INIT; \
89SoType _class_::getClassTypeId(void) { return _class_::classTypeId; } \
94int _class_::getClassStackIndex(void) { return _class_::classStackIndex; }
97#define SO_ELEMENT_ABSTRACT_SOURCE(_class_) \
98PRIVATE_SOELEMENT_VARIABLES(_class_) \
99_class_::_class_(void) { }
101#define SO_ELEMENT_SOURCE(_class_) \
102PRIVATE_SOELEMENT_VARIABLES(_class_) \
103_class_::_class_(void) { this->setTypeId(_class_::classTypeId); \
104 this->setStackIndex(_class_::classStackIndex); } \
109void * _class_::createInstance(void) { return new _class_; }
114#define SO_ELEMENT_CUSTOM_CONSTRUCTOR_SOURCE(_class_) \
115PRIVATE_SOELEMENT_VARIABLES(_class_) \
120void * _class_::createInstance(void) { return new _class_; }
124#define PRIVATE_SOELEMENT_INIT(_class_, _parent_, _instantiate_) \
126 assert(_class_::classTypeId == SoType::badType()); \
127 assert(_parent_::getClassTypeId() != SoType::badType()); \
128 _class_::classTypeId = SoType::createType(_parent_::getClassTypeId(), \
129 SO__QUOTE(_class_), \
131 if (_parent_::getClassStackIndex() < 0) _class_::classStackIndex = _class_::createStackIndex(_class_::classTypeId); \
132 else _class_::classStackIndex = _parent_::getClassStackIndex(); \
133 cc_coin_atexit_static_internal(reinterpret_cast<coin_atexit_f*>(_class_::cleanupClass)); \
137#define SO_ELEMENT_INIT_ABSTRACT_CLASS(_class_, _parent_) \
138 PRIVATE_SOELEMENT_INIT(_class_, _parent_, NULL)
140#define SO_ELEMENT_INIT_CLASS(_class_, _parent_) \
141 PRIVATE_SOELEMENT_INIT(_class_, _parent_, &_class_::createInstance)