Salome HOME
5a847abce16589cfe4f65c7c2b274afcbfe8586d
[modules/shaper.git] / src / Model / Model_PluginManager.h
1 // File:        Model_PluginManager.hxx
2 // Created:     20 Mar 2014
3 // Author:      Mikhail PONIKAROV
4
5 #ifndef Model_PluginManager_HeaderFile
6 #define Model_PluginManager_HeaderFile
7
8 #include "Model.h"
9 #include <ModelAPI_PluginManager.h>
10 #include <Event_Listener.h>
11 #include <map>
12
13 /**\class Model_PluginManager
14  * \ingroup DataModel
15  * \brief Object that knows (from the initial XML file) which
16  * plugin contains which feature, loads and stores reference to loaded plugins by
17  * the feature functionality request.
18  */
19
20 class Model_PluginManager : public ModelAPI_PluginManager, public Event_Listener
21 {
22   bool myPluginsInfoLoaded; ///< it true if plugins information is loaded
23   /// map of feature IDs to plugin name and object
24   std::map<std::string, std::string> myPlugins;
25   std::map<std::string, ModelAPI_Plugin*> myPluginObjs; ///< instances of the already plugins
26   std::string myCurrentPluginName; ///< name of the plugin that must be loaded currently
27 public:
28   /// Creates the feature object using plugins functionality
29   MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_Feature> createFeature(std::string theFeatureID);
30
31   /// Registers the plugin that creates features.
32   /// It is obligatory for each plugin to call this function on loading to be found by 
33   /// the plugin manager on call of the feature)
34   virtual void registerPlugin(ModelAPI_Plugin* thePlugin);
35
36   /// Processes the configuration file reading
37   MODEL_EXPORT virtual void processEvent(const Event_Message* theMessage);
38
39   /// Is called only once, on startup of the application
40   Model_PluginManager();
41
42 private:
43   /// Loads (if not done yet) the information about the features and plugins
44   void LoadPluginsInfo();
45 };
46
47 #endif