|
Infinity Engine v0.6.20
C++ API Documentation
|
Global registry for runtime type information and factory functions. More...
#include <TypeRegistry.hpp>
Static Public Member Functions | |
| static Core::Base * | create (const TypeID &type) |
| Creates a default-constructed instance of the specified type. | |
| static const TypeID & | findID (TypeHash hash) |
| Finds a TypeID by its hash value. | |
| static const TypeID & | findID (std::string_view name) |
| Finds a TypeID by its string name. | |
| static const TypeID & | emptyID () |
| Gets the sentinel TypeID representing an empty/invalid type. | |
Global registry for runtime type information and factory functions.
TypeRegistry provides centralized access to type metadata and default construction capabilities for all registered types in the Infinity type system. It maintains a mapping between TypeIDs, type hashes, and type names, enabling runtime type lookup and instantiation.
The registry supports:
All methods are static as the registry is a singleton that is initialized automatically by the type system. Types are registered when their INFINITY_TYPE_IMPL macro is first invoked.
Example usage:
|
static |
Creates a default-constructed instance of the specified type.
Instantiates a new object of the type identified by the given TypeID using the type's registered factory function. The returned pointer is owned by the caller and must be properly managed (typically via smart pointers).
| type | The TypeID of the type to instantiate. |
|
static |
Gets the sentinel TypeID representing an empty/invalid type.
Returns a special TypeID that represents the absence of a valid type. This is useful as a null value for optional type references or to indicate uninitialized type fields.
|
static |
Finds a TypeID by its string name.
Performs a lookup to find the TypeID associated with a given type name. This enables dynamic type resolution from string identifiers, useful for scripting interfaces, configuration files, or user input.
| name | The fully-qualified type name to search for (e.g., "Infinity::Types::Mesh"). |
Finds a TypeID by its hash value.
Performs a reverse lookup to find the complete TypeID associated with a given hash value. This is primarily used during deserialization when only the hash is available (e.g., from binary data or network protocols).
| hash | The 64-bit hash value to search for. |