Open Inventor Reference
SoSubNode.h File Reference

Go to the source code of this file.

Macros

#define SO__NODE_CHECK_INIT(className)   { }
 *** note: many of the macros use the "do { ... } while(0)" *** hack to define multiline blocks as a single statement *** of code that can be used anywhere and ended with a semicolon
 
#define SO__NODE_CHECK_CONSTRUCT(where)   { }
 
#define SO_NODE_ABSTRACT_HEADER(className)
 Macros to be called within the class definition header for a node subclass:
 
#define SO_NODE_HEADER(className)
 Non-abstract classes have everything abstract classes have, plus a way to create an instance.
 
#define SO__NODE_ABSTRACT_VARS(className)
 Macros to be called within the source file for a node subclass:
 
#define SO__NODE_VARS(className)    SO__NODE_ABSTRACT_VARS(className)
 Non-abstract nodes have all the stuff abstract nodes do.
 
#define SO__NODE_ABSTRACT_METHODS(className)
 Methods on the abstract type.
 
#define SO__NODE_METHODS(className)
 These implement the methods defined in SO_NODE_HEADER or SO_NODE_ABSTRACT_HEADER.
 
#define SO_NODE_SOURCE(className)
 These include all the definitions required at file scope.
 
#define SO_NODE_ABSTRACT_SOURCE(className)
 
#define SO__NODE_INIT_CLASS(className, classPrintName, parentClass)
 Internal initialization macros.
 
#define SO__NODE_INIT_ABSTRACT_CLASS(className, classPrintName, parentClass)
 
#define SO_NODE_INIT_CLASS(className, parentClass, parentPrintClass)
 This initializes the type identifer variables defined in SO_NODE_HEADER or SO_NODE_ABSTRACT_HEADER.
 
#define SO_NODE_INIT_ABSTRACT_CLASS(className, parentClass, parentPrintClass)
 
#define SO_NODE_CONSTRUCTOR(className)
 This is included at the beginning of a constructor, to do required initializations.
 
#define SO_NODE_IS_FIRST_INSTANCE()    (firstInstance == TRUE)
 This is a boolean value that can be tested in constructors.
 
#define SO_NODE_ADD_REMOVED_FIELD(fieldName)
 This adds the info for a removed field to the SoFieldData.
 
#define SO_NODE_ADD_FIELD(fieldName, defValue)
 This adds the info for a field to the SoFieldData and sets the default value for it.
 
#define SO_NODE_ADD_ENUM_FIELD(field, type, defaultValue)
 This adds an enum field of the given type to the SoFieldData and sets it's default value.
 
#define SO_NODE_DEFINE_ENUM_VALUE(enumType, enumValue)
 This registers a value of an enum type.
 
#define SO_NODE_DEFINE_ENUM_VALUE_NAMED(enumType, enumValue, enumValueName)
 This registers a named value of an enum type.
 
#define SO_NODE_DEFINE_ENUM_VALUE_SCOPED(enumScope, enumType, enumValue)
 This registers a value of a scoped enum type.
 

Macro Definition Documentation

◆ SO__NODE_ABSTRACT_METHODS

#define SO__NODE_ABSTRACT_METHODS (   className)
Value:
\
SoType \
className::getTypeId() const \
{ \
return classTypeId; \
} \
\
const SoFieldData * \
className::getFieldData() const \
{ \
SO__NODE_CHECK_CONSTRUCT(SO__QUOTE(className)); \
return fieldData; \
}
#define SO__QUOTE(str)
Handy macros.
Definition SoBasic.h:69
The SoFieldData class holds data about fields of an object: the number of fields the object has,...
Definition SoFieldData.h:88

Definition at line 202 of file SoSubNode.h.

◆ SO__NODE_ABSTRACT_VARS

#define SO__NODE_ABSTRACT_VARS (   className)
Value:
SoType className::classTypeId; \
SoFieldData *className::fieldData; \
const SoFieldData **className::parentFieldData; \
bool className::firstInstance = TRUE
#define TRUE
Definition SbBasic.h:76
SoType has no virtual functions to keep it small...
Definition SoType.h:103

