1 // File: ModelAPI_Object.hxx
2 // Created: 19 May 2014
3 // Author: Mikhail PONIKAROV
5 #ifndef ModelAPI_Object_H_
6 #define ModelAPI_Object_H_
9 #include "ModelAPI_Data.h"
11 #include <boost/shared_ptr.hpp>
14 class ModelAPI_Document;
16 /**\class ModelAPI_Object
18 * \brief Represents any object in the data model and in the object browser.
20 * It may be feature or result of the feature. User just may set name for it
21 * or change this name later. Generic class for Feature, Body, Parameter and other
22 * objects related to the features and their results. Contains attributes of this
23 * object in the "Data".
27 boost::shared_ptr<ModelAPI_Data> myData; ///< manager of the data model of a feature
28 boost::shared_ptr<ModelAPI_Document> myDoc; ///< document this object belongs to
30 /// By default object is displayed in the object browser.
31 virtual bool isInHistory()
36 /// Returns the data manager of this object: attributes
37 virtual boost::shared_ptr<ModelAPI_Data> data() const
42 /// Returns true if object refers to the same data model instance
43 virtual bool isSame(const boost::shared_ptr<ModelAPI_Object>& theObject)
45 return theObject.get() == this;
48 /// Returns document this feature belongs to
49 virtual boost::shared_ptr<ModelAPI_Document> document() const
54 /// Returns the group identifier of this object
55 virtual std::string groupName() = 0;
57 /// Called on change of any argument-attribute of this object
58 MODELAPI_EXPORT virtual void attributeChanged()
61 /// To use virtuality for destructors
62 virtual ~ModelAPI_Object() {}
65 /// Sets the data manager of an object (document does)
66 virtual void setData(boost::shared_ptr<ModelAPI_Data> theData)
71 /// Sets the data manager of an object (document does)
72 virtual void setDoc(boost::shared_ptr<ModelAPI_Document> theDoc)
77 /// removes all fields from this feature
78 MODELAPI_EXPORT virtual void erase() {
79 if (myData) myData->erase();
83 friend class Model_Document;
87 typedef boost::shared_ptr<ModelAPI_Object> ObjectPtr;