Salome HOME
Fix of crash on feature in new part creation
[modules/shaper.git] / src / Model / Model_Data.h
index c057cede3f2aa85d5cb2dcc95acf7c91d8caa3b2..4e96a5be5c65e126cc2352ca2fc2f07e72904e44 100644 (file)
@@ -163,7 +163,10 @@ class Model_Data : public ModelAPI_Data
   MODEL_EXPORT virtual ModelAPI_ExecState execState();
 
   /// Registers error during the execution, causes the ExecutionFailed state
-  MODEL_EXPORT virtual void setError(const std::string& theError);
+  MODEL_EXPORT virtual void setError(const std::string& theError, bool theSend = true);
+
+  /// Registers error during the execution, causes the ExecutionFailed state
+  MODEL_EXPORT virtual std::string error() const;
 
   /// Returns the identifier of feature-owner, unique in this document
   MODEL_EXPORT virtual int featureId() const;
@@ -183,6 +186,7 @@ private:
   /// Removes all information about back references
   void eraseBackReferences();
   /// Adds a back reference (with identifier which attribute references to this object
+  /// It does not change the consealment flag of the data object result
   /// \param theFeature feature referenced to this
   /// \param theAttrID identifier of the attribute that is references from theFeature to this
   void removeBackReference(FeaturePtr theFeature, std::string theAttrID);
@@ -194,4 +198,28 @@ private:
     const bool theApplyConcealment = true);
 };
 
+/// Generic method to register back reference, used in referencing attributes.
+/// Without concealment change, it will be done later, on synchronization.
+#define ADD_BACK_REF(TARGET) \
+  if (TARGET.get() != NULL) { \
+    FeaturePtr anAttributeOwnerFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(owner()); \
+    if (anAttributeOwnerFeature.get()) { \
+      std::shared_ptr<Model_Data> aTargetData = std::dynamic_pointer_cast<Model_Data>( \
+        (TARGET)->data()); \
+      aTargetData->addBackReference(anAttributeOwnerFeature, id(), false); \
+    } \
+  }
+
+/// Generic method to unregister back reference, used in referencing attributes.
+/// Without concealment change, it will be done later, on synchronization.
+#define REMOVE_BACK_REF(TARGET) \
+  if (TARGET.get() != NULL) { \
+    FeaturePtr anAttOwnerFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(owner()); \
+    if (anAttOwnerFeature.get()) { \
+      std::shared_ptr<Model_Data> aTargetData = std::dynamic_pointer_cast<Model_Data>( \
+        (TARGET)->data()); \
+      aTargetData->removeBackReference(anAttOwnerFeature, id()); \
+    } \
+  }
+
 #endif