Refureku v2.2.0
C++17 runtime reflection library.
VariableBase.h
1
8#pragma once
9
10#include <cassert>
11#include <utility> //std::forward, std::move
12#include <type_traits> //std::is_rvalue_reference_v, std::is_lvalue_reference_v, std::is_const_v...
13
14#include "Refureku/TypeInfo/Entity/Entity.h"
15#include "Refureku/TypeInfo/Type.h"
16
17namespace rfk
18{
19 class VariableBase : public Entity
20 {
21 public:
27 REFUREKU_API Type const& getType() const noexcept;
28
29 protected:
30 //Forward declaration
31 class VariableBaseImpl;
32
33 template <typename T>
34 static constexpr bool is_value_v = !std::is_lvalue_reference_v<T> && !std::is_rvalue_reference_v<T>;
35
36 REFUREKU_INTERNAL VariableBase(VariableBaseImpl* implementation) noexcept;
37 REFUREKU_INTERNAL VariableBase(VariableBase&&) noexcept;
38 REFUREKU_INTERNAL ~VariableBase() noexcept;
39
40 RFK_GEN_GET_PIMPL(VariableBaseImpl, Entity::getPimpl())
41
59 template <typename ValueType>
60 RFK_NODISCARD ValueType get(void* ptr) const;
61
80 template <typename ValueType>
81 RFK_NODISCARD ValueType get(void const* ptr) const;
82
96 template <typename ValueType>
97 void set(void* ptr,
98 ValueType&& value) const;
99
109 REFUREKU_INTERNAL void set(void* target,
110 void const* source,
111 std::size_t bytesCount) const;
112
119 RFK_NORETURN REFUREKU_API static void throwConstViolationException(char const* message);
120 };
121
122 #include "Refureku/TypeInfo/Variables/VariableBase.inl"
123}
Definition: Entity.h:29
Definition: Type.h:20
Definition: VariableBase.h:20
RFK_NORETURN static REFUREKU_API void throwConstViolationException(char const *message)
Throw a ConstViolation exception with the specified message. /!\ This method is called from template ...
REFUREKU_API Type const & getType() const noexcept
Get the type of this variable.
RFK_NODISCARD ValueType get(void *ptr) const
Get the data stored in the provided ptr. This method in not safe if you provide a wrong DataType.
void set(void *ptr, ValueType &&value) const
Set the provided pointer content. This method is not safe if you provide a wrong ValueType.
Definition: Allocator.h:16