From a9843de03f586057314bea3e131b9a23bcada4bb Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Wed, 19 Jun 2019 10:46:28 +0200 Subject: [PATCH] Last tuning --- idl/SALOME_CommonTypes.idl | 1 + idl/SALOME_ExternalServerLauncher.idl | 1 + idl/SALOME_SDS.idl | 1 - src/Container/SALOME_ContainerManager.cxx | 4 +-- .../SALOME_ExternalServerLauncher.cxx | 29 +++++++++++++++++++ .../SALOME_ExternalServerLauncher.hxx | 1 + 6 files changed, 34 insertions(+), 3 deletions(-) diff --git a/idl/SALOME_CommonTypes.idl b/idl/SALOME_CommonTypes.idl index f5e62485d..ba3eaa085 100644 --- a/idl/SALOME_CommonTypes.idl +++ b/idl/SALOME_CommonTypes.idl @@ -25,6 +25,7 @@ module SALOME { typedef sequence StringVec; typedef sequence LongVec; + typedef sequence ByteVec; }; #endif diff --git a/idl/SALOME_ExternalServerLauncher.idl b/idl/SALOME_ExternalServerLauncher.idl index cee79cb76..2f9efcd12 100644 --- a/idl/SALOME_ExternalServerLauncher.idl +++ b/idl/SALOME_ExternalServerLauncher.idl @@ -47,6 +47,7 @@ module SALOME void registerToKill(in string server_name, in long PID) raises (SALOME::SALOME_Exception); void shutdownServers() raises (SALOME::SALOME_Exception); string gethostname(); + ByteVec fetchContentOfFileAndRm(in string file_name) raises (SALOME::SALOME_Exception); }; }; diff --git a/idl/SALOME_SDS.idl b/idl/SALOME_SDS.idl index 749b400aa..98447e142 100644 --- a/idl/SALOME_SDS.idl +++ b/idl/SALOME_SDS.idl @@ -28,7 +28,6 @@ module SALOME { - typedef sequence ByteVec; typedef sequence SeqOfByteVec; interface DataScopeServer; diff --git a/src/Container/SALOME_ContainerManager.cxx b/src/Container/SALOME_ContainerManager.cxx index c50c8c0f8..608fda19d 100644 --- a/src/Container/SALOME_ContainerManager.cxx +++ b/src/Container/SALOME_ContainerManager.cxx @@ -1407,10 +1407,10 @@ long SALOME_ContainerManager::SystemWithPIDThreadSafe(const std::vector #include +#include #include +#include constexpr char NAME_IN_NS[]="/ExternalServers"; @@ -156,6 +158,33 @@ char *SALOME_ExternalServerLauncher::gethostname() return CORBA::string_dup(ret.c_str()); } +SALOME::ByteVec *SALOME_ExternalServerLauncher::fetchContentOfFileAndRm(const char *file_name) +{ + std::ifstream t(file_name); + if(!t.good()) + { + std::ostringstream oss; oss << "SALOME_ExternalServerLauncher::fetchContentOfFileAndRm : Error when trying to open \"" << file_name << "\" file !"; + throw SALOME_LauncherException(oss.str()); + } + t.seekg(0, std::ios::end); + size_t size(t.tellg()); + std::unique_ptr > buffer(new char[size],[](char *pt) { delete [] pt; }); + t.seekg(0); + t.read(buffer.get(),size); + // + std::unique_ptr ret(new SALOME::ByteVec); + ret->length(size); + for(std::size_t i=0;i SALOME_ExternalServerLauncher::ListOfExternalServersCpp(SALOME_NamingService *ns) { ns->Change_Directory(NAME_IN_NS); diff --git a/src/Launcher/SALOME_ExternalServerLauncher.hxx b/src/Launcher/SALOME_ExternalServerLauncher.hxx index 32824e6d5..e83016df9 100644 --- a/src/Launcher/SALOME_ExternalServerLauncher.hxx +++ b/src/Launcher/SALOME_ExternalServerLauncher.hxx @@ -45,6 +45,7 @@ class SALOMELAUNCHER_EXPORT SALOME_ExternalServerLauncher : public POA_SALOME::E SALOME::StringVec *listServersInNS() override; SALOME::ExternalServerHandler_ptr retrieveServerRefGivenNSEntry( const char *ns_entry ) override; char *gethostname() override; + SALOME::ByteVec *fetchContentOfFileAndRm(const char *file_name) override; const SALOME_CPythonHelper *getPyHelper() const { return _pyHelper; } private: static std::string CreateAbsNameInNSFromServerName(const std::string& scopeName); -- 2.39.2