diff --git a/code/nel/tools/pipeline/plugin_library/pipeline_process.h b/code/nel/tools/pipeline/plugin_library/pipeline_process.h index 41d363cdc..e744fb31f 100644 --- a/code/nel/tools/pipeline/plugin_library/pipeline_process.h +++ b/code/nel/tools/pipeline/plugin_library/pipeline_process.h @@ -48,16 +48,21 @@ class IPipelineProcess public: IPipelineProcess() { } virtual ~IPipelineProcess() { } - + static IPipelineProcess *getInstance(); - + // ***************** PROCESS FUNCTIONS (EASILY EXPOSABLE TO SCRIPTS ETCETERA) ***************** - - /// Get a parsed georges sheets value from the current project. (example: Interface.DstDirectory) - virtual std::string getProjectValue(const std::string &name) = 0; - + + /// Gets the output directory for the project. + virtual std::string getOutputDirectory() = 0; + /// Get the temporary directory for the current process. The directory must be deleted when the process ends. May return random temporary directories if no process is running. - virtual std::string getTempDir() = 0; + virtual std::string getTempDirectory() = 0; + + /// Get a value from the currently active project configuration + virtual bool getValue(std::string &result, const std::string &name) = 0; + virtual bool getValues(std::vector &resultAppend, const std::string &name) = 0; + virtual bool getValueNb(uint &result, const std::string &name) = 0; }; /* class IPipelineProcess */ } /* namespace PIPELINE */ diff --git a/code/nel/tools/pipeline/plugin_library/process_info.h b/code/nel/tools/pipeline/plugin_library/process_info.h index ab0aa5f2e..0495af92e 100644 --- a/code/nel/tools/pipeline/plugin_library/process_info.h +++ b/code/nel/tools/pipeline/plugin_library/process_info.h @@ -38,6 +38,7 @@ #include // Project includes +#include "pipeline_process.h" namespace PIPELINE { @@ -49,16 +50,19 @@ namespace PIPELINE { */ class IProcessInfo : public NLMISC::IClassable { +protected: + IPipelineProcess *m_PipelineProcess; + public: - IProcessInfo() { } + IProcessInfo() : m_PipelineProcess(IPipelineProcess::getInstance()) { } virtual ~IProcessInfo() { } + void setPipelineProcess(IPipelineProcess *pipelineProcess) { m_PipelineProcess = pipelineProcess; } + /// Dependency information used to store the initial state of files on which the process depends. /// A process handler is not allowed to depend on any files it does not list here. - /// Must return all directories on which the process handler recursively depends. - virtual void getDependentDirectoriesRecursive(std::vector &result) = 0; - /// Must return all directories on which the process handler depends. + /// Must return all directories on which the process handler depends, these are NOT RECURSIVE. virtual void getDependentDirectories(std::vector &result) = 0; /// Must return all files on which the process handler depends, ONLY if these are not in dependent directories. virtual void getDependentFiles(std::vector &result) = 0; diff --git a/code/nel/tools/pipeline/plugin_max/process_max_shape.cpp b/code/nel/tools/pipeline/plugin_max/process_max_shape.cpp index 9be9b30d3..a9379d18d 100644 --- a/code/nel/tools/pipeline/plugin_max/process_max_shape.cpp +++ b/code/nel/tools/pipeline/plugin_max/process_max_shape.cpp @@ -66,7 +66,7 @@ public: virtual void run() { - std::string tempDirectory = PIPELINE::IPipelineProcess::getInstance()->getTempDir(); + std::string tempDirectory = PIPELINE::IPipelineProcess::getInstance()->getTempDirectory(); PIPELINE::IPipelineInterface::getInstance()->endedRunnableTask(); } 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 4eb368c09..8d07840a5 100644 --- a/code/nel/tools/pipeline/plugin_nel/process_interface_info.cpp +++ b/code/nel/tools/pipeline/plugin_nel/process_interface_info.cpp @@ -29,6 +29,7 @@ #include "process_interface_info.h" // STL includes +#include // NeL includes // #include @@ -50,14 +51,42 @@ CProcessInterfaceInfo::~CProcessInterfaceInfo() } -void CProcessInterfaceInfo::getDependentDirectoriesRecursive(std::vector &result) -{ - -} - void CProcessInterfaceInfo::getDependentDirectories(std::vector &result) { - + { + uint nb; + if (m_PipelineProcess->getValueNb(nb, "Interface.Atlas")) + { + for (uint i = 0; i < nb; ++i) + { + std::stringstream ss; + ss << "Interface.Atlas[" << i << "].SrcDirectories"; + m_PipelineProcess->getValues(result, ss.str()); + } + } + } + { + uint nb; + if (m_PipelineProcess->getValueNb(nb, "Interface.AtlasDxtc")) + { + for (uint i = 0; i < nb; ++i) + { + std::stringstream ss; + ss << "Interface.AtlasDxtc[" << i << "].SrcDirectories"; + m_PipelineProcess->getValues(result, ss.str()); + } + } + } + { + std::stringstream ss; + ss << "Interface.Fullscreen.SrcDirectories"; + m_PipelineProcess->getValues(result, ss.str()); + } + { + std::stringstream ss; + ss << "Interface.3D.SrcDirectories"; + m_PipelineProcess->getValues(result, ss.str()); + } } void CProcessInterfaceInfo::getDependentFiles(std::vector &result) diff --git a/code/nel/tools/pipeline/plugin_nel/process_interface_info.h b/code/nel/tools/pipeline/plugin_nel/process_interface_info.h index b294af536..6a6cfbf7b 100644 --- a/code/nel/tools/pipeline/plugin_nel/process_interface_info.h +++ b/code/nel/tools/pipeline/plugin_nel/process_interface_info.h @@ -56,7 +56,6 @@ public: CProcessInterfaceInfo(); virtual ~CProcessInterfaceInfo(); - virtual void getDependentDirectoriesRecursive(std::vector &result); virtual void getDependentDirectories(std::vector &result); virtual void getDependentFiles(std::vector &result); diff --git a/code/nel/tools/pipeline/service/pipeline_process_impl.cpp b/code/nel/tools/pipeline/service/pipeline_process_impl.cpp index db973cc11..84cf9b227 100644 --- a/code/nel/tools/pipeline/service/pipeline_process_impl.cpp +++ b/code/nel/tools/pipeline/service/pipeline_process_impl.cpp @@ -38,34 +38,48 @@ // Project includes #include "pipeline_service.h" +#include "pipeline_project.h" using namespace std; // using namespace NLMISC; namespace PIPELINE { -CPipelineProcessImpl::CPipelineProcessImpl() +CPipelineProcessImpl::CPipelineProcessImpl(CPipelineProject *activeProject) : m_ActiveProject(activeProject) { - nlassert(getInstance() == NULL); - NLMISC::INelContext::getInstance().setSingletonPointer("IPipelineProcess", this); + if (activeProject == NULL) + { + nlassert(getInstance() == NULL); + NLMISC::INelContext::getInstance().setSingletonPointer("IPipelineProcess", this); + } } CPipelineProcessImpl::~CPipelineProcessImpl() { - NLMISC::INelContext::getInstance().releaseSingletonPointer("IPipelineProcess", this); + if (m_ActiveProject == NULL) + { + NLMISC::INelContext::getInstance().releaseSingletonPointer("IPipelineProcess", this); + } } -std::string CPipelineProcessImpl::getProjectValue(const std::string &name) +std::string CPipelineProcessImpl::getOutputDirectory() { - return ""; // TODO + if (m_ActiveProject == NULL) + { + nlwarning("(m_ActiveProject == NULL)"); + return getTempDirectory(); + } + else + { + return m_ActiveProject->getOutputDirectory(); + } } -std::string CPipelineProcessImpl::getTempDir() +std::string CPipelineProcessImpl::getTempDirectory() { - // IF PROJECT blahblah TODO - // ELSE - + if (m_ActiveProject == NULL) { + nlwarning("(m_ActiveProject == NULL)"); std::stringstream ss; ss << g_PipelineDirectory; ss << NLMISC::CTime::getSecondsSince1970(); @@ -74,6 +88,49 @@ std::string CPipelineProcessImpl::getTempDir() ss << PIPELINE_DIRECTORY_TEMP_SUFFIX; return ss.str(); } + else + { + return m_ActiveProject->getTempDirectory(); + } +} + +bool CPipelineProcessImpl::getValue(std::string &result, const std::string &name) +{ + if (m_ActiveProject == NULL) + { + nlwarning("(m_ActiveProject == NULL)"); + return false; + } + else + { + return m_ActiveProject->getValue(result, name); + } +} + +bool CPipelineProcessImpl::getValues(std::vector &resultAppend, const std::string &name) +{ + if (m_ActiveProject == NULL) + { + nlwarning("(m_ActiveProject == NULL)"); + return false; + } + else + { + return m_ActiveProject->getValues(resultAppend, name); + } +} + +bool CPipelineProcessImpl::getValueNb(uint &result, const std::string &name) +{ + if (m_ActiveProject == NULL) + { + nlwarning("(m_ActiveProject == NULL)"); + return false; + } + else + { + return m_ActiveProject->getValueNb(result, name); + } } } /* namespace PIPELINE */ diff --git a/code/nel/tools/pipeline/service/pipeline_process_impl.h b/code/nel/tools/pipeline/service/pipeline_process_impl.h index 53faf3ccb..7e8d00d49 100644 --- a/code/nel/tools/pipeline/service/pipeline_process_impl.h +++ b/code/nel/tools/pipeline/service/pipeline_process_impl.h @@ -37,6 +37,7 @@ #include "../plugin_library/pipeline_process.h" namespace PIPELINE { + class CPipelineProject; /** * \brief CPipelineProcessImpl @@ -46,12 +47,19 @@ namespace PIPELINE { */ class CPipelineProcessImpl : public IPipelineProcess { +private: + CPipelineProject *m_ActiveProject; + public: - CPipelineProcessImpl(); + CPipelineProcessImpl(CPipelineProject *activeProject); virtual ~CPipelineProcessImpl(); + + virtual std::string getOutputDirectory(); + virtual std::string getTempDirectory(); + virtual bool getValue(std::string &result, const std::string &name); + virtual bool getValues(std::vector &resultAppend, const std::string &name); + virtual bool getValueNb(uint &result, const std::string &name); - virtual std::string getProjectValue(const std::string &name); - virtual std::string getTempDir(); }; /* class CPipelineProcessImpl */ } /* namespace PIPELINE */ diff --git a/code/nel/tools/pipeline/service/pipeline_service.cpp b/code/nel/tools/pipeline/service/pipeline_service.cpp index 635741cc3..b1027842c 100644 --- a/code/nel/tools/pipeline/service/pipeline_service.cpp +++ b/code/nel/tools/pipeline/service/pipeline_service.cpp @@ -53,7 +53,7 @@ #include "database_status.h" #include "pipeline_interface_impl.h" #include "pipeline_process_impl.h" - +#include "../plugin_library/process_info.h" // using namespace std; using namespace NLMISC; @@ -318,7 +318,7 @@ public: s_DatabaseStatus = new CDatabaseStatus(); s_PipelineInterfaceImpl = new CPipelineInterfaceImpl(); - s_PipelineProcessImpl = new CPipelineProcessImpl(); + s_PipelineProcessImpl = new CPipelineProcessImpl(NULL); // Create a singleton impl for global usage without running project for test purposes. // Load libraries const CConfigFile::CVar &usedPlugins = ConfigFile.getVar("UsedPlugins"); @@ -526,6 +526,48 @@ NLMISC_COMMAND(showProjectValue, "Show project value.", " ") +{ + if(args.size() != 2) return false; + std::vector plugins; + PIPELINE::g_PipelineWorkspace->getProcessPlugins(plugins, args[1]); + PIPELINE::CPipelineProject *project = PIPELINE::g_PipelineWorkspace->getProject(args[0]); + if (project) + { + PIPELINE::IPipelineProcess *pipelineProcess = new PIPELINE::CPipelineProcessImpl(project); + for (std::vector::iterator plugin_it = plugins.begin(), plugin_end = plugins.end(); plugin_it != plugin_end; ++plugin_it) + { + switch (plugin_it->InfoType) + { + case PIPELINE::PLUGIN_REGISTERED_CLASS: + { + PIPELINE::IProcessInfo *processInfo = static_cast(NLMISC::CClassRegistry::create(plugin_it->Info)); + log.displayNL("PROCESS_INFO: %s", plugin_it->Info.c_str()); + processInfo->setPipelineProcess(pipelineProcess); + std::vector result; + processInfo->getDependentDirectories(result); + for (std::vector::iterator it = result.begin(), end = result.end(); it != end; ++it) + log.displayNL("DIRECTORY: %s", it->c_str()); + result.clear(); + processInfo->getDependentFiles(result); + for (std::vector::iterator it = result.begin(), end = result.end(); it != end; ++it) + log.displayNL("FILE: %s", it->c_str()); + } + break; + default: + nlwarning("Not implemented."); + break; + } + } + } + else + { + log.displayNL("Project '%s' does not exist", args[0].c_str()); + return false; + } + return true; +} + 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 */