Salome HOME
Updated copyright comment
[modules/kernel.git] / src / Launcher / SALOME_ExternalServerLauncher.cxx
index 89b18b9197c5f5e81e7bf28073a7a5e480acae8f..450e4f61439c9bc89a89348be541c6d41da62e32 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2019-2020  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2019-2024  CEA, EDF, OPEN CASCADE
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -44,9 +44,9 @@ const char SALOME_ExternalServerLauncher::NAME_IN_NS[]="/ExternalServers";
 
 unsigned SALOME_ExternalServerLauncher::CNT = 0;
 
-SALOME_ExternalServerLauncher::SALOME_ExternalServerLauncher(const SALOME_CPythonHelper *pyHelper, CORBA::ORB_ptr orb, PortableServer::POA_var poa):_pyHelper(pyHelper),_poa(poa)
+SALOME_ExternalServerLauncher::SALOME_ExternalServerLauncher(const SALOME_CPythonHelper *pyHelper, CORBA::ORB_ptr orb, PortableServer::POA_var poa,SALOME_NamingService_Abstract *ns):_pyHelper(pyHelper),_poa(poa)
 {
-  _NS = new SALOME_NamingService(orb);
+  _NS = ns == nullptr ? new SALOME_NamingService(orb) : ns;
   PortableServer::ObjectId_var id(_poa->activate_object(this));
   CORBA::Object_var obj(_poa->id_to_reference(id));
   SALOME::ExternalServerLauncher_var refPtr(SALOME::ExternalServerLauncher::_narrow(obj));
@@ -92,8 +92,7 @@ SALOME::ExternalServerHandler_ptr SALOME_ExternalServerLauncher::launchServer(co
       throw SALOME_LauncherException(oss2.str());
     }
   std::vector<std::string> cmd(command_list.length());
-  const char *toto(command_list[0]);
-  for(auto i=0;i<command_list.length();i++)
+  for(size_t i=0;i<command_list.length();i++)
     cmd[i] = command_list[i];
   long pid(0);
   try
@@ -166,7 +165,7 @@ SALOME::StringVec *SALOME_ExternalServerLauncher::listServersInNS()
   std::vector<std::string> loes(ListOfExternalServersCpp(_NS));
   std::size_t sz(loes.size());
   ret->length(sz);
-  for(auto i = 0; i<sz ; i++)
+  for(size_t i=0; i<sz; i++)
     {
       (*ret)[i]=CORBA::string_dup(loes[i].c_str());
     }
@@ -201,7 +200,7 @@ SALOME::ByteVec *SALOME_ExternalServerLauncher::fetchContentOfFileAndRm(const ch
   //
   std::unique_ptr<SALOME::ByteVec> ret(new SALOME::ByteVec);
   ret->length(size);
-  for(std::size_t i=0;i<size;++i)
+  for(size_t i=0;i<size;++i)
     (*ret)[i] = buffer.get()[i];
   //
   if( unlink(file_name)!=0 )
@@ -212,7 +211,7 @@ SALOME::ByteVec *SALOME_ExternalServerLauncher::fetchContentOfFileAndRm(const ch
   return ret.release();
 }
 
-std::vector<std::string> SALOME_ExternalServerLauncher::ListOfExternalServersCpp(SALOME_NamingService *ns)
+std::vector<std::string> SALOME_ExternalServerLauncher::ListOfExternalServersCpp(SALOME_NamingService_Abstract *ns)
 {
   ns->Change_Directory(NAME_IN_NS);
   std::vector<std::string> ret(ns->list_directory());
@@ -237,7 +236,7 @@ bool SALOME_ExternalServerLauncher::IsAliveAndKicking(SALOME::ExternalServerHand
   return ret;
 }
 
-bool SALOME_ExternalServerLauncher::IsAliveAndKicking(SALOME_NamingService *ns, const std::string& serverName)
+bool SALOME_ExternalServerLauncher::IsAliveAndKicking(SALOME_NamingService_Abstract *ns, const std::string& serverName)
 {
   SALOME::ExternalServerHandler_var pt(GetServerHandlerGivenName(ns, serverName));
   if( CORBA::is_nil(pt) )
@@ -245,7 +244,7 @@ bool SALOME_ExternalServerLauncher::IsAliveAndKicking(SALOME_NamingService *ns,
   return IsAliveAndKicking(pt);
 }
 
-SALOME::ExternalServerHandler_var SALOME_ExternalServerLauncher::GetServerHandlerGivenName(SALOME_NamingService *ns, const std::string& serverName)
+SALOME::ExternalServerHandler_var SALOME_ExternalServerLauncher::GetServerHandlerGivenName(SALOME_NamingService_Abstract *ns, const std::string& serverName)
 {
   std::vector<std::string> serverNames(ListOfExternalServersCpp(ns));
   if(std::find(serverNames.begin(),serverNames.end(),serverName)==serverNames.end())