This declares the static variables defined in SO_NODE_HEADER or SO_NODE_ABSTRACT_HEADER.

Definition at line 185 of file SoSubNode.h.

◆ SO__NODE_CHECK_CONSTRUCT

#define SO__NODE_CHECK_CONSTRUCT (   where)    { }

Definition at line 135 of file SoSubNode.h.

◆ SO__NODE_CHECK_INIT

#define SO__NODE_CHECK_INIT (   className)    { }

Debugging macros (used by other macros in this file)

Definition at line 134 of file SoSubNode.h.

◆ SO__NODE_INIT_ABSTRACT_CLASS

#define SO__NODE_INIT_ABSTRACT_CLASS (   className,
  classPrintName,
  parentClass 
)
Value:
{ \
SoDebugError::post("SO__NODE_INIT_ABSTRACT_CLASS", \
"Overflow of SoNode::nextActionMethodIndex"); \
abort(); \
} \
classTypeId = \
SoType::createType(parentClass::getClassTypeId(), \
classPrintName, \
NULL, \
static_cast<short>(SoNode::nextActionMethodIndex++)); \
parentFieldData = parentClass::getFieldDataPtr(); \
}
static int nextActionMethodIndex
Next index into the action method table.
Definition SoNode.h:237

Definition at line 269 of file SoSubNode.h.

◆ SO__NODE_INIT_CLASS

#define SO__NODE_INIT_CLASS (   className,
  classPrintName,
  parentClass 
)
Value:
{ \
SoDebugError::post("SO__NODE_INIT_CLASS", \
"Overflow of SoNode::nextActionMethodIndex"); \
abort(); \
} \
classTypeId = \
SoType::createType(parentClass::getClassTypeId(), \
classPrintName, \
&className::createInstance, \
static_cast<short>(SoNode::nextActionMethodIndex++)); \
parentFieldData = parentClass::getFieldDataPtr(); \
}

Definition at line 254 of file SoSubNode.h.

◆ SO__NODE_METHODS

#define SO__NODE_METHODS (   className)
Value:
\
SO__NODE_ABSTRACT_METHODS(className) \
\
void * \
className::createInstance() \
{ \
return static_cast<void *>(new className); \
}

Definition at line 223 of file SoSubNode.h.

◆ SO__NODE_VARS

#define SO__NODE_VARS (   className)     SO__NODE_ABSTRACT_VARS(className)

Definition at line 194 of file SoSubNode.h.

◆ SO_NODE_ABSTRACT_HEADER

#define SO_NODE_ABSTRACT_HEADER (   className)
Value:
public: \
typedef className InventorThisClass; \
static SoType getClassTypeId() /* Returns class type id */ \
{ return classTypeId; } \
virtual SoType getTypeId() const; /* Returns type id */ \
protected: \
virtual const SoFieldData *getFieldData() const; \
static const SoFieldData **getFieldDataPtr() \
{ return const_cast<const SoFieldData **>(&fieldData); } \
private: \
static SoType classTypeId; /* Type id */ \
static bool firstInstance; /* true until 2nd c'tor call */ \
static SoFieldData *fieldData; \
static const SoFieldData **parentFieldData

These defines type-identifier and naming variables and methods that all subclasses and abstract subclasses must support.

Definition at line 150 of file SoSubNode.h.

◆ SO_NODE_ABSTRACT_SOURCE

#define SO_NODE_ABSTRACT_SOURCE (   className)
Value:
SO__NODE_ABSTRACT_VARS(className); \
SO__NODE_ABSTRACT_METHODS(className)
#define SO__NODE_ABSTRACT_VARS(className)
Macros to be called within the source file for a node subclass:
Definition SoSubNode.h:185

Definition at line 244 of file SoSubNode.h.

◆ SO_NODE_ADD_ENUM_FIELD

#define SO_NODE_ADD_ENUM_FIELD (   field,
  type,
  defaultValue 
)
Value:
SO_NODE_SET_SF_ENUM_TYPE(field, type);\
SO_NODE_ADD_FIELD(field, (defaultValue));
#define SO_NODE_SET_SF_ENUM_TYPE(fieldName, enumType)
Definition SoSFEnum.h:167

