// Copyright (C) 2015 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp #include #include namespace Ndk { template Component::Component() : BaseComponent(GetComponentIndex()) { } template Component::~Component() = default; template BaseComponent* Component::Clone() const { ///FIXME: Pas encore supporté par GCC (4.9.2) //static_assert(std::is_trivially_copy_constructible::value, "ComponentType must be copy-constructible"); return new ComponentType(static_cast(*this)); } template ComponentIndex Component::RegisterComponent(ComponentId id) { // Il faut que notre composant possède un constructeur par défaut (pour la factory) static_assert(std::is_default_constructible::value, "ComponentType must be default-constructible"); // On utilise les lambda pour créer une fonction factory auto factory = []() -> BaseComponent* { return new ComponentType; }; return BaseComponent::RegisterComponent(id, factory); } template template ComponentIndex Component::RegisterComponent(const char (&name)[N]) { // 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); return RegisterComponent(id); } }