]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
[30157] Improve steering control methods to pilot protocol of exchange file
authorAnthony Geay <anthony.geay@edf.fr>
Mon, 17 Jun 2024 07:47:04 +0000 (09:47 +0200)
committerAnthony Geay <anthony.geay@edf.fr>
Mon, 17 Jun 2024 07:47:04 +0000 (09:47 +0200)
src/Basics/KernelBasis.cxx
src/Basics/KernelBasis.hxx
src/Basics/KernelBasis.i

index c49036e7f96242d29514199ef9f340d6ca941a96..63e6929222131da276c1c7f248411f16d0354cef 100644 (file)
@@ -20,6 +20,7 @@
 #include "KernelBasis.hxx"
 
 #include <sstream>
+#include <stdexcept>
 
 static bool DEFAULT_SSL_MODE = true;
 static bool GUI_MODE = false;
@@ -155,12 +156,6 @@ void SALOME::SetBigObjOnDiskThreshold(int newThresholdInByte)
   SALOME_BIG_OBJ_ON_DISK_THRES = newThresholdInByte;
 }
 
-enum class BigObjTransferProtocol : char
-{
-  SharedFileSystem = 0,
-  SSDCopyFileSystem = 1
-};
-
 constexpr char SALOME_FILE_BIG_OBJ_DIR_SEP = '@';
 
 static std::string SALOME_FILE_BIG_OBJ_DIR;
@@ -169,27 +164,62 @@ constexpr int DFT_SALOME_NB_RETRY = 1;
 
 static int SALOME_NB_RETRY = DFT_SALOME_NB_RETRY;
 
+SALOME::BigObjTransferProtocol SALOME::FromIntToBigObjOnDiskProtocol(char protocol)
+{
+  switch( protocol )
+  {
+    case SALOME::SHARED_FILE_SYSTEM_PROTOCOL:
+      return SALOME::BigObjTransferProtocol::SharedFileSystem;
+    case SALOME::SSD_COPY_FILE_SYSTEM_PROTOCOL:
+      return SALOME::BigObjTransferProtocol::SSDCopyFileSystem;
+    default:
+      throw std::runtime_error("FromIntToBigObjOnDiskProtocol unrecognized protocol ! should be in [0,1] !");
+  }
+}
+
+SALOME::BigObjTransferProtocol SALOME::BigObjOnDiskProtocolFromStr(const std::string& protocol)
+{
+  if( protocol == SALOME::SHARED_FILE_SYSTEM_PROTOCOL_STR )
+    return SALOME::BigObjTransferProtocol::SharedFileSystem;
+  if( protocol == SALOME::SSD_COPY_FILE_SYSTEM_PROTOCOL_STR )
+    return SALOME::BigObjTransferProtocol::SSDCopyFileSystem;
+  throw std::runtime_error("BigObjOnDiskProtocolFromStr unrecognized protocol !");
+}
+
+std::string SALOME::BigObjOnDiskProtocolToStr(BigObjTransferProtocol protocol)
+{
+  switch( protocol )
+  {
+    case SALOME::BigObjTransferProtocol::SharedFileSystem:
+      return SALOME::SHARED_FILE_SYSTEM_PROTOCOL_STR;
+    case SALOME::BigObjTransferProtocol::SSDCopyFileSystem:
+      return SALOME::SSD_COPY_FILE_SYSTEM_PROTOCOL_STR;
+    default:
+      throw std::runtime_error("FromIntToBigObjOnDiskProtocol unrecognized protocol ! should be in [0,1] !");
+  }
+}
+
 /*!
  * This method returns the protocol of proxy transfert and the directory
  */
-int SALOME::GetBigObjOnDiskProtocolAndDirectory(std::string& directory)
+SALOME::BigObjTransferProtocol SALOME::GetBigObjOnDiskProtocolAndDirectory(std::string& directory)
 {
   if(SALOME_FILE_BIG_OBJ_DIR.size() < 3)
   {
     directory = SALOME_FILE_BIG_OBJ_DIR;
-    return static_cast<char>( BigObjTransferProtocol::SharedFileSystem );
+    return SALOME::BigObjTransferProtocol::SharedFileSystem;
   }
   std::string protocol = SALOME_FILE_BIG_OBJ_DIR.substr(0,3);
   directory = SALOME_FILE_BIG_OBJ_DIR.substr(3);
   if( protocol[0]!=SALOME_FILE_BIG_OBJ_DIR_SEP || protocol[2]!=SALOME_FILE_BIG_OBJ_DIR_SEP)
   {
     directory = SALOME_FILE_BIG_OBJ_DIR;
-    return static_cast<char>( BigObjTransferProtocol::SharedFileSystem );
+    return SALOME::BigObjTransferProtocol::SharedFileSystem;
   }
   std::istringstream iss(protocol.substr(1,1)); iss.exceptions(std::istringstream::failbit | std::istringstream::badbit);
   char iproxyprot = 0;
   iss >> iproxyprot;
-  return iproxyprot;
+  return FromIntToBigObjOnDiskProtocol( iproxyprot );
 }
 
 std::string SALOME::GetBigObjOnDiskDirectory()
