Refureku v2.2.0
C++17 runtime reflection library.
rfk::ClassTemplate Class Referencefinal
Inheritance diagram for rfk::ClassTemplate:
rfk::Struct rfk::Archetype rfk::Entity

Public Member Functions

REFUREKU_API ClassTemplate (char const *name, std::size_t id, bool isClass) noexcept
 
RFK_NODISCARD REFUREKU_API TemplateParameter const & getTemplateParameterAt (std::size_t index) const noexcept
 Retrieve the template parameter at the given index. If index is greater or equal to getTemplateParametersCount(), the behaviour is undefined. More...
 
RFK_NODISCARD REFUREKU_API std::size_t getTemplateParametersCount () const noexcept
 Get the number of template parameters for this class template. More...
 
template<std::size_t ArgsCount>
RFK_NODISCARD ClassTemplateInstantiation const * getTemplateInstantiation (TemplateArgument const *(&args)[ArgsCount]) const noexcept
 Get an existing template instantiation corresponding to the provided arguments. More...
 
RFK_NODISCARD REFUREKU_API ClassTemplateInstantiation const * getTemplateInstantiation (TemplateArgument const **args, std::size_t argsCount) const noexcept
 Get an existing template instantiation corresponding to the provided arguments. More...
 
RFK_NODISCARD REFUREKU_API std::size_t getTemplateInstantiationsCount () const noexcept
 Get the number of instantiations (with different template parameters) of this class template within the program. More...
 
REFUREKU_API bool foreachTemplateInstantiation (Visitor< ClassTemplateInstantiation > visitor, void *userData) const
 Execute the given visitor on all template instantiations of this class. More...
 
REFUREKU_API void addTemplateParameter (TemplateParameter const &param) noexcept
 Append a template parameter to the list of template parameters. More...
 
REFUREKU_API void registerTemplateInstantiation (ClassTemplateInstantiation const &inst) noexcept
 Register an instantiation of this class template. More...
 
REFUREKU_API void unregisterTemplateInstantiation (ClassTemplateInstantiation const &inst) noexcept
 Unregister an instantiation of this class template. More...
 
- Public Member Functions inherited from rfk::Struct
REFUREKU_API Struct (char const *name, std::size_t id, std::size_t memorySize, bool isClass) noexcept
 
template<typename ReturnType , typename... ArgTypes>
RFK_NODISCARD rfk::SharedPtr< ReturnType > makeSharedInstance (ArgTypes &&... args) const
 Make an instance of the class represented by this archetype with the matching instantiator. One can add new instantiators to any class by using the Instantiator method property. More...
 
template<typename ReturnType , typename... ArgTypes>
RFK_NODISCARD rfk::UniquePtr< ReturnType > makeUniqueInstance (ArgTypes &&... args) const
 Make an instance of the class represented by this archetype with the matching instantiator. One can add new instantiators to any class by using the Instantiator method property. More...
 
RFK_NODISCARD REFUREKU_API Vector< Struct const * > getDirectSubclasses () const noexcept
 Compute the list of all direct reflected subclasses of this struct. Direct subclasses are computed by iterating over all subclasses (direct or not), so this method might have a heavy performance cost on big class hierarchies. More...
 
RFK_NODISCARD REFUREKU_API bool isSubclassOf (Struct const &archetype) const noexcept
 Check if this struct is a subclass of another struct/class. More...
 
RFK_NODISCARD REFUREKU_API bool isBaseOf (Struct const &archetype) const noexcept
 Check if this struct is a base class of another struct/class. More...
 
RFK_NODISCARD REFUREKU_API ParentStruct const & getDirectParentAt (std::size_t index) const noexcept
 Get the index'th direct parent of this struct. If index is greater or equal to getDirectParentsCount(), the behaviour is undefined. More...
 
RFK_NODISCARD REFUREKU_API std::size_t getDirectParentsCount () const noexcept
 Get the number of reflected direct parents this struct is inheriting from. More...
 
REFUREKU_API bool foreachDirectParent (Visitor< ParentStruct > visitor, void *userData) const
 Execute the given visitor on all direct parents of this struct. More...
 
