Cogs.Core
Public Member Functions | Protected Member Functions | List of all members
Cogs::Reflection::Attribute Struct Reference

An attribute containing metadata or describing behavior of a structure. More...

#include <Attributes.h>

Inheritance diagram for Cogs::Reflection::Attribute:
Cogs::Reflection::GenericAttribute< DefaultValueAttribute, T > Cogs::Reflection::GenericAttribute< RangeAttribute, T > Cogs::Reflection::GenericAttribute< StepSizeAttribute, T > Cogs::Reflection::RegularAttribute< ColorAttribute > Cogs::Reflection::RegularAttribute< DescriptionAttribute > Cogs::Reflection::RegularAttribute< SerializableAttribute > Cogs::Reflection::GenericAttribute< T, U > Cogs::Reflection::RegularAttribute< T >

Public Member Functions

TypeId getType () const
 Get the type of the derived attribute class.
 
TypeId getGenericType () const
 
bool isRuntime () const
 Gets value of the runtime attribute flag.
 

Protected Member Functions

 Attribute (TypeId type)
 Constructs an attribute instance with the given type.
 
 Attribute (TypeId type, TypeId genericType, bool runtime=true)
 Constructs a generic attribute instance with the given type and generic type parameter.
 
template<typename T >
T & get (size_t index=0)
 Get the stored value of the given type, with an optional index.
 
template<typename T >
const T & get (size_t index=0) const
 See non-const get() implementation.
 

Detailed Description

An attribute containing metadata or describing behavior of a structure.

Attributes can be used to store arbitrary metadata on a structure. The base attribute class is designed to offer data storage and type information for derived attributes.

Derived types shall not have local storage.

See also
Attributes

Definition at line 24 of file Attributes.h.

Constructor & Destructor Documentation

◆ Attribute() [1/2]

Cogs::Reflection::Attribute::Attribute ( TypeId  type)
inlineprotected

Constructs an attribute instance with the given type.

Parameters
typeType id of the derived attribute type.

Definition at line 43 of file Attributes.h.

◆ Attribute() [2/2]

Cogs::Reflection::Attribute::Attribute ( TypeId  type,
TypeId  genericType,
bool  runtime = true 
)
inlineprotected

Constructs a generic attribute instance with the given type and generic type parameter.

Parameters
typeType id of the derived attribute type.
genericTypeType id of the derived attributes template value type.
runtimebool True if the attribute can be used for runtime information, false if code-generation.

Definition at line 52 of file Attributes.h.

Member Function Documentation

◆ get() [1/2]

template<typename T >
T & Cogs::Reflection::Attribute::get ( size_t  index = 0)
inlineprotected

Get the stored value of the given type, with an optional index.

If an index is given, the storage is assumed to contain an array of values of type T, and the index is used to look up the nth value.

Template Parameters
Typeof the value to retrieve.
Parameters
indexOptional array index of the value to retrieve.
Returns
A reference to the stored value.

Definition at line 71 of file Attributes.h.

◆ get() [2/2]

template<typename T >
const T & Cogs::Reflection::Attribute::get ( size_t  index = 0) const
inlineprotected

See non-const get() implementation.

Definition at line 80 of file Attributes.h.

◆ getGenericType()

TypeId Cogs::Reflection::Attribute::getGenericType ( ) const
inline

Gets an optional generic type parameter when the derived attribute class is a template.

Definition at line 32 of file Attributes.h.

◆ getType()

TypeId Cogs::Reflection::Attribute::getType ( ) const
inline

Get the type of the derived attribute class.

Definition at line 28 of file Attributes.h.

◆ isRuntime()

bool Cogs::Reflection::Attribute::isRuntime ( ) const
inline

Gets value of the runtime attribute flag.

Definition at line 35 of file Attributes.h.


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