From 3f423239f57133e5f9b2a1bf1f0c6babc843f90f Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 2 May 2015 21:03:30 +0200 Subject: [PATCH] Ndk/Algorithm: Added Is[Component|System] function Former-commit-id: 946f5081cea0b8df7faf0e95cfea2a3e5dd9f7bb --- SDK/include/NDK/Algorithm.hpp | 5 +++++ SDK/include/NDK/Algorithm.inl | 14 ++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/SDK/include/NDK/Algorithm.hpp b/SDK/include/NDK/Algorithm.hpp index c98e63c6c..7c8de5a31 100644 --- a/SDK/include/NDK/Algorithm.hpp +++ b/SDK/include/NDK/Algorithm.hpp @@ -11,11 +11,16 @@ namespace Ndk { + class BaseComponent; + class BaseSystem; + template ComponentId BuildComponentId(const char (&name)[N]); template constexpr ComponentIndex GetComponentIndex(); template constexpr SystemIndex GetSystemIndex(); template ComponentIndex InitializeComponent(const char (&name)[N]); template SystemIndex InitializeSystem(); + template bool IsComponent(BaseComponent& component); + template bool IsSystem(BaseSystem& system); } #include diff --git a/SDK/include/NDK/Algorithm.inl b/SDK/include/NDK/Algorithm.inl index 2f2586868..8392e0ed6 100644 --- a/SDK/include/NDK/Algorithm.inl +++ b/SDK/include/NDK/Algorithm.inl @@ -3,6 +3,8 @@ // For conditions of distribution and use, see copyright notice in Prerequesites.hpp #include +#include +#include namespace Ndk { @@ -44,4 +46,16 @@ namespace Ndk SystemType::systemIndex = SystemType::RegisterSystem(); return SystemType::systemIndex; } + + template + bool IsComponent(BaseComponent& component) + { + return component.GetIndex() == GetComponentIndex(); + } + + template + bool IsSystem(BaseSystem& system) + { + return system.GetIndex() == GetSystemIndex(); + } }