NOTE: The enum type's values need to be registered beforehand, using SO_NODE_DEFINE_ENUM_VALUE. This is a shortcut for using SO_NODE_ADD_FIELD and SO_NODE_SET_SF_ENUM_TYPE.

Definition at line 388 of file SoSubNode.h.

◆ SO_NODE_ADD_FIELD

#define SO_NODE_ADD_FIELD (   fieldName,
  defValue 
)
Value:
{ \
SO__NODE_CHECK_CONSTRUCT(__FILE__); \
if (firstInstance) \
fieldData->addField(this, SO__QUOTE(fieldName), \
&this->fieldName); \
this->fieldName.setValue defValue; \
this->fieldName.setContainer(this); \
}

The parameters are as follows: fieldName: the name of the field (as a member) defValue: the default value enclosed in parentheses

For example,

 SO_NODE_ADD_FIELD(ambientColor, (0.2, 0.2, 0.2));
 SO_NODE_ADD_FIELD(shininess,    (0.0));

adds info about fields named ambientColor and shininess with the given default values.

Definition at line 372 of file SoSubNode.h.

◆ SO_NODE_ADD_REMOVED_FIELD

#define SO_NODE_ADD_REMOVED_FIELD (   fieldName)
Value:
{\
if (firstInstance) \
fieldData->addRemovedFieldName(SO__QUOTE(fieldName)); \
}

Definition at line 351 of file SoSubNode.h.

◆ SO_NODE_CONSTRUCTOR

#define SO_NODE_CONSTRUCTOR (   className)
Value:
{ \
SO__NODE_CHECK_INIT(className); \
if (fieldData == NULL) \
fieldData = new SoFieldData( \
parentFieldData ? *parentFieldData : NULL); \
else \
firstInstance = FALSE; \
isBuiltIn = FALSE; \
}
#define FALSE
Definition SbBasic.h:79

Definition at line 328 of file SoSubNode.h.

◆ SO_NODE_DEFINE_ENUM_VALUE

#define SO_NODE_DEFINE_ENUM_VALUE (   enumType,
  enumValue 
)
Value:
{ \
SO__NODE_CHECK_CONSTRUCT(__FILE__); \
if (firstInstance) \
fieldData->addEnumValue(SO__QUOTE(enumType), \
SO__QUOTE(enumValue), \
enumValue); \
}

enumType: the name of the enum type enumValue: the name of a value of that enum type

If a node defines an enum, each of the enum's values should be registered using this macro. For example:

 [ in MyNode.h file: ]
 class MyNode {
         ...
         enum Chipmunk { ALVIN, SIMON, THEODORE };
         ...
 }

 [ in constructor MyNode::MyNode(): ]
 SO_NODE_DEFINE_ENUM_VALUE(Chipmunk, ALVIN);
 SO_NODE_DEFINE_ENUM_VALUE(Chipmunk, SIMON);
 SO_NODE_DEFINE_ENUM_VALUE(Chipmunk, THEODORE);

Definition at line 414 of file SoSubNode.h.

◆ SO_NODE_DEFINE_ENUM_VALUE_NAMED

#define SO_NODE_DEFINE_ENUM_VALUE_NAMED (   enumType,
  enumValue,
  enumValueName 
)
Value:
{ \
SO__NODE_CHECK_CONSTRUCT(__FILE__); \
if (firstInstance) \
fieldData->addEnumValue(SO__QUOTE(enumType), \
enumValueName, \
enumValue); \
}

enumType: the name of the enum type enumValue: the value of that enum type enumValueName: the name of the enum value (as a string)

This macro is useful if you want to register enum values that are part of class scope and you want to register a shorter name for the enum value. Or you can use it to give the enum items names that are better readably for the user of the node.

 [ in MyNode.h file: ]
 class SomeOtherClass {
         enum Chipmunk { ALVIN, SIMON, THEODORE };
 };
 class MyNode {
 }

 [ in constructor MyNode::MyNode(): ]
 SO_NODE_DEFINE_ENUM_VALUE_NAMED(SomeOtherClass::Chipmunk, SomeOtherClass::ALVIN, "Alvin");
 SO_NODE_DEFINE_ENUM_VALUE_NAMED(SomeOtherClass::Chipmunk, SomeOtherClass::SIMON, "Simon");
 SO_NODE_DEFINE_ENUM_VALUE_NAMED(SomeOtherClass::Chipmunk, SomeOtherClass::THEODORE, "Theodore");

