]> SALOME platform Git repositories - modules/shaper.git/blob - src/Model/Model_PluginManager.h
Salome HOME
Merge remote-tracking branch 'remotes/origin/master' into SolveSpace
[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 <Events_Listener.h>
11 #include <map>
12
13 class Model_Document;
14
15 /**\class Model_PluginManager
16  * \ingroup DataModel
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.
20  */
21 class Model_PluginManager : public ModelAPI_PluginManager, public Events_Listener
22 {
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   boost::shared_ptr<ModelAPI_Document> myCurrentDoc; ///< current working document
29   bool myCheckTransactions; ///< if true, generates error if document is updated outside of transaction
30 public:
31   /// Returns the root document of the application (that may contains sub-documents)
32   MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_Document> rootDocument();
33
34   /// Return true if root document has been already created
35   MODEL_EXPORT virtual bool hasRootDocument();
36
37   /// Returns the current document that used for current work in the application
38   MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_Document> currentDocument();
39
40   /// Defines the current document that used for current work in the application
41   MODEL_EXPORT virtual void setCurrentDocument(boost::shared_ptr<ModelAPI_Document> theDoc);
42
43   /// Registers the plugin that creates features.
44   /// It is obligatory for each plugin to call this function on loading to be found by 
45   /// the plugin manager on call of the feature)
46   MODEL_EXPORT virtual void registerPlugin(ModelAPI_Plugin* thePlugin);
47
48   /// Processes the configuration file reading
49   MODEL_EXPORT virtual void processEvent(const Events_Message* theMessage);
50
51   /// Copies the document to the new one wit hthe given id
52   MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_Document> copy(
53     boost::shared_ptr<ModelAPI_Document> theSource, std::string theID);
54
55   void setCheckTransactions(const bool theCheck) {myCheckTransactions = theCheck;}
56
57   /// Is called only once, on startup of the application
58   Model_PluginManager();
59
60 protected:
61   /// Loads (if not done yet) the information about the features and plugins
62   void LoadPluginsInfo();
63
64   /// Creates the feature object using plugins functionality
65   virtual boost::shared_ptr<ModelAPI_Feature> createFeature(std::string theFeatureID);
66 };
67
68 #endif