Salome HOME
6b25bf4a378dfc68758dc6f500b33ee692219054
[modules/shaper.git] / src / ModelAPI / ModelAPI_PluginManager.h
1 // File:        ModelAPI_PluginManager.hxx
2 // Created:     20 Mar 2014
3 // Author:      Mikhail PONIKAROV
4
5 #ifndef ModelAPI_PluginManager_HeaderFile
6 #define ModelAPI_PluginManager_HeaderFile
7
8 #include "ModelAPI.h"
9 #include <string>
10 #include <boost/shared_ptr.hpp>
11
12 class ModelAPI_Feature;
13 class ModelAPI_Plugin;
14 class ModelAPI_Document;
15
16 /**\class ModelAPI_PluginManager
17  * \ingroup DataModel
18  * \brief Object that knows (from the initial XML file) which
19  * plugin contains which feature, loads and stores reference to loaded plugins by
20  * the feature functionality request.
21  */
22
23 class MODELAPI_EXPORT ModelAPI_PluginManager
24 {
25 public:
26   /// Returns the real implementation (the alone instance per application) of the plugin manager
27   static boost::shared_ptr<ModelAPI_PluginManager> get();
28
29   /// Registers the plugin that creates features.
30   /// It is obligatory for each plugin to call this function on loading to be found by 
31   /// the plugin manager on call of the feature)
32   virtual void registerPlugin(ModelAPI_Plugin* thePlugin) = 0;
33
34   /// Returns the root document of the application (that may contains sub-documents)
35   virtual boost::shared_ptr<ModelAPI_Document> rootDocument() = 0;
36
37   /// Return true if root document has been already created
38   virtual bool hasRootDocument() = 0;
39
40   /// Returns the current document that used for current work in the application
41   virtual boost::shared_ptr<ModelAPI_Document> currentDocument() = 0;
42
43   /// Defines the current document that used for current work in the application
44   virtual void setCurrentDocument(boost::shared_ptr<ModelAPI_Document> theDoc) = 0;
45
46   /// Copies the document to the new one wit hthe given id
47   virtual boost::shared_ptr<ModelAPI_Document> copy(
48     boost::shared_ptr<ModelAPI_Document> theSource, std::string theID) = 0;
49
50   /// Is needed for python wrapping by swig, call Get to get an instance
51   ModelAPI_PluginManager();
52
53   /// To virtually destroy the fields of successors
54   virtual ~ModelAPI_PluginManager() {}
55
56 protected:
57   /// Creates the feature object using plugins functionality
58   virtual boost::shared_ptr<ModelAPI_Feature> createFeature(std::string theFeatureID) = 0;
59
60   static void SetPluginManager(boost::shared_ptr<ModelAPI_PluginManager> theManager);
61
62   friend class Model_Document;
63 };
64
65 typedef boost::shared_ptr<ModelAPI_PluginManager> PluginManagerPtr;
66
67
68 #endif