Salome HOME
Merge from V7_siman 11/10/2013
authorvsr <vsr@opencascade.com>
Fri, 11 Oct 2013 12:25:31 +0000 (12:25 +0000)
committervsr <vsr@opencascade.com>
Fri, 11 Oct 2013 12:25:31 +0000 (12:25 +0000)
30 files changed:
CMakeLists.txt
SalomeKERNELConfig.cmake.in
bin/launchConfigureParser.py
bin/runSalome.py
idl/SALOMEDS.idl
idl/SALOME_Component.idl
salome_adm/cmake_files/FindSIMANIO.cmake [new file with mode: 0644]
salome_adm/cmake_files/FindSalomeSIMANIO.cmake [new file with mode: 0644]
salome_adm/unix/config_files/check_simanio.m4 [new file with mode: 0644]
src/CMakeLists.txt
src/Container/CMakeLists.txt
src/Container/Component_i.cxx
src/Container/SALOME_ComponentPy.py
src/Container/SALOME_Component_i.hxx
src/Container/SALOME_DataContainerPy.py [new file with mode: 0755]
src/Container/SALOME_DataContainer_i.cxx [new file with mode: 0644]
src/Container/SALOME_DataContainer_i.hxx [new file with mode: 0644]
src/SALOMEDS/CMakeLists.txt
src/SALOMEDS/SALOMEDS_SimanStudy.cxx [new file with mode: 0644]
src/SALOMEDS/SALOMEDS_SimanStudy.hxx [new file with mode: 0644]
src/SALOMEDS/SALOMEDS_SimanStudy_i.cxx [new file with mode: 0644]
src/SALOMEDS/SALOMEDS_SimanStudy_i.hxx [new file with mode: 0644]
src/SALOMEDS/SALOMEDS_Study.hxx
src/SALOMEDS/SALOMEDS_StudyManager.cxx
src/SALOMEDS/SALOMEDS_StudyManager.hxx
src/SALOMEDS/SALOMEDS_StudyManager_i.cxx
src/SALOMEDS/SALOMEDS_StudyManager_i.hxx
src/SALOMEDSClient/SALOMEDSClient.hxx
src/SALOMEDSClient/SALOMEDSClient_SimanStudy.hxx [new file with mode: 0644]
src/SALOMEDSClient/SALOMEDSClient_StudyManager.hxx

index 50690064e7467807e375c11a9f137d350e41612c..7969345522808e196228864385757f238d611f63 100755 (executable)
@@ -64,9 +64,10 @@ OPTION(SALOME_BUILD_TESTS "Build SALOME tests" ON)
 # Advanced:
 OPTION(SALOME_LIGHT_ONLY "Build SALOME Light only (no CORBA)" OFF)
 OPTION(SALOME_USE_LIBBATCH "Use LibBatch in KERNEL" OFF)
+OPTION(SALOME_USE_SIMAN "Add SIMAN support" OFF)
 OPTION(SALOME_PACO_PARALLEL "Build with PACO (implies SALOME_USE_MPI)" OFF)
 OPTION(SALOME_LAUNCHER_ONLY "Build only the Launcher part" OFF)
-MARK_AS_ADVANCED(SALOME_LIGHT_ONLY SALOME_USE_LIBBATCH SALOME_PACO_PARALLEL SALOME_LAUNCHER_ONLY)
+MARK_AS_ADVANCED(SALOME_LIGHT_ONLY SALOME_USE_LIBBATCH SALOME_USE_SIMAN SALOME_PACO_PARALLEL SALOME_LAUNCHER_ONLY)
 
 # Required prerequisites
 #   Find "big" prerequisites first - they reference themselves many others
@@ -90,6 +91,11 @@ FIND_PACKAGE(SalomeBoost REQUIRED)
 # Optional prerequisites
 # ======================
 
+IF(SALOME_USE_SIMAN)
+  FIND_PACKAGE(SalomeSIMANIO)
+  SALOME_LOG_OPTIONAL_PACKAGE(SIMANIO SALOME_USE_SIMAN)
+  ADD_DEFINITIONS(-DWITH_SIMANIO)
+ENDIF()
 IF(NOT SALOME_LIGHT_ONLY)
   FIND_PACKAGE(SalomeOmniORB REQUIRED)
   FIND_PACKAGE(SalomeOmniORBPy REQUIRED)
@@ -236,6 +242,7 @@ SET(MPI_ROOT_DIR "${MPI_ROOT_DIR}")
 SET(OMNIORB_ROOT_DIR "${OMNIORB_ROOT_DIR}")
 SET(OMNIORBPY_ROOT_DIR "${OMNIORBPY_ROOT_DIR}")
 SET(LIBBATCH_ROOT_DIR "${LIBBATCH_ROOT_DIR}")
