Salome HOME
Merge branch 'master' of newgeom:newgeom
[modules/shaper.git] / src / ModelAPI / ModelAPI_Object.h
index 581f045884c0e45f2bf4efc43271fbfa47634611..9241d9b6545310c70a13dd62e1e65d30186314d4 100644 (file)
@@ -2,36 +2,80 @@
 // Created:     19 May 2014
 // Author:      Mikhail PONIKAROV
 
-#ifndef ModelAPI_Object_HeaderFile
-#define ModelAPI_Object_HeaderFile
+#ifndef ModelAPI_Object_H_
+#define ModelAPI_Object_H_
 
-#include "ModelAPI_Feature.h"
+#include "ModelAPI.h"
+#include "ModelAPI_Data.h"
 
 #include <boost/shared_ptr.hpp>
 
+class ModelAPI_Data;
+class ModelAPI_Document;
+
 /**\class ModelAPI_Object
  * \ingroup DataModel
- * \brief Represents the result of some feature in the object browser
- * under the specific folder. Just a reference to specific feature-operation
- * with possibility to rename it.
+ * \brief Represents any object in the data model and in the object browser.
+ *
+ * It may be feature or result of the feature. User just may set name for it
+ * or change this name later. Generic class for Feature, Body, Parameter and other
+ * objects related to the features and their results. Contains attributes of this 
+ * object in the "Data".
  */
-class ModelAPI_Object : public ModelAPI_Feature
+class ModelAPI_Object
 {
-public:
+  boost::shared_ptr<ModelAPI_Data> myData;  ///< manager of the data model of a feature
+  boost::shared_ptr<ModelAPI_Document> myDoc;  ///< document this object belongs to
+ public:
+  /// By default object is displayed in the object browser.
+  virtual bool isInHistory()
+  {
+    return true;
+  }
 
-  /// It is never located in history
-  MODELAPI_EXPORT virtual bool isInHistory() {return false;}
+  /// Returns the data manager of this object: attributes
+  virtual boost::shared_ptr<ModelAPI_Data> data()
+  {
+    return myData;
+  }
 
-  /// Reference to the feature-operation that produces this object
-  MODELAPI_EXPORT virtual FeaturePtr featureRef() = 0;
+  /// Returns true if object refers to the same data model instance
+  virtual bool isSame(const boost::shared_ptr<ModelAPI_Object>& theObject)
+  {
+    return theObject.get() == this;
+  }
 
-  /// Returns the name of this object (by default equal to the name of feature)
-  MODELAPI_EXPORT virtual std::string getName() = 0;
+  /// Returns document this feature belongs to
+  virtual boost::shared_ptr<ModelAPI_Document> document()
+  {
+    return myDoc;
+  }
 
-  /// Defines the name of the object
-  MODELAPI_EXPORT virtual void setName(std::string theName) = 0;
-};
+  /// Returns the group identifier of this object
+  virtual std::string groupName() = 0;
+
+ protected:
+  /// Sets the data manager of an object (document does)
+  virtual void setData(boost::shared_ptr<ModelAPI_Data> theData)
+  {
+    myData = theData;
+  }
+
+  /// Sets the data manager of an object (document does)
+  virtual void setDoc(boost::shared_ptr<ModelAPI_Document> theDoc)
+  {
+    myDoc = theDoc;
+  }
 
+  /// removes all fields from this feature
+  MODELAPI_EXPORT virtual void erase() {
+    if (myData) myData->erase();
+    setData(DataPtr());
+  }
+
+  friend class Model_Document;
+
+};
 
 typedef boost::shared_ptr<ModelAPI_Object> ObjectPtr;