]> SALOME platform Git repositories - modules/kernel.git/blobdiff - src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx
Salome HOME
Compilation under Windows: add missing header
[modules/kernel.git] / src / LifeCycleCORBA / SALOME_LifeCycleCORBA.cxx
index 5351562b6a091d59a55a15ace2e8a588f12981b0..08223ade7cec6f02c61e67296d59eb984d7a01f1 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2019  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2021  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
@@ -82,7 +82,7 @@ IncompatibleComponent::IncompatibleComponent(const IncompatibleComponent &ex):
  */
 //=============================================================================
 
-SALOME_LifeCycleCORBA::SALOME_LifeCycleCORBA(SALOME_NamingService *ns)
+SALOME_LifeCycleCORBA::SALOME_LifeCycleCORBA(SALOME_NamingService_Abstract *ns)
 {
   // be sure to have an instance of traceCollector, when used via SWIG
   // in a Python module
@@ -104,17 +104,19 @@ SALOME_LifeCycleCORBA::SALOME_LifeCycleCORBA(SALOME_NamingService *ns)
   // not enough: set a current directory in naming service is not thread safe
   // if naming service instance is shared among several threads...
   // ==> always use absolute path and don't rely on current directory!
-
-  CORBA::Object_var obj =
-    _NS->Resolve(SALOME_ContainerManager::_ContainerManagerNameInNS);
-  if (CORBA::is_nil(obj))
-    throw SALOME_Exception("Error: Cannot resolve ContainerManager in Naming Service");
-  _ContManager=Engines::ContainerManager::_narrow(obj);
-
-  obj = _NS->Resolve(SALOME_ResourcesManager::_ResourcesManagerNameInNS);
-  if (CORBA::is_nil(obj))
-    throw SALOME_Exception("Error: Cannot resolve ResourceManager in Naming Service");
-  _ResManager=Engines::ResourcesManager::_narrow(obj);
+  //if( dynamic_cast<SALOME_NamingService *>(_NS) )
+  {
+    CORBA::Object_var obj =
+      _NS->Resolve(SALOME_ContainerManager::_ContainerManagerNameInNS);
+    if (CORBA::is_nil(obj))
+      throw SALOME_Exception("Error: Cannot resolve ContainerManager in Naming Service");
+    _ContManager=Engines::ContainerManager::_narrow(obj);
+
+    obj = _NS->Resolve(SALOME_ResourcesManager::_ResourcesManagerNameInNS);
+    if (CORBA::is_nil(obj))
+      throw SALOME_Exception("Error: Cannot resolve ResourceManager in Naming Service");
+    _ResManager=Engines::ResourcesManager::_narrow(obj);
+  }
 }
 
 //=============================================================================
