53 : type(type), genericType(genericType), runtime(runtime)
55 std::memset(storage, 0,
sizeof(storage));
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;
#define COGSFOUNDATION_API
Definition: FoundationBase.h:31
Field definition describing a single data member of a data structure.
Definition: Field.h:70
uint16_t TypeId
Built in type used to uniquely identify a single type instance.
Definition: Name.h:48
constexpr TypeId NoType
Definition of no type.
Definition: Name.h:51
Main Cogs namespace.
Definition: MortonCode.h:5
An attribute containing metadata or describing behavior of a structure.
Definition: Attributes.h:25
Attribute(TypeId type)
Constructs an attribute instance with the given type.
Definition: Attributes.h:43
const T & get(size_t index=0) const
See non-const get() implementation.
Definition: Attributes.h:80
TypeId getGenericType() const
Definition: Attributes.h:32
bool isRuntime() const
Gets value of the runtime attribute flag.
Definition: Attributes.h:35
T & get(size_t index=0)
Get the stored value of the given type, with an optional index.
Definition: Attributes.h:71
TypeId getType() const
Get the type of the derived attribute class.
Definition: Attributes.h:28
Attribute(TypeId type, TypeId genericType, bool runtime=true)
Constructs a generic attribute instance with the given type and generic type parameter.
Definition: Attributes.h:52
Attribute storage for structures.
Definition: Attributes.h:130
Field & add(Field &field, T &attribute)
Add the given attribute to the attribute storage, with the given field as continuation parameter.
Definition: Attributes.h:155
const T * get() const
Retrieve an attribute of the given type from storage, if present.
Definition: Attributes.h:172
void add(T &attribute)
Add the given attribute to the attribute storage.
Definition: Attributes.h:139
Base attribute type for generic attributes.
Definition: Attributes.h:119
GenericAttribute(bool runtime=true)
Construct a generic attribute. True if runtime attribute.
Base attribute type for regular attributes.
Definition: Attributes.h:104
RegularAttribute(bool runtime=true)
Construct a regular attribute. True if runtime attribute.