53 : type(type), genericType(genericType), runtime(runtime)
55 std::memset(storage, 0,
sizeof(storage));
71 T &
get(
size_t index = 0)
73 return reinterpret_cast<T *
>(storage)[index];
80 const T &
get(
size_t index = 0)
const
82 return reinterpret_cast<const T *
>(storage)[index];
90 uint8_t storage[256 - (
sizeof(
TypeId) * 2) -
sizeof(bool)];
117 template<
template<
typename>
class T,
typename U>
141 attributes.push_back(attribute);
157 attributes.push_back(attribute);
174 return static_cast<const T *
>(getAttribute(
static_cast<T *
>(
nullptr)));
182 template<
template<
typename>
class T,
typename U>
187 std::vector<Attribute> attributes;
Field definition describing a single data member of a data structure.
uint16_t TypeId
Built in type used to uniquely identify a single type instance.
constexpr TypeId NoType
Definition of no type.
Contains all Cogs related functionality.
An attribute containing metadata or describing behavior of a structure.
Attribute(TypeId type)
Constructs an attribute instance with the given type.
const T & get(size_t index=0) const
See non-const get() implementation.
TypeId getGenericType() const
bool isRuntime() const
Gets value of the runtime attribute flag.
T & get(size_t index=0)
Get the stored value of the given type, with an optional index.
TypeId getType() const
Get the type of the derived attribute class.
Attribute(TypeId type, TypeId genericType, bool runtime=true)
Constructs a generic attribute instance with the given type and generic type parameter.
Attribute storage for structures.
Field & add(Field &field, T &attribute)
Add the given attribute to the attribute storage, with the given field as continuation parameter.
const T * get() const
Retrieve an attribute of the given type from storage, if present.
void add(T &attribute)
Add the given attribute to the attribute storage.
Base attribute type for generic attributes.
GenericAttribute(bool runtime=true)
Construct a generic attribute. True if runtime attribute.
Base attribute type for regular attributes.
RegularAttribute(bool runtime=true)
Construct a regular attribute. True if runtime attribute.