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