Salome HOME
Fix for the bug IPAL22164: Fatal error during save/load a SMESH study
[modules/kernel.git] / src / SALOMEDSImpl / SALOMEDSImpl_SObject.cxx
index 4ec2311a3e0dea50b488dc1ba4341ae2e69e325f..7cf41a0f8b91955b57905e89ec7e02a4f3321023 100644 (file)
@@ -1,4 +1,4 @@
-//  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
+//  Copyright (C) 2007-2010  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
@@ -19,6 +19,7 @@
 //
 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
+
 //  SALOME SALOMEDS : data structure of SALOME and sources of Salome data server 
 //  File   : SALOMEDSImpl_SObject.cxx
 //  Author : Sergey RUIN
@@ -29,8 +30,6 @@
 #include "SALOMEDSImpl_SComponent.hxx"
 #include "SALOMEDSImpl_Study.hxx"
 
-using namespace std;
-
 #include <map>
 #include <string.h>
 
@@ -85,7 +84,7 @@ SALOMEDSImpl_SObject::~SALOMEDSImpl_SObject()
  *  Purpose  : 
  */
 //============================================================================
-string SALOMEDSImpl_SObject::GetID() const
+std::string SALOMEDSImpl_SObject::GetID() const
 {
   return _lab.Entry();
 }
@@ -135,7 +134,7 @@ SALOMEDSImpl_Study* SALOMEDSImpl_SObject::GetStudy() const
  */
 //============================================================================
 bool SALOMEDSImpl_SObject::FindAttribute(DF_Attribute*& theAttribute, 
-                                         const string& theTypeOfAttribute) const
+                                         const std::string& theTypeOfAttribute) const
 {
   if(_lab.IsNull()) return false;
   std::string aGUID = GetGUID(theTypeOfAttribute);
@@ -150,12 +149,12 @@ bool SALOMEDSImpl_SObject::FindAttribute(DF_Attribute*& theAttribute,
  *  Purpose  : Returns list of all attributes for this sobject
  */
 //============================================================================
-vector<DF_Attribute*> SALOMEDSImpl_SObject::GetAllAttributes() const
+std::vector<DF_Attribute*> SALOMEDSImpl_SObject::GetAllAttributes() const
 {
-  vector<DF_Attribute*> va1, va = _lab.GetAttributes();
+  std::vector<DF_Attribute*> va1, va = _lab.GetAttributes();
   for(int i = 0, len = va.size(); i<len; i++) {
     SALOMEDSImpl_GenericAttribute* ga = dynamic_cast<SALOMEDSImpl_GenericAttribute*>(va[i]); 
-    if(ga && ga->Type() != string("AttributeReference"))
+    if(ga && ga->Type() != std::string("AttributeReference"))
         va1.push_back(va[i]);
   }
 
@@ -199,9 +198,9 @@ bool SALOMEDSImpl_SObject::FindSubObject(int theTag, SALOMEDSImpl_SObject& theOb
  *  Purpose  : 
  */
 //============================================================================
-string SALOMEDSImpl_SObject::GetName() const
+std::string SALOMEDSImpl_SObject::GetName() const
 {
-  string aStr = "";
+  std::string aStr = "";
   SALOMEDSImpl_AttributeName* aName;
   if ((aName=(SALOMEDSImpl_AttributeName*)_lab.FindAttribute(SALOMEDSImpl_AttributeName::GetID()))) {
     aStr =aName->Value();
@@ -214,9 +213,9 @@ string SALOMEDSImpl_SObject::GetName() const
  *  Purpose  : 
  */
 //============================================================================
-string SALOMEDSImpl_SObject::GetComment() const
+std::string SALOMEDSImpl_SObject::GetComment() const
 {
-  string aStr = "";
+  std::string aStr = "";
   SALOMEDSImpl_AttributeComment* aComment;
   if ((aComment=(SALOMEDSImpl_AttributeComment*)_lab.FindAttribute(SALOMEDSImpl_AttributeComment::GetID()))) {
     aStr = aComment->Value();
@@ -229,9 +228,9 @@ string SALOMEDSImpl_SObject::GetComment() const
  *  Purpose  : 
  */
 //============================================================================
-string SALOMEDSImpl_SObject::GetIOR() const 
+std::string SALOMEDSImpl_SObject::GetIOR() const 
 {
-  string aStr = "";
+  std::string aStr = "";
   SALOMEDSImpl_AttributeIOR* anIOR;
   if ((anIOR=(SALOMEDSImpl_AttributeIOR*)_lab.FindAttribute(SALOMEDSImpl_AttributeIOR::GetID()))) {
     aStr = dynamic_cast<SALOMEDSImpl_AttributeIOR*>(anIOR)->Value();
@@ -240,7 +239,7 @@ string SALOMEDSImpl_SObject::GetIOR() const
 }
 
 
-std::string SALOMEDSImpl_SObject::GetGUID(const string& theType) 
+std::string SALOMEDSImpl_SObject::GetGUID(const std::string& theType) 
 {
   __AttributeTypeToGUIDForSObject
 
@@ -293,3 +292,10 @@ bool SALOMEDSImpl_SObject::IsComponent() const
     return SALOMEDSImpl_SComponent::IsA(_lab);
 }
 
+void SALOMEDSImpl_SObject::SetAttrString(const std::string& name, const std::string& value)
+{
+  if(name=="AttributeName")SALOMEDSImpl_AttributeName::Set(GetLabel(), value);
+  else if(name=="AttributeIOR")SALOMEDSImpl_AttributeIOR::Set(GetLabel(), value);
+  else if(name=="AttributeString")SALOMEDSImpl_AttributeString::Set(GetLabel(), value);
+  else if(name=="AttributePixMap")SALOMEDSImpl_AttributePixMap::Set(GetLabel(), value);
+}