Refureku v2.2.0
C++17 runtime reflection library.
rfk::StaticMethod Class Referencefinal
Inheritance diagram for rfk::StaticMethod:
rfk::MethodBase rfk::FunctionBase rfk::Entity

Public Member Functions

REFUREKU_API StaticMethod (char const *name, std::size_t id, Type const &returnType, ICallable *internalMethod, EMethodFlags flags, Entity const *outerEntity) noexcept
 
REFUREKU_INTERNAL StaticMethod (StaticMethod &&) noexcept
 
template<typename ReturnType = void, typename... ArgTypes>
ReturnType invoke (ArgTypes &&... args) const
 Call the function with the forwarded argument(s) if any, and return the result. Providing bad return type / parameters is undefined behaviour. WARNING: Template type deduction might forward wrong types to the function (int instead of int8_t or char* instead of std::string for example), so it is recommended to explicitly specify all template types when calling the function. More...
 
template<typename ReturnType = void, typename... ArgTypes>
ReturnType checkedInvoke (ArgTypes &&... args) const
 Call the function with the forwarded argument(s) if any, and return the result. The return type and arguments types will be strictly checked before calling the function. If there is any mismatch, ArgCountMismatch, ArgTypeMismatch or ReturnTypeMismatch will be thrown. WARNING 1: Unreflected archetypes can't be compared, so they will pass through the type checks. WARNING 2: Template type deduction might forward wrong types to the function (int instead of int8_t or char* instead of std::string for example), so it is recommended to explicitly specify all template types when calling the function. More...
 
- Public Member Functions inherited from rfk::MethodBase
RFK_NODISCARD REFUREKU_API bool hasSameSignature (MethodBase const &other) const noexcept
 Check that another function has the same prototype as this function. WARNING: Non reflected type archetypes are considered equal since their archetype is nullptr. More...
 
RFK_NODISCARD REFUREKU_API bool isStatic () const noexcept
 Check if this method is static. More...
 
RFK_NODISCARD REFUREKU_API bool isInline () const noexcept
 Check if this method is marked with the inline qualifier or defined in the header file. More...
 
RFK_NODISCARD REFUREKU_API bool isVirtual () const noexcept
 Check if this method is virtual. More...
 
RFK_NODISCARD REFUREKU_API bool isPureVirtual () const noexcept
 Check if this method is pure virtual. More...
 
RFK_NODISCARD REFUREKU_API bool isOverride () const noexcept
 Check if this method is override-qualified. WARNING: An overriding method not explicitly qualified with the override keyword will return false. More...
 
RFK_NODISCARD REFUREKU_API bool isFinal () const noexcept
 Check if this method is final-qualified. WARNING: An override method part of a final class will return false. More...
 
RFK_NODISCARD REFUREKU_API bool isConst () const noexcept
 Check if this method is const-qualified. More...
 
RFK_NODISCARD REFUREKU_API EMethodFlags getFlags () const noexcept
 Get the flags qualifying this method. More...
 
RFK_NODISCARD REFUREKU_API EAccessSpecifier getAccess () const noexcept
 Get the access specifier of this method in its owner struct/class. More...
 
template<typename ReturnType , typename... ArgTypes>
RFK_NODISCARD bool hasSameSignature () const noexcept
 Check whether 2 functions have the same signature. Non reflected types are compared equal, so NonReflectedType1 and NonReflectedType2 are considered equal since their archetype is the same. More...
 
RFK_NODISCARD REFUREKU_API bool hasSameSignature (FunctionBase const &other) const noexcept
 Check that another function has the same prototype as this function. Non reflected types are compared equal, so NonReflectedType1 and NonReflectedType2 are considered equal since their archetype is the same. More...
 
- Public Member Functions inherited from rfk::FunctionBase
template<typename ReturnType , typename... ArgTypes>
RFK_NODISCARD bool hasSameSignature () const noexcept
 Check whether 2 functions have the same signature. Non reflected types are compared equal, so NonReflectedType1 and NonReflectedType2 are considered equal since their archetype is the same. More...
 
