Refureku v2.2.0
C++17 runtime reflection library.
FunctionBase.h
1
8#pragma once
9
10#include "Refureku/TypeInfo/Entity/Entity.h"
11#include "Refureku/TypeInfo/Functions/FunctionParameter.h"
12#include "Refureku/TypeInfo/Functions/ICallable.h"
13
14namespace rfk
15{
16 class FunctionBase : public Entity
17 {
18 public:
29 template <typename ReturnType, typename... ArgTypes>
30 RFK_NODISCARD bool hasSameSignature() const noexcept;
31
40 RFK_NODISCARD REFUREKU_API bool hasSameSignature(FunctionBase const& other) const noexcept;
41
47 template <typename... ArgTypes>
48 RFK_NODISCARD bool hasSameParameters() const noexcept;
49
55 RFK_NODISCARD REFUREKU_API Type const& getReturnType() const noexcept;
56
65 RFK_NODISCARD REFUREKU_API FunctionParameter const& getParameterAt(std::size_t index) const noexcept;
66
72 RFK_NODISCARD REFUREKU_API std::size_t getParametersCount() const noexcept;
73
79 RFK_NODISCARD REFUREKU_API ICallable* getInternalFunction() const noexcept;
80
90 REFUREKU_API FunctionParameter& addParameter(char const* name,
91 std::size_t id,
92 Type const& type) noexcept;
93
101 REFUREKU_API void setParametersCapacity(std::size_t capacity) noexcept;
102
103 protected:
104 //Forward declaration
105 class FunctionBaseImpl;
106
107 REFUREKU_INTERNAL FunctionBase(FunctionBaseImpl* implementation) noexcept;
108 REFUREKU_INTERNAL FunctionBase(FunctionBase&&) noexcept;
109 REFUREKU_INTERNAL ~FunctionBase() noexcept;
110
111 RFK_GEN_GET_PIMPL(FunctionBaseImpl, Entity::getPimpl());
112
118 template <typename... ArgTypes>
120
127 template <typename... ArgTypes>
129
135 template <typename ReturnType>
136 void checkReturnType() const;
137
138 private:
144 template <typename ReturnType>
145 RFK_NODISCARD bool hasSameReturnType() const noexcept;
146
152 template <typename... ArgTypes>
153 RFK_NODISCARD bool hasSameParametersCount() const noexcept;
154
160 template <std::size_t Rank, typename FirstArgType, typename SecondArgType, typename... OtherArgTypes>
161 RFK_NODISCARD bool hasSameParameterTypes() const noexcept;
162 template <std::size_t Rank, typename LastArgType>
163 RFK_NODISCARD bool hasSameParameterTypes() const noexcept;
164 template <typename... ArgTypes>
165 RFK_NODISCARD bool hasSameParameterTypes() const noexcept;
166
170 template <std::size_t Rank, typename FirstArgType, typename SecondArgType, typename... OtherArgTypes>
171 void checkParameterTypes() const;
172 template <std::size_t Rank, typename LastArgType>
173 void checkParameterTypes() const;
174
181 RFK_NORETURN REFUREKU_API void throwArgCountMismatchException(std::size_t received) const;
182
189 RFK_NORETURN REFUREKU_API void throwArgTypeMismatchException(std::size_t paramIndex) const;
190
195 RFK_NORETURN REFUREKU_API void throwReturnTypeMismatchException() const;
196 };
197
198 #include "Refureku/TypeInfo/Functions/FunctionBase.inl"
199}
Definition: Entity.h:29
Definition: FunctionBase.h:17
RFK_NODISCARD REFUREKU_API ICallable * getInternalFunction() const noexcept
Get the internal function handled by this object.
void checkParametersCount() const
Check that the provided argument count is the same as this function's.
REFUREKU_API FunctionParameter & addParameter(char const *name, std::size_t id, Type const &type) noexcept
Add a parameter to the function.
RFK_NODISCARD bool hasSameParameters() const noexcept
RFK_NODISCARD REFUREKU_API Type const & getReturnType() const noexcept
Get the return type of this function.
void checkReturnType() const
Check that the provided type is the same as this function return type.
REFUREKU_API void setParametersCapacity(std::size_t capacity) noexcept
Set the number of parameters for this function. Useful to avoid reallocations when adding a lot of pa...
RFK_NODISCARD REFUREKU_API FunctionParameter const & getParameterAt(std::size_t index) const noexcept
Retrieve the parameter at the given index. If index is greater or equal to the parameters count,...
RFK_NODISCARD bool hasSameSignature() const noexcept
Check whether 2 functions have the same signature. Non reflected types are compared equal,...
void checkParameterTypes() const
Check that the provided types are the same as this function parameter types.
RFK_NODISCARD REFUREKU_API std::size_t getParametersCount() const noexcept
Get the number of parameters of this function.
Definition: FunctionParameter.h:16
Definition: ICallable.h:13
Definition: Type.h:20
Definition: Allocator.h:16