Salome HOME
Merge branch 'master' of newgeom:newgeom.git
[modules/shaper.git] / src / ModelAPI / ModelAPI_Object.h
1 // File:        ModelAPI_Object.hxx
2 // Created:     19 May 2014
3 // Author:      Mikhail PONIKAROV
4
5 #ifndef ModelAPI_Object_H_
6 #define ModelAPI_Object_H_
7
8 #include "ModelAPI.h"
9
10 #include <boost/shared_ptr.hpp>
11
12 class ModelAPI_Data;
13 class ModelAPI_Document;
14
15 /**\class ModelAPI_Object
16  * \ingroup DataModel
17  * \brief Represents any object in the data model and in the object browser.
18  *
19  * It may be feature or result of the feature. User just may set name for it
20  * or change this name later. Generic class for Feature, Body, Parameter and other
21  * objects related to the features and their results. Contains attributes of this 
22  * object in the "Data".
23  */
24 class ModelAPI_Object
25 {
26   boost::shared_ptr<ModelAPI_Data> myData;  ///< manager of the data model of a feature
27   boost::shared_ptr<ModelAPI_Document> myDoc;  ///< document this feature belongs to
28  public:
29   /// By default object is displayed in the object browser.
30   virtual bool isInHistory()
31   {
32     return true;
33   }
34
35   /// Returns the data manager of this object: attributes
36   virtual boost::shared_ptr<ModelAPI_Data> data()
37   {
38     return myData;
39   }
40
41   /// Returns true if object refers to the same data model instance
42   virtual bool isSame(const boost::shared_ptr<ModelAPI_Object>& theObject)
43   {
44     return theObject.get() == this;
45   }
46
47   /// Returns document this feature belongs to
48   virtual boost::shared_ptr<ModelAPI_Document> document()
49   {
50     return myDoc;
51   }
52
53   /// Returns the group identifier of this object
54   virtual std::string groupName() = 0;
55
56  protected:
57   /// Sets the data manager of an object (document does)
58   virtual void setData(boost::shared_ptr<ModelAPI_Data> theData)
59   {
60     myData = theData;
61   }
62
63   /// Sets the data manager of an object (document does)
64   virtual void setDoc(boost::shared_ptr<ModelAPI_Document> theDoc)
65   {
66     myDoc = theDoc;
67   }
68
69   friend class Model_Document;
70 };
71
72 typedef boost::shared_ptr<ModelAPI_Object> ObjectPtr;
73
74 #endif