Re-remade component and system ids

Former-commit-id: 98b76695cca904c55c7333801c3cdf693da15086
This commit is contained in:
Lynix
2015-03-30 04:18:44 +02:00
parent 3fd217b8a3
commit 6d1ac4fe18
17 changed files with 196 additions and 126 deletions

View File

@@ -8,38 +8,26 @@ namespace Ndk
{
///TODO: constexpr avec le C++14
template<unsigned int N>
ComponentId BuildComponentId(const char (&id)[N])
ComponentId BuildComponentId(const char (&name)[N])
{
static_assert(N-1 <= sizeof(ComponentId), "ID too long for this size of component id");
static_assert(N-1 <= sizeof(ComponentId), "Name too long for this size of component id");
ComponentId componentId = 0;
for (int i = 0; i < N; ++i)
componentId |= static_cast<ComponentId>(id[i]) << i*8;
return componentId;
}
template<unsigned int N>
SystemId BuildSystemId(const char (&id)[N])
{
static_assert(N-1 <= sizeof(ComponentId), "ID too long for this size of component id");
ComponentId componentId = 0;
for (int i = 0; i < N; ++i)
componentId |= static_cast<ComponentId>(id[i]) << i*8;
componentId |= static_cast<ComponentId>(name[i]) << i*8;
return componentId;
}
template<typename ComponentType>
constexpr ComponentId GetComponentId()
constexpr ComponentIndex GetComponentIndex()
{
return ComponentType::ComponentId;
return ComponentType::ComponentIndex;
}
template<typename SystemType>
constexpr SystemId GetSystemId()
constexpr SystemIndex GetSystemIndex()
{
return SystemType::SystemId;
return SystemType::SystemIndex;
}
}