50#ifndef _SO_SUB_ACTION_
51#define _SO_SUB_ACTION_
69#define SO_ACTION_HEADER(className) \
72 virtual SoType getTypeId() const; \
74 static SoType getClassTypeId(); \
76 static void addMethod(SoType t, SoActionMethod* method); \
78 static void enableElement(SoType t, int stkIndex); \
84 static SoEnabledElementsList *enabledElements; \
85 static SoActionMethodList *methods; \
88 virtual SoActionMethodList * getActionMethods(); \
91 static SoType classTypeId; \
92 static SbBool classTypeIdIsSet
95#define SO_ACTION_HEADER_WITH_DEF(className) \
96 SO_ACTION_HEADER(className)
108#define SO__ACTION_VARS(className) \
109 SoEnabledElementsList *className::enabledElements = NULL; \
110 SoActionMethodList *className::methods = NULL; \
111 SoType className::classTypeId; \
112 SbBool className::classTypeIdIsSet = FALSE
118#define SO_ACTION_SOURCE(className) \
119 SO__ACTION_VARS(className); \
120 SO__ACTION_METHODS(className)
122#define SO_ACTION_AUTOINIT_SOURCE(className, parentClass) \
123 SO__ACTION_VARS(className); \
124 SO__ACTION_AUTOINIT_METHODS(className, parentClass)
133#define SO_ACTION_INIT_CLASS_CHECK_PARENT(className, parentClass) \
134 if (parentClass::getClassTypeId().isBad()) { \
135 SoDebugError::post( SO__QUOTE(className)"::initClass", \
136 SO__QUOTE(className)" initialized before parent class " \
137 SO__QUOTE(parentClass)"\n"); \
138 parentClass::initClass(); \
141#define SO_ACTION_INIT_CLASS_CHECK_PARENT(className, parentClass) \
142 if (parentClass::getClassTypeId().isBad()) \
143 parentClass::initClass()
146#define SO_ACTION_INIT_CLASS_INTERNAL(className, parentClass) \
147 enabledElements = new SoEnabledElementsList(parentClass::enabledElements); \
148 methods = new ::SoActionMethodList(parentClass::methods); \
149 SO_ACTION_INIT_CLASS_CHECK_PARENT(className, parentClass); \
150 classTypeId = SoType::createType(parentClass::getClassTypeId(), \
151 SO__QUOTE(className), NULL); \
152 classTypeIdIsSet = TRUE;
154#define SO_ACTION_INIT_CLASS(className, parentClass) \
155 SO_ACTION_INIT_CLASS_INTERNAL(className, parentClass)
158#define SO_ACTION_EXIT_CLASS(className) \
159 if (! SoType::removeType(classTypeId.getName())) { \
160 SoDebugError::post(SO__QUOTE(className)"::exitClass", \
161 "Unable to remove type (%s) for this class. Check exitClass() " \
162 "method is implemented and is called only once.\n", \
163 classTypeId.getName().getString() ); \
166 classTypeId = SoType::badType(); \
167 if (enabledElements) \
169 delete enabledElements; \
170 enabledElements = NULL; \
177 classTypeIdIsSet = FALSE; \
180#define SO_ACTION_EXIT_CLASS(className) \
181 SoType::removeType(classTypeId.getName()); \
182 classTypeId = SoType::badType(); \
183 if (enabledElements) \
185 delete enabledElements; \
186 enabledElements = NULL; \
193 classTypeIdIsSet = FALSE
197#define SO__ACTION_CHECK_INIT(className) { \
198 if (classTypeId.isBad()) { \
199 SoDebugError::post("SO_ACTION_CONSTRUCTOR", \
200 "Can't construct an action of type " \
201 SO__QUOTE(className) \
202 " until initClass() has been called." \
203 " Check SoDB::init() has been called."); \
204 className::initClass(); \
206 SoTypedObject::checkDatabase(SO__QUOTE(className), this, className::getClassTypeId(), classTypeId); \
209#define SO__ACTION_CHECK_INIT(className) { \
210 if (classTypeId.isBad()) { \
211 className::initClass(); \
222#define SO_ACTION_CONSTRUCTOR(className) \
223 SO__ACTION_CHECK_INIT(className);
232#define SO_ACTION_ADD_METHOD(nodeClass, method) \
233 addMethod(nodeClass::getClassTypeId(), method)
240#define SO__ACTION_ELEMENTS_METHODS(className) \
241const SoEnabledElementsList & \
242className::getEnabledElements() const \
244 return *enabledElements; \
247SoActionMethodList * \
248className::getActionMethods() \
254className::addMethod(SoType t, SoActionMethod* method) \
256 methods->addMethod(t, method); \
260className::enableElement(SoType t, int stkIndex) \
264 SoDebugError::post("SO_ENABLE_ELEMENT", \
265 "Can't enable element for " \
266 SO__QUOTE(className) \
267 " until the element initClass function has been called"); \
270 enabledElements->enable(t, stkIndex); \
273#define SO__ACTION_METHODS(className) \
275className::getClassTypeId() \
277 return classTypeId; \
281className::getTypeId() const \
283 return classTypeId; \
286SO__ACTION_ELEMENTS_METHODS(className)
294#define SO__ACTION_AUTOINIT_METHODS(className, parentClass) \
296className::getClassTypeId() \
298 if (!classTypeIdIsSet) { \
299 SO_ACTION_INIT_CLASS(className, parentClass); \
301 return classTypeId; \
305className::getTypeId() const \
307 if (classTypeIdIsSet == FALSE) { \
308 SO_ACTION_INIT_CLASS(className, parentClass); \
310 return classTypeId; \
313SO__ACTION_ELEMENTS_METHODS(className)
virtual const SoEnabledElementsList & getEnabledElements() const
Stores runtime type information.