93#ifndef _SO_SUB_ENGINE_
94#define _SO_SUB_ENGINE_
107#define SO__ENGINE_CHECK_INIT(className) \
108 if (classTypeId == SoType::badType()) { \
109 SoDebugError::post("SO_ENGINE_CONSTRUCTOR", \
110 "Can't construct an engine of type " \
111 SO__QUOTE(className), \
112 "until initClass() has been called"); \
116#define SO__ENGINE_CHECK_CONSTRUCT(where) { \
117 if (inputData == NULL) { \
118 SoDebugError::post(where, \
119 "Instance not properly constructed.\n" \
120 "Did you forget to put " \
121 "SO_ENGINE_CONSTRUCTOR()" \
122 " in the constructor?"); \
123 inputData = new SoFieldData(parentInputData ? \
124 *parentInputData : NULL); \
125 outputData = new SoEngineOutputData(parentOutputData ? \
126 *parentOutputData : NULL); \
131#define SO__ENGINE_CHECK_INIT(className)
132#define SO__ENGINE_CHECK_CONSTRUCT(where)
146#define SO_ENGINE_ABSTRACT_HEADER(className) \
148 static SoType getClassTypeId() { return classTypeId; } \
149 virtual SoType getTypeId() const; \
151 virtual const SoFieldData * getFieldData() const; \
152 virtual const SoEngineOutputData * getOutputData() const; \
154 static const SoFieldData ** getInputDataPtr() \
155 { return (const SoFieldData **)&inputData; } \
156 static const SoEngineOutputData ** getOutputDataPtr() \
157 { return (const SoEngineOutputData **)&outputData; } \
159 static SoType classTypeId; \
160 static bool firstInstance; \
161 static SoFieldData *inputData; \
162 static SoEngineOutputData *outputData; \
163 static const SoFieldData **parentInputData; \
164 static const SoEngineOutputData **parentOutputData
166#define SO_ENGINE_HEADER(className) \
168 SO_ENGINE_ABSTRACT_HEADER(className); \
171 static void *createInstance()
178#define SO__ENGINE_ABSTRACT_VARS(className) \
179 SoType className::classTypeId; \
180 bool className::firstInstance=TRUE; \
181 SoEngineOutputData *className::outputData; \
182 SoFieldData * className::inputData; \
183 const SoEngineOutputData **className::parentOutputData; \
184 const SoFieldData ** className::parentInputData
186#define SO__ENGINE_VARS(className) \
187 SO__ENGINE_ABSTRACT_VARS(className)
194#define SO__ENGINE_ABSTRACT_METHODS(className) \
197 className::getTypeId() const \
199 return classTypeId; \
202 const SoFieldData * \
203 className::getFieldData() const \
208 const SoEngineOutputData * \
209 className::getOutputData() const \
214#define SO__ENGINE_METHODS(className) \
216 SO__ENGINE_ABSTRACT_METHODS(className) \
219 className::createInstance() \
221 return (void *)(new className); \
229#define SO_ENGINE_SOURCE(className) \
230 SO__ENGINE_VARS(className); \
231 SO__ENGINE_METHODS(className)
233#define SO_ENGINE_ABSTRACT_SOURCE(className) \
234 SO__ENGINE_ABSTRACT_VARS(className); \
235 SO__ENGINE_ABSTRACT_METHODS(className)
242#define SO__ENGINE_INIT_CLASS(className, classPrintName, parentClass) { \
244 SoType::createType(parentClass::getClassTypeId(), \
246 &className::createInstance); \
247 parentInputData = parentClass::getInputDataPtr(); \
248 parentOutputData = parentClass::getOutputDataPtr(); \
251#define SO__ENGINE_INIT_ABSTRACT_CLASS(className,classPrintName,parent) { \
252 classTypeId = SoType::createType(parent::getClassTypeId(), \
254 parentInputData = parent::getInputDataPtr(); \
255 parentOutputData = parent::getOutputDataPtr(); \
265#define SO_ENGINE_INIT_CLASS(className,parentClass,parentPrintClass) { \
267 SoType::createType(SoType::fromName(parentPrintClass), \
268 SO__QUOTE(className), \
269 &className::createInstance); \
270 parentInputData = parentClass::getInputDataPtr(); \
271 parentOutputData = parentClass::getOutputDataPtr(); \
274#define SO_ENGINE_INIT_ABSTRACT_CLASS(className,parent,parentPrintClass) { \
275 classTypeId = SoType::createType(SoType::fromName(parentPrintClass), \
276 SO__QUOTE(className)); \
277 parentInputData = parent::getInputDataPtr(); \
278 parentOutputData = parent::getOutputDataPtr(); \
286#define SO_ENGINE_CONSTRUCTOR(className) { \
287 SO__ENGINE_CHECK_INIT(className); \
288 if (inputData == NULL) { \
289 inputData = new SoFieldData(parentInputData ? \
290 *parentInputData : NULL); \
291 outputData = new SoEngineOutputData(parentOutputData ? \
292 *parentOutputData : NULL); \
295 firstInstance = FALSE; \
305#define SO_ENGINE_IS_FIRST_INSTANCE() (firstInstance == TRUE)
324#define SO_ENGINE_ADD_INPUT(inputName, defValue) { \
325 SO__ENGINE_CHECK_CONSTRUCT(__FILE__); \
327 inputData->addField(this, SO__QUOTE(inputName), \
329 this->inputName.setValue defValue; \
330 this->inputName.setContainer(this); \
350#define SO_ENGINE_ADD_OUTPUT(outputName, type) { \
351 SO__ENGINE_CHECK_CONSTRUCT(__FILE__); \
353 outputData->addOutput(this, SO__QUOTE(outputName), \
355 type::getClassTypeId()); \
356 this->outputName.setContainer(this); \
381#define SO_ENGINE_DEFINE_ENUM_VALUE(enumType,enumValue) { \
382 SO__ENGINE_CHECK_CONSTRUCT(__FILE__); \
384 inputData->addEnumValue(SO__QUOTE(enumType), \
385 SO__QUOTE(enumValue), enumValue); \
394#define SO_ENGINE_OUTPUT(outputName,type,code) { \
395 if (outputName.isEnabled()) { \
396 for (int _eng_out_i = 0; \
397 _eng_out_i < outputName.getNumConnections(); \
399 type *_eng_out_temp = (type *) outputName[_eng_out_i]; \
400 if (!_eng_out_temp->isReadOnly()) { \
401 _eng_out_temp->code; \