Salome HOME
Merge branch 'Dev_0.7.1' of newgeom:newgeom.git into Dev_0.7.1
[modules/shaper.git] / src / Model / Model_AttributeRefAttr.cpp
index 09ea70ef775211f01bb9791b1839982e12bc9248..b6ac116635859ca831369e5011715e601d55fde9 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        ModelAPI_AttributeRefAttr.cxx
 // Created:     2 Apr 2014
 // Author:      Mikhail PONIKAROV
@@ -14,47 +16,45 @@ bool Model_AttributeRefAttr::isObject()
   return myID->Get().Length() == 0;
 }
 
-void Model_AttributeRefAttr::setAttr(boost::shared_ptr<ModelAPI_Attribute> theAttr)
+void Model_AttributeRefAttr::setAttr(std::shared_ptr<ModelAPI_Attribute> theAttr)
 {
-  boost::shared_ptr<Model_Data> aData = 
-    boost::dynamic_pointer_cast<Model_Data>(theAttr->owner()->data());
+  std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(
+      theAttr->owner()->data());
   string anID = aData->id(theAttr);
   if (myIsInitialized && object() == theAttr->owner() && myID->Get().IsEqual(anID.c_str()))
-    return; // nothing is changed
-
+    return;  // nothing is changed
   myRef->Set(aData->label().Father());
   myID->Set(aData->id(theAttr).c_str());
   owner()->data()->sendAttributeUpdated(this);
 }
 
-boost::shared_ptr<ModelAPI_Attribute> Model_AttributeRefAttr::attr()
+std::shared_ptr<ModelAPI_Attribute> Model_AttributeRefAttr::attr()
 {
   ObjectPtr anObj = object();
-  if (anObj) {
-    boost::shared_ptr<Model_Data> aData = 
-      boost::dynamic_pointer_cast<Model_Data>(anObj->data());
+  if (anObj && anObj->data()) {
+    std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(anObj->data());
     return aData->attribute(TCollection_AsciiString(myID->Get()).ToCString());
   }
   // not initialized
-  return boost::shared_ptr<ModelAPI_Attribute>();
+  return std::shared_ptr<ModelAPI_Attribute>();
 }
 
 void Model_AttributeRefAttr::setObject(ObjectPtr theObject)
 {
-  if (!myIsInitialized || myID->Get().Length() != 0 || object() != theObject) {
-    boost::shared_ptr<Model_Data> aData = 
-      boost::dynamic_pointer_cast<Model_Data>(theObject->data());
+  if (theObject && (!myIsInitialized || myID->Get().Length() != 0 || object() != theObject)) {
+    std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(
+        theObject->data());
     myRef->Set(aData->label().Father());
-    myID->Set(""); // feature is identified by the empty ID
+    myID->Set("");  // feature is identified by the empty ID
     owner()->data()->sendAttributeUpdated(this);
   }
 }
 
 ObjectPtr Model_AttributeRefAttr::object()
 {
-  if (myRef->Get() != myRef->Label()) { // initialized
-    boost::shared_ptr<Model_Document> aDoc = 
-      boost::dynamic_pointer_cast<Model_Document>(owner()->document());
+  if (myRef->Get() != myRef->Label()) {  // initialized
+    std::shared_ptr<Model_Document> aDoc = std::dynamic_pointer_cast<Model_Document>(
+        owner()->document());
     if (aDoc) {
       TDF_Label aRefLab = myRef->Get();
       return aDoc->object(aRefLab);
@@ -70,7 +70,7 @@ Model_AttributeRefAttr::Model_AttributeRefAttr(TDF_Label& theLabel)
   if (!myIsInitialized) {
     // create attribute: not initialized by value yet
     myID = TDataStd_Comment::Set(theLabel, "");
-    myRef = TDF_Reference::Set(theLabel, theLabel); // not initialized: reference to itself
+    myRef = TDF_Reference::Set(theLabel, theLabel);  // not initialized: reference to itself
   } else {
     theLabel.FindAttribute(TDF_Reference::GetID(), myRef);
   }