|
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. | |
| template<typename FieldType > | |
| Field (const Name &name, const FieldType &dummy, size_t off) | |
| Initializes a new field instance with the given name and the given offset 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. | |
| Field & | setCodeGen (bool codegen) |
| Mark if field shall have plumbing code generated. 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.
| Cogs::Reflection::Field::Field | ( | const Name & | name, |
| const FieldType & | dummy, | ||
| size_t | off | ||
| ) |
Initializes a new field instance with the given name and the given offset to member data.
| FieldType | Type of the field data. |
| name | Name of the field to use for lookup. |
| dummy | Dummy reference to confuse the compiler into understanding what FieldType actually is. (This is needed because initialising arrays of Fields will not compile because the compiler is unable to deduce the correct constructor and refuses to let you manually specify the type as a template argument.) |
| off | Byte offset of the field in question. |
Definition at line 29 of file Field.inl.
References Cogs::Reflection::Array, arrayDimensions, fieldFlags, and Cogs::Reflection::Pointer.
|
inline |
Adds the given attribute.
Definition at line 208 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 47 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 166 of file Field.h.
Referenced by Cogs::Core::writeEntity().
|
inline |
Get the name of the field.
Definition at line 154 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 130 of file Field.h.
Referenced by Cogs::Core::writeEntity().
|
inline |
Get the type id of the field.
Definition at line 158 of file Field.h.
Referenced by Cogs::Core::applyFieldValues(), and Cogs::Core::writeEntity().
|
inline |
|
inline |
|
inline |
Mark if field shall be serializable, e.g. value saved generating Scene. Default = true.
Definition at line 177 of file Field.h.
Referenced by Cogs::Core::CameraComponent::registerType().
|
inlineprivate |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |