|
Infinity Engine v0.6.20
C++ API Documentation
|
Runtime type identifier for the Infinity type system. More...
#include <TypeID.hpp>
Public Member Functions | |
| TypeID () | |
| Default constructor. | |
| TypeID (TypeHash hash) | |
| Constructs a TypeID from a hash value. | |
| constexpr | TypeID (TypeTag tag, TypeHash hash, const char *name) |
| Constructs a complete TypeID with all components. | |
| bool | canConvert (const TypeID &other) const |
| Checks if this type can be converted to another type. | |
| operator TypeHash () const | |
| Implicit conversion to TypeHash. | |
| void | write (std::ostream &os) const |
| Serializes the TypeID to an output stream. | |
| void | read (std::istream &is) |
| Deserializes a TypeID from an input stream. | |
| std::string | str () const |
| Gets the human-readable type name string. | |
| std::string | hashStr () const |
| Gets the hash value as a hexadecimal string. | |
| constexpr bool | operator== (const TypeID &other) const |
| Equality comparison operator. | |
| constexpr bool | operator!= (const TypeID &other) const |
| Inequality comparison operator. | |
Static Public Member Functions | |
| static TypeHash | create_stable_hash (const char *name, size_t len) |
| Computes a stable hash from a type name string. | |
Public Attributes | |
| TypeTag | tag |
| Unique compile-time identifier. | |
| TypeHash | hash |
| Stable hash of the type name for serialization. | |
| const char * | name |
| Human-readable type name string. | |
Runtime type identifier for the Infinity type system.
TypeID provides a lightweight, efficient runtime type identification system that combines compile-time uniqueness (via TypeTag) with runtime stability (via TypeHash). It enables type-safe polymorphism, serialization, and type conversion checking throughout the Infinity Engine.
Each type in the system has a unique TypeID that includes:
TypeIDs are typically obtained using the getTypeID<T>() template function and should be registered using the INFINITY_TYPE_IMPL macro.
Example usage:
| Infinity::Types::TypeID::TypeID | ( | ) |
Default constructor.
Creates an invalid/empty TypeID with null tag and zero hash.
| Infinity::Types::TypeID::TypeID | ( | TypeHash | hash | ) |
|
inlineconstexpr |
Constructs a complete TypeID with all components.
This is the primary constructor used by INFINITY_TYPE_IMPL macro to create fully-initialized TypeIDs at compile time.
| tag | Unique compile-time identifier (typically address of static name). |
| hash | Stable hash computed from the type name. |
| name | Null-terminated string containing the type name. |
| bool Infinity::Types::TypeID::canConvert | ( | const TypeID & | other | ) | const |
Checks if this type can be converted to another type.
Determines whether a value of this type can be safely converted to the target type. This enables runtime type checking for polymorphic operations and type-safe casting.
| other | The target TypeID to check conversion compatibility against. |
|
static |
Computes a stable hash from a type name string.
Creates a 64-bit hash that is consistent across compilations and program executions. This hash is used for serialization and for identifying types in persistent storage or network protocols.
| name | Null-terminated string containing the type name. |
| len | Length of the name string (excluding null terminator). |
| std::string Infinity::Types::TypeID::hashStr | ( | ) | const |
Gets the hash value as a hexadecimal string.
Returns the TypeHash formatted as a hexadecimal string, useful for debugging hash collisions or logging type identifiers.
|
inline |
Implicit conversion to TypeHash.
Allows TypeID to be used directly as a hash value in contexts requiring numeric type identifiers.
|
inlineconstexpr |
Inequality comparison operator.
| other | The TypeID to compare against. |
|
inlineconstexpr |
Equality comparison operator.
Compares two TypeIDs for equality based on their compile-time tags. This is a fast pointer comparison operation.
| other | The TypeID to compare against. |
| void Infinity::Types::TypeID::read | ( | std::istream & | is | ) |
| std::string Infinity::Types::TypeID::str | ( | ) | const |
Gets the human-readable type name string.
Returns the full qualified name of the type as a string, useful for debugging and logging.
| void Infinity::Types::TypeID::write | ( | std::ostream & | os | ) | const |
| TypeHash Infinity::Types::TypeID::hash |
Stable hash of the type name for serialization.
| const char* Infinity::Types::TypeID::name |
Human-readable type name string.
| TypeTag Infinity::Types::TypeID::tag |
Unique compile-time identifier.