RFK_NODISCARD REFUREKU_API Struct const * getNestedStructByName (char const *name, EAccessSpecifier access=EAccessSpecifier::Undefined) const noexcept
 
RFK_NODISCARD REFUREKU_API Struct const * getNestedStructByPredicate (Predicate< Struct > predicate, void *userData) const
 Retrieve the first nested struct satisfying the provided predicate. More...
 
RFK_NODISCARD REFUREKU_API Vector< Struct const * > getNestedStructsByPredicate (Predicate< Struct > predicate, void *userData) const
 Retrieve all nested structs satisfying the provided predicate. More...
 
RFK_NODISCARD REFUREKU_API Class const * getNestedClassByName (char const *name, EAccessSpecifier access=EAccessSpecifier::Undefined) const noexcept
 
RFK_NODISCARD REFUREKU_API Class const * getNestedClassByPredicate (Predicate< Class > predicate, void *userData) const
 Retrieve the first nested class satisfying the provided predicate. More...
 
RFK_NODISCARD REFUREKU_API Vector< Class const * > getNestedClassesByPredicate (Predicate< Class > predicate, void *userData) const
 Retrieve all nested classes satisfying the provided predicate. More...
 
RFK_NODISCARD REFUREKU_API Enum const * getNestedEnumByName (char const *name, EAccessSpecifier access=EAccessSpecifier::Undefined) const noexcept
 
RFK_NODISCARD REFUREKU_API Enum const * getNestedEnumByPredicate (Predicate< Enum > predicate, void *userData) const
 Retrieve the first nested enum satisfying the provided predicate. More...
 
RFK_NODISCARD REFUREKU_API Vector< Enum const * > getNestedEnumsByPredicate (Predicate< Enum > predicate, void *userData) const
 Retrieve all nested enums satisfying the provided predicate. More...
 
REFUREKU_API bool foreachNestedArchetype (Visitor< Archetype > visitor, void *userData) const
 Execute the given visitor on all archetypes nested in this struct. More...
 
REFUREKU_API std::size_t getNestedArchetypesCount () const noexcept
 Get the number of archetypes nested in this struct. More...
 
RFK_NODISCARD REFUREKU_API Field const * getFieldByName (char const *name, EFieldFlags minFlags=EFieldFlags::Default, bool shouldInspectInherited=false) const noexcept
 
RFK_NODISCARD REFUREKU_API Field const * getFieldByPredicate (Predicate< Field > predicate, void *userData, bool shouldInspectInherited=false) const
 Retrieve the first field satisfying the provided predicate. More...
 
RFK_NODISCARD REFUREKU_API Vector< Field const * > getFieldsByPredicate (Predicate< Field > predicate, void *userData, bool shouldInspectInherited=false, bool orderedByDeclaration=false) const
 Retrieve all fields satisfying the provided predicate. More...
 
REFUREKU_API bool foreachField (Visitor< Field > visitor, void *userData, bool shouldInspectInherited=false) const
 Execute the given visitor on all fields in this struct. More...
 
REFUREKU_API std::size_t getFieldsCount () const noexcept
 Get the number of fields (including inherited ones) in this struct. More...
 
RFK_NODISCARD REFUREKU_API StaticField const * getStaticFieldByName (char const *name, EFieldFlags minFlags=EFieldFlags::Default, bool shouldInspectInherited=false) const noexcept
 
RFK_NODISCARD REFUREKU_API StaticField const * getStaticFieldByPredicate (Predicate< StaticField > predicate, void *userData, bool shouldInspectInherited=false) const
 Retrieve the first static field satisfying the provided predicate. More...
 
RFK_NODISCARD REFUREKU_API Vector< StaticField const * > getStaticFieldsByPredicate (Predicate< StaticField > predicate, void *userData, bool shouldInspectInherited=false) const
 Retrieve all static fields satisfying the provided predicate. More...
 
REFUREKU_API bool foreachStaticField (Visitor< StaticField > visitor, void *userData, bool shouldInspectInherited=false) const
 Execute the given visitor on all static fields in this struct. More...
 
