Ndk/Algorithm: Added Is[Component|System] function

Former-commit-id: 946f5081cea0b8df7faf0e95cfea2a3e5dd9f7bb
This commit is contained in:
Lynix 2015-05-02 21:03:30 +02:00
parent 3b8449ebc4
commit 3f423239f5
2 changed files with 19 additions and 0 deletions

View File

@ -11,11 +11,16 @@
namespace Ndk
{
class BaseComponent;
class BaseSystem;
template<unsigned int N> ComponentId BuildComponentId(const char (&name)[N]);
template<typename ComponentType> constexpr ComponentIndex GetComponentIndex();
template<typename SystemType> constexpr SystemIndex GetSystemIndex();
template<typename ComponentType, unsigned int N> ComponentIndex InitializeComponent(const char (&name)[N]);
template<typename SystemType> SystemIndex InitializeSystem();
template<typename ComponentType> bool IsComponent(BaseComponent& component);
template<typename SystemType> bool IsSystem(BaseSystem& system);
}
#include <Ndk/Algorithm.inl>

View File

@ -3,6 +3,8 @@
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
#include <Nazara/Core/Endianness.hpp>
#include <Ndk/BaseComponent.hpp>
#include <Ndk/BaseSystem.hpp>
namespace Ndk
{
@ -44,4 +46,16 @@ namespace Ndk
SystemType::systemIndex = SystemType::RegisterSystem();
return SystemType::systemIndex;
}
template<typename ComponentType>
bool IsComponent(BaseComponent& component)
{
return component.GetIndex() == GetComponentIndex<ComponentType>();
}
template<typename SystemType>
bool IsSystem(BaseSystem& system)
{
return system.GetIndex() == GetSystemIndex<SystemType>();
}
}