Cogs.Foundation
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
Cogs::Reflection::Field Class Reference

Field definition describing a single data member of a data structure. More...

#include <Field.h>

Public Member Functions

template<typename ClassType , typename FieldType >
 Field (const Name &name, FieldType ClassType::*field)
 Initializes a new field instance with the given name and the given pointer to member data.
 
 Field (const Field &other)=default
 Default copy constructor.
 
 Field (Field &&other) noexcept=default
 Default move constructor.
 
Fieldoperator= (const Field &other)=default
 Default copy assignment operator.
 
Fieldoperator= (Field &&other) noexcept=default
 Default move assignment operator.
 
template<typename FieldValueType >
FieldValueType * getPtr (void *container) const
 Get a pointer to this field on the given container.
 
template<typename FieldValueType >
const FieldValueType * getPtr (const void *container) const
 Get a const pointer to this field on the given container.
 
const NamegetName () const
 Get the name of the field.
 
TypeId getTypeId () const
 Get the type id of the field.
 
size_t getOffset () const
 Get the fields offset from the start of the structure in bytes.
 
FieldFlags getFlags () const
 Get the field flags.
 
bool isSet (FieldFlags flag) const
 Checks if the given flag(s) is set. Requires exact bit match if test of several bits.
 
size_t getDimensions () const
 Get the array dimensions of the field. Returns zero if the field is not an array.
 
FieldsetSerialize (bool serialize)
 Mark if field shall be serializable, e.g. value saved generating Scene. Default = true.
 
template<typename T >
Fieldadd (T attribute)
 Adds the given attribute.
 
template<typename T >
const Tget () const
 Retrieve an attribute of the given type from storage, if present.
 

Static Public Member Functions

template<typename ClassType , typename FieldType >
static FieldWrapper< Field, FieldType > create (const Name &name, FieldType ClassType::*field)
 Creates a new field instance, returning a wrapper for type safe continuation style setup.
 

Private Member Functions

void unsetFlag (FieldFlags flag)
 

Private Attributes

Attributes attributes
 Attribute storage.
 
FieldFlags fieldFlags = FieldFlags::Default
 Flags.
 
Name name
 Name of the field.
 
size_t offset
 Offset of the field in bytes from the beginning of the container.
 
size_t byteSize
 Size of the field in bytes.
 
size_t arrayDimensions = 0
 Dimensions.
 
TypeId typeId
 Type id of the field.
 

Detailed Description

Field definition describing a single data member of a data structure.

Constructor & Destructor Documentation

◆ Field() [1/3]

template<typename ClassType , typename FieldType >
Cogs::Reflection::Field::Field ( const Name name,
FieldType ClassType::*  field 
)

Initializes a new field instance with the given name and the given pointer to member data.

Template Parameters
ClassTypeType of the class the field resides in.
FieldTypeType of the field data.
Parameters
nameName of the field to use for lookup.
fieldMember pointer to the given field.

References Cogs::Reflection::Array, arrayDimensions, fieldFlags, and Cogs::Reflection::Pointer.

◆ Field() [2/3]

Cogs::Reflection::Field::Field ( const Field other)
default

Default copy constructor.

◆ Field() [3/3]

Cogs::Reflection::Field::Field ( Field &&  other)
defaultnoexcept

Default move constructor.

Member Function Documentation

◆ add()

template<typename T >
Field & Cogs::Reflection::Field::add ( T  attribute)
inline

◆ create()

template<typename ClassType , typename FieldType >
FieldWrapper< Field, FieldType > Cogs::Reflection::Field::create ( const Name name,
FieldType ClassType::*  field 
)
static

Creates a new field instance, returning a wrapper for type safe continuation style setup.

See also
Field::Field()

References name.

◆ get()

template<typename T >
const T * Cogs::Reflection::Field::get ( ) const
inline

Retrieve an attribute of the given type from storage, if present.

See also
Attributes::get()

References Cogs::T.

◆ getDimensions()

size_t Cogs::Reflection::Field::getDimensions ( ) const
inline

Get the array dimensions of the field. Returns zero if the field is not an array.

◆ getFlags()

FieldFlags Cogs::Reflection::Field::getFlags ( ) const
inline

Get the field flags.

◆ getName()

const Name & Cogs::Reflection::Field::getName ( ) const
inline

Get the name of the field.

◆ getOffset()

size_t Cogs::Reflection::Field::getOffset ( ) const
inline

Get the fields offset from the start of the structure in bytes.

◆ getPtr() [1/2]

template<typename FieldValueType >
const FieldValueType * Cogs::Reflection::Field::getPtr ( const void *  container) const
inline

Get a const pointer to this field on the given container.

Parameters
containerField container, e.g. component
Template Parameters
FieldValueTypeThe type of the field.

◆ getPtr() [2/2]

template<typename FieldValueType >
FieldValueType * Cogs::Reflection::Field::getPtr ( void *  container) const
inline

Get a pointer to this field on the given container.

Parameters
containerField container, e.g. component
Template Parameters
FieldValueTypeThe type of the field.

◆ getTypeId()

TypeId Cogs::Reflection::Field::getTypeId ( ) const
inline

Get the type id of the field.

◆ isSet()

bool Cogs::Reflection::Field::isSet ( FieldFlags  flag) const
inline

Checks if the given flag(s) is set. Requires exact bit match if test of several bits.

◆ operator=() [1/2]

Field & Cogs::Reflection::Field::operator= ( const Field other)
default

Default copy assignment operator.

◆ operator=() [2/2]

Field & Cogs::Reflection::Field::operator= ( Field &&  other)
defaultnoexcept

Default move assignment operator.

◆ setSerialize()

Field & Cogs::Reflection::Field::setSerialize ( bool  serialize)
inline

Mark if field shall be serializable, e.g. value saved generating Scene. Default = true.

◆ unsetFlag()

void Cogs::Reflection::Field::unsetFlag ( FieldFlags  flag)
inlineprivate

Member Data Documentation

◆ arrayDimensions

size_t Cogs::Reflection::Field::arrayDimensions = 0
private

Dimensions.

Referenced by Field().

◆ attributes

Attributes Cogs::Reflection::Field::attributes
private

Attribute storage.

◆ byteSize

size_t Cogs::Reflection::Field::byteSize
private

Size of the field in bytes.

◆ fieldFlags

FieldFlags Cogs::Reflection::Field::fieldFlags = FieldFlags::Default
private

Flags.

Referenced by Field().

◆ name

Name Cogs::Reflection::Field::name
private

Name of the field.

Referenced by create().

◆ offset

size_t Cogs::Reflection::Field::offset
private

Offset of the field in bytes from the beginning of the container.

◆ typeId

TypeId Cogs::Reflection::Field::typeId
private

Type id of the field.


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