A registry of all known RTTI types.
This class acts as a central repository for all known RTTI types. Its main use is to allow for runtime instantiation of types by name. In addition to this, the registry provides reflection features to view the list of available types and their relationship to each other.
Only a single instance of this object can exist. That instance is accessed through the GetInstance() function.
#include <utility/YiRtti.h>
Public Member Functions | |
| void | RegisterType (const CYIRuntimeTypeInfo &typeInfo, const CYIString &name) |
| const CYIRuntimeTypeInfo & | RegisterTypeHelper (const CYIRuntimeTypeInfo &typeInfo) |
| void | UnregisterType (const CYIString &name) |
| const CYIRuntimeTypeInfo * | GetTypeForName (const CYIString &typeName) const |
| std::map< CYIString, const CYIRuntimeTypeInfo * > | GetRegisteredTypes () const |
| std::vector< const CYIRuntimeTypeInfo * > | GetSuperclassesTypeInfos (const CYIRuntimeTypeInfo &type, bool bDirectSuperclassesOnly=false) const |
| std::vector< const CYIRuntimeTypeInfo * > | GetSubclassesTypeInfos (const CYIRuntimeTypeInfo &type, bool bDirectSubclassesOnly=false) const |
| std::vector< const CYIRuntimeTypeInfo * > | GetRootTypeInfos () const |
| CYIString | GenerateInheritanceTreeString (const CYIRuntimeTypeInfo &type, bool bUseASCII=false, const CYIString &textColor="", const CYIString &graphColor="", const CYIString ¬iceColor="") const |
Static Public Member Functions | |
| static CYIRTTIRegistry & | GetInstance () |
| CYIString CYIRTTIRegistry::GenerateInheritanceTreeString | ( | const CYIRuntimeTypeInfo & | type, |
| bool | bUseASCII = false, |
||
| const CYIString & | textColor = "", |
||
| const CYIString & | graphColor = "", |
||
| const CYIString & | noticeColor = "" |
||
| ) | const |
Generates and returns a graph representation of the subclasses of type. If bUseASCII is true, the returned graph is generated using ASCII characters instead of Unicode characters. Colorization strings can be provided in textColor, graphColor and noticeColor to colorize the output.
Sample generated graph:
|
static |
Returns the system's instance of this class. Only a single instance can exist on the system, and it is deleted automatically at exit.
| std::map<CYIString, const CYIRuntimeTypeInfo*> CYIRTTIRegistry::GetRegisteredTypes | ( | ) | const |
Returns a map of all registered RTTI types. The key of the map is the identification string, and the value is the assocaited CYIRuntimeTypeInfo object. Note that the same CYIRuntimeTypeInfo object may be present multiple times in the returned map.
| std::vector<const CYIRuntimeTypeInfo *> CYIRTTIRegistry::GetRootTypeInfos | ( | ) | const |
Returns a vector containing CYIRuntimeTypeInfo objects for all root types. Root types are types which do not have any RTTI superclasses.
| std::vector<const CYIRuntimeTypeInfo *> CYIRTTIRegistry::GetSubclassesTypeInfos | ( | const CYIRuntimeTypeInfo & | type, |
| bool | bDirectSubclassesOnly = false |
||
| ) | const |
Returns a vector containing CYIRuntimeTypeInfo objects for all subclasses of the type identified by type. If bDirectSubclassesOnly is true, only direct subclasses of type are returned. By default, all subclasses of type are returned.
| std::vector<const CYIRuntimeTypeInfo *> CYIRTTIRegistry::GetSuperclassesTypeInfos | ( | const CYIRuntimeTypeInfo & | type, |
| bool | bDirectSuperclassesOnly = false |
||
| ) | const |
Returns a vector containing CYIRuntimeTypeInfo objects for all superclasses of the type identified by type. If bDirectSuperclassesOnly is true, only direct superclasses of type are returned. By default, all superclasses of type are returned.
|
inline |
Finds and returns the CYIRuntimeTypeInfo object identified by typeName. If no such type exists, nullptr is returned.
| void CYIRTTIRegistry::RegisterType | ( | const CYIRuntimeTypeInfo & | typeInfo, |
| const CYIString & | name | ||
| ) |
Registers type typeInfo and associates it with the name name.
| const CYIRuntimeTypeInfo& CYIRTTIRegistry::RegisterTypeHelper | ( | const CYIRuntimeTypeInfo & | typeInfo | ) |
An utility function used by the RTTI implementation to automatically register RTTI types at application startup.
| void CYIRTTIRegistry::UnregisterType | ( | const CYIString & | name | ) |
Removes the type identified by name from the registry. Whether the type exists in the registry or not, a warning is logged.