Added: Plugin process class registration.

--HG--
branch : build_pipeline_v3
hg/feature/build_pipeline_v3
kaetemi 13 years ago
parent a007f7f2c9
commit 10f7ac32be

@ -32,6 +32,7 @@
// STL includes // STL includes
// NeL includes // NeL includes
#include <nel/misc/class_registry.h>
// Project includes // Project includes
@ -53,11 +54,15 @@ public:
IPipelineInterface() { } IPipelineInterface() { }
virtual ~IPipelineInterface() { } virtual ~IPipelineInterface() { }
IPipelineInterface *getInstance(); static IPipelineInterface *getInstance();
virtual NLMISC::CConfigFile &getConfigFile() = 0; virtual NLMISC::CConfigFile &getConfigFile() = 0;
virtual void registerClass(const std::string &className, NLMISC::IClassable* (*creator)(), const std::string &typeidCheck) throw(NLMISC::ERegistry) = 0;
}; /* class IPipelineInterface */ }; /* class IPipelineInterface */
#define PIPELINE_REGISTER_CLASS(_class_) PIPELINE::IPipelineInterface::getInstance()->registerClass(#_class_, _class_::creator, typeid(_class_).name());
} /* namespace PIPELINE */ } /* namespace PIPELINE */
#endif /* #ifndef PIPELINE_PIPELINE_INTERFACE_H */ #endif /* #ifndef PIPELINE_PIPELINE_INTERFACE_H */

@ -32,6 +32,7 @@
// STL includes // STL includes
// NeL includes // NeL includes
#include <nel/misc/class_registry.h>
// Project includes // Project includes
@ -47,7 +48,7 @@ namespace PIPELINE {
* The master service may dispatch these seperately to different slave services to executa a single process sheets using multiple process plugins. * The master service may dispatch these seperately to different slave services to executa a single process sheets using multiple process plugins.
* This enables creating seperate plugins for different file formats for the same process, to allow handling files from different modeling packages on different build servers. * This enables creating seperate plugins for different file formats for the same process, to allow handling files from different modeling packages on different build servers.
*/ */
class IProcessPlugin class IProcessPlugin : public NLMISC::IClassable
{ {
protected: protected:
// pointers // pointers

@ -35,6 +35,8 @@
#include "nel/misc/debug.h" #include "nel/misc/debug.h"
// Project includes // Project includes
#include "../pipeline_library/pipeline_interface.h"
#include "process_max_shape.h"
using namespace std; using namespace std;
// using namespace NLMISC; // using namespace NLMISC;
@ -43,9 +45,17 @@ namespace PIPELINE {
// ****************************************************************** // ******************************************************************
class CPipelinePluginMaxNelLibrary : public NLMISC::INelLibrary { class CPipelinePluginMaxNelLibrary : public NLMISC::INelLibrary
void onLibraryLoaded(bool /* firstTime */) { nldebug("Library loaded: CPipelinePluginMax"); } {
void onLibraryUnloaded(bool /* lastTime */) { nldebug("Library unloaded: CPipelinePluginMax"); } void onLibraryLoaded(bool /* firstTime */)
{
nldebug("Library loaded: CPipelinePluginMax");
PIPELINE_REGISTER_CLASS(CProcessMaxShape);
}
void onLibraryUnloaded(bool /* lastTime */)
{
nldebug("Library unloaded: CPipelinePluginMax");
}
}; };
NLMISC_DECL_PURE_LIB(CPipelinePluginMaxNelLibrary) NLMISC_DECL_PURE_LIB(CPipelinePluginMaxNelLibrary)

@ -34,6 +34,7 @@
// NeL includes // NeL includes
// Project includes // Project includes
#include "../pipeline_library/process_plugin.h"
namespace PIPELINE { namespace PIPELINE {
@ -43,7 +44,7 @@ namespace PIPELINE {
* \author Jan Boon (Kaetemi) * \author Jan Boon (Kaetemi)
* CProcessMaxShape * CProcessMaxShape
*/ */
class CProcessMaxShape class CProcessMaxShape : public IProcessPlugin
{ {
protected: protected:
// pointers // pointers
@ -54,6 +55,8 @@ protected:
public: public:
CProcessMaxShape(); CProcessMaxShape();
virtual ~CProcessMaxShape(); virtual ~CProcessMaxShape();
NLMISC_DECLARE_CLASS(CProcessMaxShape)
}; /* class CProcessMaxShape */ }; /* class CProcessMaxShape */
} /* namespace PIPELINE */ } /* namespace PIPELINE */

@ -34,6 +34,7 @@
#include <nel/misc/app_context.h> #include <nel/misc/app_context.h>
#include <nel/misc/debug.h> #include <nel/misc/debug.h>
#include <nel/net/service.h> #include <nel/net/service.h>
#include <nel/misc/class_registry.h>
// Project includes // Project includes
@ -58,6 +59,13 @@ NLMISC::CConfigFile &CPipelineInterfaceImpl::getConfigFile()
return NLNET::IService::getInstance()->ConfigFile; return NLNET::IService::getInstance()->ConfigFile;
} }
void CPipelineInterfaceImpl::registerClass(const std::string &className, NLMISC::IClassable* (*creator)(), const std::string &typeidCheck) throw(NLMISC::ERegistry)
{
NLMISC::CClassRegistry::registerClass(className, creator, typeidCheck);
RegisteredClasses.push_back(className);
nldebug("Registered class '%s'", className.c_str());
}
} /* namespace PIPELINE */ } /* namespace PIPELINE */
/* end of file */ /* end of file */

@ -30,6 +30,8 @@
#include <nel/misc/types_nl.h> #include <nel/misc/types_nl.h>
// STL includes // STL includes
#include <vector>
#include <string>
// NeL includes // NeL includes
@ -46,6 +48,8 @@ namespace PIPELINE {
*/ */
class CPipelineInterfaceImpl : public IPipelineInterface class CPipelineInterfaceImpl : public IPipelineInterface
{ {
public:
std::vector<std::string> RegisteredClasses;
protected: protected:
// pointers // pointers
// ... // ...
@ -57,6 +61,7 @@ public:
virtual ~CPipelineInterfaceImpl(); virtual ~CPipelineInterfaceImpl();
virtual NLMISC::CConfigFile &getConfigFile(); virtual NLMISC::CConfigFile &getConfigFile();
virtual void registerClass(const std::string &className, NLMISC::IClassable* (*creator)(), const std::string &typeidCheck) throw(NLMISC::ERegistry);
}; /* class CPipelineInterfaceImpl */ }; /* class CPipelineInterfaceImpl */
} /* namespace PIPELINE */ } /* namespace PIPELINE */

@ -50,6 +50,7 @@
// Project includes // Project includes
#include "pipeline_workspace.h" #include "pipeline_workspace.h"
#include "database_status.h" #include "database_status.h"
#include "pipeline_interface_impl.h"
// using namespace std; // using namespace std;
using namespace NLMISC; using namespace NLMISC;
@ -108,6 +109,7 @@ UFormLoader *s_FormLoader = NULL;
CPipelineWorkspace *s_PipelineWorkspace = NULL; CPipelineWorkspace *s_PipelineWorkspace = NULL;
CTaskManager *s_TaskManager = NULL; CTaskManager *s_TaskManager = NULL;
CDatabaseStatus *s_DatabaseStatus = NULL; CDatabaseStatus *s_DatabaseStatus = NULL;
CPipelineInterfaceImpl *s_PipelineInterfaceImpl = NULL;
EState s_State = STATE_IDLE; EState s_State = STATE_IDLE;
CMutex s_StateMutex; CMutex s_StateMutex;
@ -273,6 +275,8 @@ public:
s_DatabaseStatus = new CDatabaseStatus(); s_DatabaseStatus = new CDatabaseStatus();
s_PipelineInterfaceImpl = new CPipelineInterfaceImpl();
// Load libraries // Load libraries
const CConfigFile::CVar &usedPlugins = ConfigFile.getVar("UsedPlugins"); const CConfigFile::CVar &usedPlugins = ConfigFile.getVar("UsedPlugins");
s_LoadedLibraries.reserve(usedPlugins.size()); s_LoadedLibraries.reserve(usedPlugins.size());
@ -311,6 +315,9 @@ public:
} }
s_LoadedLibraries.clear(); s_LoadedLibraries.clear();
delete s_PipelineInterfaceImpl;
s_PipelineInterfaceImpl = NULL;
delete s_DatabaseStatus; delete s_DatabaseStatus;
s_DatabaseStatus = NULL; s_DatabaseStatus = NULL;

Loading…
Cancel
Save