Salome HOME
Migration on new model architecture
[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_HeaderFile
6 #define ModelAPI_Object_HeaderFile
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() {return true;}
31
32   /// Returns the data manager of this object: attributes
33   virtual boost::shared_ptr<ModelAPI_Data> data() {return myData;}
34
35   /// Returns true if feature refers to the same data model instance
36   virtual bool isSame(const boost::shared_ptr<ModelAPI_Object>& theObject)
37     {return theObject.get() == this;}
38
39   /// Returns document this feature belongs to
40   virtual boost::shared_ptr<ModelAPI_Document> document()
41     {return myDoc;}
42
43   /// Returns the group identifier of this object
44   virtual std::string groupName() = 0;
45
46 protected:
47   /// Sets the data manager of an object (document does)
48   virtual void setData(boost::shared_ptr<ModelAPI_Data> theData) 
49     {myData = theData;}
50
51   /// Sets the data manager of an object (document does)
52   virtual void setDoc(boost::shared_ptr<ModelAPI_Document> theDoc) {myDoc = theDoc;}
53
54   friend class Model_Document;
55 };
56
57 typedef boost::shared_ptr<ModelAPI_Object> ObjectPtr;
58
59 #endif