1 // File: Model_PluginManager.hxx
2 // Created: 20 Mar 2014
3 // Author: Mikhail PONIKAROV
5 #ifndef Model_PluginManager_H_
6 #define Model_PluginManager_H_
9 #include <ModelAPI_PluginManager.h>
10 #include <ModelAPI_Feature.h>
12 #include <Events_Listener.h>
17 /**\class Model_PluginManager
19 * \brief Object that knows (from the initial XML file) which
20 * plugin contains which feature, loads and stores reference to loaded plugins by
21 * the feature functionality request.
23 class Model_PluginManager : public ModelAPI_PluginManager, public Events_Listener
25 bool myPluginsInfoLoaded; ///< it true if plugins information is loaded
26 /// map of feature IDs to plugin name
27 std::map<std::string, std::string> myPlugins;
28 std::map<std::string, ModelAPI_Plugin*> myPluginObjs; ///< instances of the already plugins
29 std::string myCurrentPluginName; ///< name of the plugin that must be loaded currently
30 boost::shared_ptr<ModelAPI_Document> myCurrentDoc; ///< current working document
31 bool myCheckTransactions; ///< if true, generates error if document is updated outside of transaction
33 /// Returns the root document of the application (that may contains sub-documents)
34 MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_Document> rootDocument();
36 /// Return true if root document has been already created
37 MODEL_EXPORT virtual bool hasRootDocument();
39 /// Returns the current document that used for current work in the application
40 MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_Document> currentDocument();
42 /// Defines the current document that used for current work in the application
43 MODEL_EXPORT virtual void setCurrentDocument(boost::shared_ptr<ModelAPI_Document> theDoc);
45 /// Registers the plugin that creates features.
46 /// It is obligatory for each plugin to call this function on loading to be found by
47 /// the plugin manager on call of the feature)
48 MODEL_EXPORT virtual void registerPlugin(ModelAPI_Plugin* thePlugin);
50 /// Processes the configuration file reading
51 MODEL_EXPORT virtual void processEvent(const Events_Message* theMessage);
53 /// Copies the document to the new one wit hthe given id
54 MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_Document> copy(
55 boost::shared_ptr<ModelAPI_Document> theSource, std::string theID);
57 /// Returns the validators factory: the only one instance per application
58 MODEL_EXPORT virtual ModelAPI_ValidatorsFactory* validators();
60 void setCheckTransactions(const bool theCheck)
62 myCheckTransactions = theCheck;
65 /// Is called only once, on startup of the application
66 Model_PluginManager();
69 /// Loads (if not done yet) the information about the features and plugins
70 void LoadPluginsInfo();
72 /// Creates the feature object using plugins functionality
73 virtual FeaturePtr createFeature(std::string theFeatureID);