From a007f7f2c9ea2776442ba4b98f732e83f58d1647 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sat, 25 Feb 2012 14:01:59 +0100 Subject: [PATCH] Added: Access to config file from pipeline plugin. --HG-- branch : build_pipeline_v3 --- .../pipeline/pipeline_library/pipeline_interface.cpp | 9 ++++++++- .../pipeline/pipeline_library/pipeline_interface.h | 8 ++++++++ .../pipeline_service/pipeline_interface_impl.cpp | 12 ++++++++---- .../pipeline_service/pipeline_interface_impl.h | 2 ++ .../pipeline/pipeline_service/pipeline_service.cpp | 8 ++++++++ 5 files changed, 34 insertions(+), 5 deletions(-) diff --git a/code/nel/tools/pipeline/pipeline_library/pipeline_interface.cpp b/code/nel/tools/pipeline/pipeline_library/pipeline_interface.cpp index ad30913c1..ddb6c9097 100644 --- a/code/nel/tools/pipeline/pipeline_library/pipeline_interface.cpp +++ b/code/nel/tools/pipeline/pipeline_library/pipeline_interface.cpp @@ -31,7 +31,8 @@ // STL includes // NeL includes -// #include +#include +#include // Project includes @@ -42,6 +43,12 @@ namespace PIPELINE { void fksjdlfkjdskfljdsklfjdslkfjdsf() { } +IPipelineInterface *IPipelineInterface::getInstance() +{ + nlassert(NLMISC::INelContext::isContextInitialised()); + return static_cast(NLMISC::INelContext::getInstance().getSingletonPointer("IPipelineInterface")); +} + } /* namespace PIPELINE */ /* end of file */ diff --git a/code/nel/tools/pipeline/pipeline_library/pipeline_interface.h b/code/nel/tools/pipeline/pipeline_library/pipeline_interface.h index 7f591517e..3249902f4 100644 --- a/code/nel/tools/pipeline/pipeline_library/pipeline_interface.h +++ b/code/nel/tools/pipeline/pipeline_library/pipeline_interface.h @@ -35,6 +35,10 @@ // Project includes +namespace NLMISC { + class CConfigFile; +} + namespace PIPELINE { /** @@ -48,6 +52,10 @@ class IPipelineInterface public: IPipelineInterface() { } virtual ~IPipelineInterface() { } + + IPipelineInterface *getInstance(); + + virtual NLMISC::CConfigFile &getConfigFile() = 0; }; /* class IPipelineInterface */ } /* namespace PIPELINE */ diff --git a/code/nel/tools/pipeline/pipeline_service/pipeline_interface_impl.cpp b/code/nel/tools/pipeline/pipeline_service/pipeline_interface_impl.cpp index 6462f0999..bdac390ad 100644 --- a/code/nel/tools/pipeline/pipeline_service/pipeline_interface_impl.cpp +++ b/code/nel/tools/pipeline/pipeline_service/pipeline_interface_impl.cpp @@ -31,9 +31,9 @@ // STL includes // NeL includes -// #include #include #include +#include // Project includes @@ -44,14 +44,18 @@ namespace PIPELINE { CPipelineInterfaceImpl::CPipelineInterfaceImpl() { - nlassert(NLMISC::INelContext::isContextInitialised()); - nlassert(NLMISC::INelContext::getInstance().getSingletonPointer("IPipelineInterface") == NULL); + nlassert(getInstance() == NULL); NLMISC::INelContext::getInstance().setSingletonPointer("IPipelineInterface", this); } CPipelineInterfaceImpl::~CPipelineInterfaceImpl() { - + NLMISC::INelContext::getInstance().releaseSingletonPointer("IPipelineInterface", this); +} + +NLMISC::CConfigFile &CPipelineInterfaceImpl::getConfigFile() +{ + return NLNET::IService::getInstance()->ConfigFile; } } /* namespace PIPELINE */ diff --git a/code/nel/tools/pipeline/pipeline_service/pipeline_interface_impl.h b/code/nel/tools/pipeline/pipeline_service/pipeline_interface_impl.h index 10b2fd95b..e12c54afb 100644 --- a/code/nel/tools/pipeline/pipeline_service/pipeline_interface_impl.h +++ b/code/nel/tools/pipeline/pipeline_service/pipeline_interface_impl.h @@ -55,6 +55,8 @@ protected: public: CPipelineInterfaceImpl(); virtual ~CPipelineInterfaceImpl(); + + virtual NLMISC::CConfigFile &getConfigFile(); }; /* class CPipelineInterfaceImpl */ } /* namespace PIPELINE */ diff --git a/code/nel/tools/pipeline/pipeline_service/pipeline_service.cpp b/code/nel/tools/pipeline/pipeline_service/pipeline_service.cpp index 819871f31..9dcd4633d 100644 --- a/code/nel/tools/pipeline/pipeline_service/pipeline_service.cpp +++ b/code/nel/tools/pipeline/pipeline_service/pipeline_service.cpp @@ -275,6 +275,7 @@ public: // Load libraries const CConfigFile::CVar &usedPlugins = ConfigFile.getVar("UsedPlugins"); + s_LoadedLibraries.reserve(usedPlugins.size()); for (uint i = 0; i < usedPlugins.size(); ++i) { CLibrary *library = new CLibrary(); @@ -303,6 +304,13 @@ public: } NLMISC::CAsyncFileManager::terminate(); + for (std::vector::iterator it = s_LoadedLibraries.begin(), end = s_LoadedLibraries.end(); it != end; ++it) + { + (*it)->freeLibrary(); + delete (*it); + } + s_LoadedLibraries.clear(); + delete s_DatabaseStatus; s_DatabaseStatus = NULL;