WIP
This commit is contained in:
committed by
Jérôme Leclercq
parent
b379518479
commit
292ca60592
@@ -9,6 +9,7 @@
|
||||
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/Core/Config.hpp>
|
||||
#include <Nazara/Utils/Algorithm.hpp>
|
||||
#include <string>
|
||||
|
||||
#ifdef NAZARA_COMPILER_MSVC
|
||||
@@ -37,6 +38,14 @@ namespace Nz
|
||||
PluginInterface& operator=(const PluginInterface&) = delete;
|
||||
PluginInterface& operator=(PluginInterface&&) = delete;
|
||||
};
|
||||
|
||||
#ifdef NAZARA_PLUGINS_STATIC
|
||||
template<typename T>
|
||||
struct PluginProvider
|
||||
{
|
||||
static_assert(AlwaysFalse<T>(), "unknown plugin");
|
||||
};
|
||||
#endif
|
||||
}
|
||||
|
||||
#include <Nazara/Core/PluginInterface.inl>
|
||||
|
||||
@@ -29,7 +29,9 @@ namespace Nz
|
||||
void AddSearchDirectory(const std::filesystem::path& directoryPath);
|
||||
|
||||
template<typename T> Plugin<T> Load(bool activate = true);
|
||||
#ifndef NAZARA_PLUGINS_STATIC
|
||||
GenericPlugin Load(const std::filesystem::path& pluginPath, bool activate = true);
|
||||
#endif
|
||||
|
||||
void RemoveSearchDirectory(const std::filesystem::path& directoryPath);
|
||||
|
||||
|
||||
@@ -11,8 +11,16 @@ namespace Nz
|
||||
template<typename T>
|
||||
Plugin<T> PluginLoader::Load(bool activate)
|
||||
{
|
||||
#ifdef NAZARA_PLUGINS_STATIC
|
||||
std::unique_ptr<T> pluginInterface = PluginProvider<T>::Instantiate();
|
||||
if (activate && !pluginInterface->Activate())
|
||||
throw std::runtime_error("failed to activate plugin");
|
||||
|
||||
return Plugin<T>({}, std::move(pluginInterface), activate);
|
||||
#else
|
||||
GenericPlugin plugin = Load(Utf8Path(T::Filename), activate);
|
||||
return std::move(plugin).Cast<T>();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include <Nazara/Utility/AbstractTextDrawer.hpp>
|
||||
#include <Nazara/Utility/Algorithm.hpp>
|
||||
#include <Nazara/Utility/Animation.hpp>
|
||||
#include <Nazara/Utility/BasicMainloop.hpp>
|
||||
#include <Nazara/Utility/Buffer.hpp>
|
||||
#include <Nazara/Utility/BufferMapper.hpp>
|
||||
#include <Nazara/Utility/Config.hpp>
|
||||
|
||||
@@ -31,6 +31,14 @@ namespace Nz
|
||||
AssimpPlugin& operator=(const AssimpPlugin&) = delete;
|
||||
AssimpPlugin& operator=(AssimpPlugin&&) = delete;
|
||||
};
|
||||
|
||||
#ifdef NAZARA_PLUGINS_STATIC
|
||||
template<>
|
||||
struct PluginProvider<AssimpPlugin>
|
||||
{
|
||||
static std::unique_ptr<AssimpPlugin> Instantiate();
|
||||
};
|
||||
#endif
|
||||
}
|
||||
|
||||
#include <Nazara/Utility/Plugins/AssimpPlugin.inl>
|
||||
|
||||
Reference in New Issue
Block a user