Salome HOME
1b166b600c1dfaa4116612b4904a832821435078
[modules/shaper.git] / src / ModelAPI / ModelAPI_Feature.h
1 // File:        ModelAPI_Feature.hxx
2 // Created:     21 Mar 2014
3 // Author:      Mikhail PONIKAROV
4
5 #ifndef ModelAPI_Feature_HeaderFile
6 #define ModelAPI_Feature_HeaderFile
7
8 #include "ModelAPI.h"
9 #include "ModelAPI_PluginManager.h"
10
11 #include <string>
12 #include <memory>
13
14 class ModelAPI_Object;
15 class ModelAPI_Document;
16
17 /**\class ModelAPI_Feature
18  * \ingroup DataModel
19  * \brief Functionality of the model object: to update result,
20  * to initialize attributes, etc.
21  */
22 class ModelAPI_Feature
23 {
24   std::shared_ptr<ModelAPI_Object> myData; ///< manager of the data model of a feature
25
26 public:
27   /// Returns the kind of a feature (like "Point")
28   MODELAPI_EXPORT virtual const std::string& getKind() = 0;
29
30   /// Returns to which group in the document must be added feature
31   MODELAPI_EXPORT virtual const std::string& getGroup() = 0;
32
33   /// Request for initialization of data model of the feature: adding all attributes
34   MODELAPI_EXPORT virtual void initAttributes() = 0;
35
36   /// Computes or recomputes the result
37   MODELAPI_EXPORT virtual void execute() = 0;
38
39   /// Returns the data manager of this feature
40   MODELAPI_EXPORT virtual std::shared_ptr<ModelAPI_Object> data() {return myData;}
41
42   /// Must return document where the new feature must be added to
43   /// By default it is current document
44   MODELAPI_EXPORT virtual std::shared_ptr<ModelAPI_Document> documentToAdd()
45   {return ModelAPI_PluginManager::get()->currentDocument();}
46
47 protected:
48   /// Use plugin manager for features creation: this method is 
49   /// defined here only for SWIG-wrapping
50   ModelAPI_Feature()
51   {}
52
53   /// Sets the data manager of an object (document does)
54   MODELAPI_EXPORT void setData(std::shared_ptr<ModelAPI_Object> theData) {myData = theData;}
55   friend class Model_Document;
56 };
57
58 #endif