Cogs.Foundation
Loading...
Searching...
No Matches
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 >
Tget (size_t index=0)
 Get the stored value of the given type, with an optional index.
 
template<typename T >
const Tget (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

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.

◆ 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.

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.

References Cogs::T.

◆ get() [2/2]

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

See non-const get() implementation.

References Cogs::T.

◆ getGenericType()

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

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

◆ getType()

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

Get the type of the derived attribute class.

◆ isRuntime()

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

Gets value of the runtime attribute flag.


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