Cafu Engine
cf::TypeSys::TypeInfoManT Class Reference

This class manages the type infos. More...

#include "TypeSys.hpp"

Public Member Functions

 TypeInfoManT ()
 The constructor. More...
 
void Register (TypeInfoT *TI)
 Registers the given TypeInfoT with this type info manager. More...
 
void Init ()
 Completes the initialization of the TypeInfoManT and the registered type infos. More...
 
const TypeInfoTFindTypeInfoByName (const char *ClassName) const
 Returns the type info matching the class name ClassName. More...
 
const TypeInfoTFindTypeInfoByNr (unsigned long TypeNr) const
 Returns the type info matching the type number TypeNr. More...
 
const ArrayT< const TypeInfoT * > & GetTypeInfosByName () const
 Returns all type infos registered with this TypeInfoManT, ordered by name. More...
 
const ArrayT< const TypeInfoT * > & GetTypeInfosByNr () const
 Returns all type infos registered with this TypeInfoManT, ordered by type number. More...
 
const ArrayT< const TypeInfoT * > & GetTypeInfoRoots () const
 Returns the roots of the inheritance trees. (Normally there should only be one root.) More...
 

Detailed Description

This class manages the type infos.

Intended usage: Each entity class that occurs in the game keeps a static TypeInfoT member (plus a non-static, virtual GetTypeInfo() method that returns that member). The constructor of each such TypeInfoT member registers its own this-pointer with an instance of this class, so that when main() begins, the TypeInfoManT is aware of all TypeInfoTs and thus all entity classes. Its Init() method then completes the type initialization.

Constructor & Destructor Documentation

TypeInfoManT::TypeInfoManT ( )

The constructor.

Member Function Documentation

const TypeInfoT * TypeInfoManT::FindTypeInfoByName ( const char *  ClassName) const

Returns the type info matching the class name ClassName.

Returns
the (pointer to the) TypeInfoT matching ClassName, or NULL if not found.
const TypeInfoT * TypeInfoManT::FindTypeInfoByNr ( unsigned long  TypeNr) const

Returns the type info matching the type number TypeNr.

Returns
the (pointer to the) TypeInfoT T, so that T->TypeNr==TypeNr.
const ArrayT<const TypeInfoT*>& cf::TypeSys::TypeInfoManT::GetTypeInfoRoots ( ) const
inline

Returns the roots of the inheritance trees. (Normally there should only be one root.)

const ArrayT<const TypeInfoT*>& cf::TypeSys::TypeInfoManT::GetTypeInfosByName ( ) const
inline

Returns all type infos registered with this TypeInfoManT, ordered by name.

const ArrayT<const TypeInfoT*>& cf::TypeSys::TypeInfoManT::GetTypeInfosByNr ( ) const
inline

Returns all type infos registered with this TypeInfoManT, ordered by type number.

GetTypeInfosByNr()[i]->TypeNr == i

void TypeInfoManT::Init ( )

Completes the initialization of the TypeInfoManT and the registered type infos.

Should be called exactly once before any other TypeInfoManT method is called.

void TypeInfoManT::Register ( TypeInfoT TI)

Registers the given TypeInfoT with this type info manager.

Only the TypeInfoT constructor code should call this, which in turn should only occur during global static initialization time, never after Init() has been called.


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