RFK_NODISCARD REFUREKU_API bool hasSameSignature (FunctionBase const &other) const noexcept
 Check that another function has the same prototype as this function. Non reflected types are compared equal, so NonReflectedType1 and NonReflectedType2 are considered equal since their archetype is the same. More...
 
template<typename... ArgTypes>
RFK_NODISCARD bool hasSameParameters () const noexcept
 
RFK_NODISCARD REFUREKU_API Type const & getReturnType () const noexcept
 Get the return type of this function. More...
 
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, the behaviour is undefined. More...
 
RFK_NODISCARD REFUREKU_API std::size_t getParametersCount () const noexcept
 Get the number of parameters of this function. More...
 
RFK_NODISCARD REFUREKU_API ICallablegetInternalFunction () const noexcept
 Get the internal function handled by this object. More...
 
REFUREKU_API FunctionParameteraddParameter (char const *name, std::size_t id, Type const &type) noexcept
 Add a parameter to the function. More...
 
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 parameters. If the number of parameters is already >= to the provided count, this method has no effect. More...
 
- Public Member Functions inherited from rfk::Entity
 Entity (Entity const &)=delete
 
RFK_NODISCARD REFUREKU_API Property const * getPropertyAt (std::size_t propertyIndex) const noexcept
 Retrieve the property at the given index. If propertyIndex is greater or equal to the properties count, the behaviour is undefined. More...
 
template<typename PropertyType , typename = std::enable_if_t<std::is_base_of_v<Property, PropertyType> && !std::is_same_v<PropertyType, Property>>>
RFK_NODISCARD PropertyType const * getProperty (bool isChildClassValid=true) const noexcept
 Retrieve a property of a given type from this entity. More...
 
RFK_NODISCARD REFUREKU_API Property const * getProperty (Struct const &archetype, bool isChildClassValid=true) const noexcept
 Retrieve the first property matching with the provided archetype. More...
 
RFK_NODISCARD REFUREKU_API Property const * getPropertyByName (char const *name) const noexcept
 Retrieve the first property named with the provided name. More...
 
RFK_NODISCARD REFUREKU_API Property const * getPropertyByPredicate (Predicate< Property > predicate, void *userData) const
 Retrieve a property matching with a predicate. More...
 
template<typename PropertyType , typename = std::enable_if_t<std::is_base_of_v<Property, PropertyType> && !std::is_same_v<PropertyType, Property>>>
RFK_NODISCARD Vector< PropertyType const * > getProperties (bool isChildClassValid=true) const noexcept
 Retrieve all properties matching with the provided archetype. If PropertyType uses multiple inheritance, its first inherited type must be rfk::Property or derived. More...
 
RFK_NODISCARD REFUREKU_API Vector< Property const * > getProperties (Struct const &archetype, bool isChildClassValid=true) const noexcept
 Retrieve all properties matching with the provided archetype. More...
 
RFK_NODISCARD REFUREKU_API Vector< Property const * > getPropertiesByName (char const *name) const noexcept
 Retrieve all properties named with the provided name. More...
 
RFK_NODISCARD REFUREKU_API Vector< Property const * > getPropertiesByPredicate (Predicate< Property > predicate, void *userData) const
 Retrieve all properties matching with a predicate in this entity. More...
 
RFK_NODISCARD REFUREKU_API std::size_t getPropertiesCount () const noexcept
 Get the number of properties attached to this entity. More...
 
REFUREKU_API bool foreachProperty (Visitor< Property > visitor, void *userData) const
 Execute the given visitor on all properties attached to this entity. More...
 
RFK_NODISCARD REFUREKU_API char const * getName () const noexcept
 Get the name of the entity. More...
 
RFK_NODISCARD REFUREKU_API bool hasSameName (char const *name) const noexcept
 Check that this entity has the same name as the provided string. More...
 
RFK_NODISCARD REFUREKU_API std::size_t getId () const noexcept
 Get the program-unique id of the entity. More...
 
RFK_NODISCARD REFUREKU_API EEntityKind getKind () const noexcept
 Get the kind of the entity. Knowing the kind allows to safely cast to child classes. Check the EEntityKind documentation for more information. More...
 
