From fd686eadf81e85bd4993a483adcefd6a153d259f Mon Sep 17 00:00:00 2001 From: hop311 Date: Tue, 7 Nov 2023 22:18:08 +0000 Subject: GUI and GFX file loading --- src/openvic-simulation/utility/Getters.hpp | 32 ++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'src/openvic-simulation/utility') diff --git a/src/openvic-simulation/utility/Getters.hpp b/src/openvic-simulation/utility/Getters.hpp index c8f2193..8f5dd28 100644 --- a/src/openvic-simulation/utility/Getters.hpp +++ b/src/openvic-simulation/utility/Getters.hpp @@ -4,6 +4,38 @@ #include #include +#include +#include + +#define OV_DETAIL_GET_TYPE_BASE_CLASS(CLASS) \ + static constexpr std::string_view get_type_static() { return ::ovdl::detail::type_name(); } \ + constexpr virtual std::string_view get_type() const = 0; \ + static constexpr std::string_view get_base_type_static() { return ::ovdl::detail::type_name(); } \ + constexpr virtual std::string_view get_base_type() const { return get_base_type_static(); } \ + template constexpr bool is_type() const { \ + return get_type().compare(::ovdl::detail::type_name()) == 0; } \ + template constexpr bool is_derived_from() const { \ + return is_type() || get_base_type().compare(::ovdl::detail::type_name()) == 0; } \ + template constexpr T* cast_to() { \ + if (is_derived_from() || is_type()) return (static_cast(this)); \ + return nullptr; } \ + template constexpr const T* const cast_to() const { \ + if (is_derived_from() || is_type()) return (static_cast(this)); \ + return nullptr; } + +#define OV_DETAIL_GET_TYPE \ + struct _self_type_tag {}; \ + constexpr auto _self_type_helper()->decltype(::ovdl::detail::Writer<_self_type_tag, decltype(this)> {}); \ + using type = ::ovdl::detail::Read<_self_type_tag>; \ + static constexpr std::string_view get_type_static() { return ::ovdl::detail::type_name(); } \ + constexpr std::string_view get_type() const override { \ + return ::ovdl::detail::type_name>(); } + +#define OV_DETAIL_GET_BASE_TYPE(CLASS) \ + static constexpr std::string_view get_base_type_static() { return ::ovdl::detail::type_name(); } \ + constexpr std::string_view get_base_type() const override { \ + return ::ovdl::detail::type_name>(); } + #define REF_GETTERS(var) \ constexpr decltype(var)& get_##var() { \ return var; \ -- cgit v1.2.3-56-ga3b1