1 // File: Model_PluginManager.hxx
2 // Created: 20 Mar 2014
3 // Author: Mikhail PONIKAROV
5 #ifndef Model_PluginManager_HeaderFile
6 #define Model_PluginManager_HeaderFile
9 #include <ModelAPI_PluginManager.h>
10 #include <Event_Listener.h>
15 /**\class Model_PluginManager
17 * \brief Object that knows (from the initial XML file) which
18 * plugin contains which feature, loads and stores reference to loaded plugins by
19 * the feature functionality request.
21 class Model_PluginManager : public ModelAPI_PluginManager, public Event_Listener
23 bool myPluginsInfoLoaded; ///< it true if plugins information is loaded
24 /// map of feature IDs to plugin name
25 std::map<std::string, std::string> myPlugins;
26 std::map<std::string, ModelAPI_Plugin*> myPluginObjs; ///< instances of the already plugins
27 std::string myCurrentPluginName; ///< name of the plugin that must be loaded currently
28 std::shared_ptr<ModelAPI_Document> myCurrentDoc; ///< current working document
30 /// Returns the root document of the application (that may contains sub-documents)
31 MODEL_EXPORT virtual std::shared_ptr<ModelAPI_Document> rootDocument();
33 /// Return true if root document has been already created
34 MODEL_EXPORT virtual bool hasRootDocument();
36 /// Returns the current document that used for current work in the application
37 MODEL_EXPORT virtual std::shared_ptr<ModelAPI_Document> currentDocument();
39 /// Defines the current document that used for current work in the application
40 MODEL_EXPORT virtual void setCurrentDocument(std::shared_ptr<ModelAPI_Document> theDoc);
42 /// Registers the plugin that creates features.
43 /// It is obligatory for each plugin to call this function on loading to be found by
44 /// the plugin manager on call of the feature)
45 MODEL_EXPORT virtual void registerPlugin(ModelAPI_Plugin* thePlugin);
47 /// Processes the configuration file reading
48 MODEL_EXPORT virtual void processEvent(const Event_Message* theMessage);
50 /// Is called only once, on startup of the application
51 Model_PluginManager();
54 /// Loads (if not done yet) the information about the features and plugins
55 void LoadPluginsInfo();
57 /// Creates the feature object using plugins functionality
58 virtual std::shared_ptr<ModelAPI_Feature> createFeature(std::string theFeatureID);