Salome HOME
add method NameChanged to update title name
[modules/kernel.git] / src / SALOMEDSImpl / SALOMEDSImpl_AttributeTarget.cxx
index 36272891becfe1c92cd3282f6a4b6b39f26c1ab3..0687420a033c2d07937120cb1ba9d170ff26adf5 100644 (file)
@@ -1,24 +1,25 @@
-//  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
 //
-//  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 //
-//  This library is free software; you can redistribute it and/or
-//  modify it under the terms of the GNU Lesser General Public
-//  License as published by the Free Software Foundation; either
-//  version 2.1 of the License.
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
 //
-//  This library is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-//  Lesser General Public License for more details.
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
 //
-//  You should have received a copy of the GNU Lesser General Public
-//  License along with this library; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
-//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
+
 //  File   : SALOMEDSImpl_AttributeTarget.cxx
 //  Author : Sergey RUIN
 //  Module : SALOME
@@ -27,9 +28,6 @@
 #include "SALOMEDSImpl_AttributeReference.hxx"
 #include "SALOMEDSImpl_Study.hxx"
 
-using namespace std;
-
-
 //=======================================================================
 //function : GetID
 //purpose  : 
@@ -88,8 +86,7 @@ void SALOMEDSImpl_AttributeTarget::Add(const SALOMEDSImpl_SObject& theSO)
   DF_Label aRefLabel = theSO.GetLabel();
   SALOMEDSImpl_AttributeReference* aReference;
   if ((aReference=(SALOMEDSImpl_AttributeReference*)aRefLabel.FindAttribute(SALOMEDSImpl_AttributeReference::GetID()))) {
-    for(int i = 0, len = myVariables.size(); i<len; i++) if(myVariables[i]->Label() == aRefLabel) return; //BugID: PAL6192    
-    myVariables.push_back(aReference);
+    myVariables[aRefLabel.Entry()]=aReference;
   } 
   
   SetModifyFlag(); //SRN: Mark the study as being modified, so it could be saved 
@@ -99,12 +96,12 @@ void SALOMEDSImpl_AttributeTarget::Add(const SALOMEDSImpl_SObject& theSO)
 //function : Get
 //purpose  : 
 //=======================================================================
-vector<SALOMEDSImpl_SObject> SALOMEDSImpl_AttributeTarget::Get() 
+std::vector<SALOMEDSImpl_SObject> SALOMEDSImpl_AttributeTarget::Get() 
 {
-  vector<SALOMEDSImpl_SObject> aSeq;
+  std::vector<SALOMEDSImpl_SObject> aSeq;
   
-  for(int i = 0, len = myVariables.size(); i<len; i++) 
-    aSeq.push_back( SALOMEDSImpl_Study::SObject(myVariables[i]->Label()));
+  for (std::map< std::string , DF_Attribute* >::iterator iter = myVariables.begin(); iter != myVariables.end(); ++iter)
+    aSeq.push_back( SALOMEDSImpl_Study::SObject(iter->second->Label()));
   
   return aSeq;
 }
@@ -118,15 +115,7 @@ void SALOMEDSImpl_AttributeTarget::Remove(const SALOMEDSImpl_SObject& theSO)
   Backup();
   DF_Label aRefLabel = theSO.GetLabel();
 
-  vector<DF_Attribute*> va;
-  for(int i = 0, len = myVariables.size(); i<len; i++) {
-    DF_Label L = myVariables[i]->Label();
-    if(myVariables[i]->Label() == aRefLabel) continue;
-    va.push_back(myVariables[i]);      
-  }
-
-  myVariables.clear();
-  myVariables = va;    
+  myVariables.erase(aRefLabel.Entry());
   
   SetModifyFlag(); //SRN: Mark the study as being modified, so it could be saved 
 }
@@ -146,8 +135,8 @@ void SALOMEDSImpl_AttributeTarget::Restore(DF_Attribute* With)
   SALOMEDSImpl_AttributeTarget* REL = dynamic_cast<SALOMEDSImpl_AttributeTarget*>(With);
   myRelation = REL->GetRelation();
   myVariables.clear();
-  for (int i = 0, len = REL->myVariables.size(); i<len; i++) {
-    myVariables.push_back(REL->myVariables[i]);
+  for (std::map< std::string , DF_Attribute* >::iterator iter = REL->myVariables.begin(); iter != REL->myVariables.end(); ++iter){
+    myVariables[iter->first]=iter->second;
   }
 }
 
@@ -169,7 +158,7 @@ void SALOMEDSImpl_AttributeTarget::Paste(DF_Attribute* into)
   SALOMEDSImpl_AttributeTarget* REL = dynamic_cast<SALOMEDSImpl_AttributeTarget*>(into);
   REL->SetRelation(myRelation);
   REL->myVariables.clear();
-  for (int i = 0, len = myVariables.size(); i<len; i++) {
-    REL->myVariables.push_back(myVariables[i]);
+  for (std::map< std::string , DF_Attribute* >::iterator iter = myVariables.begin(); iter != myVariables.end(); ++iter){
+    REL->myVariables[iter->first]=iter->second;
   }  
 }