Open Inventor Release 2024.2.1
 
Loading...
Searching...
No Matches
SoType Class Reference

Stores runtime type information. More...

#include <Inventor/SoType.h>

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 (const SoType &t) const
 Returns TRUE if the type is derived from type t.
 
template<typename TypedObjectClass >
SbBool isDerivedFrom () const
 Returns TRUE if the type is derived from the type of class TypedObjectClass.
 
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 (SoType *overrideType=NULL) const
 Creates and returns a pointer to an instance of the type.
 
bool operator== (const SoType t) const
 Returns TRUE if this type is the same as the given type.
 
bool operator!= (const SoType t) const
 Returns TRUE if this type is not the same as the given type.
 
bool operator< (const SoType t) const
 Less-than comparison operator that can be used to sort types.
 

Static Public Member Functions

static SoType fromName (const SbName &name)
 Returns the type associated with the given name.
 
static SoType badType ()
 Returns an always-illegal type.
 
static int getAllDerivedFrom (const SoType &type, SoTypeList &list)
 Adds all types derived from the given type to the given type list.
 

Friends

std::ostream & operator<< (std::ostream &os, const SoType &t)
 Writes the SoType to the specified output stream.
 

Detailed Description

Stores runtime type information.

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

Many Open 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 Open Inventor classes do not contain the "So" prefix.

SEE ALSO

SoAction, SoBase, SoDetail, SoError, SoEvent, SoField

Definition at line 98 of file SoType.h.

Member Function Documentation

◆ badType()

static SoType SoType::badType ( )
inlinestatic

Returns an always-illegal type.

Useful for returning errors.

Definition at line 124 of file SoType.h.

◆ canCreateInstance()

SbBool SoType::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.

This method returns TRUE if the type supports such creation.

◆ createInstance()

void * SoType::createInstance ( SoType overrideType = NULL) const

Creates and returns a pointer to an instance of the type.

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:123
static SoType getClassTypeId()
Returns the type identifier for this class.
void * createInstance(SoType *overrideType=NULL) const
Creates and returns a pointer to an instance of the type.

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

◆ fromName()

static SoType SoType::fromName ( const SbName name)
static

Returns the type associated with the given name.

◆ getAllDerivedFrom()

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

Adds all types derived from the given type to the given type list.

Returns the number of types added.

◆ getName()

SbName SoType::getName ( ) const

Returns the name associated with a type.

◆ getParent()

SoType SoType::getParent ( ) const

Returns the type of the parent class.

◆ isBad()

SbBool SoType::isBad ( ) const

Returns TRUE if the type is a bad type.

◆ isDerivedFrom() [1/2]

template<typename TypedObjectClass >
SbBool SoType::isDerivedFrom ( ) const
inline

Returns TRUE if the type is derived from the type of class TypedObjectClass.

Note: TypedObjectClass must be derived from SoTypedObject

Definition at line 145 of file SoType.h.

◆ isDerivedFrom() [2/2]

SbBool SoType::isDerivedFrom ( const SoType t) const

Returns TRUE if the type is derived from type t.

◆ operator!=()

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

Returns TRUE if this type is not the same as the given type.

◆ operator<()

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

Less-than comparison operator that can be used to sort types.

This is pretty useless otherwise.

◆ operator==()

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

Returns TRUE if this type is the same as the given type.

Friends And Related Symbol Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream &  os,
const SoType t 
)
friend

Writes the SoType to the specified output stream.

Definition at line 199 of file SoType.h.

Member Data Documentation

◆ data

unsigned int SoType::data

Definition at line 283 of file SoType.h.

◆ index

unsigned int SoType::index

Definition at line 284 of file SoType.h.

◆ intValue

unsigned int SoType::intValue

Definition at line 287 of file SoType.h.

◆ isPublic

unsigned int SoType::isPublic

Definition at line 285 of file SoType.h.

◆ [struct]

struct { ... } SoType::storageStruct

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