Open Inventor Reference
SoType Class Reference

SoType has no virtual functions to keep it small... More...

#include <Inventor/SoType.h>

Public Member Functions

SbName getName () const
 Returns the name associated with a type. More...
 
SoType getParent () const
 Returns the type of the parent class. More...
 
bool isBad () const
 Returns TRUE if the type is a bad type. More...
 
bool isDerivedFrom (SoType t) const
 Returns TRUE if the type is derived from type t. More...
 
bool canCreateInstance () const
 Some types are able to create instances; for example, most nodes and engines (those which are not abstract classes) can be created this way. More...
 
void * createInstance () const
 Creates and returns a pointer to an instance of the type. More...
 
bool operator== (const SoType t) const
 Returns TRUE if this type is the same as or not the same as the given type. More...
 
bool operator!= (const SoType t) const
 Returns TRUE if this type is the same as or not the same as the given type. More...
 
bool operator< (const SoType t) const
 Less-than comparison operator that can be used to sort types. More...
 
short getData () const
 Get data. More...
 
short getKey () const
 Returns the type key as a short. More...
 
void makeInternal ()
 Mark this type as internal; if internal, getAllDerivedFrom and fromName will not return the type. More...
 

Static Public Member Functions

static SoType fromName (SbName name)
 Returns the type associated with the given name. More...
 
static SoType badType ()
 Returns an always-illegal type. Useful for returning errors. More...
 
static int getAllDerivedFrom (SoType type, SoTypeList &list)
 Adds all types derived from the given type to the given type list. More...
 
static SoType createType (SoType parent, SbName name, void *(*createMethod)()=NULL, short data=0)
 Create a new type. More...
 
static SoType overrideType (SoType existingType, void *(*createMethod)()=NULL)
 Make an new type act like an existing type. More...
 
static void init ()
 Initialize the type system. More...
 
static int getNumTypes ()
 Get the number of types currently registed in the types dictionary. More...
 

Detailed Description

Stores runtime type information.

The SoType class keeps track of runtime type information in Inventor. Each type is associated with a given name, so lookup is possible in either direction.

Many Inventor classes request a unique SoType when they are initialized. This type can then be used to find out the actual class of an instance when only its base class is known, or to obtain an instance of a particular class given its type or name.

Note that the names associated with types of Inventor classes do not contain the "So" prefix.

See Also
SoAction, SoBase, SoDetail, SoError, SoEvent, SoField

Definition at line 103 of file SoType.h.

Member Function Documentation

◆ badType()

static SoType SoType::badType ( )
static

◆ canCreateInstance()

bool SoType::canCreateInstance ( ) const

This method returns TRUE if the type supports such creation.

◆ createInstance()

void* SoType::createInstance ( ) const

Returns NULL if an instance could not be created for some reason. The pointer is returned as a generic pointer, but can be cast to the appropriate type. For example:

Cube shape node.
Definition: SoCube.h:119
static SoType getClassTypeId()
Returns type identifier for the SoNode class.
Definition: SoNode.h:114
void * createInstance() const
Creates and returns a pointer to an instance of the type.

is a convoluted way of creating a new instance of an SoCube.

◆ createType()

static SoType SoType::createType ( SoType  parent,
SbName  name,
void *(*)()  createMethod = NULL,
short  data = 0 
)
static

◆ fromName()

static SoType SoType::fromName ( SbName  name)
static

◆ getAllDerivedFrom()

static int SoType::getAllDerivedFrom ( SoType  type,
SoTypeList list 
)
static

Returns the number of types added.

◆ getData()

short SoType::getData ( ) const
inline

Definition at line 177 of file SoType.h.

Referenced by SoNode::getActionMethodIndex().

◆ getKey()

short SoType::getKey ( ) const
inline

Definition at line 180 of file SoType.h.

◆ getName()

SbName SoType::getName ( ) const

◆ getNumTypes()

static int SoType::getNumTypes ( )
inlinestatic

This is used by SoAction when setting up the action method list.

Definition at line 188 of file SoType.h.

◆ getParent()

SoType SoType::getParent ( ) const

◆ init()

static void SoType::init ( )
static

◆ isBad()

bool SoType::isBad ( ) const
inline

Definition at line 119 of file SoType.h.

◆ isDerivedFrom()

bool SoType::isDerivedFrom ( SoType  t) const

◆ makeInternal()

void SoType::makeInternal ( )

◆ operator!=()

bool SoType::operator!= ( const SoType  t) const
inline

Definition at line 149 of file SoType.h.

References index.

◆ operator<()

bool SoType::operator< ( const SoType  t) const
inline

This is pretty useless otherwise.

Definition at line 154 of file SoType.h.

References index.

◆ operator==()

bool SoType::operator== ( const SoType  t) const
inline

Definition at line 146 of file SoType.h.

References index.

◆ overrideType()

static SoType SoType::overrideType ( SoType  existingType,
void *(*)()  createMethod = NULL 
)
static

The new type MUST be a C++ subclass of the original (e.g. MyCubeClass must be derived from SoCube), but there is no way for us to check that. This can be used to get the database to create a different subclass whenever it reads in a SoNode class from a file.

Member Data Documentation

◆ data

unsigned int SoType::data

Definition at line 194 of file SoType.h.

◆ index

unsigned int SoType::index

Definition at line 195 of file SoType.h.

Referenced by operator!=(), operator<(), and operator==().

◆ isPublic

unsigned int SoType::isPublic

Definition at line 197 of file SoType.h.


The documentation for this class was generated from the following file: