Cogs.Core
|
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. | |
Field & | operator= (const Field &other)=default |
Default copy assignment operator. | |
Field & | operator= (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 Name & | getName () 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. | |
Field & | setSerialize (bool serialize) |
Mark if field shall be serializable, e.g. value saved generating Scene. Default = true. | |
template<typename T > | |
Field & | add (T attribute) |
Adds the given attribute. | |
template<typename T > | |
const T * | get () 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. | |
Field definition describing a single data member of a data structure.
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.
ClassType | Type of the class the field resides in. |
FieldType | Type of the field data. |
name | Name of the field to use for lookup. |
field | Member pointer to the given field. |
Definition at line 11 of file Field.inl.
References Cogs::Reflection::Array, arrayDimensions, fieldFlags, and Cogs::Reflection::Pointer.
|
inline |
Adds the given attribute.
Definition at line 177 of file Field.h.
References add().
Referenced by add(), Cogs::Core::CameraComponent::registerType(), Cogs::Core::FogComponent::registerType(), Cogs::Reflection::FieldWrapper< T, U >::setDefault(), Cogs::Reflection::FieldWrapper< T, U >::setRange(), and Cogs::Reflection::FieldWrapper< T, U >::setStep().
|
static |
Creates a new field instance, returning a wrapper for type safe continuation style setup.
Definition at line 29 of file Field.inl.
References name.
Referenced by Cogs::Core::FogComponent::registerType(), and Cogs::Core::LightComponent::registerType().
|
inline |
Retrieve an attribute of the given type from storage, if present.
|
inline |
|
inline |
Get the field flags.
Definition at line 148 of file Field.h.
Referenced by Cogs::Core::writeEntity().
|
inline |
Get the name of the field.
Definition at line 136 of file Field.h.
Referenced by Cogs::Core::applyFieldValues(), and Cogs::Core::writeEntity().
|
inline |
|
inline |
|
inline |
Get a pointer to this field on the given container.
container | Field container, e.g. component |
FieldValueType | The type of the field. |
Definition at line 112 of file Field.h.
Referenced by Cogs::Core::writeEntity().
|
inline |
Get the type id of the field.
Definition at line 140 of file Field.h.
Referenced by Cogs::Core::applyFieldValues(), and Cogs::Core::writeEntity().
|
inline |
|
inline |
Mark if field shall be serializable, e.g. value saved generating Scene. Default = true.
Definition at line 159 of file Field.h.
Referenced by Cogs::Core::CameraComponent::registerType().
|
inlineprivate |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |