Salome HOME
Define guards are corrected according to the code style
[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(
49     boost::shared_ptr<ModelAPI_Document> theSource, 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 protected:
61   /// Creates the feature object using plugins functionality
62   virtual boost::shared_ptr<ModelAPI_Feature> createFeature(std::string theFeatureID) = 0;
63
64   static void setPluginManager(boost::shared_ptr<ModelAPI_PluginManager> theManager);
65
66   friend class Model_Document;
67 };
68
69 typedef boost::shared_ptr<ModelAPI_PluginManager> PluginManagerPtr;
70
71 #endif