(Component) Added clone virtual method
Replaced Component<C>::GetId by GetComponentId<C>() Former-commit-id: 4fae3f73c7fad0a5c36dae16e49b6f12c8bf6ae2
This commit is contained in:
@@ -2,11 +2,13 @@
|
||||
// This file is part of the "Nazara Development Kit"
|
||||
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
template<typename ComponentType>
|
||||
Component<ComponentType>::Component() :
|
||||
BaseComponent(GetId())
|
||||
BaseComponent(GetComponentId<ComponentType>())
|
||||
{
|
||||
}
|
||||
|
||||
@@ -14,7 +16,15 @@ namespace Ndk
|
||||
Component<ComponentType>::~Component() = default;
|
||||
|
||||
template<typename ComponentType>
|
||||
nzUInt32 Component<ComponentType>::GetId()
|
||||
virtual BaseComponent* Component<ComponentType>::Clone() const
|
||||
{
|
||||
static_assert<std::is_trivially_copy_constructible<ComponentType>::value, "ComponentType should be copy-constructible">
|
||||
|
||||
return new ComponentType(static_cast<ComponentType&>(*this));
|
||||
}
|
||||
|
||||
template<typename ComponentType>
|
||||
constexpr nzUInt32 GetComponentId()
|
||||
{
|
||||
return ComponentType::ComponentId;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user