Salome HOME
Features and plugins loading mechanisms
authormpv <mikhail.ponikarov@opencascade.com>
Mon, 31 Mar 2014 13:21:32 +0000 (17:21 +0400)
committermpv <mikhail.ponikarov@opencascade.com>
Mon, 31 Mar 2014 13:21:32 +0000 (17:21 +0400)
21 files changed:
env.bat
src/Config/Config_FeatureReader.cpp
src/Config/Config_XMLReader.cpp
src/Event/Event_Listener.h
src/Event/Event_Loop.cxx
src/Event/Event_Loop.h
src/Event/Event_Message.h
src/Model/Model_PluginManager.cxx
src/Model/Model_PluginManager.h
src/ModelAPI/CMakeLists.txt
src/ModelAPI/ModelAPI_Document.h
src/ModelAPI/ModelAPI_Feature.h
src/ModelAPI/ModelAPI_Plugin.h [new file with mode: 0644]
src/ModelAPI/ModelAPI_PluginManager.cxx
src/ModelAPI/ModelAPI_PluginManager.h
src/PartSetPlugin/CMakeLists.txt
src/PartSetPlugin/PartSetPlugin.cxx [deleted file]
src/PartSetPlugin/PartSetPlugin_Plugin.cxx [new file with mode: 0644]
src/PartSetPlugin/PartSetPlugin_Plugin.h [new file with mode: 0644]
src/XGUI/XGUI_Workshop.cpp
src/XGUI/XGUI_Workshop.h

