Cogs.Core
Attributes.inl
1#pragma once
2
3#include "TypeDatabase.h"
4
5// \cond
6
7namespace Cogs
8{
9 namespace Reflection
10 {
11 template<template<typename> class T, typename U>
13 : Attribute(TypeDatabase::getType<T<U>>().getTypeId(), TypeDatabase::getType<U>().getTypeId(), runtime)
14 {
15
16 }
17
18 template<typename T>
19 inline RegularAttribute<T>::RegularAttribute(bool runtime)
20 : Attribute(TypeDatabase::getType<T>().getTypeId(), NoType, runtime)
21 {
22
23 }
24
25 template<typename T>
26 inline const Attribute * Attributes::getAttribute(RegularAttribute<T> *) const
27 {
28 return getAttributeByTypeId(TypeDatabase::getType<T>().getTypeId());
29 }
30
31 template<template<typename> class T, typename U>
32 inline const Attribute * Attributes::getAttribute(GenericAttribute<T, U> *) const
33 {
34 return getAttributeByTypeId(TypeDatabase::getType<T<U>>().getTypeId(), TypeDatabase::getType<U>().getTypeId());
35 }
36
37 inline const Attribute * Attributes::getAttributeByTypeId(TypeId typeId, TypeId genericTypeId) const
38 {
39 for (auto & a : attributes) {
40 if (a.getType() == typeId && a.getGenericType() == genericTypeId) {
41 return &a;
42 }
43 }
44
45 return nullptr;
46 }
47 }
48}
49
50// \endcond
constexpr TypeId NoType
Definition of no type.
Definition: Name.h:51
Contains all Cogs related functionality.
Definition: FieldSetter.h:23
GenericAttribute(bool runtime=true)
Construct a generic attribute. True if runtime attribute.