1#include "ReflectionFunctions.h"
3#include "Foundation/Logging/Logger.h"
4#include "Foundation/Reflection/TypeDatabase.h"
13int getTypeId(
const char * name)
17 if (!type.isValid()) {
18 LOG_WARNING(logger,
"Type %s does not exist.", name);
21 return static_cast<int>(type.getTypeId());
24int getBaseTypeId(
const int typeId)
29 auto base = type.getBase();
31 return static_cast<int>(base ? base->getTypeId() :
NoType);
34const char * getTypeName(
const int typeId)
40const char * getFieldName(
const int componentTypeId,
const int fieldId)
42 assert(componentTypeId !=
NoType);
46 return type.getField(
static_cast<FieldId
>(fieldId))->getName().c_str();
49int getNumFields(
const int componentTypeId)
51 assert(componentTypeId !=
NoType);
54 return static_cast<int>(type.getNumFields());
57int getNumHierarchyFields(
const int componentTypeId)
59 assert(componentTypeId !=
NoType);
62 return static_cast<int>(type.getNumHierarchyFields());
65int getFieldType(
const int componentTypeId,
const int fieldId)
67 assert(componentTypeId !=
NoType);
71 return static_cast<int>(type.getField(
static_cast<FieldId
>(fieldId))->getTypeId());
74int getFieldId(
const int componentTypeId,
const char * name)
76 assert(componentTypeId !=
NoType);
79 auto field = componentType.getField(name);
82 LOG_WARNING(logger,
"Field \"%s\" does not exist in %s.", name, componentType.getName().c_str());
87 FieldId fieldId = componentType.getFieldId(field);
89 return static_cast<int>(fieldId);
Log implementation class.
static const Type & getType()
Get the Type of the given template argument.
constexpr const Name & getName() const
Get the unique name of the type.
Provides a weakly referenced view over the contents of a string.
constexpr Log getLogger(const char(&name)[LEN]) noexcept
Contains reflection support.
uint16_t TypeId
Built in type used to uniquely identify a single type instance.
constexpr FieldId NoField
No field id.
constexpr TypeId NoType
Definition of no type.
const char * c_str() const
Gets the name as a null-terminated string.