Add module configurations
This commit is contained in:
@@ -23,7 +23,9 @@ namespace Nz
|
||||
public:
|
||||
using Dependencies = TypeList<Core>;
|
||||
|
||||
Audio();
|
||||
struct Config {};
|
||||
|
||||
Audio(Config /*config*/);
|
||||
~Audio();
|
||||
|
||||
AudioFormat GetAudioFormat(unsigned int channelCount);
|
||||
|
||||
@@ -20,7 +20,9 @@ namespace Nz
|
||||
public:
|
||||
using Dependencies = TypeList<>;
|
||||
|
||||
Core();
|
||||
struct Config {};
|
||||
|
||||
Core(Config /*config*/);
|
||||
~Core();
|
||||
|
||||
private:
|
||||
|
||||
@@ -19,11 +19,16 @@ namespace Nz
|
||||
template<typename Module, typename... Modules>
|
||||
struct ModuleTuple : ModuleTuple<Module>, ModuleTuple<Modules...>
|
||||
{
|
||||
template<typename... ModuleConfig>
|
||||
ModuleTuple(ModuleConfig&&... configs);
|
||||
};
|
||||
|
||||
template<typename Module>
|
||||
struct ModuleTuple<Module>
|
||||
{
|
||||
template<typename... ModuleConfig>
|
||||
ModuleTuple(ModuleConfig&&... configs);
|
||||
|
||||
Module m;
|
||||
};
|
||||
}
|
||||
@@ -32,7 +37,8 @@ namespace Nz
|
||||
class Modules
|
||||
{
|
||||
public:
|
||||
Modules() = default;
|
||||
template<typename... ModuleConfig>
|
||||
Modules(ModuleConfig&&... configs);
|
||||
~Modules() = default;
|
||||
|
||||
private:
|
||||
|
||||
@@ -5,22 +5,65 @@
|
||||
#include <Nazara/Core/Modules.hpp>
|
||||
#include <Nazara/Core/Debug.hpp>
|
||||
|
||||
namespace Nz::Detail
|
||||
namespace Nz
|
||||
{
|
||||
template<>
|
||||
struct BuildDepList<TypeList<>>
|
||||
namespace Detail
|
||||
{
|
||||
using Result = TypeList<>;
|
||||
};
|
||||
template<typename T>
|
||||
struct Pick
|
||||
{
|
||||
template<typename First, typename... Args>
|
||||
static auto Get(First&& first, Args&&... args)
|
||||
{
|
||||
if constexpr (std::is_same_v<T, std::decay_t<First>>)
|
||||
return std::forward<First>(first);
|
||||
else
|
||||
return Get(std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename Module, typename... ModuleList>
|
||||
struct BuildDepList<TypeList<Module, ModuleList...>>
|
||||
static auto Get()
|
||||
{
|
||||
return T{};
|
||||
}
|
||||
};
|
||||
|
||||
template<typename Module, typename... Modules>
|
||||
template<typename... ModuleConfig>
|
||||
ModuleTuple<Module, Modules...>::ModuleTuple(ModuleConfig&&... configs) :
|
||||
ModuleTuple<Module>(std::forward<ModuleConfig>(configs)...),
|
||||
ModuleTuple<Modules...>(std::forward<ModuleConfig>(configs)...)
|
||||
{
|
||||
}
|
||||
|
||||
template<typename Module>
|
||||
template<typename... ModuleConfig>
|
||||
ModuleTuple<Module>::ModuleTuple(ModuleConfig&&... configs) :
|
||||
m(Pick<Module::Config>::Get(std::forward<ModuleConfig>(configs)...))
|
||||
{
|
||||
}
|
||||
|
||||
template<>
|
||||
struct BuildDepList<TypeList<>>
|
||||
{
|
||||
using Result = TypeList<>;
|
||||
};
|
||||
|
||||
template<typename Module, typename... ModuleList>
|
||||
struct BuildDepList<TypeList<Module, ModuleList...>>
|
||||
{
|
||||
using ModuleDependencies = typename BuildDepList<typename Module::Dependencies>::Result;
|
||||
using ModuleDependenciesIncModule = TypeListAppend<ModuleDependencies, Module>;
|
||||
using RestDependencies = typename BuildDepList<TypeList<ModuleList...>>::Result;
|
||||
using Result = TypeListConcat<ModuleDependenciesIncModule, RestDependencies>;
|
||||
};
|
||||
}
|
||||
|
||||
template<typename... ModuleList>
|
||||
template<typename... ModuleConfig>
|
||||
Modules<ModuleList...>::Modules(ModuleConfig&&... configs) :
|
||||
m_modules(std::forward<ModuleConfig>(configs)...)
|
||||
{
|
||||
using ModuleDependencies = typename BuildDepList<typename Module::Dependencies>::Result;
|
||||
using ModuleDependenciesIncModule = TypeListAppend<ModuleDependencies, Module>;
|
||||
using RestDependencies = typename BuildDepList<TypeList<ModuleList...>>::Result;
|
||||
using Result = TypeListConcat<ModuleDependenciesIncModule, RestDependencies>;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/Core/DebugOff.hpp>
|
||||
|
||||
@@ -20,7 +20,9 @@ namespace Nz
|
||||
public:
|
||||
using Dependencies = TypeList<Core>;
|
||||
|
||||
Network();
|
||||
struct Config {};
|
||||
|
||||
Network(Config /*config*/);
|
||||
~Network();
|
||||
|
||||
private:
|
||||
|
||||
@@ -20,7 +20,9 @@ namespace Nz
|
||||
public:
|
||||
using Dependencies = TypeList<Core>;
|
||||
|
||||
Physics2D();
|
||||
struct Config {};
|
||||
|
||||
Physics2D(Config /*config*/);
|
||||
~Physics2D() = default;
|
||||
|
||||
private:
|
||||
|
||||
@@ -20,7 +20,9 @@ namespace Nz
|
||||
public:
|
||||
using Dependencies = TypeList<Core>;
|
||||
|
||||
Physics3D();
|
||||
struct Config {};
|
||||
|
||||
Physics3D(Config /*config*/);
|
||||
~Physics3D();
|
||||
|
||||
unsigned int GetMemoryUsed();
|
||||
|
||||
@@ -20,7 +20,9 @@ namespace Nz
|
||||
public:
|
||||
using Dependencies = TypeList<Utility>;
|
||||
|
||||
Platform();
|
||||
struct Config {};
|
||||
|
||||
Platform(Config /*config*/);
|
||||
~Platform();
|
||||
|
||||
private:
|
||||
|
||||
@@ -26,7 +26,9 @@ namespace Nz
|
||||
public:
|
||||
using Dependencies = TypeList<Platform, Shader>;
|
||||
|
||||
Renderer();
|
||||
struct Config {};
|
||||
|
||||
Renderer(Config /*config*/);
|
||||
~Renderer();
|
||||
|
||||
inline RendererImpl* GetRendererImpl();
|
||||
|
||||
@@ -20,7 +20,9 @@ namespace Nz
|
||||
public:
|
||||
using Dependencies = TypeList<Core>;
|
||||
|
||||
Shader();
|
||||
struct Config {};
|
||||
|
||||
Shader(Config /*config*/);
|
||||
~Shader() = default;
|
||||
|
||||
private:
|
||||
|
||||
@@ -20,7 +20,9 @@ namespace Nz
|
||||
public:
|
||||
using Dependencies = TypeList<Core>;
|
||||
|
||||
Utility();
|
||||
struct Config {};
|
||||
|
||||
Utility(Config /*config*/);
|
||||
~Utility();
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user