Salome HOME
Merge branch 'Dev_1.1.0' of newgeom:newgeom into Dev_1.1.0
[modules/shaper.git] / src / Model / Model_Data.h
index 1d82ad14be9a89ccb4619adf152f3f955142b01e..5a2f6296e1a385745534e42fd2c56312aa4be27a 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        Model_Data.hxx
 // Created:     21 Mar 2014
 // Author:      Mikhail PONIKAROV
@@ -15,6 +17,7 @@
 #include <ModelAPI_AttributeReference.h>
 #include <ModelAPI_AttributeRefList.h>
 #include <ModelAPI_AttributeString.h>
+#include <ModelAPI_AttributeIntArray.h>
 #include <ModelAPI_Data.h>
 #include <ModelAPI_Feature.h>
 #include <ModelAPI_Object.h>
@@ -47,6 +50,8 @@ class Model_Data : public ModelAPI_Data
 
   /// List of attributes referenced to owner (updated only during the transaction change)
   std::set<AttributePtr> myRefsToMe;
+  /// flag that may block the "attribute updated" sending
+  bool mySendAttributeUpdated;
 
   Model_Data();
 
@@ -96,6 +101,10 @@ class Model_Data : public ModelAPI_Data
   /// Returns the attribute that contains real value with double precision
   MODEL_EXPORT virtual std::shared_ptr<ModelAPI_AttributeString>
     string(const std::string& theID);
+  /// Returns the attribute that contains integer values array
+  MODEL_EXPORT virtual std::shared_ptr<ModelAPI_AttributeIntArray>
+    intArray(const std::string& theID);
+
   /// Returns the generic attribute by identifier
   /// \param theID identifier of the attribute
   MODEL_EXPORT virtual std::shared_ptr<ModelAPI_Attribute> attribute(const std::string& theID);
@@ -125,11 +134,15 @@ class Model_Data : public ModelAPI_Data
   /// for each attribute of the object
   /// \param theID identifier of the attribute that can be referenced by this ID later
   /// \param theAttrType type of the created attribute (received from the type method)
-  MODEL_EXPORT virtual void addAttribute(const std::string& theID, const std::string theAttrType);
+  /// \returns the just created attribute
+  MODEL_EXPORT virtual AttributePtr 
+    addAttribute(const std::string& theID, const std::string theAttrType);
 
   /// Useful method for "set" methods of the attributes: sends an UPDATE event and
   /// makes attribute initialized
   MODEL_EXPORT virtual void sendAttributeUpdated(ModelAPI_Attribute* theAttr);
+  /// Blocks sending "attribute updated" if theBlock is true
+  MODEL_EXPORT virtual void blockSendAttributeUpdated(const bool theBlock);
 
   /// Puts feature to the document data sub-structure
   MODEL_EXPORT void setLabel(TDF_Label theLab);
@@ -140,29 +153,37 @@ class Model_Data : public ModelAPI_Data
     myObject = theObject;
   }
 
+  /// Erases all the data from the data model
   MODEL_EXPORT virtual void erase();
 
-  /// Makes feature must be updated later (on rebuild). Normally the Updater must call it
-  /// in case of not-automatic update to true
-  MODEL_EXPORT virtual void mustBeUpdated(const bool theFlag);
+  /// Stores the state of the object to execute it later accordingly
+  MODEL_EXPORT virtual void execState(const ModelAPI_ExecState theState);
+
+  /// Returns the state of the latest execution of the feature
+  MODEL_EXPORT virtual ModelAPI_ExecState execState();
 
-  /// Returns true if feature must be updated (re-executed) on rebuild
-  MODEL_EXPORT virtual bool mustBeUpdated();
+  /// Registers error during the execution, causes the ExecutionFailed state
+  MODEL_EXPORT virtual void setError(const std::string& theError);
 
   /// Returns the identifier of feature-owner, unique in this document
   MODEL_EXPORT virtual int featureId() const;
 
-  // returns all objects referenced to this
+  /// returns all objects referenced to this
   MODEL_EXPORT virtual const std::set<AttributePtr>& refsToMe() {return myRefsToMe;}
 
+  /// returns all references by attributes of this data
+  /// \param theRefs returned list of pairs: id of referenced attribute and list of referenced objects
+  MODEL_EXPORT virtual void referencesToObjects(
+    std::list<std::pair<std::string, std::list<ObjectPtr> > >& theRefs);
+
+  /// Copies all atributes content into theTarget data
+  MODEL_EXPORT virtual void copyTo(std::shared_ptr<ModelAPI_Data> theTarget);
+
 private:
-  // removes all information about back references
+  /// removes all information about back references
   void eraseBackReferences();
   // adds a back reference (with identifier which attribute references to this object
   void addBackReference(FeaturePtr theFeature, std::string theAttrID);
-  // returns all references by attributes of this data
-  // \param the returned list of pairs: id of referenced attribute and list of referenced objects
-  void referencesToObjects(std::list<std::pair<std::string, std::list<ObjectPtr> > >& theRefs);
 };
 
 #endif