Salome HOME
add method NameChanged to update title name
[modules/kernel.git] / src / SALOMEDSImpl / SALOMEDSImpl_SObject.cxx
index b34f8f02bcfa16a9ef0847282d70b9806711bfe0..050e3ab72c3ec88779114ca607319856bca7f6ba 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
 //
+
 //  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,43 +84,52 @@ SALOMEDSImpl_SObject::~SALOMEDSImpl_SObject()
  *  Purpose  : 
  */
 //============================================================================
-string SALOMEDSImpl_SObject::GetID() const
+std::string SALOMEDSImpl_SObject::GetID() const
 {
   return _lab.Entry();
 }
-  
+
 //============================================================================
 /*! Function : GetFatherComponent
- *  Purpose  : 
+ *  Purpose  :
  */
 //============================================================================
 SALOMEDSImpl_SComponent SALOMEDSImpl_SObject::GetFatherComponent() const
 {
-  SALOMEDSImpl_SComponent sco;    
+  SALOMEDSImpl_SComponent sco;
   DF_Label LF = _lab;
   while (!SALOMEDSImpl_SComponent::IsA(LF) && !LF.IsRoot()) {
     LF = LF.Father();
   }
-  
+
   if(LF.IsRoot()) return sco;
-  
+
   return GetStudy()->GetSComponent(LF);
 }
-  
+
 //============================================================================
 /*! Function : GetFather
- *  Purpose  : 
+ *  Purpose  :
  */
 //============================================================================
 SALOMEDSImpl_SObject SALOMEDSImpl_SObject::GetFather() const
 {
-  return GetStudy()->GetSObject(_lab.Father());    
+  return GetStudy()->GetSObject(_lab.Father());
 }
 
+//============================================================================
+/*! Function : GetLastChild
+ *  Purpose  :
+ */
+//============================================================================
+int SALOMEDSImpl_SObject::GetLastChildTag() const
+{
+  return _lab.LastChildTag();
+}
 
 //============================================================================
 /*! Function : GetStudy
- *  Purpose  : 
+ *  Purpose  :
  */
 //============================================================================
 SALOMEDSImpl_Study* SALOMEDSImpl_SObject::GetStudy() const
@@ -135,7 +143,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,13 +158,13 @@ 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"))
-       va1.push_back(va[i]);
+    if(ga && ga->Type() != std::string("AttributeReference"))
+        va1.push_back(va[i]);
   }
 
   return va1;
@@ -199,9 +207,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 +222,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 +237,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,13 +248,16 @@ string SALOMEDSImpl_SObject::GetIOR() const
 }
 
 
-std::string SALOMEDSImpl_SObject::GetGUID(const string& theType) 
+std::string SALOMEDSImpl_SObject::GetGUID(const std::string& theType) 
 {
   __AttributeTypeToGUIDForSObject
 
   if (strncmp(theType.c_str(), "AttributeTreeNodeGUID",21) == 0) {
     return theType.substr(21, theType.size()); 
   }
+  if (strncmp(theType.c_str(), "AttributeUserID",15) == 0) {
+    return theType.substr(15, theType.size()); 
+  }
   return "";
 }
 
@@ -290,3 +301,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);
+}