From: vsr Date: Thu, 14 Feb 2013 12:11:29 +0000 (+0000) Subject: Merge from BR_siman_phase1 14/02/2013 X-Git-Tag: Delivery_V1_0_2013_07_12~8 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=5a21cdc3fe9c7a18509cda6f649ccd39d6bc736d;p=modules%2Fkernel.git Merge from BR_siman_phase1 14/02/2013 --- diff --git a/bin/launchConfigureParser.py b/bin/launchConfigureParser.py index 92b5e9aea..f5427dd3d 100755 --- a/bin/launchConfigureParser.py +++ b/bin/launchConfigureParser.py @@ -66,6 +66,10 @@ valgrind_session_nam = "valgrind_session" shutdown_servers_nam = "shutdown_servers" foreground_nam = "foreground" wake_up_session_nam = "wake_up_session" +siman_nam = "siman" +siman_study_nam = "siman_study" +siman_scenario_nam = "siman_scenario" +siman_user_nam = "siman_user" # values in XML configuration file giving specific module parameters ( section) # which are stored in opts with key _ (eg SMESH_plugins) @@ -773,6 +777,40 @@ def CreateOptionParser (theAdditionalOptions=[]): dest="server_launch_mode", help=help_str) + # SIMAN launch mode + help_str = "Special mode for interacting with SIMAN." + o_siman = optparse.Option("--siman", + action="store_true", + dest="siman", + help=help_str) + + # SIMAN study + help_str = "SIMAN study identifier." + o_siman_study = optparse.Option("--siman-study", + metavar="", + type="string", + action="store", + dest="siman_study", + help=help_str) + + # SIMAN scenario + help_str = "SIMAN scenario identifier." + o_siman_scenario = optparse.Option("--siman-scenario", + metavar="", + type="string", + action="store", + dest="siman_scenario", + help=help_str) + + # SIMAN user + help_str = "SIMAN user identifier." + o_siman_user = optparse.Option("--siman-user", + metavar="", + type="string", + action="store", + dest="siman_user", + help=help_str) + # All options opt_list = [o_t,o_g, # GUI/Terminal o_d,o_o, # Desktop @@ -802,6 +840,10 @@ def CreateOptionParser (theAdditionalOptions=[]): o_foreground, o_wake_up, o_slm, # Server launch mode + o_siman, # Siman launch mode + o_siman_study, # Siman study + o_siman_scenario,# Siman scenario + o_siman_user, # Siman user ] #std_options = ["gui", "desktop", "log_file", "py_scripts", "resources", @@ -1109,6 +1151,16 @@ def get_env(theAdditionalOptions=[], appname=salomeappname, cfgname=salomecfgnam if cmd_opts.wake_up_session is not None: args[wake_up_session_nam] = cmd_opts.wake_up_session + # siman options + if cmd_opts.siman is not None: + args[siman_nam] = cmd_opts.siman + if cmd_opts.siman_study is not None: + args[siman_study_nam] = cmd_opts.siman_study + if cmd_opts.siman_scenario is not None: + args[siman_scenario_nam] = cmd_opts.siman_scenario + if cmd_opts.siman_user is not None: + args[siman_user_nam] = cmd_opts.siman_user + #################################################### # Add values to args for add_opt in theAdditionalOptions: diff --git a/bin/runSalome.py b/bin/runSalome.py index f6e76652f..4d1787e5e 100755 --- a/bin/runSalome.py +++ b/bin/runSalome.py @@ -142,7 +142,27 @@ def get_cata_path(list_modules,modules_root_dir): return cata_path - +_siman_name = None +def simanStudyName(args): + global _siman_name + if _siman_name is None: + # siman session paramenters and checkout processing + _siman_name = "" + if 'siman' in args: + siman_data = [] + for param in [ 'study', 'scenario', 'user']: + if param in args: + siman_data.append(args["siman_%s"%param]) + else: + print "SIMAN %s must be defined using parameter --siman-%s=XXX" % (param, param) + pass + pass + pass + if len(siman_data) == 3: + _siman_name = "_".join(siman_data) + pass + pass + return _siman_name class CatalogServer(Server): def __init__(self,args): @@ -275,6 +295,9 @@ class SessionServer(Server): if self.args['study_hdf'] is not None: self.SCMD2+=['--study-hdf=%s'%self.args['study_hdf']] pass + if simanStudyName(self.args): + self.SCMD2+=['--siman-study=%s'%simanStudyName(self.args)] + pass pass if self.args.has_key('pyscript') and len(self.args['pyscript']) > 0: self.SCMD2+=['--pyscript=%s'%(",".join(self.args['pyscript']))] @@ -512,6 +535,12 @@ def startSalome(args, modules_list, modules_root_dir): myServer=NotifyServer(args,modules_root_dir) myServer.run() + # set siman python path before the session server launching to import scripts inside python console + if simanStudyName(args): + # MPV: use os.environ here because session server is launched in separated process and sys.path in missed in this case + os.environ["PYTHONPATH"] = "/tmp/SimanSalome/" + args['siman_study'] + "/" + \ + args['siman_scenario'] + "/" + args['siman_user'] + os.pathsep + os.environ["PYTHONPATH"]; + # Launch Session Server (to show splash ASAP) # @@ -669,7 +698,28 @@ def startSalome(args, modules_list, modules_root_dir): import readline except ImportError: pass - + + # siman session paramenters and checkout processing + if simanStudyName(args): + print '**********************************************' + print "Siman study name= '" + simanStudyName(args) + "'" + import SALOMEDS + obj = clt.Resolve('myStudyManager') + myStudyManager = obj._narrow(SALOMEDS.StudyManager) + aNewStudy = myStudyManager.NewStudy(simanStudyName(args)) + aSimS = myStudyManager.GetSimanStudy() + aSimS._set_StudyId(args['siman_study']) + aSimS._set_ScenarioId(args['siman_scenario']) + aSimS._set_UserId(args['siman_user']) + aSimS.CheckOut(aNewStudy) + # if session server is enabled, activate the created study + if args["gui"]: + print "Activate the SIMAN study in the SALOME GUI" + obj = clt.Resolve('/Kernel/Session') + mySession = obj._narrow(SALOME.Session) + mySession.emitMessage("simanCheckoutDone " + simanStudyName(args)) + print '**********************************************' + return clt # ----------------------------------------------------------------------------- diff --git a/configure.ac b/configure.ac index d3200df43..b5e589ba0 100644 --- a/configure.ac +++ b/configure.ac @@ -400,6 +400,17 @@ echo --------------------------------------------- echo CHECK_SPHINX +echo +echo --------------------------------------------- +echo testing SimanIO +echo --------------------------------------------- +echo + +CHECK_SIMANIO + +# Additional conditional to avoid compilation errors +AM_CONDITIONAL(WITH_SIMANIO, [test x"$simanio_ok" = xyes]) + echo echo ============================================================ echo Summary @@ -468,7 +479,7 @@ echo --- Kernel parallel extensions: summary $parallel_products echo -optional_products="cppunit_ok numpy_ok libbatch_ok" +optional_products="cppunit_ok numpy_ok libbatch_ok simanio_ok" echo --- Optional products: echo [" These products are optional because the KERNEL functions"] echo [" using them are built only if the products are detected."] diff --git a/idl/SALOMEDS.idl b/idl/SALOMEDS.idl index 4502aaeb6..38afde16e 100644 --- a/idl/SALOMEDS.idl +++ b/idl/SALOMEDS.idl @@ -557,6 +557,76 @@ during each working session. void attach(in SALOMEDS::Observer theObserver, in boolean modify); }; + //=========================================================================== + /*! \brief %SimanStudy Interface + + The Siman (simulation management) study is an interface extension to the %Study + with functions for working with SIMAN server. Is allows to get data from SIMAN (check-out operation) + and to store it back (check-in operation). + This interface is correctly working if SALOME is compiled with SimanIO library, launched with siman + option and connection to SIMAN server is established and alive. Only one study per application, + checked out from the SIMAN is SimanStudy. For other studies all functionality is unaccessible. +*/ + + interface SimanStudy + { + +//! No connection with SIMAN server + exception SimanStudyNoConnection {}; +//! There is no SimanStudy with: study with checked out data. + exception SimanStudyNotExists {}; + +/*! \brief The ID of the study in SIMAN server + + This is equivalent to the methods setStudyId() & getStudyId() +*/ + attribute string StudyId; + +/*! \brief The ID of the scenario in SIMAN server + + This is equivalent to the methods setScenarioId() & getScenarioId() +*/ + attribute string ScenarioId; +/*! \brief The ID of the user in SIMAN server + + This is equivalent to the methods setUserId() & getUserId() +*/ + attribute string UserId; + +/*! \brief Get data from SIMAN and put it to the given study + + This method is called for just created study to make it referenced + by this Siman study. Also it fills this study by the checked out + data from SIMAN server. + Warning: StudyID, ScenarioID and User Id must be set before calling of this method! + + \param theTarget referenced study for checking out +*/ + void CheckOut(in Study theTarget); + +/*! \brief Get data from the source study and store in SIMAN + + It works only with already checked out study. + \param theModuleName name of the module the check in must be perfrormed for. If empty, check in is performed for all modules. +*/ + void CheckIn(in string theModuleName); + +/*! \brief Returns the %Study with checked out data + + If study is null, there is no such study in this application instance, or Salome was + launched without siman option. +*/ + Study getReferencedStudy(); + +/*! + Private method, returns an implementation of this Study. + \param theHostname is a hostname of the caller + \param thePID is a process ID of the caller + \param isLocal is set True if the Study is launched locally with the caller +*/ + long long GetLocalImpl(in string theHostname, in long thePID, out boolean isLocal); +}; + //========================================================================== /*! \brief %Study Builder Interface @@ -985,6 +1055,12 @@ Gets the list of open studies */ long long GetLocalImpl(in string theHostname, in long thePID, out boolean isLocal); +/*! \brief Returns the siman study based on the given study. + + Creates a new Siman study, or returns just a previously created. + \return Siman study, or none if it is not siman mode +*/ + SimanStudy GetSimanStudy(); }; diff --git a/idl/SALOME_Component.idl b/idl/SALOME_Component.idl index 4a1701ddf..50e00542d 100644 --- a/idl/SALOME_Component.idl +++ b/idl/SALOME_Component.idl @@ -60,12 +60,17 @@ module Engines }; typedef sequence FieldsDict; + typedef sequence ListOfOptions; + typedef sequence ListOfIdentifiers; interface EngineComponent ; interface fileRef ; interface fileTransfer ; interface Salome_file; + interface DataContainer; + typedef sequence ListOfData; + /*! \brief Interface of the %Container. This interface defines the process of loading and registration of new components in %SALOME application @@ -225,6 +230,32 @@ module Engines PyScriptNode createPyScriptNode(in string nodeName, in string code) raises(SALOME::SALOME_Exception); }; + /*! \brief Interface to pass data files from the client side to the SALOME Container. + Passes data from client side to the SALOME container (where component engine is running) + size via the CORBA bus as a stream of bytes. + */ + + interface DataContainer + { + //! This operation returns the stream with the data file content. + TMPFile get(); + + //! Returns the name of the document corresponding to this data container. + string name(); + + //! Returns the identifier of the document corresponding to this data container. + string identifier(); + + //! Returns the extension (type) of the document corresponding to this data container. + //! It is taked from the SIMAN URL. + string extension(); + + //! Defines the extension. It is required is extension of the file is not + //! matched with a read extension: archived file, for example. + void setExtension(in string extension); + }; + + /*! \brief Interface of the %component. This interface is used for interaction between the %container and the %component and between the components inside the container. @@ -464,7 +495,22 @@ module Engines \return string containing component's version, e.g. "1.0" */ string getVersion(); - } ; + + //! Generic Import operation to let the component to import data, corresponding to it. + /*! + \param studyId indentifier of the study where the data must be placed + \param data data for import: usually this is just imported file content + \param options additional options for Importat operation + \return the sequence of identifiers of the importedData in the component (to use later in the export function) + */ + ListOfIdentifiers importData(in long studyId, in DataContainer data, in ListOfOptions options); + + //! Generic Export operation to ket the component export all modified data corresponding to it. + /*! + \param studyId identifier of the study that contains the exported data + */ + ListOfData getModifiedData(in long studyId); + }; /*! \brief Base interface of the %component that supports exporting data. diff --git a/salome_adm/cmake_files/CMakeLists.txt b/salome_adm/cmake_files/CMakeLists.txt index d78a6f18d..751aa6e52 100755 --- a/salome_adm/cmake_files/CMakeLists.txt +++ b/salome_adm/cmake_files/CMakeLists.txt @@ -39,6 +39,7 @@ SET(DATA FindPYTHON.cmake FindSWIG.cmake FindSPHINX.cmake + FindSIMANIO.cmake install_python_from_idl.cmake install_and_compile_python_file.cmake InstallAndCompilePythonFile.cmake diff --git a/salome_adm/cmake_files/FindSIMANIO.cmake b/salome_adm/cmake_files/FindSIMANIO.cmake new file mode 100644 index 000000000..47e0c3a58 --- /dev/null +++ b/salome_adm/cmake_files/FindSIMANIO.cmake @@ -0,0 +1,137 @@ +# Copyright (C) 2007-2012 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 +# +# 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. +# +# 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 +# + +# ------ + +MESSAGE(STATUS "Check for SimanIO ...") + +# ------ + +IF(SIMANIO_IS_MANDATORY STREQUAL 0) + SET(SIMANIO_IS_MANDATORY 0) + SET(SIMANIO_IS_OPTIONAL 1) +ENDIF(SIMANIO_IS_MANDATORY STREQUAL 0) +IF(SIMANIO_IS_OPTIONAL STREQUAL 0) + SET(SIMANIO_IS_MANDATORY 1) + SET(SIMANIO_IS_OPTIONAL 0) +ENDIF(SIMANIO_IS_OPTIONAL STREQUAL 0) +IF(NOT SIMANIO_IS_MANDATORY AND NOT SIMANIO_IS_OPTIONAL) + SET(SIMANIO_IS_MANDATORY 0) + SET(SIMANIO_IS_OPTIONAL 1) +ENDIF(NOT SIMANIO_IS_MANDATORY AND NOT SIMANIO_IS_OPTIONAL) + +# ------ + +SET(SIMANIO_STATUS 1) +IF(WITHOUT_SIMANIO OR WITH_SIMANIO STREQUAL 0) + SET(SIMANIO_STATUS 0) + MESSAGE(STATUS "SimanIO disabled from command line.") +ENDIF(WITHOUT_SIMANIO OR WITH_SIMANIO STREQUAL 0) + +# ------ + +IF(SIMANIO_STATUS) + IF(WITH_SIMANIO) + SET(SIMANIO_ROOT_USER ${WITH_SIMANIO}) + ELSE(WITH_SIMANIO) + SET(SIMANIO_ROOT_USER $ENV{SIMANIO_ROOT_DIR}) + ENDIF(WITH_SIMANIO) +ENDIF(SIMANIO_STATUS) + +# ----- + +IF(SIMANIO_STATUS) + IF(SIMANIO_ROOT_USER) + SET(SIMANIO_FIND_PATHS_OPTION NO_DEFAULT_PATH) + ELSE(SIMANIO_ROOT_USER) + SET(SIMANIO_FIND_PATHS_OPTION) + ENDIF(SIMANIO_ROOT_USER) +ENDIF(SIMANIO_STATUS) + +# ----- + +IF(SIMANIO_STATUS) + IF(SIMANIO_ROOT_USER) + SET(SIMANIO_INCLUDE_PATHS ${SIMANIO_ROOT_USER} ${SIMANIO_ROOT_USER}/include) + ELSE(SIMANIO_ROOT_USER) + SET(SIMANIO_INCLUDE_PATHS) + ENDIF(SIMANIO_ROOT_USER) + SET(SIMANIO_INCLUDE_TO_FIND SimanIO_Link.hxx) + FIND_PATH(SIMANIO_INCLUDE_DIR ${SIMANIO_INCLUDE_TO_FIND} PATHS ${SIMANIO_INCLUDE_PATHS} ${SIMANIO_FIND_PATHS_OPTION}) + IF(SIMANIO_INCLUDE_DIR) + IF(SIMANIO_ROOT_USER) + SET(SIMANIO_CPPFLAGS -I${SIMANIO_INCLUDE_DIR}) + ENDIF(SIMANIO_ROOT_USER) + MESSAGE(STATUS "${SIMANIO_INCLUDE_TO_FIND} found in ${SIMANIO_INCLUDE_DIR}") + ELSE(SIMANIO_INCLUDE_DIR) + SET(SIMANIO_STATUS 0) + IF(SIMANIO_ROOT_USER) + MESSAGE(STATUS "${SIMANIO_INCLUDE_TO_FIND} not found in ${SIMANIO_INCLUDE_PATHS}, check your SimanIO installation.") + ELSE(SIMANIO_ROOT_USER) + MESSAGE(STATUS "${SIMANIO_INCLUDE_TO_FIND} not found on system, try to use WITH_SIMANIO option or SIMANIO_ROOT environment variable.") + ENDIF(SIMANIO_ROOT_USER) + ENDIF(SIMANIO_INCLUDE_DIR) +ENDIF(SIMANIO_STATUS) + +# ---- + +IF(SIMANIO_STATUS) + IF(SIMANIO_ROOT_USER) + SET(SIMANIO_LIB_PATHS ${SIMANIO_ROOT_USER}/lib) + ELSE(SIMANIO_ROOT_USER) + SET(SIMANIO_LIB_PATHS) + ENDIF(SIMANIO_ROOT_USER) +ENDIF(SIMANIO_STATUS) + +IF(SIMANIO_STATUS) + IF(WINDOWS) + FIND_LIBRARY(SIMANIO_LIB SimanIO PATHS ${SIMANIO_LIB_PATHS} ${SIMANIO_FIND_PATHS_OPTION}) + ELSE(WINDOWS) + FIND_LIBRARY(SIMANIO_LIB SimanIO PATHS ${SIMANIO_LIB_PATHS} ${SIMANIO_FIND_PATHS_OPTION}) + ENDIF(WINDOWS) + SET(SIMANIO_LIBS) + IF(SIMANIO_LIB) + SET(SIMANIO_LIBS ${SIMANIO_LIBS} ${SIMANIO_LIB}) + MESSAGE(STATUS "SimanIO lib found: ${SIMANIO_LIB}") + ELSE(SIMANIO_LIB) + SET(SIMANIO_STATUS 0) + IF(SIMANIO_ROOT_USER) + MESSAGE(STATUS "SimanIO lib not found in ${SIMANIO_LIB_PATHS}, check your SimanIO installation.") + ELSE(SIMANIO_ROOT_USER) + MESSAGE(STATUS "SimanIO lib not found on system, try to use WITH_SIMANIO option or SIMANIO_ROOT environment variable.") + ENDIF(SIMANIO_ROOT_USER) + ENDIF(SIMANIO_LIB) +ENDIF(SIMANIO_STATUS) + +# ---- + +IF(SIMANIO_STATUS) + SET(WITH_SIMANIO 1) +ELSE(SIMANIO_STATUS) + IF(SIMANIO_IS_MANDATORY) + MESSAGE(FATAL_ERROR "SimanIO not found ... mandatory ... abort") + ELSE(SIMANIO_IS_MANDATORY) + MESSAGE(STATUS "SimanIO not found ... optional ... disabled") + ENDIF(SIMANIO_IS_MANDATORY) +ENDIF(SIMANIO_STATUS) + +# ------ diff --git a/salome_adm/cmake_files/Makefile.am b/salome_adm/cmake_files/Makefile.am index 22ede73e6..49b43ef8f 100644 --- a/salome_adm/cmake_files/Makefile.am +++ b/salome_adm/cmake_files/Makefile.am @@ -39,6 +39,7 @@ FindPTHREADS.cmake \ FindPYTHON.cmake \ FindSWIG.cmake \ FindSPHINX.cmake \ +FindSIMANIO.cmake \ SalomeMacros.cmake \ install_python_from_idl.cmake \ install_and_compile_python_file.cmake \ diff --git a/salome_adm/cmake_files/am2cmake.py b/salome_adm/cmake_files/am2cmake.py index afb446bb0..54b5d6f3b 100644 --- a/salome_adm/cmake_files/am2cmake.py +++ b/salome_adm/cmake_files/am2cmake.py @@ -505,6 +505,7 @@ class CMakeFile(object): INCLUDE(${CMAKE_SOURCE_DIR}/salome_adm/cmake_files/FindDOXYGEN.cmake) INCLUDE(${CMAKE_SOURCE_DIR}/salome_adm/cmake_files/FindLIBBATCH.cmake) INCLUDE(${CMAKE_SOURCE_DIR}/salome_adm/cmake_files/FindSPHINX.cmake) + INCLUDE(${CMAKE_SOURCE_DIR}/salome_adm/cmake_files/FindSIMANIO.cmake) """) pass else: diff --git a/salome_adm/unix/config_files/CMakeLists.txt b/salome_adm/unix/config_files/CMakeLists.txt index e7add33e2..623f3dd70 100755 --- a/salome_adm/unix/config_files/CMakeLists.txt +++ b/salome_adm/unix/config_files/CMakeLists.txt @@ -70,6 +70,7 @@ SET(m4_DATA check_swig.m4 check_vtk.m4 check_withihm.m4 + check_simanio.m4 enable_pthreads.m4 production.m4 pyembed.m4 diff --git a/salome_adm/unix/config_files/Makefile.am b/salome_adm/unix/config_files/Makefile.am index f92e4c144..b1a26650a 100644 --- a/salome_adm/unix/config_files/Makefile.am +++ b/salome_adm/unix/config_files/Makefile.am @@ -83,7 +83,8 @@ check_libxml.m4 \ check_paco++.m4 \ local_install.m4 \ hack_libtool.m4 \ -check_tbb.m4 +check_tbb.m4 \ +check_simanio.m4 dist_salome4depr_DATA=\ $(DEPRECATED_FILES) diff --git a/salome_adm/unix/config_files/check_simanio.m4 b/salome_adm/unix/config_files/check_simanio.m4 new file mode 100644 index 000000000..6c3f57cb3 --- /dev/null +++ b/salome_adm/unix/config_files/check_simanio.m4 @@ -0,0 +1,96 @@ +`dnl Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE +dnl +dnl Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +dnl CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +dnl +dnl This library is free software; you can redistribute it and/or +dnl modify it under the terms of the GNU Lesser General Public +dnl License as published by the Free Software Foundation; either +dnl version 2.1 of the License. +dnl +dnl This library is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +dnl Lesser General Public License for more details. +dnl +dnl You should have received a copy of the GNU Lesser General Public +dnl License along with this library; if not, write to the Free Software +dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +dnl +dnl See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +dnl + +AC_DEFUN([CHECK_SIMANIO],[ + +SIMANIO_CPPFLAGS="" +SIMANIO_LIBS="" + +AC_CHECKING(for SimanIO location) +AC_ARG_WITH(simanio, + [AC_HELP_STRING([--with-simanio=DIR],[root directory path to SimanIO installation])], + [SIMANIODIR="$withval" + AC_MSG_RESULT("select $withval as path to SimanIO installation") + ]) + +if test "x$SIMANIO_DIR" = "x" ; then + # no --with-simanio option used + if test "x$SIMANIO_ROOT_DIR" != "x" ; then + # SIMANIO_ROOT_DIR environment variable defined + SIMANIODIR=$SIMANIO_ROOT_DIR + fi +fi + +AC_MSG_RESULT(\$SIMANIODIR = ${SIMANIODIR}) + +CPPFLAGS_old="${CPPFLAGS}" +LIBS_old=$LIBS + +LIB_SUFFIX="${LIB_LOCATION_SUFFIX}" + +if test "x${SIMANIODIR}" != "x" ; then + SIMANIO_CPPFLAGS="-I${SIMANIODIR}/include" + SIMANIO_LIBS="-L${SIMANIODIR}/lib" +fi + +if test "x${SIMANIODIR}" = "x/usr" ; then + SIMANIO_CPPFLAGS="" + SIMANIO_LIBS="" +fi + +simanio_ok=no +simanio_headers_ok=no +simanio_binaries_ok=no + +dnl SIMANIO headers +#AC_CHECKING(for SimanIO headers) + +simanio_headers_ok=yes +if test "x${SIMANIODIR}" != "x" ; then + AC_CHECK_FILE(${SIMANIODIR}/include/SimanIO_Link.hxx, + simanio_headers_ok=yes, + simanio_headers_ok=no) +fi + +if test "x${simanio_headers_ok}" = "xno" ; then + SIMANIO_CPPFLAGS="SIMANIO_CPPFLAGS_NOT_DEFINED" +else + #AC_MSG_RESULT(\$SIMANIO_CPPFLAGS = ${SIMANIO_CPPFLAGS}) + AC_CHECK_FILE(${SIMANIODIR}/lib/libSimanIO.so, + simanio_lib_ok=yes, + simanio_lib_ok=no) +fi +#AC_MSG_RESULT(for SimanIO libraries: $simanio_lib_ok) + +if test "x${simanio_headers_ok}" = "xyes" ; then + if test "x${simanio_lib_ok}" = "xyes" ; then + SIMANIO_LIBS="-L${SIMANIODIR}/lib -lSimanIO" + simanio_ok=yes + fi +fi + +AC_MSG_RESULT(for simanio: $simanio_ok) + +AC_SUBST(SIMANIO_CPPFLAGS) +AC_SUBST(SIMANIO_LIBS) + +])dnl diff --git a/src/Container/Component_i.cxx b/src/Container/Component_i.cxx index ed5b16b6d..3d26ddb17 100644 --- a/src/Container/Component_i.cxx +++ b/src/Container/Component_i.cxx @@ -1077,6 +1077,38 @@ Engines_Component_i::configureSalome_file(std::string service_name, // By default this method does nothing } +//============================================================================= +/*! + * C++ method: allows to import data file into the Component internal data + structure (like import operation of BRep file in GEOM module). + * \param studyId identifier of the working study + * \param data container of the file content + * \param options additional options for import (if needed) + */ +//============================================================================= +Engines::ListOfIdentifiers* Engines_Component_i::importData(CORBA::Long studyId, + Engines::DataContainer_ptr data, + const Engines::ListOfOptions& options) +{ + // By default this method does nothing + Engines::ListOfIdentifiers_var aList = new Engines::ListOfIdentifiers; + return aList._retn(); +} + +//============================================================================= +/*! + * C++ method: allows to export data files from the Component internal data + structure (like Export operation of Step file in GEOM module). + * \param studyId identifier of the working study + */ +//============================================================================= +Engines::ListOfData* Engines_Component_i::getModifiedData(CORBA::Long studyId) +{ + // By default this method does nothing + Engines::ListOfData_var aList = new Engines::ListOfData; + return aList._retn(); +} + //============================================================================= /*! * C++ method: return the name of the container associated with this component diff --git a/src/Container/Makefile.am b/src/Container/Makefile.am index 7243153df..2d7a75c8c 100644 --- a/src/Container/Makefile.am +++ b/src/Container/Makefile.am @@ -37,6 +37,7 @@ include $(top_srcdir)/salome_adm/unix/make_common_starter.am salomeinclude_HEADERS = \ SALOME_Component_i.hxx \ SALOME_Container_i.hxx \ + SALOME_DataContainer_i.hxx \ SALOME_FileTransfer_i.hxx \ SALOME_FileRef_i.hxx \ SALOME_ContainerManager.hxx \ @@ -48,7 +49,8 @@ salomeinclude_HEADERS = \ dist_salomescript_PYTHON =\ SALOME_ComponentPy.py \ SALOME_PyNode.py \ - SALOME_Container.py + SALOME_Container.py \ + SALOME_DataContainerPy.py # These files are executable scripts dist_salomescript_SCRIPTS=\ @@ -106,6 +108,7 @@ lib_LTLIBRARIES = libSalomeContainer.la libSalomeContainer_la_SOURCES=\ Component_i.cxx \ Container_i.cxx \ + SALOME_DataContainer_i.cxx \ SALOME_FileTransfer_i.cxx \ SALOME_FileRef_i.cxx \ Container_init_python.cxx \ diff --git a/src/Container/SALOME_ComponentPy.py b/src/Container/SALOME_ComponentPy.py index 66c9de634..5039a4578 100755 --- a/src/Container/SALOME_ComponentPy.py +++ b/src/Container/SALOME_ComponentPy.py @@ -319,4 +319,14 @@ class SALOME_ComponentPy_i (Engines__POA.EngineComponent): def getVersion(self): return "" # empty string means "unknown" version + #------------------------------------------------------------------------- + + def importData(self, studyId, dataContainer, options): + return [] # no implmenetation by default + + #------------------------------------------------------------------------- + + def getModifiedData(self, studyId): + return [] # no implmenetation by default + pass # end of SALOME_ComponentPy_i diff --git a/src/Container/SALOME_Component_i.hxx b/src/Container/SALOME_Component_i.hxx index 3581cd9d2..ffe5fafa8 100644 --- a/src/Container/SALOME_Component_i.hxx +++ b/src/Container/SALOME_Component_i.hxx @@ -149,6 +149,10 @@ public: std::string file_port_name, Salome_file_i * file); + virtual Engines::ListOfIdentifiers* importData(CORBA::Long studyId, + Engines::DataContainer_ptr data, + const Engines::ListOfOptions& options); + virtual Engines::ListOfData* getModifiedData(CORBA::Long studyId); protected: int _studyId; // -1: not initialised; 0: multiStudy; >0: study diff --git a/src/Container/SALOME_DataContainerPy.py b/src/Container/SALOME_DataContainerPy.py new file mode 100755 index 000000000..65b7d02e0 --- /dev/null +++ b/src/Container/SALOME_DataContainerPy.py @@ -0,0 +1,96 @@ +#! /usr/bin/env python +# -*- coding: iso-8859-1 -*- +# Copyright (C) 2007-2012 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 +# +# 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. +# +# 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 +# + +# SALOME DataContainer : implementation of data container +# File : SALOME_DataContainerPy.py +# Author : Mikhail PONIKARIOV +# Module : SALOME +# $Header$ +# +import os +import sys +import string + +from omniORB import CORBA, PortableServer +import Engines, Engines__POA +from SALOME_ComponentPy import * + +#============================================================================= + +#define an implementation of the data container interface for the data transfer implemented in Python + +class SALOME_DataContainerPy_i (Engines__POA.DataContainer): + _url = "" + _name = "" + _identifier = "" + _ext = -1 + _removeAfterGet = True; + + #------------------------------------------------------------------------- + + def __init__(self, urlorstream, name, identifier, removeAfterGet, isStream = False): + self._urlorstream = urlorstream + self._name = name + self._identifier = identifier + self._removeAfterGet = removeAfterGet + self._isStream = isStream + if isStream: + self._ext = "" + else: + self._ext = urlorstream[urlorstream.rfind(".") + 1 : ] + + #------------------------------------------------------------------------- + + def get(self): + if self._isStream: + return self._urlorstream + + f = open(self._urlorstream, 'r') + stream = f.read() + f.close() + if self._removeAfterGet: + os.remove(self._urlorstream) + try: # try to remove directory if it is empty + index = max(self._urlorstream.rfind("\\"), self._url.rfind("/")) + if index > 0: + os.rmdir(self._urlorstream[:index]) + except: + pass + return stream + + #------------------------------------------------------------------------- + + def name(self): + return self._name + + #------------------------------------------------------------------------- + + def identifier(self): + return self._identifier + + def extension(self): + return self._ext + + def setExtension(self, ext): + self._ext = ext diff --git a/src/Container/SALOME_DataContainer_i.cxx b/src/Container/SALOME_DataContainer_i.cxx new file mode 100644 index 000000000..6bbc41b0b --- /dev/null +++ b/src/Container/SALOME_DataContainer_i.cxx @@ -0,0 +1,131 @@ +// Copyright (C) 2007-2012 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 +// +// 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. +// +// 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 +// + +// SALOME DataContainer : implementation of data container +// File : SALOME_DataContainer_i.cxx +// Author : Mikhail PONIKAROV +// Module : SALOME +// $Header$ +// + +#include + +#include +#include + +using namespace std; + +Engines_DataContainer_i::Engines_DataContainer_i() +{ +} + +Engines_DataContainer_i::Engines_DataContainer_i(const char* url, + const char* name, const char* identifier, const bool removeAfterGet) + : myName(name), myIdentifier(identifier), myURL(url), myRemoveAfterGet(removeAfterGet), + myStream(0) +{ + std::string anExtension(url); + if (anExtension.rfind(".") != std::string::npos) { // keep only extension + myExt = anExtension.substr(anExtension.rfind(".") + 1); + } else myExt = ""; +} + +Engines_DataContainer_i::Engines_DataContainer_i(char* stream, + const int streamSize, const char* name, const char* identifier, const bool removeAfterGet) + : myName(name), myIdentifier(identifier), myRemoveAfterGet(removeAfterGet), + myStream(stream), myStreamSize(streamSize), myExt("") +{ +} + +Engines_DataContainer_i::~Engines_DataContainer_i() +{ +} + +Engines::TMPFile* Engines_DataContainer_i::get() +{ + char* aBuffer = NULL; + int aFileSize = 0; + if (myStream) { // send from stream + aBuffer = myStream; + aFileSize = myStreamSize; + } else { // send from file + // open file to make stream from its content +#ifdef WIN32 + ifstream aFile(myURL.c_str(), std::ios::binary); +#else + ifstream aFile(myURL.c_str()); +#endif + if (!aFile.good()) { + std::cerr<<"File "< +#include CORBA_SERVER_HEADER(SALOME_Component) + +#include + +class CONTAINER_EXPORT Engines_DataContainer_i: + public POA_Engines::DataContainer +{ +public: + Engines_DataContainer_i(); + Engines_DataContainer_i(const char* url, + const char* name, + const char* identifier, + const bool removeAfterGet); + + Engines_DataContainer_i(char* stream, + const int streamSize, + const char* name, + const char* identifier, + const bool removeAfterGet); + virtual ~Engines_DataContainer_i(); + + // --- CORBA methods + virtual Engines::TMPFile* get(); + virtual char* name(); + virtual char* identifier(); + virtual char* extension(); + virtual void setExtension(const char* theExt); + +protected: + + std::string myExt; ///< extension (type) of the file + std::string myName; ///< name of the document corresponding to this data + std::string myIdentifier; ///< module identifier of the document corresponding to this data + std::string myURL; ///< path to the locally located file + bool myRemoveAfterGet; ///< if this flag is true, file must be removed after the first "get" method call + char* myStream; ///< if it is not NULL, data must be get from this stream, not from the file + int myStreamSize; ///< size (in bytes) if the stream in myStream +}; + +#endif diff --git a/src/Makefile.am b/src/Makefile.am index 598d9e790..a4bc2e06a 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -53,9 +53,9 @@ SUBDIR_CORBA = \ LifeCycleCORBA_SWIG \ SALOMEDSClient \ TOOLSDS \ + KernelHelpers \ SALOMEDSImpl \ SALOMEDS \ - KernelHelpers \ ModuleGenerator \ Communication \ Communication_SWIG \ diff --git a/src/SALOMEDS/CMakeLists.txt b/src/SALOMEDS/CMakeLists.txt index 7d6201b2a..c19bcadeb 100755 --- a/src/SALOMEDS/CMakeLists.txt +++ b/src/SALOMEDS/CMakeLists.txt @@ -64,6 +64,8 @@ SET(SalomeDS_SOURCES SALOMEDS_UseCaseIterator_i.cxx SALOMEDS_ChildIterator_i.cxx SALOMEDS_SComponentIterator_i.cxx + SALOMEDS_SimanStudy_i.cxx + SALOMEDS_SimanStudy.cxx SALOMEDS_Study_i.cxx SALOMEDS_StudyBuilder_i.cxx SALOMEDS_SObject_i.cxx @@ -175,5 +177,7 @@ SET(COMMON_HEADERS_HXX SALOMEDS_Defines.hxx SALOMEDS_wrap.hxx SALOMEDS_Attributes_wrap.hxx + SALOMEDS_SimanStudy.hxx + SALOMEDS_SimanStudy_i.hxx ) INSTALL(FILES ${COMMON_HEADERS_HXX} DESTINATION ${KERNEL_salomeinclude_HEADERS}) diff --git a/src/SALOMEDS/Makefile.am b/src/SALOMEDS/Makefile.am index b4afc7773..3760c9fc0 100644 --- a/src/SALOMEDS/Makefile.am +++ b/src/SALOMEDS/Makefile.am @@ -106,6 +106,8 @@ libSalomeDS_la_SOURCES = \ SALOMEDS_UseCaseIterator_i.cxx \ SALOMEDS_ChildIterator_i.cxx \ SALOMEDS_SComponentIterator_i.cxx \ + SALOMEDS_SimanStudy_i.cxx \ + SALOMEDS_SimanStudy.cxx \ SALOMEDS_Study_i.cxx \ SALOMEDS_StudyBuilder_i.cxx \ SALOMEDS_SObject_i.cxx \ @@ -256,6 +258,8 @@ libSalomeDS_la_SOURCES = \ SALOMEDS_SComponent_i.hxx \ SALOMEDS_SComponentIterator.hxx \ SALOMEDS_SComponentIterator_i.hxx \ + SALOMEDS_SimanStudy.hxx \ + SALOMEDS_SimanStudy_i.hxx \ SALOMEDS_SObject.hxx \ SALOMEDS_SObject_i.hxx \ SALOMEDS_StudyBuilder.hxx \ @@ -274,6 +278,12 @@ libSalomeDS_la_SOURCES = \ SALOMEDS_AttributeString_i.hxx \ SALOMEDS_TMPFile_i.hxx +if WITH_SIMANIO + +COMMON_CPPFLAGS += -DWITH_SIMANIO + +endif + libSalomeDS_la_CPPFLAGS = $(COMMON_CPPFLAGS) libSalomeDS_la_LDFLAGS = -Wl,-E -no-undefined -version-info=0:0:0 @LDEXPDYNFLAGS@ libSalomeDS_la_LIBADD = $(COMMON_LIBS) diff --git a/src/SALOMEDS/SALOMEDS_SimanStudy.cxx b/src/SALOMEDS/SALOMEDS_SimanStudy.cxx new file mode 100644 index 000000000..1000eadd7 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_SimanStudy.cxx @@ -0,0 +1,179 @@ +// Copyright (C) 2007-2012 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 +// +// 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. +// +// 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 +// + +// File : SALOMEDS_SimanStudy.cxx +// Author : Mikhail PONIKAROV +// Module : SALOME +// +#include "utilities.h" + +#include "SALOMEDS_SimanStudy.hxx" + +#include "SALOMEDS.hxx" +#include "SALOMEDS_Study.hxx" + +#include "SALOMEDSImpl_Study.hxx" + +#include "SALOMEDS_SimanStudy_i.hxx" + +#include "Basics_Utils.hxx" + +#include "Utils_ORB_INIT.hxx" +#include "Utils_SINGLETON.hxx" + +SALOMEDS_SimanStudy::SALOMEDS_SimanStudy(SALOMEDSImpl_SimanStudy* theStudy) +{ + _isLocal = true; + _local_impl = theStudy; + _corba_impl = SALOMEDS::SimanStudy::_nil(); + init_orb(); +} + +SALOMEDS_SimanStudy::SALOMEDS_SimanStudy(SALOMEDS::SimanStudy_ptr theStudy) +{ +#ifdef WIN32 + long pid = (long)_getpid(); +#else + long pid = (long)getpid(); +#endif + + long addr = theStudy->GetLocalImpl(Kernel_Utils::GetHostname().c_str(), pid, _isLocal); + if(_isLocal) { + _local_impl = reinterpret_cast(addr); + _corba_impl = SALOMEDS::SimanStudy::_duplicate(theStudy); + } + else { + _local_impl = NULL; + _corba_impl = SALOMEDS::SimanStudy::_duplicate(theStudy); + } + + init_orb(); +} + +SALOMEDS_SimanStudy::~SALOMEDS_SimanStudy() +{ +} + +void SALOMEDS_SimanStudy::CheckOut(const _PTR(Study) theTarget) +{ + if (!theTarget) return; + SALOMEDS_Study* aStudy = dynamic_cast(theTarget.get()); + if (_isLocal) { + //SALOMEDS::Locker lock; mpv: this may cause dedlock when importData in module calls another SALOMEDS method with lock + _local_impl->CheckOut(aStudy->GetLocalImpl()); + } + else _corba_impl->CheckOut(aStudy->GetStudy()); +} + +void SALOMEDS_SimanStudy::CheckIn(const std::string theModuleName) +{ + if (_isLocal) { + //SALOMEDS::Locker lock; mpv: this may cause dedlock when getModifiedData in module calls another SALOMEDS method with lock + _local_impl->CheckIn(theModuleName); + } + else _corba_impl->CheckIn((char*)theModuleName.c_str()); +} + +_PTR(Study) SALOMEDS_SimanStudy::getReferencedStudy() +{ + SALOMEDSClient_Study* aStudy = NULL; + if (_isLocal) { + SALOMEDS::Locker lock; + + SALOMEDSImpl_Study* aStudy_impl = _local_impl->getReferencedStudy(); + if (!aStudy_impl) return _PTR(Study)(aStudy); + aStudy = new SALOMEDS_Study(aStudy_impl); + } + else { + SALOMEDS::Study_var aStudy_impl = _corba_impl->getReferencedStudy(); + if (CORBA::is_nil(aStudy_impl)) return _PTR(Study)(aStudy); + aStudy = new SALOMEDS_Study(aStudy_impl); + } + return _PTR(Study)(aStudy); +} + +std::string SALOMEDS_SimanStudy::StudyId() +{ + std::string anId; + if (_isLocal) { + SALOMEDS::Locker lock; + anId = _local_impl->StudyId(); + } + else anId = (CORBA::String_var)_corba_impl->StudyId(); + return anId; +} + +void SALOMEDS_SimanStudy::StudyId(const std::string theId) +{ + if (_isLocal) { + SALOMEDS::Locker lock; + _local_impl->StudyId(theId); + } + else _corba_impl->StudyId((char*)theId.c_str()); +} + +std::string SALOMEDS_SimanStudy::ScenarioId() +{ + std::string anId; + if (_isLocal) { + SALOMEDS::Locker lock; + anId = _local_impl->ScenarioId(); + } + else anId = (CORBA::String_var)_corba_impl->ScenarioId(); + return anId; +} + +void SALOMEDS_SimanStudy::ScenarioId(const std::string theId) +{ + if (_isLocal) { + SALOMEDS::Locker lock; + _local_impl->ScenarioId(theId); + } + else _corba_impl->ScenarioId((char*)theId.c_str()); +} + +std::string SALOMEDS_SimanStudy::UserId() +{ + std::string anId; + if (_isLocal) { + SALOMEDS::Locker lock; + anId = _local_impl->UserId(); + } + else anId = (CORBA::String_var)_corba_impl->UserId(); + return anId; +} + +void SALOMEDS_SimanStudy::UserId(const std::string theId) +{ + if (_isLocal) { + SALOMEDS::Locker lock; + _local_impl->UserId(theId); + } + else _corba_impl->UserId((char*)theId.c_str()); +} + +void SALOMEDS_SimanStudy::init_orb() +{ + ORB_INIT &init = *SINGLETON_::Instance(); + ASSERT(SINGLETON_::IsAlreadyExisting()); + _orb = init(0, 0); +} diff --git a/src/SALOMEDS/SALOMEDS_SimanStudy.hxx b/src/SALOMEDS/SALOMEDS_SimanStudy.hxx new file mode 100644 index 000000000..3cfe76f4f --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_SimanStudy.hxx @@ -0,0 +1,69 @@ +// Copyright (C) 2007-2012 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 +// +// 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. +// +// 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 +// + +// File : SALOMEDS_SimanStudy.hxx +// Author : Mikhail PONIKAROV +// Module : SALOME +// +#ifndef __SALOMEDS_SIMANSTUDY_H__ +#define __SALOMEDS_SIMANSTUDY_H__ + +#include +#include + +#include "SALOMEDSClient.hxx" +#include "SALOMEDSImpl_SimanStudy.hxx" + +// IDL headers +#include +#include CORBA_SERVER_HEADER(SALOMEDS) + +class Standard_EXPORT SALOMEDS_SimanStudy: public SALOMEDSClient_SimanStudy +{ + +private: + bool _isLocal; + SALOMEDSImpl_SimanStudy* _local_impl; + SALOMEDS::SimanStudy_var _corba_impl; + CORBA::ORB_var _orb; + +public: + + SALOMEDS_SimanStudy(SALOMEDSImpl_SimanStudy* theStudy); + SALOMEDS_SimanStudy(SALOMEDS::SimanStudy_ptr theStudy); + ~SALOMEDS_SimanStudy(); + + virtual void CheckOut(const _PTR(Study) theTarget); + virtual void CheckIn(const std::string theModuleName); + virtual _PTR(Study) getReferencedStudy() ; + virtual std::string StudyId(); + virtual void StudyId(const std::string theId); + virtual std::string ScenarioId(); + virtual void ScenarioId(const std::string theId); + virtual std::string UserId(); + virtual void UserId(const std::string theId); + +private: + void init_orb(); + +}; +#endif diff --git a/src/SALOMEDS/SALOMEDS_SimanStudy_i.cxx b/src/SALOMEDS/SALOMEDS_SimanStudy_i.cxx new file mode 100644 index 000000000..c9785f2b7 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_SimanStudy_i.cxx @@ -0,0 +1,176 @@ +// Copyright (C) 2007-2012 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 +// +// 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. +// +// 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 +// + +// File : SALOMEDS_SimanStudy_i.cxx +// Author : Mikhail PONIKAROV +// Module : SALOME +// +#include "utilities.h" +#include "SALOMEDS_SimanStudy_i.hxx" +#include "SALOMEDSImpl_SimanStudy.hxx" +#include "SALOMEDSImpl_StudyManager.hxx" +#include "SALOMEDS_Study_i.hxx" +#include "SALOMEDS_Study.hxx" + +#include "Basics_Utils.hxx" + +//============================================================================ +/*! Function : SALOMEDS_SimanStudy_i + * Purpose : standard constructor + */ +//============================================================================ +SALOMEDS_SimanStudy_i::SALOMEDS_SimanStudy_i(SALOMEDSImpl_SimanStudy* theImpl, CORBA::ORB_ptr orb) +{ + _orb = CORBA::ORB::_duplicate(orb); + _impl = theImpl; +} + +//============================================================================ +/*! Function : ~SALOMEDS_SimanStudy_i + * Purpose : standard destructor + */ +//============================================================================ +SALOMEDS_SimanStudy_i::~SALOMEDS_SimanStudy_i() +{ + //delete implementation + delete _impl; +} + +//============================================================================ +/*! Function : CheckOut + * Purpose : Get data from SIMAN and put it to the given study + */ +//============================================================================ +void SALOMEDS_SimanStudy_i::CheckOut(SALOMEDS::Study_ptr theTarget) +{ + // SimanStudy and Study must be located at the same place anyway + SALOMEDS_Study aStudy(theTarget); + _study = aStudy.GetLocalImpl(); + if (_study) { + _impl->CheckOut(_study); + } +} + +//============================================================================ +/*! Function : CheckIn + * Purpose : Get data from SIMAN study and stores to SIMAN + */ +//============================================================================ +void SALOMEDS_SimanStudy_i::CheckIn(const char* theModuleName) +{ + if (_study) { + _impl->CheckIn(theModuleName); + } +} + +//============================================================================ +/*! Function : getReferencedStudy + * Purpose : Returns the %Study with checked out data + */ +//============================================================================ +SALOMEDS::Study_ptr SALOMEDS_SimanStudy_i::getReferencedStudy() +{ + SALOMEDS::Study_var aStudy = (new SALOMEDS_Study_i(_study, _orb))->_this(); + return aStudy._retn(); +} + +//============================================================================ +/*! Function : StudyId + * Purpose : The ID of the study in SIMAN server + */ +//============================================================================ +char* SALOMEDS_SimanStudy_i::StudyId() +{ + return CORBA::string_dup(_impl->StudyId().c_str()); +} + +//============================================================================ +/*! Function : StudyId + * Purpose : The ID of the study in SIMAN server + */ +//============================================================================ +void SALOMEDS_SimanStudy_i::StudyId(const char* theId) +{ + _impl->StudyId(theId); +} + +//============================================================================ +/*! Function : ScenarioId + * Purpose : The ID of the scenario in SIMAN server + */ +//============================================================================ +char* SALOMEDS_SimanStudy_i::ScenarioId() +{ + return CORBA::string_dup(_impl->ScenarioId().c_str()); +} + +//============================================================================ +/*! Function : ScenarioId + * Purpose : The ID of the scenario in SIMAN server + */ +//============================================================================ +void SALOMEDS_SimanStudy_i::ScenarioId(const char* theId) +{ + _impl->ScenarioId(theId); +} + +//============================================================================ +/*! Function : UserId + * Purpose : The ID of the user in SIMAN server + */ +//============================================================================ +char* SALOMEDS_SimanStudy_i::UserId() +{ + return CORBA::string_dup(_impl->UserId().c_str()); +} + +//============================================================================ +/*! Function : UserId + * Purpose : The ID of the user in SIMAN server + */ +//============================================================================ +void SALOMEDS_SimanStudy_i::UserId(const char* theId) +{ + _impl->UserId(theId); +} + + +SALOMEDS_SimanStudy_i* SALOMEDS_SimanStudy_i::GetSimanServant(SALOMEDSImpl_SimanStudy* aSimanImpl, CORBA::ORB_ptr orb) +{ + static SALOMEDS_SimanStudy_i* aServant = 0; + if (aServant == 0) { + aServant = new SALOMEDS_SimanStudy_i(aSimanImpl, orb); + } + return aServant; +} + +/// PRIVATE FUNCTIONS +CORBA::LongLong SALOMEDS_SimanStudy_i::GetLocalImpl(const char* theHostname, CORBA::Long thePID, CORBA::Boolean& isLocal) +{ +#ifdef WIN32 + long pid = (long)_getpid(); +#else + long pid = (long)getpid(); +#endif + isLocal = (strcmp(theHostname, Kernel_Utils::GetHostname().c_str()) == 0 && pid == thePID)?1:0; + return reinterpret_cast(_impl); +} diff --git a/src/SALOMEDS/SALOMEDS_SimanStudy_i.hxx b/src/SALOMEDS/SALOMEDS_SimanStudy_i.hxx new file mode 100644 index 000000000..cd894aa47 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_SimanStudy_i.hxx @@ -0,0 +1,119 @@ +// Copyright (C) 2007-2012 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 +// +// 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. +// +// 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 +// + +// File : SALOMEDS_SimanStudy_i.hxx +// Author : Mikhail PONIKAROV +// Module : SALOME +// +#ifndef __SALOMEDS_SIMANSTUDY_I_H__ +#define __SALOMEDS_SIMANSTUDY_I_H__ + +// IDL headers +#include +#include CORBA_SERVER_HEADER(SALOMEDS) + +//SALOMEDS headers +#include "SALOMEDS_Study_i.hxx" + +class SALOMEDSImpl_SimanStudy; +class SALOMEDSImpl_Study; + +class Standard_EXPORT SALOMEDS_SimanStudy_i: public POA_SALOMEDS::SimanStudy +{ +private: + CORBA::ORB_var _orb; + SALOMEDSImpl_SimanStudy* _impl; + SALOMEDSImpl_Study* _study; + +public: + + //! standard constructor + SALOMEDS_SimanStudy_i(SALOMEDSImpl_SimanStudy*, CORBA::ORB_ptr); + + //! standard destructor + virtual ~SALOMEDS_SimanStudy_i(); + + /*! \brief Get data from SIMAN and put it to the given study + + This method is called for just created study to make it referenced + by this Siman study. Also it fills this study by the checked out + data from SIMAN server. + Warning: StudyID, ScenarioID and User Id must be set before calling of this method! + + \param theTarget referenced study for checking out + */ + virtual void CheckOut(SALOMEDS::Study_ptr theTarget); + + /*! \brief Get data from all modules and calls the corresponding SimanIO methods to store it. + + It works only with already checked out study + */ + virtual void CheckIn(const char* themoduleName); + + /*! \brief Returns the %Study with checked out data + + If study is null, there is no such study in this application instance, or Salome was + launched without siman option. + */ + virtual SALOMEDS::Study_ptr getReferencedStudy(); + + /*! \brief The ID of the study in SIMAN server + + Returns the Id of SIMAN study, used for CheckOut before. + */ + virtual char* StudyId(); + + /*! \brief The ID of the study in SIMAN server + + Defines the Id of SIMAN study, used for CheckOut after. + */ + virtual void StudyId(const char* theId); + + /*! \brief The ID of the scenario in SIMAN server + + Returns the Id of SIMAN scenario, used for CheckOut before. + */ + virtual char* ScenarioId(); + + /*! \brief The ID of the scenario in SIMAN server + + Defines the Id of SIMAN scenario, used for CheckOut after. + */ + virtual void ScenarioId(const char* theId); + + /*! \brief The ID of the user in SIMAN server + + Returns the Id of SIMAN user, used for CheckOut before. + */ + virtual char* UserId(); + + /*! \brief The ID of the user in SIMAN server + + Defines the Id of SIMAN user, used for CheckOut after. + */ + virtual void UserId(const char* theId); + + virtual CORBA::LongLong GetLocalImpl(const char* theHostname, CORBA::Long thePID, CORBA::Boolean& isLocal); + + static SALOMEDS_SimanStudy_i* GetSimanServant(SALOMEDSImpl_SimanStudy*, CORBA::ORB_ptr orb); +}; +#endif diff --git a/src/SALOMEDS/SALOMEDS_Study.hxx b/src/SALOMEDS/SALOMEDS_Study.hxx index 3e0c43498..58ed7ebb3 100644 --- a/src/SALOMEDS/SALOMEDS_Study.hxx +++ b/src/SALOMEDS/SALOMEDS_Study.hxx @@ -128,7 +128,9 @@ public: CORBA::Object_ptr ConvertIORToObject(const std::string& theIOR); SALOMEDS::Study_ptr GetStudy(); - + + SALOMEDSImpl_Study* GetLocalImpl() { return _local_impl; } + private: void init_orb(); diff --git a/src/SALOMEDS/SALOMEDS_StudyManager.cxx b/src/SALOMEDS/SALOMEDS_StudyManager.cxx index 814f58bc3..37fc806dc 100644 --- a/src/SALOMEDS/SALOMEDS_StudyManager.cxx +++ b/src/SALOMEDS/SALOMEDS_StudyManager.cxx @@ -29,8 +29,8 @@ #include "SALOMEDS.hxx" #include "SALOMEDS_Study.hxx" #include "SALOMEDS_SObject.hxx" - #include "SALOMEDS_Driver_i.hxx" +#include "SALOMEDS_SimanStudy.hxx" #include "SALOMEDSImpl_Study.hxx" @@ -324,3 +324,21 @@ SALOMEDS_Driver_i* GetDriver(const SALOMEDSImpl_SObject& theObject, CORBA::ORB_p return driver; } + +_PTR(SimanStudy) SALOMEDS_StudyManager::GetSimanStudy() +{ + SALOMEDSClient_SimanStudy* aSiman = NULL; + if (_isLocal) { + SALOMEDS::Locker lock; + + SALOMEDSImpl_SimanStudy* aSiman_impl = _local_impl->GetSimanStudy(); + if(!aSiman_impl) return _PTR(SimanStudy)(aSiman); + aSiman = new SALOMEDS_SimanStudy(aSiman_impl); + } + else { + SALOMEDS::SimanStudy_var aSiman_impl = _corba_impl->GetSimanStudy(); + if(CORBA::is_nil(aSiman_impl)) return _PTR(SimanStudy)(aSiman); + aSiman = new SALOMEDS_SimanStudy(aSiman_impl); + } + return _PTR(SimanStudy)(aSiman); +} diff --git a/src/SALOMEDS/SALOMEDS_StudyManager.hxx b/src/SALOMEDS/SALOMEDS_StudyManager.hxx index b48175bf7..991f3ae17 100644 --- a/src/SALOMEDS/SALOMEDS_StudyManager.hxx +++ b/src/SALOMEDS/SALOMEDS_StudyManager.hxx @@ -66,6 +66,7 @@ public: virtual bool Copy(const _PTR(SObject)& theSO); virtual bool CanPaste(const _PTR(SObject)& theSO); virtual _PTR(SObject) Paste(const _PTR(SObject)& theSO); + virtual _PTR(SimanStudy) GetSimanStudy(); private: void init_orb(); diff --git a/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx b/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx index 7c87675b9..55c6f2bcd 100644 --- a/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx +++ b/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx @@ -30,6 +30,7 @@ #include "SALOMEDS_Study_i.hxx" #include "SALOMEDS_SComponent_i.hxx" #include "SALOMEDS_Driver_i.hxx" +#include "SALOMEDS_SimanStudy_i.hxx" #include "SALOMEDS.hxx" #include "SALOMEDSImpl_Study.hxx" @@ -478,6 +479,21 @@ void SALOMEDS_StudyManager_i::ShutdownWithExit() exit( EXIT_SUCCESS ); } +//============================================================================ +/*! Function : GetSimanStudy + * Purpose : Retruns the created or cashed SimanStudy + */ +//============================================================================ +SALOMEDS::SimanStudy_ptr SALOMEDS_StudyManager_i::GetSimanStudy() +{ + SALOMEDS::Locker lock; + + SALOMEDSImpl_SimanStudy* aSimanImpl = _impl->GetSimanStudy(); + + SALOMEDS_SimanStudy_i* aSiman_servant = SALOMEDS_SimanStudy_i::GetSimanServant(aSimanImpl, _orb); + return aSiman_servant->_this(); +} + //=========================================================================== // PRIVATE FUNCTIONS //=========================================================================== diff --git a/src/SALOMEDS/SALOMEDS_StudyManager_i.hxx b/src/SALOMEDS/SALOMEDS_StudyManager_i.hxx index 5b44f0602..5d08c4803 100644 --- a/src/SALOMEDS/SALOMEDS_StudyManager_i.hxx +++ b/src/SALOMEDS/SALOMEDS_StudyManager_i.hxx @@ -151,6 +151,8 @@ public: static PortableServer::POA_ptr GetPOA(const SALOMEDS::Study_ptr theStudy); void Shutdown() { if(!CORBA::is_nil(_orb)) _orb->shutdown(0); } + + virtual SALOMEDS::SimanStudy_ptr GetSimanStudy(); }; #endif diff --git a/src/SALOMEDS/Test/Makefile.am b/src/SALOMEDS/Test/Makefile.am index 4394dd9cc..463a9d6ae 100644 --- a/src/SALOMEDS/Test/Makefile.am +++ b/src/SALOMEDS/Test/Makefile.am @@ -85,6 +85,10 @@ COMMON_LIBS =\ $(RPATH)/SALOMEDS/libSalomeDS.la \ $(top_builddir)/idl/libSalomeIDLKernel.la +if WITH_SIMANIO + COMMON_CPPFLAGS += -DWITH_SIMANIO +endif + # # =============================================================== # Libraries targets diff --git a/src/SALOMEDSClient/Makefile.am b/src/SALOMEDSClient/Makefile.am index 9e65df0b2..7c7140d9d 100644 --- a/src/SALOMEDSClient/Makefile.am +++ b/src/SALOMEDSClient/Makefile.am @@ -66,6 +66,7 @@ salomeinclude_HEADERS=\ SALOMEDSClient_SComponentIterator.hxx \ SALOMEDSClient_SObject.hxx \ SALOMEDSClient_Study.hxx \ + SALOMEDSClient_SimanStudy.hxx \ SALOMEDSClient_StudyBuilder.hxx \ SALOMEDSClient_StudyManager.hxx \ SALOMEDSClient_UseCaseBuilder.hxx \ @@ -87,7 +88,12 @@ COMMON_CPPFLAGS= \ -I$(top_builddir)/idl \ @CORBA_CXXFLAGS@ @CORBA_INCLUDES@ +if WITH_SIMANIO +COMMON_CPPFLAGS += -DWITH_SIMANIO + +endif + # This local variable defines the list of dependant libraries common to all target in this package. COMMON_LIBS = $(top_builddir)/idl/libSalomeIDLKernel.la diff --git a/src/SALOMEDSClient/SALOMEDSClient.hxx b/src/SALOMEDSClient/SALOMEDSClient.hxx index cb606ef13..0289ab11b 100644 --- a/src/SALOMEDSClient/SALOMEDSClient.hxx +++ b/src/SALOMEDSClient/SALOMEDSClient.hxx @@ -65,4 +65,8 @@ #include "SALOMEDSClient_UseCaseBuilder.hxx" #include "SALOMEDSClient_UseCaseIterator.hxx" +#ifdef WITH_SIMANIO +#include "SALOMEDSClient_SimanStudy.hxx" +#endif + #endif diff --git a/src/SALOMEDSClient/SALOMEDSClient_SimanStudy.hxx b/src/SALOMEDSClient/SALOMEDSClient_SimanStudy.hxx new file mode 100644 index 000000000..456019816 --- /dev/null +++ b/src/SALOMEDSClient/SALOMEDSClient_SimanStudy.hxx @@ -0,0 +1,56 @@ +// Copyright (C) 2007-2012 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 +// +// 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. +// +// 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 +// + +// File : SALOMEDSClient_SimanStudy.hxx +// Author : Mikhail PONIKAROV +// Module : SALOME +// +#ifndef __SALOMEDSClient_SIMANSTUDY_H__ +#define __SALOMEDSClient_SIMANSTUDY_H__ + +#include +#include + +#include "SALOMEDSClient_definitions.hxx" +#include "SALOMEDSClient_Study.hxx" +#include +#include CORBA_CLIENT_HEADER(SALOMEDS) + +class SALOMEDSClient_SimanStudy +{ + +public: + virtual ~SALOMEDSClient_SimanStudy() {} + + virtual void CheckOut(const _PTR(Study) theTarget) = 0; + virtual void CheckIn(const std::string theModuleName) = 0; + virtual _PTR(Study) getReferencedStudy() = 0; + virtual std::string StudyId() = 0; + virtual void StudyId(const std::string theId) = 0; + virtual std::string ScenarioId() = 0; + virtual void ScenarioId(const std::string theId) = 0; + virtual std::string UserId() = 0; + virtual void UserId(const std::string theId) = 0; +}; + + +#endif diff --git a/src/SALOMEDSClient/SALOMEDSClient_StudyManager.hxx b/src/SALOMEDSClient/SALOMEDSClient_StudyManager.hxx index a7081c4f2..43717c1b9 100644 --- a/src/SALOMEDSClient/SALOMEDSClient_StudyManager.hxx +++ b/src/SALOMEDSClient/SALOMEDSClient_StudyManager.hxx @@ -32,6 +32,7 @@ #include "SALOMEDSClient_definitions.hxx" #include "SALOMEDSClient_Study.hxx" +#include "SALOMEDSClient_SimanStudy.hxx" class SALOMEDSClient_StudyManager { @@ -52,6 +53,8 @@ public: virtual bool Copy(const _PTR(SObject)& theSO) = 0; virtual bool CanPaste(const _PTR(SObject)& theSO) = 0; virtual _PTR(SObject) Paste(const _PTR(SObject)& theSO) = 0; + + virtual _PTR(SimanStudy) GetSimanStudy() = 0; }; diff --git a/src/SALOMEDSImpl/CMakeLists.txt b/src/SALOMEDSImpl/CMakeLists.txt index c98ef85b9..fd96d2153 100755 --- a/src/SALOMEDSImpl/CMakeLists.txt +++ b/src/SALOMEDSImpl/CMakeLists.txt @@ -90,6 +90,7 @@ SET(SalomeDSImpl_SOURCES SALOMEDSImpl_TMPFile.cxx SALOMEDSImpl_GenericVariable.cxx SALOMEDSImpl_ScalarVariable.cxx + SALOMEDSImpl_SimanStudy.cxx SALOMEDSImpl_AttributeComment.hxx SALOMEDSImpl_AttributeDrawable.hxx SALOMEDSImpl_AttributeExpandable.hxx @@ -141,6 +142,7 @@ SET(SalomeDSImpl_SOURCES SALOMEDSImpl_UseCaseIterator.hxx SALOMEDSImpl_GenericVariable.hxx SALOMEDSImpl_ScalarVariable.hxx + SALOMEDSImpl_SimanStudy.hxx ) ADD_LIBRARY(SalomeDSImpl ${SalomeDSImpl_SOURCES}) diff --git a/src/SALOMEDSImpl/Makefile.am b/src/SALOMEDSImpl/Makefile.am index 04d20e485..34e4dbbb6 100644 --- a/src/SALOMEDSImpl/Makefile.am +++ b/src/SALOMEDSImpl/Makefile.am @@ -165,6 +165,7 @@ libSalomeDSImpl_la_SOURCES =\ SALOMEDSImpl_TMPFile.cxx \ SALOMEDSImpl_GenericVariable.cxx \ SALOMEDSImpl_ScalarVariable.cxx \ + SALOMEDSImpl_SimanStudy.cxx \ \ SALOMEDSImpl_AttributeComment.hxx \ SALOMEDSImpl_AttributeDrawable.hxx \ @@ -207,6 +208,7 @@ libSalomeDSImpl_la_SOURCES =\ SALOMEDSImpl_GenericAttribute.hxx \ SALOMEDSImpl_SComponent.hxx \ SALOMEDSImpl_SComponentIterator.hxx \ + SALOMEDSImpl_SimanStudy.hxx \ SALOMEDSImpl_SObject.hxx \ SALOMEDSImpl_StudyBuilder.hxx \ SALOMEDSImpl_StudyHandle.hxx \ @@ -218,6 +220,29 @@ libSalomeDSImpl_la_SOURCES =\ SALOMEDSImpl_GenericVariable.hxx \ SALOMEDSImpl_ScalarVariable.hxx +if WITH_SIMANIO + +COMMON_CPPFLAGS += -DWITH_SIMANIO @SIMANIO_CPPFLAGS@ +COMMON_LIBS += @SIMANIO_LIBS@ + +################################################################################################### +# VSR: these commands should be removed +# vvv +COMMON_CPPFLAGS += \ + -I$(top_builddir)/idl @CORBA_CXXFLAGS@ @CORBA_INCLUDES@ \ + -I$(srcdir)/../KernelHelpers -I$(srcdir)/../NamingService -I$(srcdir)/../LifeCycleCORBA -I$(srcdir)/../Utils \ + -I$(srcdir)/../Container -I$(srcdir)/../TOOLSDS + +COMMON_LIBS += \ + $(top_builddir)/idl/libSalomeIDLKernel.la \ + ../KernelHelpers/libSalomeKernelHelpers.la ../LifeCycleCORBA/libSalomeLifeCycleCORBA.la \ + ../Container/libSalomeContainer.la ../TOOLSDS/libTOOLSDS.la + +# ^^^ +################################################################################################### + +endif + libSalomeDSImpl_la_CPPFLAGS = $(COMMON_CPPFLAGS) libSalomeDSImpl_la_LDFLAGS = -no-undefined -version-info=0:0:0 libSalomeDSImpl_la_LIBADD = $(COMMON_LIBS) diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_SimanStudy.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_SimanStudy.cxx new file mode 100644 index 000000000..923ec702b --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_SimanStudy.cxx @@ -0,0 +1,312 @@ +// Copyright (C) 2007-2012 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 +// +// 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. +// +// 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 +// + +// File : SALOMEDSImpl_SimanStudy.cxx +// Author : Mikhail PONIKAROV +// Module : SALOME +// +#include "SALOMEDSImpl_SimanStudy.hxx" + +#ifdef WITH_SIMANIO +#include +#include +#include +#include +#include +#include +#include +#endif + +#include +#include CORBA_SERVER_HEADER(SALOME_Component) + +using namespace std; + +//============================================================================ +/*! Function : SALOMEDSImpl_SimanStudy + * Purpose : SALOMEDSImpl_SimanStudy constructor + */ +//============================================================================ +SALOMEDSImpl_SimanStudy::SALOMEDSImpl_SimanStudy() +{ + _study = 0; +#ifdef WITH_SIMANIO + _checkedOut = new SimanIO_Configuration; +#endif +} + +//============================================================================ +/*! Function : ~SALOMEDSImpl_SimanStudy + * Purpose : SALOMEDSImpl_SimanStudy destructor + */ +//============================================================================ +SALOMEDSImpl_SimanStudy::~SALOMEDSImpl_SimanStudy() +{ +#ifdef WITH_SIMANIO + if (_checkedOut) { + SimanIO_Configuration::ActivitiesIterator actIter(*_checkedOut); + for(; actIter.More(); actIter.Next()) { + SimanIO_Activity::DocumentsIterator aDocIter(actIter.Activity()); + for(; aDocIter.More(); aDocIter.Next()) { + const SimanIO_Document& aDoc = aDocIter.Document(); + SimanIO_Document::FilesIterator aFileIter(aDoc); + for(; aFileIter.More(); aFileIter.Next()) { + string aURL = aFileIter.URL(); + string aDir = Kernel_Utils::GetDirName(aURL); + aDir += "/"; + string aFileName = aURL.substr(aDir.size()); + SALOMEDS::ListOfFileNames aTmpFiles; + aTmpFiles.length(1); + aTmpFiles[0] = aFileName.c_str(); + // try to remove temporary directory that contains this file if directory becomes empty + SALOMEDS_Tool::RemoveTemporaryFiles(aDir, aTmpFiles, true); + } + } + } + delete _checkedOut; + } +#endif +} + +//============================================================================ +/*! Function : CheckOut + * Purpose : Fills the referenced study by the SIMAN data + */ +//============================================================================ +void SALOMEDSImpl_SimanStudy::CheckOut(SALOMEDSImpl_Study* theTarget) +{ + _study = theTarget; +#ifdef WITH_SIMANIO + int aLocked = _study->GetProperties()->IsLocked(); + if (aLocked) _study->GetProperties()->SetLocked(false); + + SimanIO_Link aLink(_studyId.c_str(), _scenarioId.c_str(), _userId.c_str()); + if (aLink.IsConnected()) { + // Set "C" locale temporarily to avoid possible localization problems + Kernel_Utils::Localizer loc; + *_checkedOut = aLink.RetrieveConf(); + SimanIO_Configuration::ActivitiesIterator actIter(*_checkedOut); + for(; actIter.More(); actIter.Next()) { + Engines::EngineComponent_var aComp = + KERNEL::getLifeCycleCORBA()->FindOrLoad_Component("FactoryServerPy", actIter.Activity().Module()); + if (CORBA::is_nil(aComp)) // it is not python container, try to find in C++ container + aComp = KERNEL::getLifeCycleCORBA()->FindOrLoad_Component("FactoryServer", actIter.Activity().Module()); + if (CORBA::is_nil(aComp)) { + MESSAGE("Checkout: component "<(); + const SimanIO_Document& aDoc = aDocIter.Document(); + SimanIO_Document::FilesIterator aFileIter(aDoc); + for(; aFileIter.More(); aFileIter.Next()) { + if (aFileIter.GetProcessing() == FILE_IMPORT) { + // files provided by SIMAN will be removed later, on study close + Engines::DataContainer_var aData = (new Engines_DataContainer_i( + aFileIter.URL(), aDoc.Name(), "", false))->_this(); + Engines::ListOfOptions anEmptyOpts; + Engines::ListOfIdentifiers_var anIds = aComp->importData(_study->StudyId(), aData, anEmptyOpts); + for(int anIdNum = 0; anIdNum < anIds->length(); anIdNum++) { + const char* anId = anIds[anIdNum]; + _filesId[aDocIter.DocId()][anId] = aFileIter.Id(); + } + } else { + cout<<"!!! File just downloaded, not imported:"<GetProperties()->SetLocked(true); + +#endif +} + +//============================================================================ +/*! Function : CheckIn + * Purpose : Fills the SIMAN by the SIMAN study data + */ +//============================================================================ +void SALOMEDSImpl_SimanStudy::CheckIn(const std::string theModuleName) +{ +#ifdef WITH_SIMANIO + if (!_study) { + MESSAGE("No siman study defined"); + return; + } + SimanIO_Link aLink(_studyId.c_str(), _scenarioId.c_str(), _userId.c_str()); + if (aLink.IsConnected()) { + // Set "C" locale temporarily to avoid possible localization problems + Kernel_Utils::Localizer loc; + SimanIO_Configuration aToStore; // here create and store data in this configuration to check in to SIMAN + string aTmpDir = SALOMEDS_Tool::GetTmpDir(); // temporary directory for checked in files + int aFileIndex = 0; // for unique file name generation + list aTemporaryFileNames; + SimanIO_Configuration::ActivitiesIterator actIter(*_checkedOut); + for(; actIter.More(); actIter.Next()) { + int aDocId = actIter.Activity().DocumentMaxID(); + //if (aDocId < 0) continue; // no documents => no check in + if (!theModuleName.empty() && theModuleName != actIter.Activity().Module()) { + continue; + } + Engines::EngineComponent_var aComp = + KERNEL::getLifeCycleCORBA()->FindOrLoad_Component("FactoryServerPy", actIter.Activity().Module()); + if (CORBA::is_nil(aComp)) // it is not python container, try to find in C++ container + aComp = KERNEL::getLifeCycleCORBA()->FindOrLoad_Component("FactoryServer", actIter.Activity().Module()); + if (CORBA::is_nil(aComp)) { + MESSAGE("Checkin: component "<getModifiedData(_study->StudyId()); + int aNumData = aList->length(); + for(int aDataIndex = 0; aDataIndex < aNumData; aDataIndex++) { + Engines::DataContainer_var aData = aList[aDataIndex]; + // store this in the configuration + SimanIO_Activity& aStoreActivity = aToStore.GetOrCreateActivity(actIter.ActivityId()); + aStoreActivity.SetName(actIter.Activity().Name()); + aStoreActivity.SetModule(actIter.Activity().Module()); + SimanIO_Document& aStoreDoc = aStoreActivity.GetOrCreateDocument(aDocId); + aStoreDoc.SetName(aDoc.Name()); + // prepare a file to store + SimanIO_File aStoreFile; + + stringstream aNumStore; + aNumStore<<"file"<<(++aFileIndex); + string aFileName(aNumStore.str()); + string anExtension(aData->extension()); + aFileName += "." + anExtension; + string aFullPath = aTmpDir + aFileName; + Engines::TMPFile* aFileStream = aData->get(); + const char *aBuffer = (const char*)aFileStream->NP_data(); +#ifdef WIN32 + std::ofstream aFile(aFullPath.c_str(), std::ios::binary); +#else + std::ofstream aFile(aFullPath.c_str()); +#endif + aFile.write(aBuffer, aFileStream->length()); + aFile.close(); + aTemporaryFileNames.push_back(aFileName); + + aStoreFile.url = aFullPath; + if (_filesId[aDocId].find(aData->identifier()) != _filesId[aDocId].end()) { // file is already exists + aStoreFile.id = _filesId[aDocId][aData->identifier()]; + aStoreFile.result = aDoc.File(aStoreFile.id).result; + } else { + aStoreFile.id = -1; // to be created as new + aStoreFile.result = true; // new is always result + } + + aStoreDoc.AddFile(aStoreFile); + } + } + } + aLink.StoreConf(aToStore); + // after files have been stored, remove them from the temporary directory + SALOMEDS::ListOfFileNames aTmpFiles; + aTmpFiles.length(aTemporaryFileNames.size()); + list::iterator aFilesIter = aTemporaryFileNames.begin(); + for(int a = 0; aFilesIter != aTemporaryFileNames.end(); aFilesIter++, a++) { + aTmpFiles[a] = aFilesIter->c_str(); + } + SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir, aTmpFiles, true); + } else { + MESSAGE("There is no connection to SIMAN!") + } +#endif +} + +//============================================================================ +/*! Function : getReferencedStudy + * Purpose : + */ +//============================================================================ +SALOMEDSImpl_Study* SALOMEDSImpl_SimanStudy::getReferencedStudy() +{ + return _study; +} + +//============================================================================ +/*! Function : StudyId + * Purpose : + */ +//============================================================================ +std::string SALOMEDSImpl_SimanStudy::StudyId() +{ + return _studyId; +} + +//============================================================================ +/*! Function : StudyId + * Purpose : + */ +//============================================================================ +void SALOMEDSImpl_SimanStudy::StudyId(const std::string theId) +{ + _studyId = theId; +} + +//============================================================================ +/*! Function : ScenarioId + * Purpose : + */ +//============================================================================ +std::string SALOMEDSImpl_SimanStudy::ScenarioId() +{ + return _scenarioId; +} + +//============================================================================ +/*! Function : ScenarioId + * Purpose : + */ +//============================================================================ +void SALOMEDSImpl_SimanStudy::ScenarioId(const std::string theId) +{ + _scenarioId = theId; +} + +//============================================================================ +/*! Function : UserId + * Purpose : + */ +//============================================================================ +std::string SALOMEDSImpl_SimanStudy::UserId() +{ + return _userId; +} + +//============================================================================ +/*! Function : UserId + * Purpose : + */ +//============================================================================ +void SALOMEDSImpl_SimanStudy::UserId(const std::string theId) +{ + _userId = theId; +} diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_SimanStudy.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_SimanStudy.hxx new file mode 100644 index 000000000..27959f6c9 --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_SimanStudy.hxx @@ -0,0 +1,69 @@ +// Copyright (C) 2007-2012 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 +// +// 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. +// +// 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 +// + +// File : SALOMEDSImpl_SimanStudy.hxx +// Author : Mikhail PONIKAROV +// Module : SALOME +// +#ifndef __SALOMEDSIMPL_SIMANSTUDY_I_H__ +#define __SALOMEDSIMPL_SIMANSTUDY_I_H__ + +// std C++ headers +#include +#include + +//SALOMEDSImpl headers +#include "SALOMEDSImpl_Defines.hxx" +#include "SALOMEDSImpl_Study.hxx" + +class SimanIO_Configuration; + +class SALOMEDSIMPL_EXPORT SALOMEDSImpl_SimanStudy +{ +private: + SALOMEDSImpl_Study* _study; // referenced study + std::string _studyId; // SIMAN ID + std::string _scenarioId; // SIMAN ID + std::string _userId; // SIMAN ID + + SimanIO_Configuration* _checkedOut; // pointer to information about checked out data + std::map > _filesId; // map from document id to component identifiers to SIMAN file ID + +public: + + virtual void CheckOut(SALOMEDSImpl_Study* theTarget); + virtual void CheckIn(const std::string theModuleName); + virtual SALOMEDSImpl_Study* getReferencedStudy(); + virtual std::string StudyId(); + virtual void StudyId(const std::string theId); + virtual std::string ScenarioId(); + virtual void ScenarioId(const std::string theId); + virtual std::string UserId(); + virtual void UserId(const std::string theId); + + //! standard constructor + SALOMEDSImpl_SimanStudy(); + + //! standard destructor + virtual ~SALOMEDSImpl_SimanStudy(); +}; +#endif diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_StudyManager.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_StudyManager.cxx index cae31faee..e3469514f 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_StudyManager.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_StudyManager.cxx @@ -41,6 +41,8 @@ #include "SALOMEDSImpl_GenericAttribute.hxx" #include "SALOMEDSImpl_ScalarVariable.hxx" #include "SALOMEDSImpl_IParameters.hxx" +#include "SALOMEDSImpl_SimanStudy.hxx" + #include #include "HDFOI.hxx" @@ -104,6 +106,7 @@ SALOMEDSImpl_StudyManager::SALOMEDSImpl_StudyManager() _appli = new DF_Application(); _IDcounter = 0; _clipboard = _appli->NewDocument("SALOME_STUDY"); + _siman = 0; } //============================================================================ @@ -116,6 +119,7 @@ SALOMEDSImpl_StudyManager::~SALOMEDSImpl_StudyManager() _appli->Close(_clipboard); // Destroy application delete _appli; + if (_siman) delete _siman; } @@ -1566,3 +1570,15 @@ void ReadNoteBookVariables(SALOMEDSImpl_Study* theStudy, HDFgroup* theGroup) theGroup->CloseOnDisk(); } + +//============================================================================ +/*! Function : GetSimanStudy + * Purpose : Retruns the created or cashed SimanStudy + */ +//==================================================T========================== +SALOMEDSImpl_SimanStudy* SALOMEDSImpl_StudyManager::GetSimanStudy() +{ + if (_siman == 0) + _siman = new SALOMEDSImpl_SimanStudy(); + return _siman; +} diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_StudyManager.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_StudyManager.hxx index f65863d88..c3d48aa66 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_StudyManager.hxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_StudyManager.hxx @@ -43,6 +43,7 @@ #include "DF_Document.hxx" class HDFgroup; +class SALOMEDSImpl_SimanStudy; class SALOMEDSIMPL_EXPORT SALOMEDSImpl_StudyManager { @@ -53,6 +54,7 @@ private: int _IDcounter; DF_Document* _clipboard; std::string _errorCode; + SALOMEDSImpl_SimanStudy* _siman; public: @@ -139,6 +141,9 @@ public: std::string GetErrorCode() { return _errorCode; } virtual bool IsError() { return _errorCode != ""; } + //! Retruns the created or cashed SimanStudy + virtual SALOMEDSImpl_SimanStudy* GetSimanStudy(); + }; #endif