Cortex  10.0.0-a4
Public Types | Public Member Functions | Protected Types | Static Protected Member Functions | Static Protected Attributes | List of all members
IECore::RunTimeTyped Class Reference

#include <RunTimeTyped.h>

+ Inheritance diagram for IECore::RunTimeTyped:

Public Types

typedef RefCounted BaseClass
 A typedef for the class this class derives from. All RunTimeTyped classes define this typedef.
 
- Public Types inherited from IECore::RefCounted
typedef size_t RefCount
 

Public Member Functions

 IE_CORE_DECLAREMEMBERPTR (RunTimeTyped)
 
- Public Member Functions inherited from IECore::RefCounted
 IE_CORE_DECLAREMEMBERPTR (RefCounted)
 
void addRef () const
 Add a reference to the current object.
 
void removeRef () const
 Remove a reference from the current object.
 
RefCount refCount () const
 Returns the current reference count.
 

Protected Types

typedef std::map< TypeId, TypeIdBaseTypeRegistryMap
 
typedef std::map< TypeId, std::vector< TypeId > > BaseTypesRegistryMap
 
typedef std::map< TypeId, std::set< TypeId > > DerivedTypesRegistryMap
 
typedef tbb::spin_rw_mutex Mutex
 
typedef std::map< TypeId, std::string > TypeIdsToTypeNamesMap
 
typedef std::map< std::string, TypeIdTypeNamesToTypeIdsMap
 

Static Protected Member Functions

static BaseTypeRegistryMap & baseTypeRegistry ()
 
static DerivedTypesRegistryMap & derivedTypesRegistry ()
 
static BaseTypesRegistryMap & completeBaseTypesRegistry ()
 
static DerivedTypesRegistryMap & completeDerivedTypesRegistry ()
 
static void derivedTypeIdsWalk (TypeId typeId, std::set< TypeId > &)
 
static TypeIdsToTypeNamesMap & typeIdsToTypeNames ()
 
static TypeNamesToTypeIdsMap & typeNamesToTypeIds ()
 

Static Protected Attributes

static Mutex g_baseTypeIdsMutex
 
static Mutex g_derivedTypeIdsMutex
 

Type identification functions.

These functions provide useful queries about the typing of both classes and instances. They must be reimplemented appropriately in all derived classes. This is achieved through the use of the IE_CORE_DECLARERUNTIMETYPED macro.

virtual TypeId typeId () const
 
virtual const char * typeName () const
 
virtual bool isInstanceOf (TypeId typeId) const
 
virtual bool isInstanceOf (const char *typeName) const
 
static TypeId staticTypeId ()
 Returns the TypeId for this class, without needing an instance.
 
static const char * staticTypeName ()
 Returns the type name for this class, without needing an instance.
 
static TypeId baseTypeId ()
 
static const char * baseTypeName ()
 
static bool inheritsFrom (TypeId typeId)
 Returns true if this class inherits from the specified type.
 
static bool inheritsFrom (const char *typeName)
 Returns true if this class inherits from the specified type.
 
static bool inheritsFrom (TypeId type, TypeId baseType)
 Returns true if type inherits from baseType.
 
static bool inheritsFrom (const char *typeName, const char *baseTypeName)
 Returns true if typeName inherits from baseTypeName.
 
static TypeId baseTypeId (TypeId typeId)
 Returns the base type of the given type, or InvalidTypeId if no such base exists.
 
static const std::vector< TypeId > & baseTypeIds (TypeId typeId)
 
static const std::set< TypeId > & derivedTypeIds (TypeId typeId)
 
static TypeId typeIdFromTypeName (const char *typeName)
 
static const char * typeNameFromTypeId (TypeId typeId)
 
static void registerType (TypeId derivedTypeId, const char *derivedTypeName, TypeId baseTypeId)
 Allows external modules to register their own type ids.
 

Detailed Description

An abstract base class for objects whose type we wish to determine at runtime. The rationale for using such a type system rather than the std c++ typeid() stuff is as follows :

1) The GCC implentation of the C++ system breaks down with
templated types across module boundaries.

2) We wish to use the type system to identify the type of serialised objects in files (see the serialisation interface defined in Object), but the C++ type_info object provides us with no information we can usefully use for that.

Member Function Documentation

static TypeId IECore::RunTimeTyped::baseTypeId ( )
static

Returns the TypeId of the base of this class, without needing an instance. The base type of RunTimeTyped itself is defined to be InvalidTypeId;

Referenced by IECoreMaya.ParameterUI::create(), IECore.ParameterParser::parse(), and IECore.ParameterParser::serialise().

static const std::vector<TypeId>& IECore::RunTimeTyped::baseTypeIds ( TypeId  typeId)
static

Returns all bases of the given type, or an empty vector if no such bases exist. The elements are ordered by "distance" from the given TypeId. That is to say, the first element will be the immediate base class, and the last elemenet will be RunTimeTyped. Should not be called during static initialization as it's likely that not all types will have been registered at that point, so to do so would yield an incomplete list.

static const char* IECore::RunTimeTyped::baseTypeName ( )
static

Returns the type name of the base of this class, without needing an instance. The base type name of RunTimeTyped itself is defined to be "InvalidType";

static const std::set<TypeId>& IECore::RunTimeTyped::derivedTypeIds ( TypeId  typeId)
static

Returns all derived types of the given type, or an empty set if no such derived types exist. Should not be called during static initialization as it's likely that not all types will have been registered at that point, so to do so would yield an incomplete list.

virtual bool IECore::RunTimeTyped::isInstanceOf ( TypeId  typeId) const
virtual

Returns true if this object is an instance of the specified type, or of a class inherited from the specified type.

virtual bool IECore::RunTimeTyped::isInstanceOf ( const char *  typeName) const
virtual

Returns true if this object is an instance of the specified type, or of a class inherited from the specified type.

virtual TypeId IECore::RunTimeTyped::typeId ( ) const
virtual

Returns a unique numeric identifier for the type of this instance. For classes defined in the core library this should be a member of the TypeId enum defined in IECore/TypeIds.h

static TypeId IECore::RunTimeTyped::typeIdFromTypeName ( const char *  typeName)
static

Returns the corresponding TypeId for the specified typeName, or InvalidTypeId if typeName is not a registered type.

virtual const char* IECore::RunTimeTyped::typeName ( ) const
virtual

Returns a unique name for the type of this instance. This should be implemented to return the class name.

Referenced by IECoreMaya.FnParameterisedHolder::ls().

static const char* IECore::RunTimeTyped::typeNameFromTypeId ( TypeId  typeId)
static

Returns the corresponding typeName for the specified TypeId, or InvalidTypeId if typeId is not a registered type.

Referenced by IECore::registerRunTimeTyped().


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