REFUREKU_API std::size_t getStaticFieldsCount () const noexcept
 Get the number of static fields (including inherited ones) in this struct. More...
 
template<typename MethodSignature >
RFK_NODISCARD Method const * getMethodByName (char const *name, EMethodFlags minFlags=EMethodFlags::Default, bool shouldInspectInherited=false) const noexcept
 Get a method by name and signature. This template overload using signature comes handy when wanting to disambiguate 2 method overloads with and without const qualifier for example. More...
 
RFK_NODISCARD REFUREKU_API Method const * getMethodByName (char const *name, EMethodFlags minFlags=EMethodFlags::Default, bool shouldInspectInherited=false) const noexcept
 
RFK_NODISCARD REFUREKU_API Vector< Method const * > getMethodsByName (char const *name, EMethodFlags minFlags=EMethodFlags::Default, bool shouldInspectInherited=false) const noexcept
 
RFK_NODISCARD REFUREKU_API Method const * getMethodByPredicate (Predicate< Method > predicate, void *userData, bool shouldInspectInherited=false) const
 Retrieve the first method satisfying the provided predicate. More...
 
RFK_NODISCARD REFUREKU_API Vector< Method const * > getMethodsByPredicate (Predicate< Method > predicate, void *userData, bool shouldInspectInherited=false) const
 Retrieve all methods satisfying the provided predicate. More...
 
REFUREKU_API bool foreachMethod (Visitor< Method > visitor, void *userData, bool shouldInspectInherited=false) const
 Execute the given visitor on all methods in this struct. More...
 
REFUREKU_API std::size_t getMethodsCount () const noexcept
 Get the number of methods (excluding inherited ones) in this struct. More...
 
template<typename StaticMethodSignature >
RFK_NODISCARD StaticMethod const * getStaticMethodByName (char const *name, EMethodFlags minFlags=EMethodFlags::Default, bool shouldInspectInherited=false) const noexcept
 
RFK_NODISCARD REFUREKU_API StaticMethod const * getStaticMethodByName (char const *name, EMethodFlags minFlags=EMethodFlags::Default, bool shouldInspectInherited=false) const noexcept
 
RFK_NODISCARD REFUREKU_API Vector< StaticMethod const * > getStaticMethodsByName (char const *name, EMethodFlags minFlags=EMethodFlags::Default, bool shouldInspectInherited=false) const noexcept
 
RFK_NODISCARD REFUREKU_API StaticMethod const * getStaticMethodByPredicate (Predicate< StaticMethod > predicate, void *userData, bool shouldInspectInherited=false) const
 Retrieve the first static method satisfying the provided predicate. More...
 
RFK_NODISCARD REFUREKU_API Vector< StaticMethod const * > getStaticMethodsByPredicate (Predicate< StaticMethod > predicate, void *userData, bool shouldInspectInherited=false) const
 Retrieve all static methods satisfying the provided predicate. More...
 
REFUREKU_API bool foreachStaticMethod (Visitor< StaticMethod > visitor, void *userData, bool shouldInspectInherited=false) const
 Execute the given visitor on all static methods in this struct. More...
 
REFUREKU_API std::size_t getStaticMethodsCount () const noexcept
 Get the number of static methods (excluding inherited ones) in this struct. More...
 
RFK_NODISCARD REFUREKU_API EClassKind getClassKind () const noexcept
 Get the class kind of this instance. More...
 
RFK_NODISCARD REFUREKU_API bool getPointerOffset (Struct const &to, std::ptrdiff_t &out_pointerOffset) const noexcept
 Get the pointer offset to transform an instance of this Struct pointer to a pointer of the provided Struct. Search in both directions (whether to is a parent class or a child class). More...
 
RFK_NODISCARD REFUREKU_API bool getSubclassPointerOffset (Struct const &to, std::ptrdiff_t &out_pointerOffset) const noexcept
 Get the pointer offset to transform an instance of this Struct pointer to a pointer of the provided Struct. Only search the offset in this struct subclasses. If to is a parent of this struct, false will be returned. More...
 
