From bee06f226e50c6b2f9aac0bb830d68cf1eb6cbbc Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Sat, 17 Apr 2021 07:32:22 +0200 Subject: [PATCH] Ajout dans KernelBasis du selecteur de mode en C++ et Python pour discriminer le mode de lancement de SALOME --- src/Basics/CMakeLists.txt | 21 +++++++++++++++++++++ src/Basics/KernelBasis.cxx | 32 ++++++++++++++++++++++++++++++++ src/Basics/KernelBasis.hxx | 25 +++++++++++++++++++++++++ src/Basics/KernelBasis.i | 27 +++++++++++++++++++++++++++ src/KERNEL_PY/__init__.py | 5 ++++- 5 files changed, 109 insertions(+), 1 deletion(-) create mode 100644 src/Basics/KernelBasis.cxx create mode 100644 src/Basics/KernelBasis.hxx create mode 100644 src/Basics/KernelBasis.i diff --git a/src/Basics/CMakeLists.txt b/src/Basics/CMakeLists.txt index 9939866a1..59ea78c00 100644 --- a/src/Basics/CMakeLists.txt +++ b/src/Basics/CMakeLists.txt @@ -17,8 +17,12 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # +include(${SWIG_USE_FILE}) + INCLUDE_DIRECTORIES( ${PTHREAD_INCLUDE_DIR} + ${PYTHON_INCLUDE_DIRS} + ${CMAKE_CURRENT_SOURCE_DIR} ) SET(SALOMEBasics_SOURCES @@ -29,6 +33,7 @@ SET(SALOMEBasics_SOURCES BasicsGenericDestructor.hxx Basics_Utils.hxx Basics_DirUtils.hxx + KernelBasis.cxx ) ADD_LIBRARY(SALOMEBasics ${SALOMEBasics_SOURCES}) @@ -38,3 +43,19 @@ TARGET_LINK_LIBRARIES(SALOMEBasics ${PLATFORM_LIBS} ${PTHREAD_LIBRARIES}) FILE(GLOB SALOMEBasics_HEADERS_HXX "${CMAKE_CURRENT_SOURCE_DIR}/*.hxx") INSTALL(FILES ${SALOMEBasics_HEADERS_HXX} DESTINATION ${SALOME_INSTALL_HEADERS}) + +SET(KernelBasis_HEADERS KernelBasis.hxx KernelBasis.i) +SET(KernelBasis_SOURCES ${KernelBasis_HEADERS}) +SET_SOURCE_FILES_PROPERTIES(KernelBasis.i PROPERTIES CPLUSPLUS ON) +SET_SOURCE_FILES_PROPERTIES(KernelBasis.i PROPERTIES SWIG_FLAGS "-py3") +SET_SOURCE_FILES_PROPERTIES(KernelBasis_wrap.cpp PROPERTIES COMPILE_FLAGS "-DHAVE_CONFIG_H") +SET(_swig_SCRIPTS ${CMAKE_CURRENT_BINARY_DIR}/KernelBasis.py ) +IF(${CMAKE_VERSION} VERSION_LESS "3.8.0") + SWIG_ADD_MODULE(KernelBasis python ${KernelBasis_SOURCES}) +ELSE() + SWIG_ADD_LIBRARY(KernelBasis LANGUAGE python SOURCES ${KernelBasis_SOURCES}) +ENDIF() +SWIG_LINK_LIBRARIES(KernelBasis ${PYTHON_LIBRARIES} ${PLATFORM_LIBS} SALOMEBasics) +install(TARGETS _KernelBasis DESTINATION ${SALOME_INSTALL_LIBS}) +install(FILES ${KernelBasis_HEADERS} DESTINATION ${SALOME_INSTALL_HEADERS}) +SALOME_INSTALL_SCRIPTS("${_swig_SCRIPTS}" ${SALOME_INSTALL_BINS} EXTRA_DPYS "${SWIG_MODULE_KernelBasis_REAL_NAME}") diff --git a/src/Basics/KernelBasis.cxx b/src/Basics/KernelBasis.cxx new file mode 100644 index 000000000..b634f7265 --- /dev/null +++ b/src/Basics/KernelBasis.cxx @@ -0,0 +1,32 @@ +// Copyright (C) 2021 CEA/DEN, EDF R&D +// +// 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. +// +// 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 +// + +#include "KernelBasis.hxx" + +static bool DEFAULT_SSL_MODE = false; + +bool getSSLMode() +{ + return DEFAULT_SSL_MODE; +} + +void setSSLMode(bool sslMode) +{ + DEFAULT_SSL_MODE = sslMode; +} diff --git a/src/Basics/KernelBasis.hxx b/src/Basics/KernelBasis.hxx new file mode 100644 index 000000000..184fb9987 --- /dev/null +++ b/src/Basics/KernelBasis.hxx @@ -0,0 +1,25 @@ +// Copyright (C) 2021 CEA/DEN, EDF R&D +// +// 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. +// +// 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 +// + +#pragma once + +#include "SALOME_Basics.hxx" + +bool BASICS_EXPORT getSSLMode(); +void BASICS_EXPORT setSSLMode(bool sslMode); diff --git a/src/Basics/KernelBasis.i b/src/Basics/KernelBasis.i new file mode 100644 index 000000000..44b2e221a --- /dev/null +++ b/src/Basics/KernelBasis.i @@ -0,0 +1,27 @@ +// Copyright (C) 2021 CEA/DEN, EDF R&D +// +// 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. +// +// 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 +// + +%module KernelBasis + +%{ +#include "KernelBasis.hxx" +%} + +bool getSSLMode(); +void setSSLMode(bool sslMode); diff --git a/src/KERNEL_PY/__init__.py b/src/KERNEL_PY/__init__.py index bbdd1a73d..150bb4bc2 100644 --- a/src/KERNEL_PY/__init__.py +++ b/src/KERNEL_PY/__init__.py @@ -192,6 +192,8 @@ class StandAloneLifecyle: def salome_init_without_session(): global lcc,myStudy,orb,modulcat,sg,cm lcc = StandAloneLifecyle() + import KernelBasis + KernelBasis.setSSLMode(True) import KernelDS myStudy = KernelDS.myStudy() import CORBA @@ -228,7 +230,8 @@ def salome_init_with_session(path=None, embedded=False): global orb, lcc, naming_service, cm, esm, dsm, modulcat global sg global myStudy, myStudyName - + import KernelBasis + KernelBasis.setSSLMode(False) try: if salome_initial: salome_initial=False -- 2.39.2