Salome HOME
#18963 Minimize compiler warnings
[modules/kernel.git] / src / SALOMEDS / SALOMEDS_SObject.cxx
index 1c6c05b4a6d54787554c44b298e9240858ec0be8..3858a9e55954d33701446143b6e12b7d8f16424a 100644 (file)
@@ -1,24 +1,25 @@
-//  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2020  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   : SALOMEDS_SObject.hxx
 //  Author : Sergey RUIN
 //  Module : SALOME
@@ -53,9 +54,6 @@
 #endif
 
 
-
-using namespace std;  
-
 SALOMEDS_SObject::SALOMEDS_SObject(SALOMEDS::SObject_ptr theSObject)
 {
 #ifdef WIN32
@@ -98,13 +96,18 @@ SALOMEDS_SObject::SALOMEDS_SObject(const SALOMEDSImpl_SObject& theSObject)
 SALOMEDS_SObject::~SALOMEDS_SObject()
 {
   if (!_isLocal) {
-    _corba_impl->Destroy();
+    _corba_impl->UnRegister();
   }
   else {
     if(_local_impl) delete _local_impl;
   }
 }
 
+bool SALOMEDS_SObject::IsNull() const
+{
+  return _isLocal ? ( !_local_impl || _local_impl->IsNull() ) : _corba_impl->IsNull();
+}
+
 std::string SALOMEDS_SObject::GetID()
 {
   std::string aValue;
@@ -112,7 +115,7 @@ std::string SALOMEDS_SObject::GetID()
     SALOMEDS::Locker lock;
     aValue = _local_impl->GetID();
   }
-  else aValue = _corba_impl->GetID();  
+  else aValue = (CORBA::String_var)_corba_impl->GetID();  
   return aValue;
 }
 
@@ -122,7 +125,7 @@ _PTR(SComponent) SALOMEDS_SObject::GetFatherComponent()
     SALOMEDS::Locker lock;
     return _PTR(SComponent)(new SALOMEDS_SComponent(_local_impl->GetFatherComponent()));
   }
-  return _PTR(SComponent)(new SALOMEDS_SComponent(_corba_impl->GetFatherComponent()));
+  return _PTR(SComponent)(new SALOMEDS_SComponent((SALOMEDS::SComponent_var)_corba_impl->GetFatherComponent()));
 }
 
 _PTR(SObject) SALOMEDS_SObject::GetFather()
@@ -131,7 +134,7 @@ _PTR(SObject) SALOMEDS_SObject::GetFather()
     SALOMEDS::Locker lock;
     return _PTR(SObject)(new SALOMEDS_SObject(_local_impl->GetFather()));
   }
-  return _PTR(SObject)(new SALOMEDS_SObject(_corba_impl->GetFather()));
+  return _PTR(SObject)(new SALOMEDS_SObject((SALOMEDS::SObject_var)_corba_impl->GetFather()));
 }
 
 bool SALOMEDS_SObject::FindAttribute(_PTR(GenericAttribute)& anAttribute,
@@ -193,15 +196,6 @@ bool SALOMEDS_SObject::FindSubObject(int theTag, _PTR(SObject)& theObject)
   return ret;   
 }
 
-_PTR(Study) SALOMEDS_SObject::GetStudy()
-{
-  if (_isLocal) {
-    SALOMEDS::Locker lock;
-    return _PTR(Study)(new SALOMEDS_Study(_local_impl->GetStudy()));
-  }
-  return _PTR(Study)(new SALOMEDS_Study(_corba_impl->GetStudy()));
-}
-
 std::string SALOMEDS_SObject::Name()
 {
   std::string aName;
@@ -209,7 +203,7 @@ std::string SALOMEDS_SObject::Name()
     SALOMEDS::Locker lock;
     aName = _local_impl->Name();
   }
-  else aName = _corba_impl->Name();
+  else aName = (CORBA::String_var)_corba_impl->Name();
 
   return aName;
 }
@@ -223,16 +217,16 @@ void  SALOMEDS_SObject::Name(const std::string& theName)
   else _corba_impl->Name(theName.c_str());
 }
 
-vector<_PTR(GenericAttribute)> SALOMEDS_SObject::GetAllAttributes()
+std::vector<_PTR(GenericAttribute)> SALOMEDS_SObject::GetAllAttributes()
 {
-  vector<_PTR(GenericAttribute)> aVector;
+  std::vector<_PTR(GenericAttribute)> aVector;
   int aLength = 0;
   SALOMEDSClient_GenericAttribute* anAttr;
 
   if (_isLocal) {
     SALOMEDS::Locker lock;
-    vector<DF_Attribute*> aSeq = _local_impl->GetAllAttributes();
-    aLength = aSeq.size();
+    std::vector<DF_Attribute*> aSeq = _local_impl->GetAllAttributes();
+    aLength = (int)aSeq.size(); //!< TODO: conversion from size_t to int
     for (int i = 0; i < aLength; i++) {
       anAttr = SALOMEDS_GenericAttribute::CreateAttribute(dynamic_cast<SALOMEDSImpl_GenericAttribute*>(aSeq[i]));
       aVector.push_back(_PTR(GenericAttribute)(anAttr));
@@ -257,7 +251,7 @@ std::string SALOMEDS_SObject::GetName()
     SALOMEDS::Locker lock;
     aName = _local_impl->GetName();
   }
-  else aName = _corba_impl->GetName();
+  else aName = (CORBA::String_var) _corba_impl->GetName();
 
   return aName;
 }
@@ -269,7 +263,7 @@ std::string SALOMEDS_SObject::GetComment()
     SALOMEDS::Locker lock;
     aComment = _local_impl->GetComment();
   }
-  else aComment = _corba_impl->GetComment();
+  else aComment = (CORBA::String_var) _corba_impl->GetComment();
 
   return aComment;
 }
@@ -281,7 +275,7 @@ std::string SALOMEDS_SObject::GetIOR()
     SALOMEDS::Locker lock;
     anIOR = _local_impl->GetIOR();
   }
-  else anIOR = _corba_impl->GetIOR();
+  else anIOR = (CORBA::String_var) _corba_impl->GetIOR();
 
   return anIOR;
 }
@@ -295,6 +289,15 @@ int SALOMEDS_SObject::Tag()
   return _corba_impl->Tag(); 
 }
 
+int SALOMEDS_SObject::GetLastChildTag()
+{
+  if (_isLocal) {
+    SALOMEDS::Locker lock;
+    return _local_impl->GetLastChildTag();
+  }
+  return _corba_impl->GetLastChildTag(); 
+}
+
 int SALOMEDS_SObject::Depth()
 {
   if (_isLocal) {
@@ -343,3 +346,16 @@ void SALOMEDS_SObject::init_orb()
   ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting());
   _orb = init(0 , 0 ) ;     
 }
+
+void SALOMEDS_SObject::SetAttrString(const std::string& name, const std::string& value)
+{
+  if(_isLocal)
+    {
+      SALOMEDS::Locker lock;
+      _local_impl->SetAttrString(name,value);
+    }
+  else
+    {
+      _corba_impl->SetAttrString(name.c_str(),value.c_str());
+    }
+}