+SET(SIMANIO_ROOT_DIR "${SIMANIO_ROOT_DIR}")
  
 SET(CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/include" "${PROJECT_BINARY_DIR}/include")
 CONFIGURE_PACKAGE_CONFIG_FILE(${PROJECT_NAME}Config.cmake.in 
@@ -244,7 +251,7 @@ CONFIGURE_PACKAGE_CONFIG_FILE(${PROJECT_NAME}Config.cmake.in
     PATH_VARS CONF_INCLUDE_DIRS SALOME_INSTALL_CMAKE CMAKE_INSTALL_PREFIX
        CPPUNIT_ROOT_DIR GRAPHVIZ_ROOT_DIR DOXYGEN_ROOT_DIR
        SPHINX_ROOT_DIR MPI_ROOT_DIR OMNIORB_ROOT_DIR OMNIORBPY_ROOT_DIR LIBBATCH_ROOT_DIR
-       PTHREAD_ROOT_DIR BOOST_ROOT_DIR HDF5_ROOT_DIR LIBXML2_ROOT_DIR
+       SIMANIO_ROOT_DIR PTHREAD_ROOT_DIR BOOST_ROOT_DIR HDF5_ROOT_DIR LIBXML2_ROOT_DIR
        PYTHON_ROOT_DIR SWIG_ROOT_DIR)
 
 #   - in the install tree (VSR 16/08/2013: TEMPORARILY COMMENT THIS - TO REMOVE?):
@@ -257,7 +264,7 @@ CONFIGURE_PACKAGE_CONFIG_FILE(${PROJECT_NAME}Config.cmake.in
 #    PATH_VARS CONF_INCLUDE_DIRS SALOME_INSTALL_CMAKE CMAKE_INSTALL_PREFIX 
 #       CPPUNIT_ROOT_DIR GRAPHVIZ_ROOT_DIR DOXYGEN_ROOT_DIR
 #       SPHINX_ROOT_DIR MPI_ROOT_DIR OMNIORB_ROOT_DIR OMNIORBPY_ROOT_DIR LIBBATCH_ROOT_DIR
-#       PTHREAD_ROOT_DIR BOOST_ROOT_DIR HDF5_ROOT_DIR LIBXML2_ROOT_DIR
+#       SIMANIO_ROOT_DIR PTHREAD_ROOT_DIR BOOST_ROOT_DIR HDF5_ROOT_DIR LIBXML2_ROOT_DIR
 #       PYTHON_ROOT_DIR SWIG_ROOT_DIR)
 
 WRITE_BASIC_PACKAGE_VERSION_FILE(${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
index 7de8498ff4f2608193860bf4b7ce6e9ae0844008..02816bdebb58f2fc3f7789318d41b3a009662c1a 100644 (file)
@@ -56,15 +56,20 @@ SET(KERNEL_DEFINITIONS)
 # Options exported by the package:
 SET(SALOME_USE_MPI     @SALOME_USE_MPI@)
 IF(SALOME_USE_MPI)
-  SET(KERNEL_INCLUDE_DIRS "${KERNEL_INCLUDE_DIRS};@MPI_INCLUDE_DIRS@")
-  SET(KERNEL_DEFINITIONS "@MPI_DEFINITIONS@")
+  LIST(APPEND KERNEL_INCLUDE_DIRS "@MPI_INCLUDE_DIRS@")
+  LIST(APPEND KERNEL_DEFINITIONS "@MPI_DEFINITIONS@")
 ENDIF()
 
-SET(SALOME_BUILD_DOC   @SALOME_BUILD_DOC@)
-SET(SALOME_BUILD_TESTS @SALOME_BUILD_TESTS@)
-SET(SALOME_LIGHT_ONLY  @SALOME_LIGHT_ONLY@)
+SET(SALOME_BUILD_DOC     @SALOME_BUILD_DOC@)
+SET(SALOME_BUILD_TESTS   @SALOME_BUILD_TESTS@)
+SET(SALOME_LIGHT_ONLY    @SALOME_LIGHT_ONLY@)
 SET(SALOME_USE_LIBBATCH  @SALOME_USE_LIBBATCH@)
 
+SET(SALOME_USE_SIMAN     @SALOME_USE_SIMAN@)
+IF(SALOME_USE_SIMAN)
+  LIST(APPEND KERNEL_DEFINITIONS "-DWITH_SIMANIO")
+ENDIF()
+
 # Prerequisites:
 IF(SALOME_BUILD_TESTS)
   SET_AND_CHECK(CPPUNIT_ROOT_DIR_EXP  "@PACKAGE_CPPUNIT_ROOT_DIR@")
@@ -84,6 +89,9 @@ ENDIF()
 IF(SALOME_USE_LIBBATCH)
   SET_AND_CHECK(LIBBATCH_ROOT_DIR_EXP "@PACKAGE_LIBBATCH_ROOT_DIR@")
 ENDIF()
+IF(SALOME_USE_SIMAN)
+  SET_AND_CHECK(SIMANIO_ROOT_DIR_EXP "@PACKAGE_SIMANIO_ROOT_DIR@")
+ENDIF()
 
 SET_AND_CHECK(PTHREAD_ROOT_DIR_EXP  "@PACKAGE_PTHREAD_ROOT_DIR@")
 SET_AND_CHECK(HDF5_ROOT_DIR_EXP     "@PACKAGE_HDF5_ROOT_DIR@")
@@ -94,10 +102,10 @@ SET_AND_CHECK(SWIG_ROOT_DIR_EXP     "@PACKAGE_SWIG_ROOT_DIR@")
 # For all prerequisites, load the corresponding targets if the package was used 
 # in CONFIG mode. This ensures dependent projects link correctly
 # without having to set LD_LIBRARY_PATH:
-SET(_PREREQ CppUnit Graphviz Doxygen Sphinx MPI omniORB LibBatch PThread Boost HDF5 libXml2 Python)
+SET(_PREREQ CppUnit Graphviz Doxygen Sphinx MPI omniORB LibBatch SIMANIO PThread Boost HDF5 libXml2 Python)
 SET(_PREREQ_CONFIG_DIR "@CppUnit_DIR@" "@Graphviz_DIR@" "@Doxygen_DIR@" "@Sphinx_DIR@" 
       "@MPI_DIR@" "@omniORB_DIR@" "@LibBatch_DIR@" "@PThread_DIR@" "@Boost_DIR@" "@HDF5_DIR@"
-      "@libXml2_DIR@" "@Python_DIR@")
+      "@libXml2_DIR@" "@Python_DIR@" "@SIMANIO_DIR@")
 LIST(LENGTH _PREREQ_CONFIG_DIR _list_len)
 # Another CMake stupidity - FOREACH(... RANGE r) generates r+1 numbers ...
 MATH(EXPR _range "${_list_len}-1")
index d89e2d1df708716bdb69e7845adc234b567e0eac..bf280c91384f5726f6faae5794f86494ab6edabc 100755 (executable)
@@ -68,6 +68,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 (<module_name> section)
 # which are stored in opts with key <module_name>_<parameter> (eg SMESH_plugins)
@@ -769,9 +773,43 @@ def CreateOptionParser (theAdditionalOptions=[]):
     o_port = optparse.Option("--port",
                              metavar="<port>",
                              type="int",
-                             action="store",
+                                   action="store",
                              dest="use_port",
-                             help=help_str)
+                                   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="<id>",
+                                    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="<id>",
+                                       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="<id>",
+                                   type="string",
+                                   action="store",
+                                   dest="siman_user",
+                                   help=help_str)
 
     # All options
     opt_list = [o_t,o_g, # GUI/Terminal
@@ -802,6 +840,10 @@ def CreateOptionParser (theAdditionalOptions=[]):
                 o_wake_up,
                 o_slm,   # Server launch mode
                 o_port,  # Use port
+                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", "resources",
@@ -1110,6 +1152,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 <theAdditionalOptions> values to args
     for add_opt in theAdditionalOptions:
index 2a3852720b4eddc1d243384f402834ecfb9609aa..676489e1fc68a767c66392553c4696e409c8149a 100755 (executable)
@@ -140,7 +140,28 @@ 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']:
+                siman_param = "siman_%s"%param
+                if siman_param in args:
+                    siman_data.append(args[siman_param])
+                else:
+                    print "SIMAN %s must be defined using parameter --siman-%s=XXX" % (siman_param, siman_param)
+                    pass
+                pass
+            if len(siman_data) == 3:
+                _siman_name = "_".join(siman_data)
+                pass
+            pass
+        pass
+    return _siman_name
 
 class CatalogServer(Server):
     def __init__(self,args):
@@ -262,6 +283,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:
                     msg = json.dumps(self.args['pyscript'])
@@ -495,6 +519,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 is 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)
     #
 
@@ -647,7 +677,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
 
 # -----------------------------------------------------------------------------
index 79ce87142a4e4c5f9fa9d52f7d65d8f6ba449c0c..d3f37f12445c9698c6f47c72c1f9b2f947b3c466 100644 (file)
@@ -557,6 +557,69 @@ 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();
+
+};
+
   //==========================================================================
 /*! \brief %Study Builder Interface
 
@@ -985,6 +1048,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();
 
   };
 
index ed31e2e072e17441ee56f083c5d40af2e03458e1..d7461809447b2d153506addd366f4bfd1718b9dc 100644 (file)
@@ -60,12 +60,17 @@ module Engines
   };
 
   typedef sequence<KeyValuePair> FieldsDict;
+  typedef sequence<string> ListOfOptions;
+  typedef sequence<string> ListOfIdentifiers;
 
   interface EngineComponent ;
   interface fileRef ;
   interface fileTransfer ;
   interface Salome_file;
+  interface DataContainer;
 
+  typedef sequence<DataContainer> 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/FindSIMANIO.cmake b/salome_adm/cmake_files/FindSIMANIO.cmake
new file mode 100644 (file)
index 0000000..dadf08a
--- /dev/null
@@ -0,0 +1,54 @@
+# - Find SIMANIO installation
+#
+# The following variable are set:
+#   SIMANIO_FOUND       - TRUE if SIMANIO installation has been found
+#   SIMANIO_INCLUDE_DIR - SIMANIO headers path
+#   SIMANIO_LIBRARIES   - SIMANIO libraries
+#
+#  The CMake (or environment) variable SIMANIO_ROOT_DIR can be set to
+#  guide the detection and indicate a root directory to look into.
+#
+############################################################################
+# Copyright (C) 2012-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+#
+# 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
+#
+
+# ------
+
+IF(NOT SIMANIO_FIND_QUIETLY)
+    MESSAGE(STATUS "Check for SimanIO ...")
+ENDIF()
+
+# ------
+
+SET(SIMANIO_ROOT_DIR $ENV{SIMANIO_ROOT_DIR} CACHE PATH "Path to the SIMANIO.")
+IF(SIMANIO_ROOT_DIR)
+  LIST(APPEND CMAKE_PREFIX_PATH "${SIMANIO_ROOT_DIR}")
+ENDIF()
+
+FIND_PATH(SIMANIO_INCLUDE_DIR SimanIO_Link.hxx)
+FIND_LIBRARY(SIMANIO_LIBRARIES NAMES SimanIO)
+
+INCLUDE(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(SIMANIO REQUIRED_VARS SIMANIO_INCLUDE_DIR SIMANIO_LIBRARIES)
+
+IF(SIMANIO_FOUND)
+  IF(NOT SIMANIO_FIND_QUIETLY)
+    MESSAGE(STATUS "SIMANIO library: ${SIMANIO_LIBRARIES}")
+  ENDIF()
+ENDIF()
diff --git a/salome_adm/cmake_files/FindSalomeSIMANIO.cmake b/salome_adm/cmake_files/FindSalomeSIMANIO.cmake
new file mode 100644 (file)
index 0000000..2391f49
--- /dev/null
@@ -0,0 +1,30 @@
+# Copyright (C) 2013  CEA/DEN, EDF R&D, OPEN CASCADE
+#
+# 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
+#
+# Author: Vadim SANDLER
+#
+
+# SIMANIO detection dor Salome
+#
+#  !! Please read the generic detection procedure in SalomeMacros.cmake !!
+#
+
+SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS(SIMANIO SIMANIO_INCLUDE_DIR 1)
+#MARK_AS_ADVANCED()
+
+SALOME_ACCUMULATE_HEADERS(SIMANIO_INCLUDE_DIR)
\ No newline at end of file
diff --git a/salome_adm/unix/config_files/check_simanio.m4 b/salome_adm/unix/config_files/check_simanio.m4
new file mode 100644 (file)
index 0000000..d6f8a69
--- /dev/null
@@ -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$SIMANIODIR" = "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
index 15d7bcadd8b30559478974d4b1ec9d092349406f..58d0acdd76f7f3021a72df7bd5c745a7dcc5effe 100755 (executable)
@@ -43,9 +43,9 @@ SET(SUBDIR_CORBA
   LifeCycleCORBA_SWIG
   SALOMEDSClient
   TOOLSDS
+  KernelHelpers
   SALOMEDSImpl
   SALOMEDS
-  KernelHelpers
   ModuleGenerator
   Communication
   Communication_SWIG
index b63ac7f244484456fecb800505009c24cec0d38f..5bc0b9c11e26cea90de57ee3ba5d0f6e80dfd4f5 100755 (executable)
@@ -40,6 +40,7 @@ SET(SCRIPTS
   SALOME_ComponentPy.py
   SALOME_PyNode.py
   SALOME_Container.py
+  SALOME_DataContainerPy.py
 )
 
 ADD_DEFINITIONS(${HDF5_DEFINITIONS} ${OMNIORB_DEFINITIONS})
@@ -75,6 +76,7 @@ ENDIF()
 SET(SalomeContainer_SOURCES
   Component_i.cxx
   Container_i.cxx
+  SALOME_DataContainer_i.cxx
   SALOME_FileTransfer_i.cxx
   SALOME_FileRef_i.cxx
   Container_init_python.cxx
index ae92c5b7e2f0a1abf0575c04a617e097b674aa67..50a6a90f9db2a8b2fa48c57b8ba259bb14b23417 100644 (file)
@@ -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
index 7ffd93e78577b1eba501d48ef889440969851165..53899ba56313805e9c1ac6f95ed10bc73bb6582d 100755 (executable)
@@ -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
index 1c8c3b4d4d53d5cd81aad05a9efe56324eaca578..34f839015186da7383de779b3c0492f4b452e15a 100644 (file)
@@ -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 (executable)
index 0000000..65b7d02
--- /dev/null
@@ -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 (file)
index 0000000..3ef9b0b
--- /dev/null
@@ -0,0 +1,132 @@
+// 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 "SALOME_DataContainer_i.hxx"
+
+#include <fstream>
+#include <iostream>
+#include <unistd.h>
+
+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 "<<myURL.c_str()<<" can not be opened for reading"<<std::endl;
+    } else {
+      aFile.seekg(0, std::ios::end);
+      aFileSize = aFile.tellg();
+      aBuffer = new char[aFileSize];
+                                                           
+      aFile.seekg(0, std::ios::beg);
+      aFile.read(aBuffer, aFileSize);
+      aFile.close();
+
+      // remove file after it converted to a stream
+      // also remove directory of the file if it is empty
+      if (myRemoveAfterGet) {
+        string aDirName = myURL.substr(0, myURL.find_last_of("/\\"));
+#ifdef WIN32
+        DeleteFile(myURL.c_str());
+        RemoveDirectory(aDirName.c_str());
+#else
+        unlink(myURL.c_str());
+        rmdir(aDirName.c_str());
+#endif
+      }
+    }
+  }
+  
+  // make CORBA TMP file from the buffer
+  CORBA::Octet* anOctetBuf =  (CORBA::Octet*)aBuffer;
+  Engines::TMPFile_var aStreamFile = new Engines::TMPFile(aFileSize, aFileSize, anOctetBuf, 1);
+  
+  if (myStream && myRemoveAfterGet)
+    delete [] myStream;
+  
+  return aStreamFile._retn();
+}
+
+char* Engines_DataContainer_i::name()
+{
+  return CORBA::string_dup(myName.c_str());
+}
+
+char* Engines_DataContainer_i::identifier()
+{
+  return CORBA::string_dup(myIdentifier.c_str());
+}
+
+char* Engines_DataContainer_i::extension()
+{
+  return CORBA::string_dup(myExt.c_str());
+}
+
+void Engines_DataContainer_i::setExtension(const char* theExt)
+{
+  myExt = theExt;
+}
diff --git a/src/Container/SALOME_DataContainer_i.hxx b/src/Container/SALOME_DataContainer_i.hxx
new file mode 100644 (file)
index 0000000..66f59d3
--- /dev/null
@@ -0,0 +1,74 @@
+// 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.hxx
+//  Author : Mikhail PONIKAROV
+//  Module : SALOME
+//  $Header$
+//
+#ifndef _SALOME_DATACONTAINER_I_HXX_
+#define _SALOME_DATACONTAINER_I_HXX_
+
+#include "SALOME_Container.hxx"
+
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SALOME_Component)
+
+#include <string>
+
+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
index 2e19bd81222525ca9a544eb49cb1e5cff81d8330..b03dd349ef25d499db41e8fd1e48df129f2301fe 100755 (executable)
@@ -22,6 +22,7 @@ INCLUDE_DIRECTORIES(
   ${OMNIORB_INCLUDE_DIR}
   ${HDF5_INCLUDE_DIRS}
   ${Boost_INCLUDE_DIR}
+  ${SIMANIO_INCLUDE_DIR}
   ${PROJECT_BINARY_DIR}/salome_adm
   ${CMAKE_CURRENT_SOURCE_DIR}/../HDFPersist
   ${CMAKE_CURRENT_SOURCE_DIR}/../Basics
@@ -33,6 +34,8 @@ INCLUDE_DIRECTORIES(
   ${CMAKE_CURRENT_SOURCE_DIR}/../GenericObj
   ${CMAKE_CURRENT_SOURCE_DIR}/../SALOMEDSClient
   ${CMAKE_CURRENT_SOURCE_DIR}/../LifeCycleCORBA
+  ${CMAKE_CURRENT_SOURCE_DIR}/../TOOLSDS
+  ${CMAKE_CURRENT_SOURCE_DIR}/../Container
   ${PROJECT_BINARY_DIR}/idl
 )
 
@@ -54,6 +57,7 @@ SET(COMMON_LIBS
   SalomeLifeCycleCORBA
   SalomeIDLKernel
   ${HDF5_C_LIBRARIES}
+  ${SIMANIO_LIBRARIES}
 )
 
 SET(SalomeDS_SOURCES
@@ -64,6 +68,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
@@ -177,5 +183,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 ${SALOME_INSTALL_HEADERS})
diff --git a/src/SALOMEDS/SALOMEDS_SimanStudy.cxx b/src/SALOMEDS/SALOMEDS_SimanStudy.cxx
new file mode 100644 (file)
index 0000000..62781d1
--- /dev/null
@@ -0,0 +1,186 @@
+// 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<SALOMEDSImpl_SimanStudy*>(addr);
+    _corba_impl = SALOMEDS::SimanStudy::_duplicate(theStudy);
+  }
+  else {
+    _local_impl = NULL;
+    _corba_impl = SALOMEDS::SimanStudy::_duplicate(theStudy);
+  }
+  */
+  _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<SALOMEDS_Study*>(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);
+  }*/
+  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_<ORB_INIT>::Instance();
+  ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting());
+  _orb = init(0, 0);
+}
diff --git a/src/SALOMEDS/SALOMEDS_SimanStudy.hxx b/src/SALOMEDS/SALOMEDS_SimanStudy.hxx
new file mode 100644 (file)
index 0000000..c8c1090
--- /dev/null
@@ -0,0 +1,70 @@
+// 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 <vector>
+#include <string>
+
+#include <DF_definitions.hxx>
+#include "SALOMEDSClient.hxx"
+//#include "SALOMEDSImpl_SimanStudy.hxx"
+
+// IDL headers
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SALOMEDS)
+
+class Standard_EXPORT SALOMEDS_SimanStudy: public SALOMEDSClient_SimanStudy
+{
+
+private:
+  // bool                       _isLocal;
+  //SALOMEDSImpl_SimanStudy*   _local_impl; // MPV: no local implementation yet: siman operations works only with CORBA interface
+  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 (file)
index 0000000..22236af
--- /dev/null
@@ -0,0 +1,342 @@
+// 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 "SALOMEDS_SimanStudy_i.hxx"
+#include "SALOMEDS_Study_i.hxx"
+#include "SALOMEDS_Study.hxx"
+#include "SALOMEDS_Tool.hxx"
+#include "SALOME_DataContainer_i.hxx"
+#include "SALOME_NamingService.hxx"
+#include "SALOME_LifeCycleCORBA.hxx"
+#include "Basics_Utils.hxx"
+#include "Basics_DirUtils.hxx"
+#include "utilities.h"
+
+#ifdef WITH_SIMANIO
+#include <SimanIO_Link.hxx>
+#include <SimanIO_Activity.hxx>
+#endif
+
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SALOME_Component)
+
+//============================================================================
+/*! 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);
+  _name_service = new SALOME_NamingService(_orb);
+#ifdef WITH_SIMANIO
+  _checkedOut = new SimanIO_Configuration;
+#endif
+}
+
+//============================================================================
+/*! Function : ~SALOMEDS_SimanStudy_i
+ *  Purpose  : standard destructor
+ */
+//============================================================================
+SALOMEDS_SimanStudy_i::~SALOMEDS_SimanStudy_i()
+{
+#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()) {
+        SimanIO_Document& aDoc = aDocIter.Document();
+        SimanIO_Document::FilesIterator aFileIter(aDoc);
+        for(; aFileIter.More(); aFileIter.Next()) {
+         std::string aURL = aFileIter.URL();
+          std::string aDir = Kernel_Utils::GetDirName(aURL);
+          aDir += "/";
+          std::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
+  delete _name_service;
+}
+
+//============================================================================
+/*! 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) {
+#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 =
+          SALOME_LifeCycleCORBA(_name_service).FindOrLoad_Component("FactoryServerPy", actIter.Activity().Module());
+        if (CORBA::is_nil(aComp)) // it is not python container, try to find in C++ container
+          SALOME_LifeCycleCORBA(_name_service).FindOrLoad_Component("FactoryServer", actIter.Activity().Module());
+        if (CORBA::is_nil(aComp)) {
+          MESSAGE("Checkout: component "<<actIter.Activity().Module()<<" is nil");
+        } else {
+          SimanIO_Activity::DocumentsIterator aDocIter(actIter.Activity());
+          for(; aDocIter.More(); aDocIter.Next()) {
+            if (_filesId.find(aDocIter.DocId()) == _filesId.end())
+              _filesId[aDocIter.DocId()] = std::map<std::string, int>();
+            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 {
+                MESSAGE("!!! File just downloaded, not imported:"<<aFileIter.Id());
+              }
+            }
+          }
+        }
+      }
+    } else {
+      MESSAGE("There is no connection to SIMAN!");
+    }
+  
+    if (aLocked) _study->GetProperties()->SetLocked(true);
+#endif
+  }
+}
+
+//============================================================================
+/*! Function : CheckIn
+ *  Purpose  : Get data from SIMAN study and stores to SIMAN
+ */
+//============================================================================
+void SALOMEDS_SimanStudy_i::CheckIn(const char* theModuleName)
+{
+  if (_study) {
+#ifdef WITH_SIMANIO
+    std::string aModuleName(theModuleName);
+    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
+      std::string aTmpDir = SALOMEDS_Tool::GetTmpDir(); // temporary directory for checked in files
+      int aFileIndex = 0; // for unique file name generation
+      std::list<std::string> 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 (!aModuleName.empty() && aModuleName != actIter.Activity().Module()) {
+          continue;
+        }
+        Engines::EngineComponent_var aComp =
+          SALOME_LifeCycleCORBA(_name_service).FindOrLoad_Component("FactoryServerPy", actIter.Activity().Module());
+        if (CORBA::is_nil(aComp)) // it is not python container, try to find in C++ container
+          SALOME_LifeCycleCORBA(_name_service).FindOrLoad_Component("FactoryServer", actIter.Activity().Module());
+        if (CORBA::is_nil(aComp)) {
+          MESSAGE("Checkin: component "<<actIter.Activity().Module()<<" is nil");
+        } else {
+          SimanIO_Document aDoc;
+          if (aDocId != -1) // get document is at least one exists in this action, "-1" is the Id of the new document otherwise
+            aDoc = actIter.Activity().Document(aDocId);
+          Engines::ListOfData_var aList = aComp->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;
+  
+            std::stringstream aNumStore;
+            aNumStore<<"file"<<(++aFileIndex);
+            std::string aFileName(aNumStore.str());
+            std::string anExtension(aData->extension());
+            aFileName += "." + anExtension;
+            std::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());
+      std::list<std::string>::const_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  : 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(_studyId.c_str());
+}
+
+//============================================================================
+/*! Function : StudyId
+ *  Purpose  : The ID of the study in SIMAN server
+ */
+//============================================================================
+void SALOMEDS_SimanStudy_i::StudyId(const char* theId)
+{
+  _studyId = theId;
+}
+
+//============================================================================
+/*! Function : ScenarioId
+ *  Purpose  : The ID of the scenario in SIMAN server
+ */
+//============================================================================
+char* SALOMEDS_SimanStudy_i::ScenarioId()
+{
+  return CORBA::string_dup(_scenarioId.c_str());
+}
+
+//============================================================================
+/*! Function : ScenarioId
+ *  Purpose  : The ID of the scenario in SIMAN server
+ */
+//============================================================================
+void SALOMEDS_SimanStudy_i::ScenarioId(const char* theId)
+{
+  _scenarioId = theId;
+}
+
+//============================================================================
+/*! Function : UserId
+ *  Purpose  : The ID of the user in SIMAN server
+ */
+//============================================================================
+char* SALOMEDS_SimanStudy_i::UserId()
+{
+  return CORBA::string_dup(_userId.c_str());
+}
+
+//============================================================================
+/*! Function : UserId
+ *  Purpose  : The ID of the user in SIMAN server
+ */
+//============================================================================
+void SALOMEDS_SimanStudy_i::UserId(const char* theId)
+{
+  _userId = theId;
+}
+
+SALOMEDS_SimanStudy_i* SALOMEDS_SimanStudy_i::GetSimanServant(CORBA::ORB_ptr orb)
+{
+  static SALOMEDS_SimanStudy_i* aServant = 0;
+  if (aServant == 0) {
+    aServant = new SALOMEDS_SimanStudy_i(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<CORBA::LongLong>(_impl);
+}
+*/
diff --git a/src/SALOMEDS/SALOMEDS_SimanStudy_i.hxx b/src/SALOMEDS/SALOMEDS_SimanStudy_i.hxx
new file mode 100644 (file)
index 0000000..55c4a76
--- /dev/null
@@ -0,0 +1,127 @@
+// 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 <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SALOMEDS)
+
+//SALOMEDS headers
+#include "SALOMEDS_Study_i.hxx"
+
+class SimanIO_Configuration;
+class SALOME_NamingService;
+
+class Standard_EXPORT SALOMEDS_SimanStudy_i: public POA_SALOMEDS::SimanStudy
+{
+private:
+  CORBA::ORB_var                 _orb;
+  SALOME_NamingService*          _name_service;
+  //SALOMEDSImpl_SimanStudy*       _impl;  
+  SALOMEDSImpl_Study*          _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<int, std::map<std::string, int> > _filesId; // map from document id to component identifiers to SIMAN file ID
+  std::map<int, std::map<std::string, int> > _filesId; // map from document id to component identifiers to SIMAN file ID
+         
+public:
+
+  //! constructor create global Siman stduy (is called in StudyManager only)
+  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(CORBA::ORB_ptr orb);
+};
+#endif
index b1b0805f1bdb305456aa9ec571d1010b294a53fb..62b51cbee683dcbe5fac52c6f443694f5906d31a 100644 (file)
@@ -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();
 
index 95a860be8de37316ffdbd85e714e7a1a388d0598..2390f1f5070e4ae5ff2b766dcc07d1e93ff0679c 100644 (file)
@@ -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,24 @@ 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);
+  }*/
+  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);
+}
index 2ad88753e62165394e48c0411cf1fb99b92f9e5d..2b9bbe0fe69c1f26fefff306571d2f717bfb560f 100644 (file)
@@ -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();
index 331aec006256ed0926259892d26de6323fdee3de..25fa381ab4435136d98be767948c7a9ba3e334a9 100644 (file)
@@ -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"
@@ -89,6 +90,7 @@ SALOMEDS_StudyManager_i::~SALOMEDS_StudyManager_i()
   delete _name_service;
   delete _factory;
   delete _impl;
