Open Inventor Reference
SoType Class Reference

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

#include <Inventor/SoType.h>

List of all members.

Public Member Functions

SbName getName () const
 Returns the name associated with a type.
SoType getParent () const
 Returns the type of the parent class.
SbBool isBad () const
 Returns TRUE if the type is a bad type.
SbBool isDerivedFrom (SoType t) const
 Returns TRUE if the type is derived from type t.
SbBool 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.
void * createInstance () const
 Creates and returns a pointer to an instance of the type.
int operator== (const SoType t) const
 Returns TRUE if this type is the same as or not the same as the given type.
int operator!= (const SoType t) const
 Returns TRUE if this type is the same as or not the same as the given type.
int operator< (const SoType t) const
 Less-than comparison operator that can be used to sort types.
short getData () const
 Get data.
short getKey () const
 Returns the type key as a short.
void makeInternal ()
 Mark this type as internal; if internal, getAllDerivedFrom and fromName will not return the type.

Static Public Member Functions

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

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

static SoType SoType::badType ( ) [static]
SbBool SoType::canCreateInstance ( ) const

This method returns TRUE if the type supports such creation.

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:

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

static SoType SoType::createType ( SoType  parent,
SbName  name,
void *(*)()  createMethod = NULL,
short  data = 0 
) [static]
static SoType SoType::fromName ( SbName  name) [static]
static int SoType::getAllDerivedFrom ( SoType  type,
SoTypeList list 
) [static]

Returns the number of types added.

short SoType::getData ( ) const [inline]

Definition at line 180 of file SoType.h.

Referenced by SoNode::getActionMethodIndex().

short SoType::getKey ( ) const [inline]

Definition at line 183 of file SoType.h.

SbName SoType::getName ( ) const
static int SoType::getNumTypes ( ) [inline, static]

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

Definition at line 191 of file SoType.h.

SoType SoType::getParent ( ) const
static void SoType::init ( ) [static]
SbBool SoType::isBad ( ) const [inline]

Definition at line 122 of file SoType.h.

SbBool SoType::isDerivedFrom ( SoType  t) const
void SoType::makeInternal ( )
int SoType::operator!= ( const SoType  t) const [inline]

Definition at line 152 of file SoType.h.

References index.

int SoType::operator< ( const SoType  t) const [inline]

This is pretty useless otherwise.

Definition at line 157 of file SoType.h.

References index.

int SoType::operator== ( const SoType  t) const [inline]

Definition at line 149 of file SoType.h.

References index.

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

unsigned int SoType::data

Definition at line 197 of file SoType.h.

unsigned int SoType::index

Definition at line 198 of file SoType.h.

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

unsigned int SoType::isPublic

Definition at line 200 of file SoType.h.


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