CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
CeresEngine::ReflectionAttributeContainer Class Reference

#include <CeresEngine/Reflection/MetaItem.hpp>

Public Types

using EnumerateFunction = FunctionView< bool(const Box &) const >
 A function that enumerates attributes of an item.
 

Public Member Functions

template<typename T >
bool has () const
 Checks if the item has the given attribute type.
 
bool has (const Type &type) const
 Checks if the item has the given attribute type.
 
template<typename T >
const T & get () const
 Gets an item attribute by type.
 
const Box & get (const Type &type) const
 Gets an item attribute by type.
 
template<typename T >
const T * getIf () const
 Gets an item attribute if it exists.
 
void set (const Type &type, Box &&value)
 Sets the attribute for the given type.
 
void set (Box &&value)
 Sets the attribute for the given type.
 
void forEach (const EnumerateFunction &func) const
 Calls the func function for each attribute present on the item.
 

Private Attributes

HashMap< TypeID, Box > mAttributes
 The underlying storage of the attributes.
 

Member Typedef Documentation

◆ EnumerateFunction

A function that enumerates attributes of an item.

Member Function Documentation

◆ forEach()

void CeresEngine::ReflectionAttributeContainer::forEach ( const EnumerateFunction &  func) const

Calls the func function for each attribute present on the item.

Parameters
funcThe function to be called for each of the attributes in the item.

◆ get() [1/2]

template<typename T >
const T & CeresEngine::ReflectionAttributeContainer::get ( ) const
inline

Gets an item attribute by type.

Template Parameters
TThe type of the attribute to be retrieved.
Returns
The item attribute; throws if there is no such attribute.

◆ get() [2/2]

const Box & CeresEngine::ReflectionAttributeContainer::get ( const Type &  type) const

Gets an item attribute by type.

Parameters
typeThe type of the attribute to be retrieved.
Returns
The item attribute; throws if there is no such attribute.

◆ getIf()

template<typename T >
const T * CeresEngine::ReflectionAttributeContainer::getIf ( ) const
inline

Gets an item attribute if it exists.

Template Parameters
TThe type of the attribute to be retrieved.
Returns
The item attribute; nullptr if not present.

◆ has() [1/2]

template<typename T >
bool CeresEngine::ReflectionAttributeContainer::has ( ) const
inline

Checks if the item has the given attribute type.

Template Parameters
TThe type of attribute to be checked if present.
Returns
True if an attribute of type T is present; false otherwise.

◆ has() [2/2]

bool CeresEngine::ReflectionAttributeContainer::has ( const Type &  type) const

Checks if the item has the given attribute type.

Parameters
typeThe type of attribute to be checked if present.
Returns
True if an attribute of type typeID is present; false otherwise.

◆ set() [1/2]

void CeresEngine::ReflectionAttributeContainer::set ( Box &&  value)

Sets the attribute for the given type.

◆ set() [2/2]

void CeresEngine::ReflectionAttributeContainer::set ( const Type &  type,
Box &&  value 
)

Sets the attribute for the given type.

Member Data Documentation

◆ mAttributes

HashMap<TypeID, Box> CeresEngine::ReflectionAttributeContainer::mAttributes
private

The underlying storage of the attributes.


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