+  delete SALOMEDS_SimanStudy_i::GetSimanServant(_orb);
 }
 
 //============================================================================
@@ -478,6 +480,19 @@ 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;
+
+  SALOMEDS_SimanStudy_i* aSiman_servant = SALOMEDS_SimanStudy_i::GetSimanServant(_orb);
+  return aSiman_servant->_this();
+}
+
 //===========================================================================
 //   PRIVATE FUNCTIONS
 //===========================================================================
index 83e7b79001d162a8c5b9207a5f96d76536a8289e..2ff3dcb467f39de7b35ce62b5e4c9645a4d3cf2d 100644 (file)
@@ -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 
index 81d57d37c01ea3b0c3a0fb0820346d291a91fffb..d471cba586dfb47986e08a8a64659e44f2c3fd80 100644 (file)
@@ -58,6 +58,7 @@
 #include "SALOMEDSClient_GenericAttribute.hxx"
 #include "SALOMEDSClient_SComponent.hxx"
 #include "SALOMEDSClient_SComponentIterator.hxx"
+#include "SALOMEDSClient_SimanStudy.hxx"
 #include "SALOMEDSClient_SObject.hxx"
 #include "SALOMEDSClient_Study.hxx"
 #include "SALOMEDSClient_StudyBuilder.hxx"
diff --git a/src/SALOMEDSClient/SALOMEDSClient_SimanStudy.hxx b/src/SALOMEDSClient/SALOMEDSClient_SimanStudy.hxx
new file mode 100644 (file)
index 0000000..e06093e
--- /dev/null
@@ -0,0 +1,55 @@
+// 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 <vector>
+#include <string>
+
+#include "SALOMEDSClient_definitions.hxx"
+#include "SALOMEDSClient_Study.hxx"
+#include <SALOMEconfig.h>
+#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
index 0c3791d6c7ccc7cfa9c88fcc5cbf46c61975f6a0..15f7bf448dacfd29374481ca1c0c021d1689d7c7 100644 (file)
@@ -32,6 +32,7 @@
 
 #include "SALOMEDSClient_definitions.hxx"
 #include "SALOMEDSClient_Study.hxx"
+#include "SALOMEDSClient_SimanStudy.hxx"
 
 class SALOMEDSClient_StudyManager
 {
@@ -52,7 +53,7 @@ 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;
 };
 
 #endif