Salome HOME
Sources formated according to the codeing standards
[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_H_
6 #define ModelAPI_PluginManager_H_
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 class ModelAPI_ValidatorsFactory;
16
17 /**\class ModelAPI_PluginManager
18  * \ingroup DataModel
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.
22  */
23
24 class MODELAPI_EXPORT ModelAPI_PluginManager
25 {
26  public:
27   /// Returns the real implementation (the alone instance per application) of the plugin manager
28   static boost::shared_ptr<ModelAPI_PluginManager> get();
29
30   /// Registers the plugin that creates features.
31   /// It is obligatory for each plugin to call this function on loading to be found by 
32   /// the plugin manager on call of the feature)
33   virtual void registerPlugin(ModelAPI_Plugin* thePlugin) = 0;
34
35   /// Returns the root document of the application (that may contains sub-documents)
36   virtual boost::shared_ptr<ModelAPI_Document> rootDocument() = 0;
37
38   /// Return true if root document has been already created
39   virtual bool hasRootDocument() = 0;
40
41   /// Returns the current document that used for current work in the application
42   virtual boost::shared_ptr<ModelAPI_Document> currentDocument() = 0;
43
44   /// Defines the current document that used for current work in the application
45   virtual void setCurrentDocument(boost::shared_ptr<ModelAPI_Document> theDoc) = 0;
46
47   /// Copies the document to the new one wit hthe given id
48   virtual boost::shared_ptr<ModelAPI_Document> copy(boost::shared_ptr<ModelAPI_Document> theSource,
49                                                     std::string theID) = 0;
50
51   /// Returns the validators factory: the only one instance per application
52   virtual ModelAPI_ValidatorsFactory* validators() = 0;
53
54   /// Is needed for python wrapping by swig, call Get to get an instance
55   ModelAPI_PluginManager();
56
57   /// To virtually destroy the fields of successors
58   virtual ~ModelAPI_PluginManager()
59   {
60   }
61
62  protected:
63   /// Creates the feature object using plugins functionality
64   virtual boost::shared_ptr<ModelAPI_Feature> createFeature(std::string theFeatureID) = 0;
65
66   static void setPluginManager(boost::shared_ptr<ModelAPI_PluginManager> theManager);
67
68   friend class Model_Document;
69 };
70
71 typedef boost::shared_ptr<ModelAPI_PluginManager> PluginManagerPtr;
72
73 #endif