From eeae925a05abb65e0df93d1dd2ec00e27638e854 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sun, 4 Mar 2012 14:35:02 +0100 Subject: [PATCH] Added: #1440 Send available plugin handlers on slave to master --HG-- branch : build_pipeline_v3 --- .../service/module_pipeline_master.cpp | 8 ++ .../service/module_pipeline_master_itf.cpp | Bin 17152 -> 20452 bytes .../service/module_pipeline_master_itf.h | Bin 12424 -> 13546 bytes .../service/module_pipeline_master_itf.xml | 6 ++ .../service/module_pipeline_slave.cpp | 13 ++- .../pipeline/service/pipeline_service.cpp | 12 +-- .../tools/pipeline/service/pipeline_service.h | 2 + .../pipeline/service/pipeline_workspace.cpp | 93 +++++++++++++++++- .../pipeline/service/pipeline_workspace.h | 5 +- 9 files changed, 128 insertions(+), 11 deletions(-) diff --git a/code/nel/tools/pipeline/service/module_pipeline_master.cpp b/code/nel/tools/pipeline/service/module_pipeline_master.cpp index 123155549..35005a484 100644 --- a/code/nel/tools/pipeline/service/module_pipeline_master.cpp +++ b/code/nel/tools/pipeline/service/module_pipeline_master.cpp @@ -73,6 +73,7 @@ class CModulePipelineMaster : std::vector Vector; uint32 ActiveTaskId; bool SheetsOk; + std::vector PluginsAvailable; ~CSlave() { @@ -203,6 +204,12 @@ public: g_DatabaseStatus->updateDatabaseStatus(CCallback(slave, &CSlave::cbUpdateDatabaseStatus), slave->Vector, false, false); slave->Vector.clear(); } + + void setAvailablePlugins(NLNET::IModuleProxy *sender, const std::vector &pluginsAvailable) + { + CSlave *slave = m_Slaves[sender]; + slave->PluginsAvailable = pluginsAvailable; + } protected: NLMISC_COMMAND_HANDLER_TABLE_EXTEND_BEGIN(CModulePipelineMaster, CModuleBase) @@ -221,6 +228,7 @@ protected: { CSlave *slave = it->second; slave->SheetsOk = false; + slave->PluginsAvailable.clear(); slave->Proxy.reloadSheets(this); CInfoFlags::getInstance()->addFlag(PIPELINE_INFO_MASTER_RELOAD_SHEETS); } diff --git a/code/nel/tools/pipeline/service/module_pipeline_master_itf.cpp b/code/nel/tools/pipeline/service/module_pipeline_master_itf.cpp index b0ebfc06b3983dd2d5d284b9e57217d756e849a9..3de223215e52214affc89796c519aa208a484bdd 100644 GIT binary patch delta 977 zcmZo@V|+57af1#2 zfMhCAK8K-{Asr}|$56a^E*mrBVjF(`$s4TMCjXOkP%Q>3A*gM#zVKahBGdt$gXy$F zX>r>!pe@Njd-55I7;J#f0Xe3G!I;5_!H$8Gp#a&5m|mD%C}Lah4AcwKqr;#;NIiol zgEa#$0~gR_P6nd<$DjdLm&cF-bY~GZJ47(T6==z1L5doj>&DGXLXh%c-Z7}W6lezKsX=w?16HAZD3JU&@o zt9i16K8q~g2$;;MA->5(ijl~q!YC?9z`RBw;mHfs>o)UQdN5ATQ&QQSU_Og`^8p7d z;v6k#YdN_=on>;Fy%^qfMO0W#zGJ0^B|9lvII}}j++<@1O?P~8q6SQnc0jCwKW2a_ POLKCrwL4oaIBfy|`;XDJ delta 35 rcmaDdpRu8haf1#2VktrX$!m0CCjU`W+3clkA-;K@Jsa=jd;V+y@bwJb diff --git a/code/nel/tools/pipeline/service/module_pipeline_master_itf.h b/code/nel/tools/pipeline/service/module_pipeline_master_itf.h index b3d159e5f64d7bd427533ebe30c75a08701b69a7..7dd4bd265436fe052923e72754f0873043cd0c49 100644 GIT binary patch delta 415 zcmeB3e3iMOM|iTHAdhk?LkWW;Lm5LNLncEGkW2!SsSE)?vXmhmD3-@iJozmD^vylO zOze{{i0cuhVWEKMqJ#8tna&n-6@MbFw369NwG{qQIiLjGFW3r)=@Z delta 39 xcmV+?0NDTPX^3I4j1!am6c)2+6zm4GMjWIKlS&j0vydzl0khsK{sxn@G&WSx5Fh{m diff --git a/code/nel/tools/pipeline/service/module_pipeline_master_itf.xml b/code/nel/tools/pipeline/service/module_pipeline_master_itf.xml index 2ce5c5d78..7b3fe75e6 100644 --- a/code/nel/tools/pipeline/service/module_pipeline_master_itf.xml +++ b/code/nel/tools/pipeline/service/module_pipeline_master_itf.xml @@ -31,6 +31,12 @@ + + + + + + diff --git a/code/nel/tools/pipeline/service/module_pipeline_slave.cpp b/code/nel/tools/pipeline/service/module_pipeline_slave.cpp index 620f69ea0..2afd180a5 100644 --- a/code/nel/tools/pipeline/service/module_pipeline_slave.cpp +++ b/code/nel/tools/pipeline/service/module_pipeline_slave.cpp @@ -96,10 +96,11 @@ public: nlinfo("Master UP (%s)", moduleProxy->getModuleName().c_str()); nlassert(m_Master == NULL); - - // TODO: SAY HELLO m_Master = new CModulePipelineMasterProxy(moduleProxy); + + // TODO: AUTHENTICATE OR GATEWAY SECURITY? + sendMasterAvailablePlugins(); } } @@ -132,6 +133,7 @@ public: if (PIPELINE::isServiceStateIdle()) { m_ReloadSheetsState = REQUEST_NONE; + sendMasterAvailablePlugins(); m_Master->slaveReloadedSheets(this); CInfoFlags::getInstance()->removeFlag(PIPELINE_INFO_SLAVE_RELOAD_SHEETS); } @@ -163,6 +165,13 @@ public: if (PIPELINE::reloadSheets()) m_ReloadSheetsState = REQUEST_WORKING; else m_ReloadSheetsState = REQUEST_MADE; } + + void sendMasterAvailablePlugins() + { + std::vector availablePlugins; + g_PipelineWorkspace->listAvailablePlugins(availablePlugins); + m_Master->setAvailablePlugins(this, availablePlugins); + } protected: NLMISC_COMMAND_HANDLER_TABLE_EXTEND_BEGIN(CModulePipelineSlave, CModuleBase) diff --git a/code/nel/tools/pipeline/service/pipeline_service.cpp b/code/nel/tools/pipeline/service/pipeline_service.cpp index abf4d459e..3370b59ed 100644 --- a/code/nel/tools/pipeline/service/pipeline_service.cpp +++ b/code/nel/tools/pipeline/service/pipeline_service.cpp @@ -72,6 +72,7 @@ bool g_IsMaster = false; NLGEORGES::UFormLoader *g_FormLoader = NULL; CPipelineWorkspace *g_PipelineWorkspace = NULL; CDatabaseStatus *g_DatabaseStatus = NULL; +CPipelineInterfaceImpl *g_PipelineInterfaceImpl = NULL; std::string unMacroPath(const std::string &path) { @@ -119,7 +120,6 @@ enum EState /// Data CInfoFlags *s_InfoFlags = NULL; CTaskManager *s_TaskManager = NULL; -CPipelineInterfaceImpl *s_PipelineInterfaceImpl = NULL; CPipelineProcessImpl *s_PipelineProcessImpl = NULL; EState s_State = STATE_IDLE; @@ -390,7 +390,7 @@ public: g_DatabaseStatus = new CDatabaseStatus(); - s_PipelineInterfaceImpl = new CPipelineInterfaceImpl(); + g_PipelineInterfaceImpl = new CPipelineInterfaceImpl(); s_PipelineProcessImpl = new CPipelineProcessImpl(NULL); // Create a singleton impl for global usage without running project for test purposes. // Load libraries @@ -442,8 +442,8 @@ public: delete s_PipelineProcessImpl; s_PipelineProcessImpl = NULL; - delete s_PipelineInterfaceImpl; - s_PipelineInterfaceImpl = NULL; + delete g_PipelineInterfaceImpl; + g_PipelineInterfaceImpl = NULL; delete g_DatabaseStatus; g_DatabaseStatus = NULL; @@ -567,7 +567,7 @@ NLMISC_COMMAND(listProcessPlugins, "List process plugins.", "") 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()) + if (std::find(PIPELINE::g_PipelineInterfaceImpl->RegisteredClasses.begin(), PIPELINE::g_PipelineInterfaceImpl->RegisteredClasses.end(), it->Handler) != PIPELINE::g_PipelineInterfaceImpl->RegisteredClasses.end()) statusHandler = "AVAILABLE"; else statusHandler = "NOT FOUND"; @@ -579,7 +579,7 @@ NLMISC_COMMAND(listProcessPlugins, "List process plugins.", "") 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()) + case PIPELINE::PLUGIN_REGISTERED_CLASS:if (std::find(PIPELINE::g_PipelineInterfaceImpl->RegisteredClasses.begin(), PIPELINE::g_PipelineInterfaceImpl->RegisteredClasses.end(), it->Info) != PIPELINE::g_PipelineInterfaceImpl->RegisteredClasses.end()) statusInfo = "AVAILABLE"; else statusInfo = "NOT FOUND"; diff --git a/code/nel/tools/pipeline/service/pipeline_service.h b/code/nel/tools/pipeline/service/pipeline_service.h index 3915d6a65..145749d65 100644 --- a/code/nel/tools/pipeline/service/pipeline_service.h +++ b/code/nel/tools/pipeline/service/pipeline_service.h @@ -47,6 +47,7 @@ namespace NLGEORGES { namespace PIPELINE { class CPipelineWorkspace; class CDatabaseStatus; + class CPipelineInterfaceImpl; #define PIPELINE_MASTER @@ -81,6 +82,7 @@ bool reloadSheets(); extern NLGEORGES::UFormLoader *g_FormLoader; extern CPipelineWorkspace *g_PipelineWorkspace; extern CDatabaseStatus *g_DatabaseStatus; +extern CPipelineInterfaceImpl *g_PipelineInterfaceImpl; } /* namespace PIPELINE */ diff --git a/code/nel/tools/pipeline/service/pipeline_workspace.cpp b/code/nel/tools/pipeline/service/pipeline_workspace.cpp index efd1b7131..b85172615 100644 --- a/code/nel/tools/pipeline/service/pipeline_workspace.cpp +++ b/code/nel/tools/pipeline/service/pipeline_workspace.cpp @@ -37,6 +37,8 @@ // Project includes #include "pipeline_project.h" +#include "pipeline_service.h" +#include "pipeline_interface_impl.h" using namespace std; // using namespace NLMISC; @@ -113,7 +115,7 @@ CPipelineWorkspace::~CPipelineWorkspace() m_Projects.clear(); } -void CPipelineWorkspace::getProcessPlugins(std::vector &result, const std::string &process) +void CPipelineWorkspace::getProcessPlugins(std::vector &resultAppend, const std::string &process) { uint16 pluginId = 0; for (std::vector >::iterator it = m_Plugins.begin(), end = m_Plugins.end(); it != end; ++it) @@ -145,7 +147,7 @@ void CPipelineWorkspace::getProcessPlugins(std::vector &resu processPlugin.InfoType = (TPluginType)infoType; processPlugin.Id.Sub.Plugin = pluginId; processPlugin.Id.Sub.Handler = i; - result.push_back(processPlugin); + resultAppend.push_back(processPlugin); nldebug("Found '%s': '%s', '%s'", process.c_str(), processPlugin.Handler.c_str(), processPlugin.Info.c_str()); } @@ -203,6 +205,93 @@ bool CPipelineWorkspace::getProcessPlugin(CProcessPluginInfo &result, uint32 glo else return false; } +void CPipelineWorkspace::listAvailablePlugins(std::vector &result) +{ + result.clear(); + uint16 pluginId = 0; + 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")) + { + 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; + processPlugin.Id.Sub.Plugin = pluginId; + processPlugin.Id.Sub.Handler = i; + + bool handlerAvailable = false; + switch (processPlugin.HandlerType) + { + case PLUGIN_REGISTERED_CLASS: + handlerAvailable = (find(g_PipelineInterfaceImpl->RegisteredClasses.begin(), g_PipelineInterfaceImpl->RegisteredClasses.end(), processPlugin.Handler) != g_PipelineInterfaceImpl->RegisteredClasses.end()); + break; + default: + nlwarning("Not implemented"); + break; + } + + if (handlerAvailable) + { + bool infoAvailable = false; + switch (processPlugin.InfoType) + { + case PLUGIN_REGISTERED_CLASS: + infoAvailable = (find(g_PipelineInterfaceImpl->RegisteredClasses.begin(), g_PipelineInterfaceImpl->RegisteredClasses.end(), processPlugin.Info) != g_PipelineInterfaceImpl->RegisteredClasses.end()); + break; + default: + nlwarning("Not implemented"); + break; + } + if (infoAvailable) + { + nldebug("Available '%s', '%s'", processPlugin.Handler.c_str(), processPlugin.Info.c_str()); + result.push_back(processPlugin.Id.Global); + } + } + + } + 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()); + } + ++pluginId; + } +} + CPipelineProject *CPipelineWorkspace::getProject(const std::string &project) { std::map::const_iterator it = m_Projects.find(project); diff --git a/code/nel/tools/pipeline/service/pipeline_workspace.h b/code/nel/tools/pipeline/service/pipeline_workspace.h index 7e48f04bd..96b2d5c9f 100644 --- a/code/nel/tools/pipeline/service/pipeline_workspace.h +++ b/code/nel/tools/pipeline/service/pipeline_workspace.h @@ -90,10 +90,13 @@ public: CPipelineWorkspace(NLGEORGES::UFormLoader *formLoader, const std::string &sheetName); virtual ~CPipelineWorkspace(); - void getProcessPlugins(std::vector &result, const std::string &process); + void getProcessPlugins(std::vector &resultAppend, const std::string &process); CPipelineProject *getProject(const std::string &project); bool getProcessPlugin(CProcessPluginInfo &result, uint32 globalId); + /// Makes a list of the global id of all available plugins to this service + void listAvailablePlugins(std::vector &result); + }; /* class CPipelineWorkspace */ } /* namespace PIPELINE */