REFUREKU_API void addDirectParent (Archetype const *archetype, EAccessSpecifier inheritanceAccess) noexcept
 Add a parent to this struct if the provided archetype is a valid struct/class. More...
 
REFUREKU_API void setDirectParentsCapacity (std::size_t capacity) noexcept
 Set the number of direct parents for this struct. Useful to avoid reallocations and avoid having unused memory. If the number of direct parents is already >= to the provided count, this method has no effect. More...
 
REFUREKU_API void addSubclass (Struct const &subclass, std::ptrdiff_t subclassPointerOffset) noexcept
 Add a subclass to this struct. More...
 
REFUREKU_API void addNestedArchetype (Archetype const *nestedArchetype, EAccessSpecifier accessSpecifier) noexcept
 Add a nested archetype to the struct. More...
 
REFUREKU_API void setNestedArchetypesCapacity (std::size_t capacity) noexcept
 Internally pre-allocate enough memory for the provided number of nested archetypes. If the number of nested archetypes is already >= to the provided capacity, this method has no effect. More...
 
REFUREKU_API FieldaddField (char const *name, std::size_t id, Type const &type, EFieldFlags flags, std::size_t memoryOffset, Struct const *outerEntity) noexcept
 Add a field to the struct. More...
 
REFUREKU_API void setFieldsCapacity (std::size_t capacity) noexcept
 Internally pre-allocate enough memory for the provided number of fields. If the number of fields is already >= to the provided capacity, this method has no effect. More...
 
REFUREKU_API StaticFieldaddStaticField (char const *name, std::size_t id, Type const &type, EFieldFlags flags, void *fieldPtr, Struct const *outerEntity) noexcept
 Add a static field to the struct. More...
 
REFUREKU_API StaticFieldaddStaticField (char const *name, std::size_t id, Type const &type, EFieldFlags flags, void const *fieldPtr, Struct const *outerEntity) noexcept
 
REFUREKU_API void setStaticFieldsCapacity (std::size_t capacity) noexcept
 Internally pre-allocate enough memory for the provided number of static fields. If the number of static fields is already >= to the provided capacity, this method has no effect. More...
 
REFUREKU_API MethodaddMethod (char const *name, std::size_t id, Type const &returnType, ICallable *internalMethod, EMethodFlags flags) noexcept
 Add a method to the struct. More...
 
REFUREKU_API void setMethodsCapacity (std::size_t capacity) noexcept
 Internally pre-allocate enough memory for the provided number of methods. If the number of methods is already >= to the provided capacity, this method has no effect. More...
 
REFUREKU_API StaticMethodaddStaticMethod (char const *name, std::size_t id, Type const &returnType, ICallable *internalMethod, EMethodFlags flags) noexcept
 Add a static method to the struct. More...
 
REFUREKU_API void setStaticMethodsCapacity (std::size_t capacity) noexcept
 Internally pre-allocate enough memory for the provided number of static methods. If the number of static methods is already >= to the provided capacity, this method has no effect. More...
 
REFUREKU_API void addSharedInstantiator (StaticMethod const &instantiator) noexcept
 Add a new way to instantiate this struct through the makeSharedInstance method. The passed static method MUST return a rfk::SharedPtr<StructType>. Otherwise, the behaviour is undefined when calling Struct::makeSharedInstance. More...
 
REFUREKU_API void addUniqueInstantiator (StaticMethod const &instantiator) noexcept
 Add a new way to instantiate this struct through the makeUniqueInstance method. The passed static method MUST return a rfk::UniquePtr<StructType>. Otherwise, the behaviour is undefined when calling Struct::makeUniqueInstance. More...
 
- Public Member Functions inherited from rfk::Archetype
 Archetype (Archetype &&)=delete
 
RFK_NODISCARD REFUREKU_API EAccessSpecifier getAccessSpecifier () const noexcept
 Get the access specifier of the archetype if it is nested in a struct or class. If the archetype is not nested in a struct or class, EAccessSpecifier::Undefined is returned. More...
 
RFK_NODISCARD REFUREKU_API std::size_t getMemorySize () const noexcept
 Get the memory size of an instance of the archetype, as the operator sizeof(type) would do. More...
 
