From 1802d9c0915323fd808b6ba3edf8637c9f336c90 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sat, 25 Feb 2012 13:24:27 +0100 Subject: [PATCH] Added: Pipeline interface class for plugins to request information from the pipeline service. --HG-- branch : build_pipeline_v3 --- .../pipeline_library/pipeline_interface.cpp | 47 ++++++++++++++ .../pipeline_library/pipeline_interface.h | 57 +++++++++++++++++ .../pipeline_plugin_max.cpp | 20 +++++- .../pipeline_interface_impl.cpp | 59 +++++++++++++++++ .../pipeline_interface_impl.h | 64 +++++++++++++++++++ .../pipeline_service/pipeline_service.cpp | 25 +++++++- 6 files changed, 268 insertions(+), 4 deletions(-) create mode 100644 code/nel/tools/pipeline/pipeline_library/pipeline_interface.cpp create mode 100644 code/nel/tools/pipeline/pipeline_library/pipeline_interface.h create mode 100644 code/nel/tools/pipeline/pipeline_service/pipeline_interface_impl.cpp create mode 100644 code/nel/tools/pipeline/pipeline_service/pipeline_interface_impl.h diff --git a/code/nel/tools/pipeline/pipeline_library/pipeline_interface.cpp b/code/nel/tools/pipeline/pipeline_library/pipeline_interface.cpp new file mode 100644 index 000000000..ad30913c1 --- /dev/null +++ b/code/nel/tools/pipeline/pipeline_library/pipeline_interface.cpp @@ -0,0 +1,47 @@ +/** + * \file pipeline_interface.cpp + * \brief IPipelineInterface + * \date 2012-02-25 12:10GMT + * \author Jan Boon (Kaetemi) + * IPipelineInterface + */ + +/* + * Copyright (C) 2012 by authors + * + * This file is part of RYZOM CORE PIPELINE. + * RYZOM CORE PIPELINE is free software: you can redistribute it + * and/or modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation, either version 2 of + * the License, or (at your option) any later version. + * + * RYZOM CORE PIPELINE is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with RYZOM CORE PIPELINE; see the file COPYING. If not, see + * . + */ + +#include +#include "pipeline_interface.h" + +// STL includes + +// NeL includes +// #include + +// Project includes + +using namespace std; +// using namespace NLMISC; + +namespace PIPELINE { + +void fksjdlfkjdskfljdsklfjdslkfjdsf() { } + +} /* 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 new file mode 100644 index 000000000..7f591517e --- /dev/null +++ b/code/nel/tools/pipeline/pipeline_library/pipeline_interface.h @@ -0,0 +1,57 @@ +/** + * \file pipeline_interface.h + * \brief IPipelineInterface + * \date 2012-02-25 12:10GMT + * \author Jan Boon (Kaetemi) + * IPipelineInterface + */ + +/* + * Copyright (C) 2012 by authors + * + * This file is part of RYZOM CORE PIPELINE. + * RYZOM CORE PIPELINE is free software: you can redistribute it + * and/or modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation, either version 2 of + * the License, or (at your option) any later version. + * + * RYZOM CORE PIPELINE is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with RYZOM CORE PIPELINE; see the file COPYING. If not, see + * . + */ + +#ifndef PIPELINE_PIPELINE_INTERFACE_H +#define PIPELINE_PIPELINE_INTERFACE_H +#include + +// STL includes + +// NeL includes + +// Project includes + +namespace PIPELINE { + +/** + * \brief IPipelineInterface + * \date 2012-02-25 12:10GMT + * \author Jan Boon (Kaetemi) + * IPipelineInterface + */ +class IPipelineInterface +{ +public: + IPipelineInterface() { } + virtual ~IPipelineInterface() { } +}; /* class IPipelineInterface */ + +} /* namespace PIPELINE */ + +#endif /* #ifndef PIPELINE_PIPELINE_INTERFACE_H */ + +/* end of file */ diff --git a/code/nel/tools/pipeline/pipeline_plugin_max/pipeline_plugin_max.cpp b/code/nel/tools/pipeline/pipeline_plugin_max/pipeline_plugin_max.cpp index 7f3c2ced6..cb5faf202 100644 --- a/code/nel/tools/pipeline/pipeline_plugin_max/pipeline_plugin_max.cpp +++ b/code/nel/tools/pipeline/pipeline_plugin_max/pipeline_plugin_max.cpp @@ -31,7 +31,8 @@ // STL includes // NeL includes -// #include +#include "nel/misc/dynloadlib.h" +#include "nel/misc/debug.h" // Project includes @@ -40,6 +41,23 @@ using namespace std; namespace PIPELINE { +// ****************************************************************** + +class CPipelinePluginMaxNelLibrary : public NLMISC::INelLibrary { + void onLibraryLoaded(bool /* firstTime */) { nldebug("Library loaded: CPipelinePluginMax"); } + void onLibraryUnloaded(bool /* lastTime */) { nldebug("Library unloaded: CPipelinePluginMax"); } +}; +NLMISC_DECL_PURE_LIB(CPipelinePluginMaxNelLibrary) + +HINSTANCE CPipelinePluginMaxDllHandle = NULL; +BOOL WINAPI DllMain(HANDLE hModule, DWORD /* ul_reason_for_call */, LPVOID /* lpReserved */) +{ + CPipelinePluginMaxDllHandle = (HINSTANCE)hModule; + return TRUE; +} + +// ****************************************************************** + CPipelinePluginMax::CPipelinePluginMax() { diff --git a/code/nel/tools/pipeline/pipeline_service/pipeline_interface_impl.cpp b/code/nel/tools/pipeline/pipeline_service/pipeline_interface_impl.cpp new file mode 100644 index 000000000..6462f0999 --- /dev/null +++ b/code/nel/tools/pipeline/pipeline_service/pipeline_interface_impl.cpp @@ -0,0 +1,59 @@ +/** + * \file pipeline_interface_impl.cpp + * \brief CPipelineInterfaceImpl + * \date 2012-02-25 12:21GMT + * \author Jan Boon (Kaetemi) + * CPipelineInterfaceImpl + */ + +/* + * Copyright (C) 2012 by authors + * + * This file is part of RYZOM CORE PIPELINE. + * RYZOM CORE PIPELINE is free software: you can redistribute it + * and/or modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation, either version 2 of + * the License, or (at your option) any later version. + * + * RYZOM CORE PIPELINE is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with RYZOM CORE PIPELINE; see the file COPYING. If not, see + * . + */ + +#include +#include "pipeline_interface_impl.h" + +// STL includes + +// NeL includes +// #include +#include +#include + +// Project includes + +using namespace std; +// using namespace NLMISC; + +namespace PIPELINE { + +CPipelineInterfaceImpl::CPipelineInterfaceImpl() +{ + nlassert(NLMISC::INelContext::isContextInitialised()); + nlassert(NLMISC::INelContext::getInstance().getSingletonPointer("IPipelineInterface") == NULL); + NLMISC::INelContext::getInstance().setSingletonPointer("IPipelineInterface", this); +} + +CPipelineInterfaceImpl::~CPipelineInterfaceImpl() +{ + +} + +} /* namespace PIPELINE */ + +/* end of file */ diff --git a/code/nel/tools/pipeline/pipeline_service/pipeline_interface_impl.h b/code/nel/tools/pipeline/pipeline_service/pipeline_interface_impl.h new file mode 100644 index 000000000..10b2fd95b --- /dev/null +++ b/code/nel/tools/pipeline/pipeline_service/pipeline_interface_impl.h @@ -0,0 +1,64 @@ +/** + * \file pipeline_interface_impl.h + * \brief CPipelineInterfaceImpl + * \date 2012-02-25 12:21GMT + * \author Jan Boon (Kaetemi) + * CPipelineInterfaceImpl + */ + +/* + * Copyright (C) 2012 by authors + * + * This file is part of RYZOM CORE PIPELINE. + * RYZOM CORE PIPELINE is free software: you can redistribute it + * and/or modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation, either version 2 of + * the License, or (at your option) any later version. + * + * RYZOM CORE PIPELINE is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with RYZOM CORE PIPELINE; see the file COPYING. If not, see + * . + */ + +#ifndef PIPELINE_PIPELINE_INTERFACE_IMPL_H +#define PIPELINE_PIPELINE_INTERFACE_IMPL_H +#include + +// STL includes + +// NeL includes + +// Project includes +#include "../pipeline_library/pipeline_interface.h" + +namespace PIPELINE { + +/** + * \brief CPipelineInterfaceImpl + * \date 2012-02-25 12:21GMT + * \author Jan Boon (Kaetemi) + * CPipelineInterfaceImpl + */ +class CPipelineInterfaceImpl : public IPipelineInterface +{ +protected: + // pointers + // ... + + // instances + // ... +public: + CPipelineInterfaceImpl(); + virtual ~CPipelineInterfaceImpl(); +}; /* class CPipelineInterfaceImpl */ + +} /* namespace PIPELINE */ + +#endif /* #ifndef PIPELINE_PIPELINE_INTERFACE_IMPL_H */ + +/* end of file */ diff --git a/code/nel/tools/pipeline/pipeline_service/pipeline_service.cpp b/code/nel/tools/pipeline/pipeline_service/pipeline_service.cpp index 36e3626cc..819871f31 100644 --- a/code/nel/tools/pipeline/pipeline_service/pipeline_service.cpp +++ b/code/nel/tools/pipeline/pipeline_service/pipeline_service.cpp @@ -45,6 +45,7 @@ #include #include #include +#include // Project includes #include "pipeline_workspace.h" @@ -57,7 +58,6 @@ using namespace NLGEORGES; namespace PIPELINE { -bool g_IsMaster = false; std::string g_DatabaseDirectory; std::string g_PipelineDirectory; bool g_IsExiting = false; @@ -89,6 +89,12 @@ namespace { #define PIPELINE_SHORT_SERVICE_NAME "PLSS" #endif +#ifdef NL_DEBUG +#define PIPELINE_SERVICE_DIRECTORY "R:\\build\\dev\\bin\\Release" +#else +#define PIPELINE_SERVICE_DIRECTORY "" +#endif + /// Enum enum EState { @@ -106,6 +112,8 @@ CDatabaseStatus *s_DatabaseStatus = NULL; EState s_State = STATE_IDLE; CMutex s_StateMutex; +std::vector s_LoadedLibraries; + // ****************************************************************** /// Service wants to broadcast all users trough pipeline @@ -254,7 +262,6 @@ public: /// Initializes the service (must be called before the first call to update()) virtual void init() { - g_IsMaster = ConfigFile.getVar("IsMaster").asBool(); g_DatabaseDirectory = CPath::standardizePath(ConfigFile.getVar("DatabaseDirectory").asString(), true); if (!CFile::isDirectory(g_DatabaseDirectory)) nlwarning("'DatabaseDirectory' does not exist! (%s)", g_DatabaseDirectory.c_str()); g_PipelineDirectory = CPath::standardizePath(ConfigFile.getVar("PipelineDirectory").asString(), true); @@ -265,6 +272,18 @@ public: initSheets(); s_DatabaseStatus = new CDatabaseStatus(); + + // Load libraries + const CConfigFile::CVar &usedPlugins = ConfigFile.getVar("UsedPlugins"); + for (uint i = 0; i < usedPlugins.size(); ++i) + { + CLibrary *library = new CLibrary(); + if (library->loadLibrary(usedPlugins.asString(i), true, true, true)) + { + s_LoadedLibraries.push_back(library); + } + else delete library; + } } /// This function is called every "frame" (you must call init() before). It returns false if the service is stopped. @@ -350,6 +369,6 @@ NLMISC_COMMAND(updateDatabaseStatus, "Updates the entire database status. This a return true; } -NLNET_SERVICE_MAIN(PIPELINE::CPipelineService, PIPELINE_SHORT_SERVICE_NAME, PIPELINE_LONG_SERVICE_NAME, 0, PIPELINE::s_ShardCallbacks, "", "") +NLNET_SERVICE_MAIN(PIPELINE::CPipelineService, PIPELINE_SHORT_SERVICE_NAME, PIPELINE_LONG_SERVICE_NAME, 0, PIPELINE::s_ShardCallbacks, PIPELINE_SERVICE_DIRECTORY, PIPELINE_SERVICE_DIRECTORY) /* end of file */