Definition at line 447 of file SoSubNode.h.

◆ SO_NODE_DEFINE_ENUM_VALUE_SCOPED

#define SO_NODE_DEFINE_ENUM_VALUE_SCOPED (   enumScope,
  enumType,
  enumValue 
)
Value:
{ \
SO__NODE_CHECK_CONSTRUCT(__FILE__); \
if (firstInstance) \
fieldData->addEnumValue(SO__QUOTE(enumScope) "::" SO__QUOTE(enumType),\
SO__QUOTE(enumValue), \
enumScope::enumValue); \
}

enumScope: the name of the enum scope (namespace/class) enumType: the type of the enum (without scope) enumValue: the value of that enum type

This macro is useful if you want to register enum values that are part of class scope and you want to register the names without the class/namespace scope.

 [ in MyNode.h file: ]
 class SomeOtherClass {
         enum Chipmunk { ALVIN, SIMON, THEODORE };
 };
 class MyNode {
 }

 [ in constructor MyNode::MyNode(): ]
 SO_NODE_DEFINE_ENUM_ITEM_SCOPED(SomeOtherClass, Chipmunk, ALVIN);
 SO_NODE_DEFINE_ENUM_ITEM_SCOPED(SomeOtherClass, Chipmunk, SIMON);
 SO_NODE_DEFINE_ENUM_ITEM_SCOPED(SomeOtherClass, Chipmunk, THEODORE);

Definition at line 479 of file SoSubNode.h.

◆ SO_NODE_HEADER

#define SO_NODE_HEADER (   className)
Value:
static void *createInstance()
#define SO_NODE_ABSTRACT_HEADER(className)
Macros to be called within the class definition header for a node subclass:
Definition SoSubNode.h:150

Definition at line 170 of file SoSubNode.h.

◆ SO_NODE_INIT_ABSTRACT_CLASS

#define SO_NODE_INIT_ABSTRACT_CLASS (   className,
  parentClass,
  parentPrintClass 
)
Value:
{ \
SoDebugError::post("SO_NODE_INIT_ABSTRACT_CLASS", \
"Overflow of SoNode::nextActionMethodIndex"); \
abort(); \
} \
classTypeId = \
SoType::createType(SoType::fromName(parentPrintClass), \
SO__QUOTE(className), \
NULL, \
static_cast<short>(SoNode::nextActionMethodIndex++)); \
parentFieldData = parentClass::getFieldDataPtr(); \
}
static SoType fromName(SbName name)
Returns the type associated with the given name.

Definition at line 307 of file SoSubNode.h.

◆ SO_NODE_INIT_CLASS

#define SO_NODE_INIT_CLASS (   className,
  parentClass,
  parentPrintClass 
)
Value:
{ \
SoDebugError::post("SO_NODE_INIT_CLASS", \
"Overflow of SoNode::nextActionMethodIndex"); \
abort(); \
} \
classTypeId = \
SoType::createType(SoType::fromName(parentPrintClass), \
SO__QUOTE(className), \
&className::createInstance, \
static_cast<short>(SoNode::nextActionMethodIndex++)); \
parentFieldData = parentClass::getFieldDataPtr(); \
}

This macro should be called from within initClass(). The parentClass argument should be the class that this subclass is derived from.

Definition at line 292 of file SoSubNode.h.

◆ SO_NODE_IS_FIRST_INSTANCE

#define SO_NODE_IS_FIRST_INSTANCE ( )     (firstInstance == TRUE)

Definition at line 344 of file SoSubNode.h.

◆ SO_NODE_SOURCE

#define SO_NODE_SOURCE (   className)
Value:
SO__NODE_VARS(className); \
SO__NODE_METHODS(className)
#define SO__NODE_VARS(className)
Non-abstract nodes have all the stuff abstract nodes do.
Definition SoSubNode.h:194

Definition at line 240 of file SoSubNode.h.