3#include "sound_bakery/core/core_fwd.h"
5#include <rttr/registration_friend>
8namespace sbk::reflection
10 template <
typename Target_Type,
typename Source_Type>
11 Target_Type cast(Source_Type
object)
13 static_assert(rttr::detail::pointer_count<Target_Type>::value == 1,
"Target type must be a pointer");
14 static_assert(rttr::detail::pointer_count<Source_Type>::value == 1,
"Source argument must be a pointer");
15 static_assert(rttr::detail::has_get_type_func<Source_Type>::value,
16 "Class has not type defined - please use the macro RTTR_ENABLE().");
18 using Return_Type = rttr::detail::remove_pointer_t<Target_Type>;
19 using Arg_Type = rttr::detail::remove_pointer_t<Source_Type>;
21 static_assert((std::is_volatile<Arg_Type>::value && std::is_volatile<Return_Type>::value) ||
22 (!std::is_volatile<Arg_Type>::value && std::is_volatile<Return_Type>::value) ||
23 (!std::is_volatile<Arg_Type>::value && !std::is_volatile<Return_Type>::value),
24 "Return type must have volatile qualifier");
26 static_assert((std::is_const<Arg_Type>::value && std::is_const<Return_Type>::value) ||
27 (!std::is_const<Arg_Type>::value && std::is_const<Return_Type>::value) ||
28 (!std::is_const<Arg_Type>::value && !std::is_const<Return_Type>::value),
29 "Return type must have const qualifier");
31 using source_type_no_cv =
typename std::remove_cv<typename std::remove_pointer<Source_Type>::type>::type;
32 return static_cast<Target_Type
>(rttr::type::apply_offset(
const_cast<source_type_no_cv*
>(
object)->get_ptr(),
33 const_cast<source_type_no_cv*
>(
object)->get_type(),
37 void registerReflectionTypes();
38 void unregisterReflectionTypes();