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>
53 template<class char_t>
54 constexpr basic_string_view<char_t> rtti_root<naming_strategy_t>::get_class_name_static() noexcept
55 {
56  return naming_strategy_type::get_name(type_strings<this_class_type, char_t>::get_signature());
57 }
58 
59 template<class naming_strategy_t>
60 inline basic_string_view<char_type> rtti_root<naming_strategy_t>::get_class_name() const noexcept
61 {
62  return get_class_name_static<char_type>();
63 }
64 
65 template<class naming_strategy_t>
66 inline qx::basic_string_view<char> rtti_root<naming_strategy_t>::get_class_name_cstring() const noexcept
67 {
68  return get_class_name_static<char>();
69 }
70 
71 template<class naming_strategy_t>
72 inline qx::basic_string_view<wchar_t> rtti_root<naming_strategy_t>::get_class_name_wstring() const noexcept
73 {
74  return get_class_name_static<wchar_t>();
75 }
76 
77 template<class naming_strategy_t>
79 {
80  constexpr class_id id = class_id::create<this_class_type>();
81  return id;
82 }
83 
84 template<class naming_strategy_t>
86 {
87  return get_class_id_static();
88 }
89 
90 template<class naming_strategy_t>
91 inline bool rtti_root<naming_strategy_t>::_is_base_id(const class_id& idBase) const noexcept
92 {
93  return idBase == get_class_id_static();
94 }
95 
96 } // 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
virtual qx::basic_string_view< char > get_class_name_cstring() const noexcept
Get the name of the object's most-derived registered RTTI type.
Definition: rtti.inl:66
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:85
static constexpr class_id get_class_id_static() noexcept
Create the declaring RTTI type's identifier from its type signature.
Definition: rtti.inl:78
virtual bool _is_base_id(const class_id &idBase) const noexcept
Traverse identifiers treated as bases by derived RTTI classes.
Definition: rtti.inl:91
static constexpr basic_string_view< char_t > get_class_name_static() noexcept
Apply the naming strategy to the declaring RTTI type's signature.
Definition: rtti.inl:54
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 qx::basic_string_view< char_type > get_class_name() const noexcept
Get the name of the object's most-derived registered RTTI type.
Definition: rtti.inl:60
virtual qx::basic_string_view< wchar_t > get_class_name_wstring() const noexcept
Get the name of the object's most-derived registered RTTI type.
Definition: rtti.inl:72
The class allows you to get strings with information about the type, including its full name,...
Definition: type_strings.h:37