(NDK) Modified component/system registration interface

Let's hope it's the last time I do this


Former-commit-id: 75f8e63e90e067a7d21efa6a1226ae4bbe050ab9
This commit is contained in:
Lynix
2015-04-05 15:57:24 +02:00
parent 28b0e26a88
commit 6a99b38be1
8 changed files with 52 additions and 33 deletions

View File

@@ -3,8 +3,6 @@
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
#include <Nazara/Core/Error.hpp>
#include <Ndk/Algorithm.hpp>
#include <type_traits>
namespace Ndk
{
@@ -18,25 +16,7 @@ namespace Ndk
return m_componentIndex;
}
template<typename ComponentType, unsigned int N>
ComponentIndex BaseComponent::Register(const char (&name)[N])
{
// Il faut que notre composant possède un constructeur par défaut (pour la factory)
static_assert(std::is_default_constructible<ComponentType>::value, "ComponentType should be default-constructible");
// On récupère la chaîne de caractère sous la forme d'un nombre qui servira d'identifiant unique
ComponentId id = BuildComponentId(name);
// On utilise les lambda pour créer une fonction factory
auto factory = []() -> BaseComponent*
{
return new ComponentType;
};
return Register(id, factory);
}
inline ComponentIndex BaseComponent::Register(ComponentId id, Factory factoryFunc)
inline ComponentIndex BaseComponent::RegisterComponent(ComponentId id, Factory factoryFunc)
{
// Nous allons rajouter notre composant à la fin
ComponentIndex index = s_entries.size();