47 template<
class naming_strategy_t = rtti_naming_strategy_
class_name>
54 using inheritance_tuple = std::tuple<this_class_type>;
55 using naming_strategy_type = naming_strategy_t;
63 bool is_derived_from()
const noexcept
65 constexpr class_identificator T_id = T::get_class_id_static();
66 return _is_base_id(T_id) || T_id == get_class_id();
70 bool is()
const noexcept
72 return get_class_id() == T::get_class_id_static();
75 bool is(string_view svClassName)
const noexcept
77 return svClassName == get_class_name();
80 bool is(class_identificator
id)
const noexcept
82 return id == get_class_id();
85 virtual bool is_derived_from_id(class_identificator
id)
const noexcept
87 return id == get_class_id_static();
90 static constexpr string_view get_class_name_static() noexcept
95 virtual string_view get_class_name()
const noexcept
97 return get_class_name_static();
100 static constexpr class_identificator get_class_id_static() noexcept
105 virtual class_identificator get_class_id()
const noexcept
107 return get_class_id_static();
110 virtual std::span<const class_identificator> get_inheritance_sequence()
const = 0;
112 auto operator<=>(
const rtti_root&)
const =
default;
117 virtual bool _is_base_id(class_identificator idBase)
const noexcept
119 return idBase == get_class_id_static();
129 #define QX_RTTI_CLASS(thisClass, ...) \
132 using this_class_type = thisClass; \
133 using super_class_type = __VA_ARGS__; \
134 using base_class_type = typename super_class_type::base_class_type; \
135 using inheritance_tuple = qx::tuple::join_t<typename super_class_type::inheritance_tuple, this_class_type>; \
138 virtual bool is_derived_from_id(qx::class_identificator id) const noexcept override \
140 return id == get_class_id_static() || super_class_type::is_derived_from_id(id); \
142 static constexpr qx::string_view get_class_name_static() noexcept \
144 return naming_strategy_type::get_name(qx::type_strings<this_class_type>::get_signature()); \
146 virtual qx::class_identificator get_class_id() const noexcept override \
148 return get_class_id_static(); \
150 static constexpr qx::class_identificator get_class_id_static() noexcept \
152 return qx::cstring_hash(qx::type_strings<this_class_type, char>::get_signature()); \
154 virtual qx::string_view get_class_name() const noexcept override \
156 return get_class_name_static(); \
158 virtual std::span<const qx::class_identificator> get_inheritance_sequence() const override \
160 static constexpr auto ids = []() \
162 std::array<qx::class_identificator, std::tuple_size_v<inheritance_tuple>> ids_; \
163 qx::tuple::iterate<inheritance_tuple>( \
164 [&ids_]<class T, size_t I>() \
166 ids_[I] = T::get_class_id_static(); \
174 virtual bool _is_base_id(qx::class_identificator base_id) const noexcept override \
176 return base_id == super_class_type::get_class_id_static() || super_class_type::_is_base_id(base_id); \
The class allows you to get strings with information about the type, including its full name,...
Contains naming strategies for qx::rtti_root class.
Contains utils for working with std::tuple.