REFUREKU_API void setAccessSpecifier (EAccessSpecifier access) noexcept
 Set the access specifier of the archetype in its outer struct/class. 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::Struct
REFUREKU_INTERNAL Struct (char const *name, std::size_t id, std::size_t memorySize, bool isClass, EClassKind classKind) noexcept
 
REFUREKU_INTERNAL Struct (StructImpl *implementation) noexcept
 
- Protected Member Functions inherited from rfk::Archetype
REFUREKU_INTERNAL Archetype (ArchetypeImpl *implementation) noexcept
 
- Protected Member Functions inherited from rfk::Entity
REFUREKU_INTERNAL Entity (Entity &&) noexcept
 
REFUREKU_INTERNAL Entity (EntityImpl *implementation) noexcept
 

Member Function Documentation

◆ addTemplateParameter()

REFUREKU_API void rfk::ClassTemplate::addTemplateParameter ( TemplateParameter const &  param)
noexcept

Append a template parameter to the list of template parameters.

Parameters
paramTemplate parameter to add.

◆ foreachTemplateInstantiation()

REFUREKU_API bool rfk::ClassTemplate::foreachTemplateInstantiation ( Visitor< ClassTemplateInstantiation visitor,
void *  userData 
) const

Execute the given visitor on all template instantiations of this class.

Parameters
visitorVisitor function to call. Return false to abort the foreach loop.
userDataOptional user data forwarded to the visitor.
Returns
The last visitor result before exiting the loop. If the visitor is nullptr, return false.
Exceptions
Anyexception potentially thrown from the provided visitor.

◆ getTemplateInstantiation() [1/2]

template<std::size_t ArgsCount>
RFK_NODISCARD ClassTemplateInstantiation const * rfk::ClassTemplate::getTemplateInstantiation ( TemplateArgument const *(&)  args[ArgsCount]) const
noexcept

Get an existing template instantiation corresponding to the provided arguments.

Parameters
argsTemplate arguments.
Returns
The found class template instantiation corresponding to the provided arguments if it exists, else nullptr.

◆ getTemplateInstantiation() [2/2]

RFK_NODISCARD REFUREKU_API ClassTemplateInstantiation const * rfk::ClassTemplate::getTemplateInstantiation ( TemplateArgument const **  args,
std::size_t  argsCount 
) const
noexcept

Get an existing template instantiation corresponding to the provided arguments.

Parameters
argsPointer to an array of argument pointers
argsCountNumber of template arguments.
Returns
The found class template instantiation corresponding to the provided arguments if it exists, else nullptr.

◆ getTemplateInstantiationsCount()

RFK_NODISCARD REFUREKU_API std::size_t rfk::ClassTemplate::getTemplateInstantiationsCount ( ) const
noexcept

Get the number of instantiations (with different template parameters) of this class template within the program.

Returns
The number of instantiations of this class template within the program.

◆ getTemplateParameterAt()

RFK_NODISCARD REFUREKU_API TemplateParameter const & rfk::ClassTemplate::getTemplateParameterAt ( std::size_t  index) const
noexcept

Retrieve the template parameter at the given index. If index is greater or equal to getTemplateParametersCount(), the behaviour is undefined.

Parameters
indexIndex of the template parameter to retrieve.
Returns
The template parameter at the given index.

◆ getTemplateParametersCount()

RFK_NODISCARD REFUREKU_API std::size_t rfk::ClassTemplate::getTemplateParametersCount ( ) const
noexcept

Get the number of template parameters for this class template.

Returns
The number of template parameters for this class template.

◆ registerTemplateInstantiation()

REFUREKU_API void rfk::ClassTemplate::registerTemplateInstantiation ( ClassTemplateInstantiation const &  inst)
noexcept

Register an instantiation of this class template.

Parameters
instThe instantiation to register.

◆ unregisterTemplateInstantiation()

REFUREKU_API void rfk::ClassTemplate::unregisterTemplateInstantiation ( ClassTemplateInstantiation const &  inst)
noexcept

Unregister an instantiation of this class template.

Parameters
instThe instantiation to unregister.

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