index d40a422b8093de5a730752dd7de3a0208ba2c26a..2b3547e4b1d467df07974f9188a90d5f3d30e633 100644 (file)
@@ -37,7 +37,16 @@ void BASICS_EXPORT WriteInStderr(const std::string& msg);
 
 namespace SALOME
 {
+  constexpr char SHARED_FILE_SYSTEM_PROTOCOL = 0;
+  constexpr char SSD_COPY_FILE_SYSTEM_PROTOCOL = 1;
+  const char SHARED_FILE_SYSTEM_PROTOCOL_STR[] = "SharedFileSystem";
+  const char SSD_COPY_FILE_SYSTEM_PROTOCOL_STR[] = "SSDCopyFileSystem";
+
   enum class PyExecutionMode { NotSet, InProcess, OutOfProcessNoReplay, OutOfProcessWithReplay, OutOfProcessNoReplayFT, OutOfProcessWithReplayFT };
+
+  enum class BigObjTransferProtocol : char
+  { SharedFileSystem = SHARED_FILE_SYSTEM_PROTOCOL, SSDCopyFileSystem = SSD_COPY_FILE_SYSTEM_PROTOCOL };
+
   void BASICS_EXPORT SetPyExecutionMode(PyExecutionMode mode);
   void BASICS_EXPORT SetPyExecutionModeStr(const std::string& mode);
   std::vector<std::string> BASICS_EXPORT GetAllPyExecutionModes();
@@ -45,7 +54,10 @@ namespace SALOME
   PyExecutionMode BASICS_EXPORT GetPyExecutionMode();
   int BASICS_EXPORT GetBigObjOnDiskThreshold();
   void BASICS_EXPORT SetBigObjOnDiskThreshold(int newThresholdInByte);
-  int BASICS_EXPORT GetBigObjOnDiskProtocolAndDirectory(std::string& directory);
+  std::string BASICS_EXPORT BigObjOnDiskProtocolToStr(BigObjTransferProtocol protocol);
+  BigObjTransferProtocol BASICS_EXPORT BigObjOnDiskProtocolFromStr(const std::string& protocol);
+  BigObjTransferProtocol BASICS_EXPORT FromIntToBigObjOnDiskProtocol(char protocol);
+  BigObjTransferProtocol BASICS_EXPORT GetBigObjOnDiskProtocolAndDirectory(std::string& directory);
   std::string BASICS_EXPORT GetBigObjOnDiskDirectory();
   void BASICS_EXPORT SetBigObjOnDiskDirectory(const std::string& directory);
   bool BASICS_EXPORT BigObjOnDiskDirectoryDefined();
index 70920c990715f4f7340a0453c68e1a58e8231d7c..c87b89a5aba7add7555496a1e50e9f1f4a21a9cc 100644 (file)
@@ -55,6 +55,8 @@ using namespace SALOME;
 %rename (SetBigObjOnDiskThreshold) SetBigObjOnDiskThresholdSwig;
 %rename (GetBigObjOnDiskDirectory) GetBigObjOnDiskDirectorySwig;
 %rename (GetBigObjOnDiskProtocolAndDirectory) GetBigObjOnDiskProtocolAndDirectorySwig;
+%rename (BigObjOnDiskProtocolFromStr) BigObjOnDiskProtocolFromStrSwig;
+%rename (BigObjOnDiskProtocolToStr) BigObjOnDiskProtocolToStrSwig;
 %rename (SetBigObjOnDiskDirectory) SetBigObjOnDiskDirectorySwig;
 %rename (BigObjOnDiskDirectoryDefined) BigObjOnDiskDirectoryDefinedSwig;
 %rename (SetNumberOfRetry) SetNumberOfRetrySwig;
@@ -155,12 +157,22 @@ int GetNumberOfRetrySwig()
   return SALOME::GetNumberOfRetry( );
 }
 
+std::string BigObjOnDiskProtocolToStrSwig( int protocol )
+{
+  return SALOME::BigObjOnDiskProtocolToStr( SALOME::FromIntToBigObjOnDiskProtocol( protocol ) );
+}
+
+int BigObjOnDiskProtocolFromStrSwig(const std::string& protocol)
+{
+  return static_cast<char>( SALOME::BigObjOnDiskProtocolFromStr( protocol ) );
+}
+
 PyObject *GetBigObjOnDiskProtocolAndDirectorySwig()
 {
   std::string directory;
-  int ret0 = SALOME::GetBigObjOnDiskProtocolAndDirectory(directory);
+  SALOME::BigObjTransferProtocol ret0 = SALOME::GetBigObjOnDiskProtocolAndDirectory(directory);
   PyObject *ret(PyTuple_New(2));
-  PyTuple_SetItem(ret,0,PyInt_FromLong(ret0));
+  PyTuple_SetItem(ret,0,PyInt_FromLong(static_cast<char>( ret0 ) ));
   PyTuple_SetItem(ret,1,PyUnicode_FromString(directory.c_str()));
   return ret;
 }