@@ -152,7 +154,7 @@ SALOME_LifeCycleCORBA::FindComponent(const Engines::ContainerParameters& params,
     {
       listOfResources = _ResManager->GetFittingResources(new_params.resource_params);
     }
-  catch( const SALOME::SALOME_Exception& ex )
+  catch( const SALOME::SALOME_Exception& /*ex*/ ) //!< TODO: unused variable
     {
       return Engines::EngineComponent::_nil();
     }
@@ -192,7 +194,7 @@ SALOME_LifeCycleCORBA::LoadComponent(const Engines::ContainerParameters& params,
     {
       listOfResources = _ResManager->GetFittingResources(new_params.resource_params);
     }
-  catch( const SALOME::SALOME_Exception& ex )
+  catch( const SALOME::SALOME_Exception& /*ex*/ ) //!< TODO: unused variable
     {
       return Engines::EngineComponent::_nil();
     }
@@ -234,7 +236,7 @@ FindOrLoad_Component(const Engines::ContainerParameters& params,
     {
       listOfResources = _ResManager->GetFittingResources(new_params.resource_params);
     }
-  catch( const SALOME::SALOME_Exception& ex )
+  catch( const SALOME::SALOME_Exception& /*ex*/ ) //!< TODO: unused variable
     {
       return Engines::EngineComponent::_nil();
     }
@@ -278,11 +280,11 @@ SALOME_LifeCycleCORBA::FindOrLoad_Component(const char *containerName,
   // --- Check if containerName contains machine name (if yes: rg>0)
   char *stContainer=strdup(containerName);
   std::string st2Container(stContainer);
-  int rg=st2Container.find("/");
+  size_t rg=st2Container.find("/");
 
   Engines::ContainerParameters params;
   preSet(params);
-  if (rg<0)
+  if (rg == std::string::npos)
   {
     // containerName doesn't contain "/" => Local container
     params.container_name = CORBA::string_dup(stContainer);
@@ -449,7 +451,7 @@ void SALOME_LifeCycleCORBA::shutdownServers(bool shutdownLauncher)
       if ( !CORBA::is_nil(connMan) && ( pid != connMan->getPID() ) )
         connMan->ShutdownWithExit();
     }
-  catch(const CORBA::Exception& e)
+  catch(const CORBA::Exception& /*e*/) //!< TODO: unused variable
     {
        // ignore and continue
     }
@@ -472,7 +474,7 @@ void SALOME_LifeCycleCORBA::shutdownServers(bool shutdownLauncher)
         study->Shutdown();
       _NS->Destroy_Name("/Study");
     }
-  catch(const CORBA::Exception& e)
+  catch(const CORBA::Exception& /*e*/) //!< TODO: unused variable
     {
        // ignore and continue
     }
@@ -491,7 +493,7 @@ void SALOME_LifeCycleCORBA::shutdownServers(bool shutdownLauncher)
         catalog->shutdown();
       _NS->Destroy_Name("/Kernel/ModulCatalog");
     }
-  catch(const CORBA::Exception& e)
+  catch(const CORBA::Exception& /*e*/) //!< TODO: unused variable
     {
        // ignore and continue
     }
@@ -508,7 +510,7 @@ void SALOME_LifeCycleCORBA::shutdownServers(bool shutdownLauncher)
       if ( !CORBA::is_nil(dsm) )
         dsm->shutdownScopes();
     }
-  catch(const CORBA::Exception& e)
+  catch(const CORBA::Exception& /*e*/) //!< TODO: unused variable
     {
        // ignore and continue
     }
@@ -520,7 +522,7 @@ void SALOME_LifeCycleCORBA::shutdownServers(bool shutdownLauncher)
       if ( !CORBA::is_nil(dsm) )
         dsm->shutdownServers();
     }
-  catch(const CORBA::Exception& e)
+  catch(const CORBA::Exception& /*e*/) //!< TODO: unused variable
     {
        // ignore and continue
     }
@@ -534,7 +536,7 @@ void SALOME_LifeCycleCORBA::shutdownServers(bool shutdownLauncher)
           launcher->Shutdown();
       }
     }
-  catch(const CORBA::Exception& e)
+  catch(const CORBA::Exception& /*e*/) //!< TODO: unused variable
     {
        // ignore and continue
     }
@@ -553,7 +555,7 @@ void SALOME_LifeCycleCORBA::shutdownServers(bool shutdownLauncher)
           registry->Shutdown();
       _NS->Destroy_Name("/Registry");
     }
-  catch(const CORBA::Exception& e)
+  catch(const CORBA::Exception& /*e*/) //!< TODO: unused variable
     {
        // ignore and continue
     }
@@ -824,7 +826,7 @@ void SALOME_LifeCycleCORBA::copyFile(const char* hostSrc, const char* fileSrc, c
  *
  *  \return the naming service
  */
-SALOME_NamingService * SALOME_LifeCycleCORBA::namingService()
+SALOME_NamingService_Abstract * SALOME_LifeCycleCORBA::namingService()
 {
   return _NS;
 }
@@ -835,5 +837,8 @@ SALOME_NamingService * SALOME_LifeCycleCORBA::namingService()
  */
 CORBA::ORB_ptr SALOME_LifeCycleCORBA::orb()
 {
-  return _NS->orb();
+  SALOME_NamingService *NSC = dynamic_cast<SALOME_NamingService *>(_NS);
+  if(!_NS)
+    THROW_SALOME_EXCEPTION("SALOME_LifeCycleCORBA::orb : not a CORBA SALOME_NamingService ");
+  return NSC->orb();
 }