RFK_NODISCARD REFUREKU_API Entity const * getOuterEntity () const noexcept
 Get the outer entity of the entity. It basically corresponds to the entity this entity was declared in from a source-code point of view. A nullptr outer entity means the entity was declared at file level. More...
 
REFUREKU_API bool addProperty (Property const &property) noexcept
 Add a property to this entity. More...
 
REFUREKU_API void setOuterEntity (Entity const *outerEntity) noexcept
 Setter for the field _outerEntity. More...
 
REFUREKU_API void setPropertiesCapacity (std::size_t capacity) noexcept
 Set the number of properties for this entity. Useful to avoid reallocations when adding a lot of properties. If the number of properties is already >= to the provided capacity, this method has no effect. More...
 
Entityoperator= (Entity const &)=delete
 
Entityoperator= (Entity &&)=delete
 
RFK_NODISCARD REFUREKU_API bool operator== (Entity const &other) const noexcept
 
RFK_NODISCARD REFUREKU_API bool operator!= (Entity const &other) const noexcept
 

Additional Inherited Members

- Protected Member Functions inherited from rfk::MethodBase
REFUREKU_INTERNAL MethodBase (MethodBaseImpl *implementation) noexcept
 
REFUREKU_INTERNAL MethodBase (MethodBase &&) noexcept
 
- Protected Member Functions inherited from rfk::FunctionBase
REFUREKU_INTERNAL FunctionBase (FunctionBaseImpl *implementation) noexcept
 
REFUREKU_INTERNAL FunctionBase (FunctionBase &&) noexcept
 
 RFK_GEN_GET_PIMPL (FunctionBaseImpl, Entity::getPimpl())
 
template<typename... ArgTypes>
void checkParametersCount () const
 Check that the provided argument count is the same as this function's. More...
 
template<typename... ArgTypes>
void checkParameterTypes () const
 Check that the provided types are the same as this function parameter types. More...
 
template<typename ReturnType >
void checkReturnType () const
 Check that the provided type is the same as this function return type. More...
 
- Protected Member Functions inherited from rfk::Entity
REFUREKU_INTERNAL Entity (Entity &&) noexcept
 
REFUREKU_INTERNAL Entity (EntityImpl *implementation) noexcept
 

Member Function Documentation

◆ checkedInvoke()

template<typename ReturnType = void, typename... ArgTypes>
ReturnType rfk::StaticMethod::checkedInvoke ( ArgTypes &&...  args) const

Call the function with the forwarded argument(s) if any, and return the result. The return type and arguments types will be strictly checked before calling the function. If there is any mismatch, ArgCountMismatch, ArgTypeMismatch or ReturnTypeMismatch will be thrown. WARNING 1: Unreflected archetypes can't be compared, so they will pass through the type checks. WARNING 2: Template type deduction might forward wrong types to the function (int instead of int8_t or char* instead of std::string for example), so it is recommended to explicitly specify all template types when calling the function.

Template Parameters
ReturnTypeReturn type of the function.

.. ArgTypes Type of all arguments. This can in some cases be omitted thanks to template deduction.

Parameters
argsArguments forwarded to the function call.
Returns
The result of the function call.
Exceptions
ArgCountMismatchif sizeof...(ArgTypes) is not the same as the value returned by getParametersCount().
ArgTypeMismatchif ArgTypes... are not strictly the same as this function parameter types. WARNING: Be careful to template deduction.
ReturnTypeMismatchif ReturnType is not strictly the same as this function return type.
Anyexception potentially thrown from the underlying function.

◆ invoke()

template<typename ReturnType = void, typename... ArgTypes>
ReturnType rfk::StaticMethod::invoke ( ArgTypes &&...  args) const

Call the function with the forwarded argument(s) if any, and return the result. Providing bad return type / parameters is undefined behaviour. WARNING: Template type deduction might forward wrong types to the function (int instead of int8_t or char* instead of std::string for example), so it is recommended to explicitly specify all template types when calling the function.

Template Parameters
ReturnTypeReturn type of the function.

.. ArgTypes Type of all arguments. This can in some cases be omitted thanks to template deduction.

Parameters
argsArguments forwarded to the function call.
Returns
The result of the function call.
Exceptions
Anyexception potentially thrown from the underlying function.

The documentation for this class was generated from the following file: