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
// NeL includes
#include <nel/misc/class_registry.h>
// Project includes
@ -53,11 +54,15 @@ public:
IPipelineInterface() { }
virtual ~IPipelineInterface() { }
IPipelineInterface *getInstance();
static IPipelineInterface *getInstance();
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 */
#define PIPELINE_REGISTER_CLASS(_class_) PIPELINE::IPipelineInterface::getInstance()->registerClass(#_class_, _class_::creator, typeid(_class_).name());
} /* namespace PIPELINE */
#endif /* #ifndef PIPELINE_PIPELINE_INTERFACE_H */

@ -32,6 +32,7 @@
// STL includes
// NeL includes
#include <nel/misc/class_registry.h>
// 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.
* 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:
// pointers

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

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

@ -34,6 +34,7 @@
#include <nel/misc/app_context.h>
#include <nel/misc/debug.h>
#include <nel/net/service.h>
#include <nel/misc/class_registry.h>
// Project includes
@ -58,6 +59,13 @@ NLMISC::CConfigFile &CPipelineInterfaceImpl::getConfigFile()
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 */
/* end of file */

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

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

Loading…
Cancel
Save