Salome HOME
Implementation of the "20830: EDF 1357 GUI : Hide/Show Icon"
[modules/kernel.git] / src / SALOMEDS / SALOMEDS_SObject_i.cxx
index 6398b8a6edc2589dc30cc8e302e5610235cf5812..fea239f5e737bc86b1a7a6bfaab329c520139c9b 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
 //
+
 //  File   : SALOMEDS_SObject_i.cxx
 //  Author : Sergey RUIN
 //  Module : SALOME
@@ -44,8 +45,6 @@
 #include <unistd.h>
 #endif
 
-using namespace std;
-
 SALOMEDS::SObject_ptr SALOMEDS_SObject_i::New(const SALOMEDSImpl_SObject& theImpl, CORBA::ORB_ptr theORB)
 {
   SALOMEDS_SObject_i* so_servant = new SALOMEDS_SObject_i(theImpl, theORB);
@@ -61,10 +60,11 @@ SALOMEDS::SObject_ptr SALOMEDS_SObject_i::New(const SALOMEDSImpl_SObject& theImp
 //============================================================================
 SALOMEDS_SObject_i::SALOMEDS_SObject_i(const SALOMEDSImpl_SObject& impl, CORBA::ORB_ptr orb)
 {
+  _impl = 0;
   if(!impl.IsNull()) {
      if(impl.IsComponent()) {
          SALOMEDSImpl_SComponent sco = impl;
-        _impl = sco.GetPersistentCopy();       
+         _impl = sco.GetPersistentCopy();       
      }
      else {
          _impl = impl.GetPersistentCopy();
@@ -85,6 +85,17 @@ SALOMEDS_SObject_i::~SALOMEDS_SObject_i()
    if(_impl) delete _impl;    
 }
 
+//================================================================================
+/*!
+ * \brief Returns true if the %SObject does not belong to any %Study
+ */
+//================================================================================
+
+CORBA::Boolean SALOMEDS_SObject_i::IsNull()
+{
+  SALOMEDS::Locker lock;
+  return !_impl || _impl->IsNull();
+}
 
 //============================================================================
 /*! Function :GetID
@@ -135,7 +146,7 @@ SALOMEDS::Study_ptr SALOMEDS_SObject_i::GetStudy()
     return SALOMEDS::Study::_nil();
   }
 
-  string IOR = aStudy->GetTransientReference();
+  std::string IOR = aStudy->GetTransientReference();
   CORBA::Object_var obj = _orb->string_to_object(IOR.c_str());
   SALOMEDS::Study_var Study = SALOMEDS::Study::_narrow(obj) ;
   ASSERT(!CORBA::is_nil(Study));
@@ -148,7 +159,7 @@ SALOMEDS::Study_ptr SALOMEDS_SObject_i::GetStudy()
  */
 //============================================================================
 CORBA::Boolean SALOMEDS_SObject_i::FindAttribute (SALOMEDS::GenericAttribute_out anAttribute,
-                                                 const char* aTypeOfAttribute)
+                                                  const char* aTypeOfAttribute)
 {
   SALOMEDS::Locker lock;
   DF_Attribute* anAttr = NULL;
@@ -169,7 +180,7 @@ CORBA::Boolean SALOMEDS_SObject_i::FindAttribute (SALOMEDS::GenericAttribute_out
 SALOMEDS::ListOfAttributes* SALOMEDS_SObject_i::GetAllAttributes()
 {
   SALOMEDS::Locker lock;
-  vector<DF_Attribute*> aSeq = _impl->GetAllAttributes();
+  std::vector<DF_Attribute*> aSeq = _impl->GetAllAttributes();
   SALOMEDS::ListOfAttributes_var SeqOfAttr = new SALOMEDS::ListOfAttributes;
   int length = aSeq.size();
 
@@ -181,7 +192,7 @@ SALOMEDS::ListOfAttributes* SALOMEDS_SObject_i::GetAllAttributes()
       SALOMEDS::GenericAttribute_var anAttribute;
       anAttribute = SALOMEDS_GenericAttribute_i::CreateAttribute(anAttr, _orb);
       if (!CORBA::is_nil(anAttribute)) {
-       SeqOfAttr[i] = anAttribute;
+        SeqOfAttr[i] = anAttribute;
       }
     }
   }
@@ -239,7 +250,7 @@ char* SALOMEDS_SObject_i::Name()
 void  SALOMEDS_SObject_i::Name(const char* name)
 {
   SALOMEDS::Locker lock;
-  string aName((char*)name);
+  std::string aName((char*)name);
   _impl->Name(aName);
 }
 
@@ -275,7 +286,7 @@ CORBA::Object_ptr SALOMEDS_SObject_i::GetObject()
   SALOMEDS::Locker lock;
   CORBA::Object_ptr obj = CORBA::Object::_nil();
   try {
-    string IOR = _impl->GetIOR();
+    std::string IOR = _impl->GetIOR();
     char* c_ior = CORBA::string_dup(IOR.c_str());
     obj = _orb->string_to_object(c_ior);
     CORBA::string_free(c_ior);
@@ -319,6 +330,17 @@ char* SALOMEDS_SObject_i::GetIOR()
   return aStr._retn();
 }
 
+//============================================================================
+/*! Function : SetAttrString
+ *  Purpose  :
+ */
+//============================================================================
+void SALOMEDS_SObject_i::SetAttrString(const char* name, const char* value)
+{
+  SALOMEDS::Locker lock;
+  _impl->SetAttrString(name,value);
+}
+
 //===========================================================================
 //   PRIVATE FUNCTIONS
 //===========================================================================