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

Public Member Functions

REFUREKU_API Enum (char const *name, std::size_t id, Archetype const *underlyingArchetype, Entity const *outerEntity=nullptr) noexcept
 
RFK_NODISCARD REFUREKU_API EnumValue const * getEnumValueByName (char const *name) const noexcept
 Search an enum value by name in this enum. More...
 
RFK_NODISCARD REFUREKU_API EnumValue const * getEnumValue (int64 value) const noexcept
 Search an enum value by value in this enum. More...
 
RFK_NODISCARD REFUREKU_API EnumValue const * getEnumValueByPredicate (Predicate< EnumValue > predicate, void *userData) const
 Retrieve from this enum the first enum value matching with a given predicate. More...
 
RFK_NODISCARD REFUREKU_API Vector< EnumValue const * > getEnumValues (int64 value) const noexcept
 Search all enum values in this enum holding the provided value. More...
 
RFK_NODISCARD REFUREKU_API Vector< EnumValue const * > getEnumValuesByPredicate (Predicate< EnumValue > predicate, void *userData) const
 Retrieve from this enum all enum values matching with a given predicate. More...
 
RFK_NODISCARD REFUREKU_API EnumValue const & getEnumValueAt (std::size_t valueIndex) const noexcept
 Get the enum value located at the provided index in the enum. If valueIndex is greater or equal to the enum values count, the behaviour is undefined. More...
 
RFK_NODISCARD REFUREKU_API std::size_t getEnumValuesCount () const noexcept
 Get the number of enum values contained in this enum. More...
 
RFK_NODISCARD REFUREKU_API Archetype const & getUnderlyingArchetype () const noexcept
 Get the type this enum is based on. More...
 
REFUREKU_API bool foreachEnumValue (Visitor< EnumValue > visitor, void *userData) const
 Execute the given visitor on all enum values in this enum. More...
 
REFUREKU_API EnumValueaddEnumValue (char const *name, std::size_t id, int64 value) noexcept
 Add an enum value to this enum. More...
 
REFUREKU_API void setEnumValuesCapacity (std::size_t capacity) noexcept
 Set the number of enum values for this entity. Useful to avoid reallocations when adding a lot of enum values. If the number of enum values is already >= to the provided capacity, this method has no effect. 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::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

◆ addEnumValue()

REFUREKU_API EnumValue * rfk::Enum::addEnumValue ( char const *  name,
std::size_t  id,
int64  value 
)
noexcept

Add an enum value to this enum.

Parameters
nameName of the enum value.
idUnique entity id of the added enum value.
valueInteger value of the enum value.
Returns
A pointer to the added enum value. If any of the parameters is unvalid, no enum value is added and nullptr is returned.

◆ foreachEnumValue()

REFUREKU_API bool rfk::Enum::foreachEnumValue ( Visitor< EnumValue visitor,
void *  userData 
) const

Execute the given visitor on all enum values in this enum.

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.

◆ getEnumValue()

RFK_NODISCARD REFUREKU_API EnumValue const * rfk::Enum::getEnumValue ( int64  value) const
noexcept

Search an enum value by value in this enum.

Parameters
valueNumerical value of the EnumValue to look for.
Returns
The first found EnumValue equals to the provided value if any, else nullptr.

◆ getEnumValueAt()

RFK_NODISCARD REFUREKU_API EnumValue const & rfk::Enum::getEnumValueAt ( std::size_t  valueIndex) const
noexcept

Get the enum value located at the provided index in the enum. If valueIndex is greater or equal to the enum values count, the behaviour is undefined.

Parameters
valueIndexIndex of the enum value to get.
Returns
The enum values at the provided index.

◆ getEnumValueByName()

RFK_NODISCARD REFUREKU_API EnumValue const * rfk::Enum::getEnumValueByName ( char const *  name) const
noexcept

Search an enum value by name in this enum.

Parameters
nameName of the enum value to look for.
Returns
The EnumValue having the provided name if any, else nullptr.

◆ getEnumValueByPredicate()

RFK_NODISCARD REFUREKU_API EnumValue const * rfk::Enum::getEnumValueByPredicate ( Predicate< EnumValue predicate,
void *  userData 
) const

Retrieve from this enum the first enum value matching with a given predicate.

Parameters
predicatePredicate returning true for any matching enum value.
userDataOptional data forwarded to the predicate.
Returns
The first matching enum value if any is found, else nullptr.
Exceptions
Anyexception potentially thrown from the provided predicate.

◆ getEnumValues()

RFK_NODISCARD REFUREKU_API Vector< EnumValue const * > rfk::Enum::getEnumValues ( int64  value) const
noexcept

Search all enum values in this enum holding the provided value.

Parameters
valueNumerical value of the EnumValues to look for.
Returns
All the EnumValues equal to the provided value.

◆ getEnumValuesByPredicate()

RFK_NODISCARD REFUREKU_API Vector< EnumValue const * > rfk::Enum::getEnumValuesByPredicate ( Predicate< EnumValue predicate,
void *  userData 
) const

Retrieve from this enum all enum values matching with a given predicate.

Parameters
predicatePredicate returning true for any matching enum value.
userDataOptional data forwarded to the predicate.
Returns
All the enum values matching with the given predicate.
Exceptions
Anyexception potentially thrown from the provided predicate.

◆ getEnumValuesCount()

RFK_NODISCARD REFUREKU_API std::size_t rfk::Enum::getEnumValuesCount ( ) const
noexcept

Get the number of enum values contained in this enum.

Returns
The number of enum values contained in this enum.

◆ getUnderlyingArchetype()

RFK_NODISCARD REFUREKU_API Archetype const & rfk::Enum::getUnderlyingArchetype ( ) const
noexcept

Get the type this enum is based on.

Returns
The type this enum is based on.

◆ setEnumValuesCapacity()

REFUREKU_API void rfk::Enum::setEnumValuesCapacity ( std::size_t  capacity)
noexcept

Set the number of enum values for this entity. Useful to avoid reallocations when adding a lot of enum values. If the number of enum values is already >= to the provided capacity, this method has no effect.

Parameters
propertiesCapacityThe number of enum values in this enum.

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