|
qxLib
|
Polymorphic base for qx class identity and inheritance queries. More...
#include <rtti.h>
Public Member Functions | |
| template<class T > | |
| bool | is_derived_from () const noexcept |
| Test exact identity or membership in the object's RTTI base chain. More... | |
| template<class T > | |
| bool | is () const noexcept |
| Compare the object's dynamic class identifier with T's identifier. More... | |
| bool | is (string_view svClassName) const noexcept |
| Compare against the class name selected by the naming strategy. More... | |
| bool | is (const class_id &id) const noexcept |
| Compare against the object's dynamic class identifier. More... | |
| virtual bool | is_derived_from_id (const class_id &id) const noexcept |
| Test an identifier against the object's dynamic RTTI hierarchy. More... | |
| virtual string_view | get_class_name () const noexcept |
| Get the name of the object's most-derived registered RTTI type. More... | |
| virtual class_id | get_class_id () const noexcept |
| Get the identifier of the object's most-derived registered RTTI type. More... | |
| virtual std::span< const class_id > | get_inheritance_sequence () const =0 |
| Get the registered inheritance chain in base-to-derived order. More... | |
Static Public Member Functions | |
| static constexpr bool | is_derived_from_id_static (const class_id &id) noexcept |
| Test an identifier against the declaring type's static RTTI hierarchy. More... | |
| static constexpr string_view | get_class_name_static () noexcept |
| Apply the naming strategy to the declaring RTTI type's signature. More... | |
| static constexpr class_id | get_class_id_static () noexcept |
| Create the declaring RTTI type's identifier from its type signature. More... | |
Protected Member Functions | |
| virtual bool | _is_base_id (const class_id &idBase) const noexcept |
| Traverse identifiers treated as bases by derived RTTI classes. More... | |
Polymorphic base for qx class identity and inheritance queries.
Derive an RTTI hierarchy from this type and use QX_RTTI_CLASS in each derived class to supply its identity and extend the inheritance chain. This system does not require compiler RTTI.
Static queries describe the type declaring them; virtual queries describe the object's most-derived registered type. is<T>() checks exact identity, while is_derived_from<T>() also accepts base types.
The naming strategy affects class names, not class identifiers. Names may be empty or shared by several types. The protected destructor prevents deleting an object directly through an rtti_root pointer.
| naming_strategy_t | - strategy providing get_name(string_view) to transform the compiler-generated type signature into a class name |
|
inlineprotectedvirtualnoexcept |
Traverse identifiers treated as bases by derived RTTI classes.
| idBase | - candidate identifier from an inheritance query |
| - | true when an identifier matches during base-chain traversal |
The root compares against its own identifier. Macro-generated overrides check their immediate base and continue recursively.
|
inlinevirtualnoexcept |
|
staticconstexprnoexcept |
Create the declaring RTTI type's identifier from its type signature.
| - | identifier independent of the selected class-name representation |
|
inlinevirtualnoexcept |
|
staticconstexprnoexcept |
|
pure virtual |
Get the registered inheritance chain in base-to-derived order.
| - | identifiers from the rtti_root specialization through the dynamic type |
QX_RTTI_CLASS returns a span backed by class-specific static storage, rather than storage owned by the object.
|
inlinenoexcept |
Compare the object's dynamic class identifier with T's identifier.
| T | - candidate type exposing QX_RTTI_CLASS() |
| - | true only when the identifiers match; base types are not accepted |
|
inlinenoexcept |
Compare against the object's dynamic class identifier.
| id | - candidate for exact identity, not an inheritance query |
| - | true when id equals get_class_id() |
|
inlinenoexcept |
Compare against the class name selected by the naming strategy.
| svClassName | - expected result of get_class_name(), not a base-class name |
| - | true when the names match exactly |
|
inlinenoexcept |
Test exact identity or membership in the object's RTTI base chain.
| T | - candidate type exposing QX_RTTI_CLASS() |
| - | true for the object's registered type and its registered bases |
|
inlinevirtualnoexcept |
|
staticconstexprnoexcept |
Test an identifier against the declaring type's static RTTI hierarchy.
rtti_root matches only its own identifier; QX_RTTI_CLASS extends this comparison recursively through the declared base class.
| id | - candidate class identifier to find in the static base chain |
| - | true when id belongs to the declaring type or one of its bases |