Salome HOME
Registering of validators
[modules/shaper.git] / src / Model / Model_Object.h
1 // File:        Model_Object.hxx
2 // Created:     19 May 2014
3 // Author:      Mikhail PONIKAROV
4
5 #ifndef Model_Object_HeaderFile
6 #define Model_Object_HeaderFile
7
8 #include <Model.h>
9 #include <ModelAPI_Object.h>
10 #include <ModelAPI_Document.h>
11
12 #include <TDataStd_Name.hxx>
13
14 /**\class ModelAPI_Object
15  * \ingroup DataModel
16  * \brief Represents the result of some feature in the object browser
17  * under the specific folder. Just a reference to specific feature-operation
18  * with possibility to rename it.
19  */
20 class Model_Object : public ModelAPI_Object
21 {
22   FeaturePtr myRef; ///< the referenced feature
23   Handle_TDataStd_Name myName; ///< the name of this object that may be changed
24 public:
25   /// Reference to the feature-operation that produces this object
26   MODEL_EXPORT virtual FeaturePtr featureRef();
27
28   /// Returns the name of this object (by default equal to the name of feature)
29   MODEL_EXPORT virtual std::string getName();
30
31   /// Defines the name of the object
32   MODEL_EXPORT virtual void setName(std::string theName);
33
34   /// Returns the kind of a feature (like "Point")
35   MODEL_EXPORT virtual const std::string& getKind() {return myRef->getKind();}
36
37   /// Returns to which group in the document must be added feature
38   MODEL_EXPORT virtual const std::string& getGroup() {return FEATURES_GROUP;}
39
40   /// Returns document this feature belongs to
41   MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_Document> document()
42   {return myRef->document();}
43
44   /// Returns true if feature refers to the same model data instance
45   MODEL_EXPORT virtual bool isSame(const FeaturePtr& theFeature)
46   {
47     boost::shared_ptr<Model_Object> anObj = boost::dynamic_pointer_cast<Model_Object>(theFeature);
48     return anObj && myRef == anObj->myRef;
49   }
50
51   /// It is just a reference: don't init attributes
52   MODEL_EXPORT virtual void initAttributes() {}
53
54   /// It is just a reference: don't execute
55   MODEL_EXPORT virtual void execute() {}
56
57 private:
58
59   /// Constructor fully defines this object
60   Model_Object(FeaturePtr theRef, Handle_TDataStd_Name theName);
61
62   friend class Model_Document;  
63 };
64
65 #endif