Refureku v2.2.0
C++17 runtime reflection library.
rfk::Entity Class Reference
Inheritance diagram for rfk::Entity:
rfk::Archetype rfk::EnumValue rfk::FunctionBase rfk::FunctionParameter rfk::Namespace rfk::NamespaceFragment rfk::VariableBase rfk::Enum rfk::FundamentalArchetype rfk::Struct rfk::Function rfk::MethodBase rfk::FieldBase rfk::Variable rfk::ClassTemplate rfk::ClassTemplateInstantiation rfk::Method rfk::StaticMethod rfk::Field rfk::StaticField

Public Member Functions

 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
 

Protected Member Functions

REFUREKU_INTERNAL Entity (Entity &&) noexcept
 
REFUREKU_INTERNAL Entity (EntityImpl *implementation) noexcept
 

Member Function Documentation

◆ addProperty()

REFUREKU_API bool rfk::Entity::addProperty ( Property const &  property)
noexcept

Add a property to this entity.

Parameters
propertyThe property to add.
Returns
true if the property was added, false if it failed to be added (allow multiple is false and the property is already in the entity for example).

◆ foreachProperty()

REFUREKU_API bool rfk::Entity::foreachProperty ( Visitor< Property visitor,
void *  userData 
) const

Execute the given visitor on all properties attached to this entity.

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.

◆ getId()

RFK_NODISCARD REFUREKU_API std::size_t rfk::Entity::getId ( ) const
noexcept

Get the program-unique id of the entity.

Returns
The program-unique id of the entity.

◆ getKind()

RFK_NODISCARD REFUREKU_API EEntityKind rfk::Entity::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.

Returns
The kind of the entity.

◆ getName()

RFK_NODISCARD REFUREKU_API char const * rfk::Entity::getName ( ) const
noexcept

Get the name of the entity.

Returns
The name of the entity.

◆ getOuterEntity()

RFK_NODISCARD REFUREKU_API Entity const * rfk::Entity::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.

Returns
The outer entity of the entity.

◆ getProperties() [1/2]

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 * > rfk::Entity::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.

Template Parameters
PropertyTypeType of the properties to retrieve. It must inherit from rfk::Property.
Parameters
isChildClassValidIf true, consider properties inheriting from the provided property type valid.
Returns
A collection of all properties matching the provided property type in this entity.

◆ getProperties() [2/2]

RFK_NODISCARD REFUREKU_API Vector< Property const * > rfk::Entity::getProperties ( Struct const &  archetype,
bool  isChildClassValid = true 
) const
noexcept

Retrieve all properties matching with the provided archetype.

Parameters
archetypeArchetype of the properties to look for.
isChildClassValidIf true, all properties inheriting from the provided archetype will be included in the result.
Returns
A collection of all properties matching the provided archetype in this entity.

◆ getPropertiesByName()

RFK_NODISCARD REFUREKU_API Vector< Property const * > rfk::Entity::getPropertiesByName ( char const *  name) const
noexcept

Retrieve all properties named with the provided name.

Parameters
nameName of the properties to retrieve.
Returns
A collection of all properties named with the provided name.

◆ getPropertiesByPredicate()

RFK_NODISCARD REFUREKU_API Vector< Property const * > rfk::Entity::getPropertiesByPredicate ( Predicate< Property predicate,
void *  userData 
) const

Retrieve all properties matching with a predicate in this entity.

Parameters
predicatePredicate returning true for any matching property.
userDataOptional data forwarded to the predicate.
Returns
A collection of all properties fulfilling the provided predicate contained in this entity.
Exceptions
Anyexception potentially thrown from the provided predicate.

◆ getPropertiesCount()

RFK_NODISCARD REFUREKU_API std::size_t rfk::Entity::getPropertiesCount ( ) const
noexcept

Get the number of properties attached to this entity.

Returns
The number of properties attached to this entity.

◆ getProperty() [1/2]

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 * rfk::Entity::getProperty ( bool  isChildClassValid = true) const
noexcept

Retrieve a property of a given type from this entity.

Template Parameters
PropertyTypeType of the property to retrieve. It must inherit from rfk::Property. If PropertyType uses multiple inheritance, its first inherited type must be rfk::Property or derived.
Parameters
isChildClassValidIf true, consider properties inheriting from the provided property type valid.
Returns
The first found property of type PropertyType if any, else nullptr.

◆ getProperty() [2/2]

RFK_NODISCARD REFUREKU_API Property const * rfk::Entity::getProperty ( Struct const &  archetype,
bool  isChildClassValid = true 
) const
noexcept

Retrieve the first property matching with the provided archetype.

Parameters
archetypeArchetype of the property to look for.
isChildClassValidIf true, consider properties inheriting from the provided archetype valid.
Returns
The first property matching the provided archetype in this entity, nullptr if none is found.

◆ getPropertyAt()

RFK_NODISCARD REFUREKU_API Property const * rfk::Entity::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.

Parameters
propertyIndexIndex of the property to retrieve in this entity.
Returns
The property at the given index.

◆ getPropertyByName()

RFK_NODISCARD REFUREKU_API Property const * rfk::Entity::getPropertyByName ( char const *  name) const
noexcept

Retrieve the first property named with the provided name.

Parameters
nameName of the property to retrieve.
Returns
The first property named with the provided name if any, else nullptr.

◆ getPropertyByPredicate()

RFK_NODISCARD REFUREKU_API Property const * rfk::Entity::getPropertyByPredicate ( Predicate< Property predicate,
void *  userData 
) const

Retrieve a property matching with a predicate.

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

◆ hasSameName()

RFK_NODISCARD REFUREKU_API bool rfk::Entity::hasSameName ( char const *  name) const
noexcept

Check that this entity has the same name as the provided string.

Returns
true if this entity has the same name as the provided string. If the provided name is nullptr, return false.

◆ setOuterEntity()

REFUREKU_API void rfk::Entity::setOuterEntity ( Entity const *  outerEntity)
noexcept

Setter for the field _outerEntity.

Parameters
outerEntityThe outer entity to set.

◆ setPropertiesCapacity()

REFUREKU_API void rfk::Entity::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.

Parameters
capacityThe number of properties of this entity.

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