113 #define SO__NODE_CHECK_INIT(className) { \
114 if (classTypeId == SoType::badType()) { \
115 SoDebugError::post("SO_NODE_CONSTRUCTOR", \
116 "Can't construct a node of type " \
117 SO__QUOTE(className) \
118 " until initClass() has been called"); \
123 #define SO__NODE_CHECK_CONSTRUCT(where) { \
124 if (fieldData == NULL) { \
125 SoDebugError::post(where, \
126 "Instance not properly constructed.\n" \
127 "Did you forget to put SO_NODE_CONSTRUCTOR()" \
128 " in the constructor?"); \
130 std::make_unique<SoFieldData>(parentFieldData ? *parentFieldData : NULL); \
131 fieldData = fieldDataStorage.get(); \
136 #define SO__NODE_CHECK_INIT(className) { }
137 #define SO__NODE_CHECK_CONSTRUCT(where) { }
152 #define SO_NODE_ABSTRACT_HEADER(className) \
154 typedef className InventorThisClass; \
155 static SoType getClassTypeId() \
156 { return classTypeId; } \
157 virtual SoType getTypeId() const; \
159 virtual const SoFieldData *getFieldData() const; \
160 static const SoFieldData **getFieldDataPtr() \
161 { return const_cast<const SoFieldData **>(&fieldData); } \
163 static SoType classTypeId; \
164 static bool firstInstance; \
165 static SoFieldData *fieldData; \
166 static std::unique_ptr<SoFieldData> fieldDataStorage; \
167 static const SoFieldData **parentFieldData
173 #define SO_NODE_HEADER(className) \
174 SO_NODE_ABSTRACT_HEADER(className); \
175 static void *createInstance()
188 #define SO__NODE_ABSTRACT_VARS(className) \
189 SoType className::classTypeId; \
190 SoFieldData *className::fieldData; \
191 std::unique_ptr<SoFieldData> className::fieldDataStorage; \
192 const SoFieldData **className::parentFieldData; \
193 bool className::firstInstance = TRUE
198 #define SO__NODE_VARS(className) \
199 SO__NODE_ABSTRACT_VARS(className)
206 #define SO__NODE_ABSTRACT_METHODS(className) \
209 className::getTypeId() const \
211 return classTypeId; \
214 const SoFieldData * \
215 className::getFieldData() const \
217 SO__NODE_CHECK_CONSTRUCT(SO__QUOTE(className)); \
227 #define SO__NODE_METHODS(className) \
229 SO__NODE_ABSTRACT_METHODS(className) \
232 className::createInstance() \
234 return static_cast<void *>(new className); \
244 #define SO_NODE_SOURCE(className) \
245 SO__NODE_VARS(className); \
246 SO__NODE_METHODS(className)
248 #define SO_NODE_ABSTRACT_SOURCE(className) \
249 SO__NODE_ABSTRACT_VARS(className); \
250 SO__NODE_ABSTRACT_METHODS(className)
258 #define SO__NODE_INIT_CLASS(className,classPrintName,parentClass) { \
259 if ((SoNode::nextActionMethodIndex < 0) || \
260 (SoNode::nextActionMethodIndex > 32767)){ \
261 SoDebugError::post("SO__NODE_INIT_CLASS", \
262 "Overflow of SoNode::nextActionMethodIndex"); \
266 SoType::createType(parentClass::getClassTypeId(), \
268 &className::createInstance, \
269 static_cast<short>(SoNode::nextActionMethodIndex++)); \
270 parentFieldData = parentClass::getFieldDataPtr(); \
273 #define SO__NODE_INIT_ABSTRACT_CLASS(className,classPrintName,parentClass) { \
274 if ((SoNode::nextActionMethodIndex < 0) || \
275 (SoNode::nextActionMethodIndex > 32767)){ \
276 SoDebugError::post("SO__NODE_INIT_ABSTRACT_CLASS", \
277 "Overflow of SoNode::nextActionMethodIndex"); \
281 SoType::createType(parentClass::getClassTypeId(), \
284 static_cast<short>(SoNode::nextActionMethodIndex++)); \
285 parentFieldData = parentClass::getFieldDataPtr(); \
296 #define SO_NODE_INIT_CLASS(className,parentClass,parentPrintClass) { \
297 if ((SoNode::nextActionMethodIndex < 0) || \
298 (SoNode::nextActionMethodIndex > 32767)){ \
299 SoDebugError::post("SO_NODE_INIT_CLASS", \
300 "Overflow of SoNode::nextActionMethodIndex"); \
304 SoType::createType(SoType::fromName(parentPrintClass), \
305 SO__QUOTE(className), \
306 &className::createInstance, \
307 static_cast<short>(SoNode::nextActionMethodIndex++)); \
308 parentFieldData = parentClass::getFieldDataPtr(); \
311 #define SO_NODE_INIT_ABSTRACT_CLASS(className, parentClass, parentPrintClass) { \
312 if ((SoNode::nextActionMethodIndex < 0) || \
313 (SoNode::nextActionMethodIndex > 32767)){ \
314 SoDebugError::post("SO_NODE_INIT_ABSTRACT_CLASS", \
315 "Overflow of SoNode::nextActionMethodIndex"); \
319 SoType::createType(SoType::fromName(parentPrintClass), \
320 SO__QUOTE(className), \
322 static_cast<short>(SoNode::nextActionMethodIndex++)); \
323 parentFieldData = parentClass::getFieldDataPtr(); \
332 #define SO_NODE_CONSTRUCTOR(className) { \
333 SO__NODE_CHECK_INIT(className); \
334 if (fieldData == NULL) \
337 std::make_unique<SoFieldData>(parentFieldData ? *parentFieldData : NULL); \
338 fieldData = fieldDataStorage.get(); \
341 firstInstance = FALSE; \
351 #define SO_NODE_IS_FIRST_INSTANCE() \
352 (firstInstance == TRUE)
358 #define SO_NODE_ADD_REMOVED_FIELD(fieldName) {\
360 fieldData->addRemovedFieldName(SO__QUOTE(fieldName)); \
379 #define SO_NODE_ADD_FIELD(fieldName,defValue) { \
380 SO__NODE_CHECK_CONSTRUCT(__FILE__); \
382 fieldData->addField(this, SO__QUOTE(fieldName), \
384 this->fieldName.setValue defValue; \
385 this->fieldName.setContainer(this); \
395 #define SO_NODE_ADD_ENUM_FIELD(field, type, defaultValue) \
396 SO_NODE_SET_SF_ENUM_TYPE(field, type);\
397 SO_NODE_ADD_FIELD(field, (defaultValue));
421 #define SO_NODE_DEFINE_ENUM_VALUE(enumType,enumValue) { \
422 SO__NODE_CHECK_CONSTRUCT(__FILE__); \
424 fieldData->addEnumValue(SO__QUOTE(enumType), \
425 SO__QUOTE(enumValue), \
454 #define SO_NODE_DEFINE_ENUM_VALUE_NAMED(enumType,enumValue,enumValueName) { \
455 SO__NODE_CHECK_CONSTRUCT(__FILE__); \
457 fieldData->addEnumValue(SO__QUOTE(enumType), \
486 #define SO_NODE_DEFINE_ENUM_VALUE_SCOPED(enumScope,enumType,enumValue) { \
487 SO__NODE_CHECK_CONSTRUCT(__FILE__); \
489 fieldData->addEnumValue(SO__QUOTE(enumScope) "::" SO__QUOTE(enumType),\
490 SO__QUOTE(enumValue), \
491 enumScope::enumValue); \