1#ifndef COIN_SOSUBACTION_H
2#define COIN_SOSUBACTION_H
38#include <Inventor/SbString.h>
39#include <Inventor/actions/SoAction.h>
41#include <Inventor/C/tidbits.h>
45#define SO_ACTION_ADD_METHOD(_nodeclass_, _method_) \
47 addMethod(_nodeclass_::getClassTypeId(), (SoActionMethod)_method_); \
52#define SO_ACTION_CONSTRUCTOR(_classname_) \
54 _classname_::traversalMethods = this->methods; \
59#define SO_ACTION_HEADER(_classname_) \
61 virtual SoType getTypeId(void) const; \
62 static SoType getClassTypeId(void); \
64 static void addMethod(const SoType type, SoActionMethod method); \
66 static void enableElement(const SoType type, const int stackindex); \
69 virtual const SoEnabledElementsList & getEnabledElements(void) const; \
73 static SoEnabledElementsList * getClassEnabledElements(void); \
74 static SoActionMethodList * getClassActionMethods(void); \
81 static void atexit_cleanup(void); \
82 static SoEnabledElementsList * enabledElements; \
83 static SoActionMethodList * methods; \
84 static SoType classTypeId
88#define SO_ACTION_SOURCE(_classname_) \
89SoEnabledElementsList * _classname_::enabledElements = NULL; \
90SoActionMethodList * _classname_::methods = NULL; \
100SoEnabledElementsList * _classname_::getClassEnabledElements(void) { return _classname_::enabledElements; } \
110SoActionMethodList * _classname_::getClassActionMethods(void) { return _classname_::methods; } \
111SoType _classname_::classTypeId STATIC_SOTYPE_INIT; \
117SoType _classname_::getClassTypeId(void) { return _classname_::classTypeId; } \
124SoType _classname_::getTypeId(void) const { return _classname_::classTypeId; } \
128const SoEnabledElementsList & _classname_::getEnabledElements(void) const \
130 assert(_classname_::enabledElements); \
131 return *_classname_::enabledElements; \
134_classname_::addMethod(const SoType type, SoActionMethod method) \
136 assert(_classname_::methods); \
137 _classname_::methods->addMethod(type, method); \
140_classname_::enableElement(const SoType type, const int stackindex) \
142 assert(_classname_::enabledElements); \
143 _classname_::enabledElements->enable(type, stackindex); \
146_classname_::atexit_cleanup(void) \
148 delete _classname_::enabledElements; \
149 _classname_::enabledElements = NULL; \
150 delete _classname_::methods; \
151 _classname_::methods = NULL; \
152 _classname_::classTypeId STATIC_SOTYPE_INIT; \
157#define SO_ACTION_INIT_CLASS(_classname_, _parentclassname_) \
159 assert(_classname_::getClassTypeId() == SoType::badType()); \
160 assert(_parentclassname_::getClassTypeId() != SoType::badType()); \
161 _classname_::classTypeId = SoType::createType(_parentclassname_::getClassTypeId(), SO__QUOTE(_classname_)); \
162 _classname_::enabledElements = new SoEnabledElementsList(_parentclassname_::getClassEnabledElements()); \
163 _classname_::methods = new SoActionMethodList(_parentclassname_::getClassActionMethods()); \
164 cc_coin_atexit_static_internal(reinterpret_cast<coin_atexit_f *>(_classname_::atexit_cleanup)); \