qxLib
rtti.inl
Go to the documentation of this file.
1 /**
2 
3  @file rtti.inl
4  @author Khrapov
5  @date 14.10.2026
6  @copyright (c) Nick Khrapov, 2026. All right reserved.
7 
8 **/
9 
10 namespace qx
11 {
12 
13 template<class naming_strategy_t>
14 template<class T>
16 {
17  constexpr class_id typeId = T::get_class_id_static();
18  return _is_base_id(typeId) || typeId == get_class_id();
19 }
20 
21 template<class naming_strategy_t>
22 template<class T>
23 inline bool rtti_root<naming_strategy_t>::is() const noexcept
24 {
25  return get_class_id() == T::get_class_id_static();
26 }
27 
28 template<class naming_strategy_t>
29 inline bool rtti_root<naming_strategy_t>::is(string_view svClassName) const noexcept
30 {
31  return svClassName == get_class_name();
32 }
33 
34 template<class naming_strategy_t>
35 inline bool rtti_root<naming_strategy_t>::is(const class_id& id) const noexcept
36 {
37  return id == get_class_id();
38 }
39 
40 template<class naming_strategy_t>
41 inline bool rtti_root<naming_strategy_t>::is_derived_from_id(const class_id& id) const noexcept
42 {
43  return is_derived_from_id_static(id);
44 }
45 
46 template<class naming_strategy_t>
48 {
49  return id == get_class_id_static();
50 }
51 
52 template<class naming_strategy_t>
54 {
55  return naming_strategy_type::get_name(type_strings<this_class_type>::get_signature());
56 }
57 
58 template<class naming_strategy_t>
59 inline string_view rtti_root<naming_strategy_t>::get_class_name() const noexcept
60 {
61  return get_class_name_static();
62 }
63 
64 template<class naming_strategy_t>
66 {
67  constexpr class_id id = class_id::create<this_class_type>();
68  return id;
69 }
70 
71 template<class naming_strategy_t>
73 {
74  return get_class_id_static();
75 }
76 
77 template<class naming_strategy_t>
78 inline bool rtti_root<naming_strategy_t>::_is_base_id(const class_id& idBase) const noexcept
79 {
80  return idBase == get_class_id_static();
81 }
82 
83 } // namespace qx
Class id, unique for each class using qx rtti system.
Definition: class_id.h:27
bool is_derived_from() const noexcept
Test exact identity or membership in the object's RTTI base chain.
Definition: rtti.inl:15
bool is() const noexcept
Compare the object's dynamic class identifier with T's identifier.
Definition: rtti.inl:23
virtual bool is_derived_from_id(const class_id &id) const noexcept
Test an identifier against the object's dynamic RTTI hierarchy.
Definition: rtti.inl:41
virtual class_id get_class_id() const noexcept
Get the identifier of the object's most-derived registered RTTI type.
Definition: rtti.inl:72
static constexpr string_view get_class_name_static() noexcept
Apply the naming strategy to the declaring RTTI type's signature.
Definition: rtti.inl:53
static constexpr class_id get_class_id_static() noexcept
Create the declaring RTTI type's identifier from its type signature.
Definition: rtti.inl:65
virtual bool _is_base_id(const class_id &idBase) const noexcept
Traverse identifiers treated as bases by derived RTTI classes.
Definition: rtti.inl:78
static constexpr bool is_derived_from_id_static(const class_id &id) noexcept
Test an identifier against the declaring type's static RTTI hierarchy.
Definition: rtti.inl:47
virtual string_view get_class_name() const noexcept
Get the name of the object's most-derived registered RTTI type.
Definition: rtti.inl:59
The class allows you to get strings with information about the type, including its full name,...
Definition: type_strings.h:37