Improved submodules
PluginManager is now a submodule Former-commit-id: 2e147317ab07447e134d15790386bd6d3494b9d1
This commit is contained in:
parent
9b74459ea8
commit
361e2a31ee
|
|
@ -10,6 +10,10 @@
|
|||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/Enums.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <set>
|
||||
#include <unordered_map>
|
||||
|
||||
class NzDynLib;
|
||||
|
||||
class NAZARA_API NzPluginManager
|
||||
{
|
||||
|
|
@ -30,6 +34,12 @@ class NAZARA_API NzPluginManager
|
|||
static void Unmount(const NzString& pluginPath);
|
||||
|
||||
static void Uninitialize();
|
||||
|
||||
private:
|
||||
static std::set<NzString> s_directories;
|
||||
static std::unordered_map<NzString, NzDynLib*> s_plugins;
|
||||
static bool s_initialized;
|
||||
|
||||
};
|
||||
|
||||
#endif // NAZARA_PLUGINMANAGER_HPP
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
#include <Nazara/Core/Error.hpp>
|
||||
#include <Nazara/Core/HardwareInfo.hpp>
|
||||
#include <Nazara/Core/Log.hpp>
|
||||
#include <Nazara/Core/PluginManager.hpp>
|
||||
#include <Nazara/Core/TaskScheduler.hpp>
|
||||
#include <Nazara/Core/Debug.hpp>
|
||||
|
||||
|
|
@ -44,6 +45,7 @@ void NzCore::Uninitialize()
|
|||
s_moduleReferenceCounter = 0;
|
||||
|
||||
NzHardwareInfo::Uninitialize();
|
||||
NzPluginManager::Uninitialize();
|
||||
NzTaskScheduler::Uninitialize();
|
||||
|
||||
NazaraNotice("Uninitialized: Core");
|
||||
|
|
|
|||
|
|
@ -118,7 +118,10 @@ bool NzHardwareInfo::Initialize()
|
|||
return true;
|
||||
|
||||
if (!NzHardwareInfoImpl::IsCpuidSupported())
|
||||
{
|
||||
NazaraError("Cpuid is not supported");
|
||||
return false;
|
||||
}
|
||||
|
||||
s_initialized = true;
|
||||
|
||||
|
|
|
|||
|
|
@ -8,8 +8,6 @@
|
|||
#include <Nazara/Core/Error.hpp>
|
||||
#include <Nazara/Core/File.hpp>
|
||||
#include <memory>
|
||||
#include <set>
|
||||
#include <unordered_map>
|
||||
#include <Nazara/Core/Debug.hpp>
|
||||
|
||||
namespace
|
||||
|
|
@ -17,9 +15,6 @@ namespace
|
|||
using PluginLoad = int (*)();
|
||||
using PluginUnload = void (*)();
|
||||
|
||||
std::set<NzString> s_directories;
|
||||
std::unordered_map<NzString, NzDynLib*> s_plugins;
|
||||
|
||||
NzString s_pluginFiles[] =
|
||||
{
|
||||
"NazaraAssimp", // nzPlugin_Assimp
|
||||
|
|
@ -29,6 +24,12 @@ namespace
|
|||
|
||||
bool NzPluginManager::AddDirectory(const NzString& directoryPath)
|
||||
{
|
||||
if (!Initialize())
|
||||
{
|
||||
NazaraError("Failed to initialize PluginManager");
|
||||
return false;
|
||||
}
|
||||
|
||||
s_directories.insert(NzFile::AbsolutePath(directoryPath));
|
||||
|
||||
return true;
|
||||
|
|
@ -36,9 +37,13 @@ bool NzPluginManager::AddDirectory(const NzString& directoryPath)
|
|||
|
||||
bool NzPluginManager::Initialize()
|
||||
{
|
||||
if (s_initialized)
|
||||
return true;
|
||||
|
||||
AddDirectory(".");
|
||||
AddDirectory("plugins");
|
||||
|
||||
s_initialized = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -49,6 +54,12 @@ bool NzPluginManager::Mount(nzPlugin plugin)
|
|||
|
||||
bool NzPluginManager::Mount(const NzString& pluginPath, bool appendExtension)
|
||||
{
|
||||
if (!Initialize())
|
||||
{
|
||||
NazaraError("Failed to initialize PluginManager");
|
||||
return false;
|
||||
}
|
||||
|
||||
NzString path = pluginPath;
|
||||
if (appendExtension && !path.EndsWith(NAZARA_DYNLIB_EXTENSION))
|
||||
path += NAZARA_DYNLIB_EXTENSION;
|
||||
|
|
@ -109,6 +120,12 @@ bool NzPluginManager::Mount(const NzString& pluginPath, bool appendExtension)
|
|||
|
||||
void NzPluginManager::RemoveDirectory(const NzString& directoryPath)
|
||||
{
|
||||
if (!Initialize())
|
||||
{
|
||||
NazaraError("Failed to initialize PluginManager");
|
||||
return;
|
||||
}
|
||||
|
||||
s_directories.erase(NzFile::AbsolutePath(directoryPath));
|
||||
}
|
||||
|
||||
|
|
@ -119,6 +136,12 @@ void NzPluginManager::Unmount(nzPlugin plugin)
|
|||
|
||||
void NzPluginManager::Unmount(const NzString& pluginPath)
|
||||
{
|
||||
if (!Initialize())
|
||||
{
|
||||
NazaraError("Failed to initialize PluginManager");
|
||||
return;
|
||||
}
|
||||
|
||||
auto it = s_plugins.find(pluginPath);
|
||||
if (it == s_plugins.end())
|
||||
{
|
||||
|
|
@ -138,6 +161,9 @@ void NzPluginManager::Unmount(const NzString& pluginPath)
|
|||
|
||||
void NzPluginManager::Uninitialize()
|
||||
{
|
||||
if (!s_initialized)
|
||||
return;
|
||||
|
||||
s_directories.clear();
|
||||
|
||||
for (auto& pair : s_plugins)
|
||||
|
|
@ -151,4 +177,10 @@ void NzPluginManager::Uninitialize()
|
|||
}
|
||||
|
||||
s_plugins.clear();
|
||||
|
||||
s_initialized = false;
|
||||
}
|
||||
|
||||
std::set<NzString> NzPluginManager::s_directories;
|
||||
std::unordered_map<NzString, NzDynLib*> NzPluginManager::s_plugins;
|
||||
bool NzPluginManager::s_initialized = false;
|
||||
|
|
|
|||
|
|
@ -35,7 +35,10 @@ bool NzTaskScheduler::Initialize()
|
|||
void NzTaskScheduler::Run()
|
||||
{
|
||||
if (!Initialize())
|
||||
NazaraError("Failed to initialize TaskScheduler");
|
||||
{
|
||||
NazaraError("Failed to initialize Task Scheduler");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!s_pendingWorks.empty())
|
||||
{
|
||||
|
|
@ -66,7 +69,10 @@ void NzTaskScheduler::Uninitialize()
|
|||
void NzTaskScheduler::WaitForTasks()
|
||||
{
|
||||
if (!Initialize())
|
||||
NazaraError("Failed to initialize TaskScheduler");
|
||||
{
|
||||
NazaraError("Failed to initialize Task Scheduler");
|
||||
return;
|
||||
}
|
||||
|
||||
NzTaskSchedulerImpl::WaitForTasks();
|
||||
}
|
||||
|
|
@ -74,7 +80,10 @@ void NzTaskScheduler::WaitForTasks()
|
|||
void NzTaskScheduler::AddTaskFunctor(NzFunctor* taskFunctor)
|
||||
{
|
||||
if (!Initialize())
|
||||
NazaraError("Failed to initialize TaskScheduler");
|
||||
{
|
||||
NazaraError("Failed to initialize Task Scheduler");
|
||||
return;
|
||||
}
|
||||
|
||||
s_pendingWorks.push_back(taskFunctor);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue