From 9417b09f515d2cdaea162b864b34eb67c7b91d0f Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sat, 3 Mar 2012 12:28:20 +0100 Subject: [PATCH] Added: #1440 List process plugins --HG-- branch : build_pipeline_v3 --- .../plugin_nel/process_interface_info.cpp | 6 +- .../tools/pipeline/service/database_status.h | 4 +- .../pipeline/service/pipeline_service.cpp | 60 ++++++++-- .../tools/pipeline/service/pipeline_service.h | 11 +- .../pipeline/service/pipeline_workspace.cpp | 107 ++++++++++++++++++ .../pipeline/service/pipeline_workspace.h | 24 +++- .../common_interface.pipeline_project | 3 +- .../pipeline/plugin_max.pipeline_plugin | 4 +- .../pipeline/plugin_nel.pipeline_plugin | 4 +- 9 files changed, 202 insertions(+), 21 deletions(-) diff --git a/code/nel/tools/pipeline/plugin_nel/process_interface_info.cpp b/code/nel/tools/pipeline/plugin_nel/process_interface_info.cpp index 70ff4195d..4eb368c09 100644 --- a/code/nel/tools/pipeline/plugin_nel/process_interface_info.cpp +++ b/code/nel/tools/pipeline/plugin_nel/process_interface_info.cpp @@ -52,17 +52,17 @@ CProcessInterfaceInfo::~CProcessInterfaceInfo() void CProcessInterfaceInfo::getDependentDirectoriesRecursive(std::vector &result) { - + } void CProcessInterfaceInfo::getDependentDirectories(std::vector &result) { - + } void CProcessInterfaceInfo::getDependentFiles(std::vector &result) { - + } } /* namespace PIPELINE */ diff --git a/code/nel/tools/pipeline/service/database_status.h b/code/nel/tools/pipeline/service/database_status.h index 981fdcf48..8d563214c 100644 --- a/code/nel/tools/pipeline/service/database_status.h +++ b/code/nel/tools/pipeline/service/database_status.h @@ -67,7 +67,7 @@ public: std::string Process; std::string Message; - void serial(NLMISC::IStream &stream); + void serial(NLMISC::IStream &stream) throw (NLMISC::EStream); }; /// Errors set by a process when the file causes a build failure. @@ -82,7 +82,7 @@ public: uint32 LastUpdate; // The start time when the CRC32 was calculated. uint32 CRC32; - void serial(NLMISC::IStream &stream); + void serial(NLMISC::IStream &stream) throw (NLMISC::EStream); }; typedef CCallback TFileStatusCallback; diff --git a/code/nel/tools/pipeline/service/pipeline_service.cpp b/code/nel/tools/pipeline/service/pipeline_service.cpp index 53035b363..a10d164e7 100644 --- a/code/nel/tools/pipeline/service/pipeline_service.cpp +++ b/code/nel/tools/pipeline/service/pipeline_service.cpp @@ -51,6 +51,8 @@ #include "pipeline_workspace.h" #include "database_status.h" #include "pipeline_interface_impl.h" +#include "pipeline_process_impl.h" + // using namespace std; using namespace NLMISC; @@ -63,6 +65,9 @@ std::string g_DatabaseDirectory; std::string g_PipelineDirectory; bool g_IsExiting = false; +NLGEORGES::UFormLoader *g_FormLoader = NULL; +CPipelineWorkspace *g_PipelineWorkspace; + std::string unMacroPath(const std::string &path) { std::string result = path; @@ -102,11 +107,10 @@ enum EState }; /// Data -UFormLoader *s_FormLoader = NULL; -CPipelineWorkspace *s_PipelineWorkspace = NULL; CTaskManager *s_TaskManager = NULL; CDatabaseStatus *s_DatabaseStatus = NULL; CPipelineInterfaceImpl *s_PipelineInterfaceImpl = NULL; +CPipelineProcessImpl *s_PipelineProcessImpl = NULL; EState s_State = STATE_IDLE; std::string s_StateRunnableTaskName = ""; @@ -195,18 +199,18 @@ void initSheets() nlinfo("Adding 'LeveldesignPipelineDirectory' to search path (%s)", leveldesignPipelineDirectory.c_str()); CPath::addSearchPath(leveldesignPipelineDirectory, true, false); - s_FormLoader = UFormLoader::createLoader(); + g_FormLoader = UFormLoader::createLoader(); - s_PipelineWorkspace = new CPipelineWorkspace(s_FormLoader, IService::getInstance()->ConfigFile.getVar("WorkspaceSheet").asString()); + g_PipelineWorkspace = new CPipelineWorkspace(g_FormLoader, IService::getInstance()->ConfigFile.getVar("WorkspaceSheet").asString()); } void releaseSheets() { - delete s_PipelineWorkspace; - s_PipelineWorkspace = NULL; + delete g_PipelineWorkspace; + g_PipelineWorkspace = NULL; - UFormLoader::releaseLoader(s_FormLoader); - s_FormLoader = NULL; + UFormLoader::releaseLoader(g_FormLoader); + g_FormLoader = NULL; CPath::releaseInstance(); } @@ -307,6 +311,7 @@ public: s_DatabaseStatus = new CDatabaseStatus(); s_PipelineInterfaceImpl = new CPipelineInterfaceImpl(); + s_PipelineProcessImpl = new CPipelineProcessImpl(); // Load libraries const CConfigFile::CVar &usedPlugins = ConfigFile.getVar("UsedPlugins"); @@ -346,6 +351,9 @@ public: } s_LoadedLibraries.clear(); + delete s_PipelineProcessImpl; + s_PipelineProcessImpl = NULL; + delete s_PipelineInterfaceImpl; s_PipelineInterfaceImpl = NULL; @@ -438,6 +446,42 @@ NLMISC_COMMAND(dumpAsyncFileManager, "Dumps the async file manager.", "") return true; } +NLMISC_COMMAND(listProcessPlugins, "List process plugins.", "") +{ + if(args.size() != 1) return false; + std::vector result; + PIPELINE::g_PipelineWorkspace->getProcessPlugins(result, args[0]); + for (std::vector::iterator it = result.begin(), end = result.end(); it != end; ++it) + { + std::string statusHandler; + switch (it->HandlerType) + { + case PIPELINE::PLUGIN_REGISTERED_CLASS: + if (std::find(PIPELINE::s_PipelineInterfaceImpl->RegisteredClasses.begin(), PIPELINE::s_PipelineInterfaceImpl->RegisteredClasses.end(), it->Handler) != PIPELINE::s_PipelineInterfaceImpl->RegisteredClasses.end()) + statusHandler = "AVAILABLE"; + else + statusHandler = "NOT FOUND"; + break; + default: + statusHandler = "UNKNOWN"; + break; + } + std::string statusInfo; + switch (it->InfoType) + { + case PIPELINE::PLUGIN_REGISTERED_CLASS:if (std::find(PIPELINE::s_PipelineInterfaceImpl->RegisteredClasses.begin(), PIPELINE::s_PipelineInterfaceImpl->RegisteredClasses.end(), it->Info) != PIPELINE::s_PipelineInterfaceImpl->RegisteredClasses.end()) + statusInfo = "AVAILABLE"; + else + statusInfo = "NOT FOUND"; + break; + default: + statusInfo = "UNKNOWN"; + break; + } + log.displayNL("LISTPP '%s': '%s' (%s), '%s' (%s)", args[0].c_str(), it->Handler.c_str(), statusHandler.c_str(), it->Info.c_str(), statusInfo.c_str()); + } +} + 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 */ diff --git a/code/nel/tools/pipeline/service/pipeline_service.h b/code/nel/tools/pipeline/service/pipeline_service.h index dd5d638e6..2d018132d 100644 --- a/code/nel/tools/pipeline/service/pipeline_service.h +++ b/code/nel/tools/pipeline/service/pipeline_service.h @@ -40,7 +40,13 @@ namespace NLMISC { class IRunnable; } +namespace NLGEORGES { + class UFormLoader; +} + namespace PIPELINE { + class CPipelineWorkspace; + /* #if defined(PIPELINE_MASTER) # if defined(PIPELINE_SLAVE) @@ -54,6 +60,8 @@ namespace PIPELINE { #define PIPELINE_MASTER +extern bool g_IsExiting; + extern std::string g_DatabaseDirectory; extern std::string g_PipelineDirectory; @@ -71,7 +79,8 @@ std::string macroPath(const std::string &path); bool tryRunnableTask(std::string stateName, NLMISC::IRunnable *task); void endedRunnableTask(); -extern bool g_IsExiting; +extern NLGEORGES::UFormLoader *g_FormLoader; +extern CPipelineWorkspace *g_PipelineWorkspace; } /* namespace PIPELINE */ diff --git a/code/nel/tools/pipeline/service/pipeline_workspace.cpp b/code/nel/tools/pipeline/service/pipeline_workspace.cpp index e625c8d0b..46e441908 100644 --- a/code/nel/tools/pipeline/service/pipeline_workspace.cpp +++ b/code/nel/tools/pipeline/service/pipeline_workspace.cpp @@ -48,6 +48,56 @@ CPipelineWorkspace::CPipelineWorkspace(NLGEORGES::UFormLoader *formLoader, const std::string description; m_Form->getRootNode().getValueByName(description, "Description"); nlinfo("Loading pipeline workspace: '%s'", description.c_str()); + + { + UFormElm *plugins; + if (m_Form->getRootNode().getNodeByName(&plugins, "Plugins")) + { + uint nb; + plugins->getArraySize(nb); + for (uint i = 0; i < nb; ++i) + { + std::string pluginSheet; + if (plugins->getArrayValue(pluginSheet, i)) + { + m_Plugins.push_back(formLoader->loadForm(pluginSheet.c_str())); + } + else + { + nlwarning("Array error in '%s'", m_Form->getFilename().c_str()); + } + } + } + else + { + nlwarning("Missing 'Plugins' in '%s'", m_Form->getFilename().c_str()); + } + } + + { + UFormElm *projects; + if (m_Form->getRootNode().getNodeByName(&projects, "Projects")) + { + uint nb; + projects->getArraySize(nb); + for (uint i = 0; i < nb; ++i) + { + std::string projectSheet; + if (projects->getArrayValue(projectSheet, i)) + { + m_Projects.push_back(formLoader->loadForm(projectSheet.c_str())); + } + else + { + nlwarning("Array error in '%s'", m_Form->getFilename().c_str()); + } + } + } + else + { + nlwarning("Missing 'Projects' in '%s'", m_Form->getFilename().c_str()); + } + } } CPipelineWorkspace::~CPipelineWorkspace() @@ -55,6 +105,63 @@ CPipelineWorkspace::~CPipelineWorkspace() } +void CPipelineWorkspace::getProcessPlugins(std::vector &result, const std::string &process) +{ + for (std::vector >::iterator it = m_Plugins.begin(), end = m_Plugins.end(); it != end; ++it) + { + UFormElm *processHandlers; + if ((*it)->getRootNode().getNodeByName(&processHandlers, "ProcessHandlers")) + { + uint nb; + processHandlers->getArraySize(nb); + for (uint i = 0; i < nb; ++i) + { + UFormElm *handler; + if (processHandlers->getArrayNode(&handler, i)) + { + std::string handlerProcess; + if (handler->getValueByName(handlerProcess, "Process")) + { + if (handlerProcess == process) + { + CProcessPluginInfo processPlugin; + uint32 handlerType; + uint32 infoType; + if (handler->getValueByName(handlerType, "HandlerType") + && handler->getValueByName(processPlugin.Handler, "Handler") + && handler->getValueByName(infoType, "InfoType") + && handler->getValueByName(processPlugin.Info, "Info")) + { + processPlugin.HandlerType = (TPluginType)handlerType; + processPlugin.InfoType = (TPluginType)infoType; + result.push_back(processPlugin); + + nldebug("Found '%s': '%s', '%s'", process.c_str(), processPlugin.Handler.c_str(), processPlugin.Info.c_str()); + } + else + { + nlwarning("Missing value in '%s' at 'ProcessHandlers' at '%i'", (*it)->getFilename().c_str(), i); + } + } + } + else + { + nlwarning("Missing 'Process' in '%s' at 'ProcessHandlers' at '%i'", (*it)->getFilename().c_str(), i); + } + } + else + { + nlwarning("Array error in '%s'", (*it)->getFilename().c_str()); + } + } + } + else + { + nlwarning("Missing 'ProcessHandlers' in '%s'", (*it)->getFilename().c_str()); + } + } +} + } /* namespace PIPELINE */ /* end of file */ diff --git a/code/nel/tools/pipeline/service/pipeline_workspace.h b/code/nel/tools/pipeline/service/pipeline_workspace.h index f5867e854..97e1010c6 100644 --- a/code/nel/tools/pipeline/service/pipeline_workspace.h +++ b/code/nel/tools/pipeline/service/pipeline_workspace.h @@ -41,6 +41,20 @@ namespace PIPELINE { +enum TPluginType +{ + PLUGIN_REGISTERED_CLASS, + PLUGIN_LUA_SCRIPT, +}; + +struct CProcessPluginInfo +{ + TPluginType HandlerType; + std::string Handler; + TPluginType InfoType; + std::string Info; +}; + /** * \brief CPipelineWorkspace * \date 2012-02-18 17:23GMT @@ -50,15 +64,17 @@ namespace PIPELINE { class CPipelineWorkspace { protected: - // pointers NLGEORGES::UFormLoader *m_FormLoader; NLMISC::CRefPtr m_Form; - - // instances - // ... + std::vector > m_Projects; + std::vector > m_Plugins; + public: CPipelineWorkspace(NLGEORGES::UFormLoader *formLoader, const std::string &sheetName); virtual ~CPipelineWorkspace(); + + void getProcessPlugins(std::vector &result, const std::string &process); + }; /* class CPipelineWorkspace */ } /* namespace PIPELINE */ diff --git a/code/ryzom/common/data_leveldesign/leveldesign/pipeline/common_interface.pipeline_project b/code/ryzom/common/data_leveldesign/leveldesign/pipeline/common_interface.pipeline_project index c93296e4e..d9b34c144 100644 --- a/code/ryzom/common/data_leveldesign/leveldesign/pipeline/common_interface.pipeline_project +++ b/code/ryzom/common/data_leveldesign/leveldesign/pipeline/common_interface.pipeline_project @@ -1,6 +1,7 @@
+ @@ -70,5 +71,5 @@ - + Sat Mar 03 12:10:45 2012 (Kaetemi) .Description = Common Interface diff --git a/code/ryzom/common/data_leveldesign/leveldesign/pipeline/plugin_max.pipeline_plugin b/code/ryzom/common/data_leveldesign/leveldesign/pipeline/plugin_max.pipeline_plugin index c95a9ee33..e903f3b31 100644 --- a/code/ryzom/common/data_leveldesign/leveldesign/pipeline/plugin_max.pipeline_plugin +++ b/code/ryzom/common/data_leveldesign/leveldesign/pipeline/plugin_max.pipeline_plugin @@ -1,6 +1,7 @@
+ @@ -18,5 +19,6 @@ Sat Mar 03 10:55:24 2012 (Kaetemi) .ProcessHandlers[0].HandlerType = RegisteredClass Sat Mar 03 10:55:24 2012 (Kaetemi) .ProcessHandlers[0].Process = ExportShape Sat Mar 03 10:55:24 2012 (Kaetemi) formName Resized = 1 -Sat Mar 03 11:07:09 2012 (Kaetemi) .ProcessHandlers[0].Info = CProcessMaxShapeInfo +Sat Mar 03 11:07:09 2012 (Kaetemi) .ProcessHandlers[0].Info = CProcessMaxShapeInfo +Sat Mar 03 12:10:36 2012 (Kaetemi) .Description = Pipeline Plugin Max diff --git a/code/ryzom/common/data_leveldesign/leveldesign/pipeline/plugin_nel.pipeline_plugin b/code/ryzom/common/data_leveldesign/leveldesign/pipeline/plugin_nel.pipeline_plugin index 06af7fe80..f411c3f99 100644 --- a/code/ryzom/common/data_leveldesign/leveldesign/pipeline/plugin_nel.pipeline_plugin +++ b/code/ryzom/common/data_leveldesign/leveldesign/pipeline/plugin_nel.pipeline_plugin @@ -1,6 +1,7 @@
+ @@ -20,5 +21,6 @@ Sat Mar 03 10:55:24 2012 (Kaetemi) .ProcessHandlers[0].Process = ExportShape Sat Mar 03 10:55:24 2012 (Kaetemi) formName Resized = 1 Sat Mar 03 10:56:08 2012 (Kaetemi) .ProcessHandlers[0].Handler = CProcessInterface Sat Mar 03 10:56:08 2012 (Kaetemi) .ProcessHandlers[0].Process = Interface -Sat Mar 03 11:13:55 2012 (Kaetemi) .ProcessHandlers[0].Info = CProcessInterfaceInfo +Sat Mar 03 11:13:55 2012 (Kaetemi) .ProcessHandlers[0].Info = CProcessInterfaceInfo +Sat Mar 03 12:10:28 2012 (Kaetemi) .Description = Pipeline Plugin NeL