diff --git a/env.bat b/env.bat
index b0d1e3dec52deb53e5ffb995c2cc46c648e61249..2ac0c4d6a685e1a6d69953c5456419257ab16cce 100644 (file)
--- a/env.bat
+++ b/env.bat
@@ -128,6 +128,9 @@ if "%QTDIR%" == "" (
 
 @SET PATH=D:\NewGEOM\build-eclipse\bin;%PATH%
 
+@SET NEW_GEOM_CONFIG_FILE=%ROOT_DIR%\install\plugins
+@SET PATH=%ROOT_DIR%\install\plugins;%PATH%
+
 rem -------- Visual Studio --------------------
 rem Detect Visual Studio (either commercial or Express edition)
 if "%VS100COMNTOOLS%" == "" (
index d95ee7dcc3b9ca35e03c4a2b7d97cbbf5b7d3d30..73a5c07fbcfddde72c466e6ea4c84725df7f7743 100644 (file)
@@ -39,7 +39,7 @@ Config_FeatureReader::Config_FeatureReader(const std::string& theXmlFile)
   myLibraryName = "";
 
 #ifdef _DEBUG
-  if (!Event_Loop::Loop()) {
+  if (!Event_Loop::loop()) {
     std::cout << "Config_FeatureReader::importWorkbench: "
         << "No event loop registered" << std::endl;
   }
@@ -53,7 +53,7 @@ Config_FeatureReader::Config_FeatureReader(const std::string& theXmlFile,
       myFetchWidgetCfg(false)
 {
 #ifdef _DEBUG
-  if (!Event_Loop::Loop()) {
+  if (!Event_Loop::loop()) {
     std::cout << "Config_FeatureReader::importWorkbench: "
         << "No event loop registered" << std::endl;
   }
@@ -74,16 +74,17 @@ std::string Config_FeatureReader::featureWidgetCfg(std::string theFeatureName)
 
 void Config_FeatureReader::processNode(xmlNodePtr theNode)
 {
+  static Event_ID aMenuItemEvent = Event_Loop::eventByName("RegisterFeature");
   if (isNode(theNode, NODE_FEATURE, NULL)) {
     if (myFetchWidgetCfg) {
       xmlBufferPtr buffer = xmlBufferCreate();
       int size = xmlNodeDump(buffer, theNode->doc, theNode, 0, 1);
       myWidgetCfg = std::string((char*) buffer->content);
     } else {
-      Event_Loop* aEvLoop = Event_Loop::Loop();
-      Config_FeatureMessage aMessage(aEvLoop->EventByName("menu_item"), this);
+      Event_Loop* aEvLoop = Event_Loop::loop();
+      Config_FeatureMessage aMessage(aMenuItemEvent, this);
       fillFeature(theNode, aMessage);
-      aEvLoop->Send(aMessage);
+      aEvLoop->send(aMessage);
     }
   }
   //The m_last* variables always defined before fillFeature() call. XML is a tree.
index 89f0d46fcd40d60665bee539f3f356f4c0131033..1b206af8223add70ded12b6f69ca69a619f8d4f2 100644 (file)
 #include <libxml\parser.h>
 #include <libxml\tree.h>
 
+/*
 #ifdef WIN32
 //For GetModuleFileNameW
 #include <windows.h>
 #endif
+*/
 
 #ifdef _DEBUG
 #include <iostream>
@@ -23,6 +25,8 @@
 Config_XMLReader::Config_XMLReader(const std::string& theXmlFileName)
 {
   std::string prefix;
+  /* the problem: application may be launched using python execuable, to use environment variable
+                  (at least for the current moment)
   //Get path to *.xml files (typically ./bin/../plugins/)
 #ifdef WIN32
   HMODULE hModule = GetModuleHandleW(NULL);
@@ -40,6 +44,11 @@ Config_XMLReader::Config_XMLReader(const std::string& theXmlFileName)
   //TODO(sbh): Find full path to binary on linux
   prefix = "../plugins/";
 #endif
+  */
+  char* anEnv = getenv("NEW_GEOM_CONFIG_FILE");
+  if (anEnv) {
+    prefix = std::string(anEnv) + "/";
+  }
 
   myDocumentPath = prefix + theXmlFileName;
 }
@@ -109,8 +118,6 @@ xmlNodePtr Config_XMLReader::findRoot()
  */
 void Config_XMLReader::readRecursively(xmlNodePtr theParent)
 {
-  static Event_ID aFeatureEvent = Event_Loop::EventByName("Feature");
-
   if (!theParent)
     return;
   xmlNodePtr aNode = theParent->xmlChildrenNode;
@@ -118,7 +125,6 @@ void Config_XMLReader::readRecursively(xmlNodePtr theParent)
     processNode(aNode);
     if (processChildren(aNode)) {
       readRecursively(aNode);
-      Config_FeatureMessage aMessage(aFeatureEvent, this);
     }
   }
 }
index 80719d42d12b8d8f27c7e454006bdf8bd47078c1..c47d28dbf42a43e3180b553f935bdf48dcbc8c68 100644 (file)
@@ -19,7 +19,7 @@ class EVENT_EXPORT Event_Listener {
 
 public:
   //! This method is called by loop when the event is started to process.
-  virtual void ProcessEvent(const Event_Message* theMessage) = 0;
+  virtual void processEvent(const Event_Message* theMessage) = 0;
 };
 
 #endif
index ffcd6c6e54993eef9de36c95a3c14c997193ef84..c5cadce448a9c687508757504dc231ddf97d90ab 100644 (file)
@@ -7,14 +7,14 @@
 
 using namespace std;
 
-Event_Loop* Event_Loop::Loop()
+Event_Loop* Event_Loop::loop()
 {
   // initialized on initialization of the application
   static Event_Loop MAIN_LOOP;
   return &MAIN_LOOP;
 }
 
-Event_ID Event_Loop::EventByName(const char* theName)
+Event_ID Event_Loop::eventByName(const char* theName)
 {
   ///! All events created in this session, uniquely identified by the text and char pointer
   static map<string, char*> CREATED_EVENTS;
@@ -30,39 +30,39 @@ Event_ID Event_Loop::EventByName(const char* theName)
   return Event_ID(aResult);
 }
 
-void Event_Loop::Send(Event_Message& theMessage)
+void Event_Loop::send(Event_Message& theMessage)
 {
   // TO DO: make it in thread and wit husage of semaphores
 
   map<char*, map<void*, list<Event_Listener*> > >::iterator aFindID = myListeners.find(
-      theMessage.EventID().EventText());
+      theMessage.eventID().eventText());
   if (aFindID != myListeners.end()) {
     map<void*, list<Event_Listener*> >::iterator aFindSender = aFindID->second.find(
-        theMessage.Sender());
+        theMessage.sender());
     if (aFindSender != aFindID->second.end()) {
       list<Event_Listener*>& aListeners = aFindSender->second;
       for(list<Event_Listener*>::iterator aL = aListeners.begin(); aL != aListeners.end(); aL++)
-        (*aL)->ProcessEvent(&theMessage);
+        (*aL)->processEvent(&theMessage);
     }
-    if (theMessage.Sender()) { // also call for NULL senders registered
+    if (theMessage.sender()) { // also call for NULL senders registered
       aFindSender = aFindID->second.find(NULL);
       if (aFindSender != aFindID->second.end()) {
         list<Event_Listener*>& aListeners = aFindSender->second;
         for(list<Event_Listener*>::iterator aL = aListeners.begin(); aL != aListeners.end(); aL++)
-          (*aL)->ProcessEvent(&theMessage);
+          (*aL)->processEvent(&theMessage);
       }
     }
   }
 }
 
-void Event_Loop::RegisterListener(Event_Listener* theListener, const Event_ID theID,
+void Event_Loop::registerListener(Event_Listener* theListener, const Event_ID theID,
                                   void* theSender)
 {
   map<char*, map<void*, list<Event_Listener*> > >::iterator aFindID = myListeners.find(
-      theID.EventText());
+      theID.eventText());
   if (aFindID == myListeners.end()) { // create container associated with ID
-    myListeners[theID.EventText()] = map<void*, list<Event_Listener*> >();
-    aFindID = myListeners.find(theID.EventText());
+    myListeners[theID.eventText()] = map<void*, list<Event_Listener*> >();
+    aFindID = myListeners.find(theID.eventText());
   }
 
   map<void*, list<Event_Listener*> >::iterator aFindSender = aFindID->second.find(theSender);
index d93b942eb668fdd8c5c3480d60183340b38afe67..60ddacd738711abe0ec4dc04920c58f05cba248d 100644 (file)
@@ -29,17 +29,17 @@ class Event_Loop {
   Event_Loop() {};
 public:
   ///! Returns the main object of the loop, one per application.
-  EVENT_EXPORT static Event_Loop* Loop();
+  EVENT_EXPORT static Event_Loop* loop();
   //! Returns the unique event by the given name. Call this method only on initialization of object
   //! to speedup the events processing without parsing of the string.
-  EVENT_EXPORT static Event_ID EventByName(const char* theName);
+  EVENT_EXPORT static Event_ID eventByName(const char* theName);
 
   //! Allows to send an event
-  EVENT_EXPORT void Send(Event_Message& theMessage);
+  EVENT_EXPORT void send(Event_Message& theMessage);
 
   //! Registers (or adds if such listener is already registered) a listener 
   //! that will be called on the event and from the defined sender
-  EVENT_EXPORT void RegisterListener(Event_Listener* theListener, const Event_ID theID, 
+  EVENT_EXPORT void registerListener(Event_Listener* theListener, const Event_ID theID, 
     void* theSender = 0);
 };
 
index 27608b7bf8641a8e42c877a48b91cd1c5ea201d5..6c851815c65372c0d3042e2e134a9ea8e2dc45ab 100644 (file)
@@ -25,7 +25,7 @@ class EVENT_EXPORT Event_ID {
   friend class Event_Loop;
 public:
   /// Returns the text-identifier of the event (for debugging reasons)
-  char* EventText() const {return myID;}
+  char* eventText() const {return myID;}
   /// Allows to compare identifiers
   bool operator==(const Event_ID& theID) const {return myID == theID.myID;}
 };
@@ -46,10 +46,10 @@ public:
   virtual ~Event_Message() {}
 
   //! Returns identifier of the message
-  const Event_ID& EventID() const {return myEventId;}
+  const Event_ID& eventID() const {return myEventId;}
 
   //! Returns sender of the message or NULL if it is anonymous message
-  void* Sender() {return mySender;}
+  void* sender() {return mySender;}
 };
 
 #endif
index e06c66518f1a5e4dba6bd8197126f686bc4962bb..c4e28665dcd82d3e7d086d489d0ca02ac801caeb 100644 (file)
@@ -4,33 +4,29 @@
 
 #include <Model_PluginManager.h>
 #include <ModelAPI_Feature.h>
+#include <ModelAPI_Plugin.h>
 #include <Model_Feature.h>
 #include <Event_Loop.h>
 #include <Config_FeatureMessage.h>
 #include <Config_ModuleReader.h>
 
-#include <OSD_SharedLibrary.hxx>
-
 using namespace std;
 
 static Model_PluginManager* myImpl = new Model_PluginManager();
 
-boost::shared_ptr<ModelAPI_Feature> Model_PluginManager::CreateFeature(string theFeatureID)
+boost::shared_ptr<ModelAPI_Feature> Model_PluginManager::createFeature(string theFeatureID)
 {
-  if (this != myImpl) return myImpl->CreateFeature(theFeatureID);
+  if (this != myImpl) return myImpl->createFeature(theFeatureID);
 
   LoadPluginsInfo();
   if (myPlugins.find(theFeatureID) != myPlugins.end()) {
-    string aLibName = myPlugins[theFeatureID];
-#ifdef WIN32
-    aLibName += ".dll";
-#else
-    aLibName += ".so";
-#endif
-    Standard_CString aLibNameCStr = aLibName.c_str();
-    OSD_SharedLibrary aLib(aLibNameCStr);
-    if (aLib.DlOpen(OSD_RTLD_NOW)) {
-      OSD_Function aFunc = aLib.DlSymb("CreateFeature");
+    if (myPluginObjs.find(myPlugins[theFeatureID]) == myPluginObjs.end()) {
+      // load plugin library if not yet done
+      myCurrentPluginName = myPlugins[theFeatureID];
+      loadLibrary(myCurrentPluginName);
+    }
+    if (myPluginObjs.find(myCurrentPluginName) != myPluginObjs.end()) {
+      return myPluginObjs[myCurrentPluginName]->createFeature(theFeatureID);
     }
   }
 
@@ -40,22 +36,22 @@ boost::shared_ptr<ModelAPI_Feature> Model_PluginManager::CreateFeature(string th
 Model_PluginManager::Model_PluginManager()
 {
   myPluginsInfoLoaded = false;
-  static Event_ID aFeatureEvent = Event_Loop::EventByName("Feature");
+  static Event_ID aFeatureEvent = Event_Loop::eventByName("RegisterFeature");
 
   ModelAPI_PluginManager::SetPluginManager(boost::shared_ptr<ModelAPI_PluginManager>(this));
   // register the configuration reading listener
-  Event_Loop* aLoop = Event_Loop::Loop();
-  aLoop->RegisterListener(myImpl, aFeatureEvent);
+  Event_Loop* aLoop = Event_Loop::loop();
+  aLoop->registerListener(this, aFeatureEvent);
 }
 
-void Model_PluginManager::ProcessEvent(const Event_Message* theMessage)
+void Model_PluginManager::processEvent(const Event_Message* theMessage)
 {
   const Config_FeatureMessage* aMsg =
-    dynamic_cast<const Config_FeatureMessage*>( theMessage );
+    dynamic_cast<const Config_FeatureMessage*>(theMessage);
   if (aMsg) {
     // proccess the plugin info, load plugin
     if (myPlugins.find(aMsg->id()) == myPlugins.end()) {
-      myPlugins[aMsg->id()] = "PartSetPlugin"; // TO DO: plugin name must be also imported from XMLs
+      myPlugins[aMsg->id()] = aMsg->pluginLibrary(); // TO DO: plugin name must be also imported from XMLs
     }
   }
   // plugins information was started to load, so, it will be loaded
@@ -72,3 +68,8 @@ void Model_PluginManager::LoadPluginsInfo()
   aXMLReader.setAutoImport(true);
   aXMLReader.readAll();
 }
+
+void Model_PluginManager::registerPlugin(ModelAPI_Plugin* thePlugin)
+{
+  myPluginObjs[myCurrentPluginName] = thePlugin;
+}
index 44dbef3b5230380426ee94e402fea24f28753050..5a847abce16589cfe4f65c7c2b274afcbfe8586d 100644 (file)
 class Model_PluginManager : public ModelAPI_PluginManager, public Event_Listener
 {
   bool myPluginsInfoLoaded; ///< it true if plugins information is loaded
-  std::map<std::string, std::string> myPlugins; ///< map of feature IDs to plugin name
+  /// map of feature IDs to plugin name and object
+  std::map<std::string, std::string> myPlugins;
+  std::map<std::string, ModelAPI_Plugin*> myPluginObjs; ///< instances of the already plugins
+  std::string myCurrentPluginName; ///< name of the plugin that must be loaded currently
 public:
   /// Creates the feature object using plugins functionality
-  MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_Feature> CreateFeature(std::string theFeatureID);
+  MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_Feature> createFeature(std::string theFeatureID);
+
+  /// Registers the plugin that creates features.
+  /// It is obligatory for each plugin to call this function on loading to be found by 
+  /// the plugin manager on call of the feature)
+  virtual void registerPlugin(ModelAPI_Plugin* thePlugin);
 
   /// Processes the configuration file reading
-  MODEL_EXPORT virtual void ProcessEvent(const Event_Message* theMessage);
+  MODEL_EXPORT virtual void processEvent(const Event_Message* theMessage);
 
   /// Is called only once, on startup of the application
   Model_PluginManager();
index 399d32f8b81cbb35702de7f70cc73bbee70c9f04..33fe1bcf872463b28e92cc516c38076fd8bf63ae 100644 (file)
@@ -11,6 +11,7 @@ SET(PROJECT_HEADERS
     ModelAPI.h
     ModelAPI_Interface.h
     ModelAPI_PluginManager.h
+    ModelAPI_Plugin.h
     ModelAPI_Feature.h
     ModelAPI_Document.h
 )
index e2941745dae1106a07ff3f8336904affeb614d88..911aca0680be06183f0093859ee21bebed285c9a 100644 (file)
@@ -55,6 +55,7 @@ public:
   //! Redoes last operation
   MODELAPI_EXPORT virtual void Redo() = 0;
 
+protected:
   /// Only for SWIG wrapping it is here
   MODELAPI_EXPORT ModelAPI_Document()
   {
index ffa5448c4a899f614c2ca3cb28d863f503f7bcac..2c9339c7410305e9336e93fa85ae8442ff97c44c 100644 (file)
@@ -22,6 +22,7 @@ public:
   /// Returns the kind of a feature (like "Point")
   virtual std::string GetKind() = 0;
 
+protected:
   /// Use plugin manager for features creation: this method is 
   /// defined here only for SWIG-wrapping
   ModelAPI_Feature()
diff --git a/src/ModelAPI/ModelAPI_Plugin.h b/src/ModelAPI/ModelAPI_Plugin.h
new file mode 100644 (file)
index 0000000..5d2d043
--- /dev/null
@@ -0,0 +1,30 @@
+// File:        ModelAPI_Plugin.hxx
+// Created:     31 Mar 2014
+// Author:      Mikhail PONIKAROV
+
+#ifndef ModelAPI_Plugin_HeaderFile
+#define ModelAPI_Plugin_HeaderFile
+
+#include "ModelAPI.h"
+#include <string>
+#include <boost/shared_ptr.hpp>
+
+class ModelAPI_Feature;
+
+/**\class ModelAPI_Plugin
+ * \ingroup DataModel
+ * \brief Interface common for any plugin: allows to use plugin by the plugins manager.
+ */
+
+class MODELAPI_EXPORT ModelAPI_Plugin
+{
+public:
+  /// Creates the feature object of this plugin by the feature string ID
+  virtual boost::shared_ptr<ModelAPI_Feature> createFeature(std::string theFeatureID) = 0;
+
+protected:
+  /// Is needed for python wrapping by swig
+  ModelAPI_Plugin() {};
+};
+
+#endif
index cde7f69bf4e8d65c65dc2f15884fb2fc77881ef3..d4a20feaeeed02c0db864f2e2f50e7dc7524ab63 100644 (file)
@@ -7,6 +7,8 @@
 #include <ModelAPI_Document.h>
 // to avoid unresolved ModelAPI_Feature()
 #include <ModelAPI_Feature.h>
+// to avoid unresolved ModelAPI_Plugin()
+#include <ModelAPI_Plugin.h>
 
 #ifdef WIN32
 #include <windows.h>
@@ -16,8 +18,6 @@
 
 using namespace std;
 
-/// loads the library with specific name, appends "lib*.dll" or "*.so" depending on the platform
-void loadLibrary(const string theLibName);
 /// Converts library name to the operation system file name
 string library(const string& theLibName);
 
@@ -34,7 +34,7 @@ void ModelAPI_PluginManager::SetPluginManager(
   MY_MANAGER = theManager;
 }
 
-boost::shared_ptr<ModelAPI_PluginManager> ModelAPI_PluginManager::Get()
+boost::shared_ptr<ModelAPI_PluginManager> ModelAPI_PluginManager::get()
 {
   if (!MY_MANAGER) { // import Model library that implements this interface of ModelAPI
     loadLibrary("Model");
@@ -62,7 +62,7 @@ string library(const string& theLibName)
   return aLibName;
 }
 
-void loadLibrary(const string theLibName)
+void ModelAPI_PluginManager::loadLibrary(const string theLibName)
 {
   string aFileName = library(theLibName);
   if ( aFileName.empty() )
index c4033c3b1dcba53ba8229eb482ccc76156f6fb6c..620501bfd07e97d18d1cbf8dc82236ba6a5fafce 100644 (file)
@@ -10,6 +10,7 @@
 #include <boost/shared_ptr.hpp>
 
 class ModelAPI_Feature;
+class ModelAPI_Plugin;
 
 /**\class ModelAPI_PluginManager
  * \ingroup DataModel
@@ -22,10 +23,18 @@ class MODELAPI_EXPORT ModelAPI_PluginManager
 {
 public:
   /// Creates the feature object using plugins functionality
-  virtual boost::shared_ptr<ModelAPI_Feature> CreateFeature(std::string theFeatureID) = 0;
+  virtual boost::shared_ptr<ModelAPI_Feature> createFeature(std::string theFeatureID) = 0;
 
   /// Returns the real implementation (the alone instance per application) of the plugin manager
-  static boost::shared_ptr<ModelAPI_PluginManager> Get();
+  static boost::shared_ptr<ModelAPI_PluginManager> get();
+
+  /// Registers the plugin that creates features.
+  /// It is obligatory for each plugin to call this function on loading to be found by 
+  /// the plugin manager on call of the feature)
+  virtual void registerPlugin(ModelAPI_Plugin* thePlugin) = 0;
+
+  /// loads the library with specific name, appends "lib*.dll" or "*.so" depending on the platform
+  static void ModelAPI_PluginManager::loadLibrary(const std::string theLibName);
 
   /// Is needed for python wrapping by swig, call Get to get an instance
   ModelAPI_PluginManager();
index d6d5787f7c9db415b3c1f3d96888ac8732b999f3..ab07cdc88c95c8d495c2127794685c3ff07cf55c 100644 (file)
@@ -5,11 +5,12 @@ INCLUDE(FindBoost)
 
 SET(PROJECT_HEADERS
     PartSetPlugin.h
+    PartSetPlugin_Plugin.h
     PartSetPlugin_NewPart.h
 )
 
 SET(PROJECT_SOURCES
-    PartSetPlugin.cxx
+    PartSetPlugin_Plugin.cxx
     PartSetPlugin_NewPart.cxx
 )
 
diff --git a/src/PartSetPlugin/PartSetPlugin.cxx b/src/PartSetPlugin/PartSetPlugin.cxx
deleted file mode 100644 (file)
index 1b641c3..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-#include "PartSetPlugin.h"
-
-#include <PartSetPlugin_NewPart.h>
-#include <boost/shared_ptr.hpp>
-
-using namespace std;
-
-/// Standard method of the plugin that creates a specific feature instance by the feature kind
-PARTSETPLUGIN_EXPORT boost::shared_ptr<ModelAPI_Feature> CreateFeature(const string& theFeatureKind) 
-{
-  if (theFeatureKind == "new_part") {
-    return boost::shared_ptr<ModelAPI_Feature>(new PartSetPlugin_NewPart());
-  }
-  // feature of such kind is not found
-  return boost::shared_ptr<ModelAPI_Feature>();
-}
diff --git a/src/PartSetPlugin/PartSetPlugin_Plugin.cxx b/src/PartSetPlugin/PartSetPlugin_Plugin.cxx
new file mode 100644 (file)
index 0000000..d3d295d
--- /dev/null
@@ -0,0 +1,23 @@
+#include "PartSetPlugin_Plugin.h"
+#include "PartSetPlugin_NewPart.h"
+#include <ModelAPI_PluginManager.h>
+
+using namespace std;
+
+// the only created instance of this plugin
+static PartSetPlugin_Plugin* MY_INSTANCE = new PartSetPlugin_Plugin();
+
+PartSetPlugin_Plugin::PartSetPlugin_Plugin() 
+{
+  // register this plugin
+  ModelAPI_PluginManager::get()->registerPlugin(this);
+}
+
+boost::shared_ptr<ModelAPI_Feature> PartSetPlugin_Plugin::createFeature(string theFeatureID)
+{
+  if (theFeatureID == "new_part") {
+    return boost::shared_ptr<ModelAPI_Feature>(new PartSetPlugin_NewPart());
+  }
+  // feature of such kind is not found
+  return boost::shared_ptr<ModelAPI_Feature>();
+}
diff --git a/src/PartSetPlugin/PartSetPlugin_Plugin.h b/src/PartSetPlugin/PartSetPlugin_Plugin.h
new file mode 100644 (file)
index 0000000..ff577f7
--- /dev/null
@@ -0,0 +1,23 @@
+// File:        PartSetPlugin_Plugin.hxx
+// Created:     31 Mar 2014
+// Author:      Mikhail PONIKAROV
+
+#ifndef PartSetPlugin_Plugin_HeaderFile
+#define PartSetPlugin_Plugin_HeaderFile
+
+
+#include "PartSetPlugin.h"
+#include "ModelAPI_Plugin.h"
+
+class PARTSETPLUGIN_EXPORT PartSetPlugin_Plugin: public ModelAPI_Plugin
+{
+public:
+  /// Creates the feature object of this plugin by the feature string ID
+  virtual boost::shared_ptr<ModelAPI_Feature> createFeature(std::string theFeatureID);
+
+public:
+  /// Is needed for python wrapping by swig
+  PartSetPlugin_Plugin();
+};
+
+#endif
index 50208485c7e1ad229be4c9434fbc7f4e14f66b4a..16d693278652bd746ff7c47e044ceed8cf07ae8e 100644 (file)
@@ -43,11 +43,11 @@ void XGUI_Workshop::startApplication()
 {
   initMenu();
   //Initialize event listening
-  Event_Loop* aLoop = Event_Loop::Loop();
-  Event_ID aFeatureId = aLoop->EventByName("menu_item");
-  aLoop->RegisterListener(this, aFeatureId);
-  Event_ID aPartSetId = aLoop->EventByName("partset_module");
-  aLoop->RegisterListener(this, aPartSetId);
+  Event_Loop* aLoop = Event_Loop::loop();
+  Event_ID aFeatureId = aLoop->eventByName("RegisterFeature");
+  aLoop->registerListener(this, aFeatureId);
+  Event_ID aPartSetId = aLoop->eventByName("partset_module");
+  aLoop->registerListener(this, aPartSetId);
   activateModule();
   myMainWindow->show();
   QMdiSubWindow* aWnd = myMainWindow->viewer()->createView();
@@ -105,7 +105,7 @@ XGUI_Workbench* XGUI_Workshop::addWorkbench(const QString& theName)
 }
 
 //******************************************************
-void XGUI_Workshop::ProcessEvent(const Event_Message* theMessage)
+void XGUI_Workshop::processEvent(const Event_Message* theMessage)
 {
   const Config_FeatureMessage* aFeatureMsg = dynamic_cast<const Config_FeatureMessage*>(theMessage);
   if (aFeatureMsg) {
index aa115e9bd374589f154d1a640aa801d82a1dd43b..3e021baddee022e98dd9defbddeef77933565d66 100644 (file)
@@ -33,7 +33,7 @@ public:
 
   XGUI_Workbench* addWorkbench(const QString& theName);
 
-  virtual void ProcessEvent(const Event_Message* theMessage);
+  virtual void processEvent(const Event_Message* theMessage);
 
 public slots:
   void onNew();