From e5867636265822b5e70ca0406c9321ccff264bb0 Mon Sep 17 00:00:00 2001 From: vsr Date: Thu, 13 Dec 2012 07:38:01 +0000 Subject: [PATCH] Merge from V6_main 13/12/2012 --- CMakeLists.txt | 2 +- bin/CMakeLists.txt | 2 + bin/Makefile.am | 10 +- bin/ORBConfigFile.py | 84 ++++++++ bin/appliskel/runRemote.sh | 13 +- bin/appliskel/runSession | 52 +++-- bin/appliskel/runTests | 40 +--- bin/appliskel/searchFreePort.sh | 45 ++-- bin/killSalome.py | 1 - bin/killSalomeWithPort.py | 50 +++-- bin/launchConfigureParser.py | 20 +- bin/launchSalome.py | 29 +-- bin/orbmodule.py | 20 +- bin/runSalome.ksh | 40 +--- bin/runSalome.py | 192 +++++------------- bin/salomeConsole.py | 4 +- bin/salome_session.py | 54 +---- bin/salome_utils.py | 7 +- bin/searchFreePort.py | 111 ++++++++++ bin/setenv.py | 3 +- bin/shutdownSalome.py | 11 +- doc/docutils/CMakeLists.txt | 66 ++++++ doc/salome/gui/CMakeLists.txt | 4 +- doc/salome/kernel_salome.dox | 34 ++++ doc/salome/tui/CMakeLists.txt | 2 +- doc/salome/tui/doxyfile.in | 143 +++++++------ idl/SALOMEDS_Attributes.idl | 21 ++ idl/SALOME_Component.idl | 11 + salome_adm/CMakeLists.txt | 8 +- salome_adm/cmake_files/FindPLATFORM.cmake | 13 +- salome_adm/cmake_files/SalomeMacros.cmake | 12 +- salome_adm/cmake_files/am2cmake.py | 168 ++++++++------- .../cmake_files/prepare_generating_doc.py | 76 ++++++- salome_adm/unix/CMakeLists.txt | 35 ++++ salome_adm/unix/config_files/CMakeLists.txt | 84 ++++++++ salome_adm/unix/config_files/check_cas.m4 | 4 +- src/Container/Component_i.cxx | 17 ++ src/Container/SALOME_ComponentPy.py | 6 + src/Container/SALOME_Component_i.hxx | 3 + src/Container/SALOME_ContainerManager.cxx | 16 +- src/DSC/DSC_Python/calcium.i | 2 + .../DSC_User/Datastream/Calcium/CalciumC.c | 12 ++ .../Datastream/Calcium/CalciumCInterface.cxx | 3 + .../Datastream/Calcium/CalciumCInterface.hxx | 3 + src/DSC/DSC_User/Datastream/Calcium/calcium.h | 39 ++++ .../DSC_User/Datastream/Calcium/calciumf.c | 20 ++ .../DSC_User/Datastream/Calcium/calciumf.h | 2 + src/KERNEL_PY/salome_study.py | 21 ++ src/Launcher/BatchTest.cxx | 2 + src/Launcher/Launcher.cxx | 3 + src/Launcher/Launcher_Job_Command.cxx | 3 +- src/Launcher/Launcher_Job_SALOME.cxx | 3 +- src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx | 3 + .../SALOME_ResourcesCatalog_Handler.cxx | 7 + .../SALOME_ResourcesCatalog_Parser.cxx | 2 + .../SALOME_ResourcesCatalog_Parser.hxx | 2 +- .../SALOME_ResourcesManager.cxx | 6 +- src/SALOMEDS/Makefile.am | 1 - .../SALOMEDS_AttributeStudyProperties.cxx | 46 +++++ .../SALOMEDS_AttributeStudyProperties.hxx | 4 +- .../SALOMEDS_AttributeStudyProperties_i.cxx | 31 +++ .../SALOMEDS_AttributeStudyProperties_i.hxx | 4 + src/SALOMEDS/SALOMEDS_Driver_i.cxx | 36 +++- src/SALOMEDS/SALOMEDS_Driver_i.hxx | 6 +- src/SALOMEDS/SALOMEDS_StudyBuilder.cxx | 3 +- src/SALOMEDS/SALOMEDS_StudyManager.cxx | 2 +- src/SALOMEDS/SALOMEDS_StudyManager_i.cxx | 2 +- src/SALOMEDS/SALOME_DriverPy.py | 6 + ...ALOMEDSClient_AttributeStudyProperties.hxx | 4 +- .../SALOMEDSImpl_AttributeStudyProperties.cxx | 153 ++++++++++++-- .../SALOMEDSImpl_AttributeStudyProperties.hxx | 24 ++- src/SALOMEDSImpl/SALOMEDSImpl_Driver.hxx | 1 + .../SALOMEDSImpl_StudyManager.cxx | 163 +++++++++++---- 73 files changed, 1480 insertions(+), 652 deletions(-) create mode 100644 bin/ORBConfigFile.py create mode 100644 bin/searchFreePort.py create mode 100755 doc/docutils/CMakeLists.txt create mode 100755 salome_adm/unix/CMakeLists.txt create mode 100755 salome_adm/unix/config_files/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 80dd89acf..326f97bba 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,7 +37,7 @@ SET(WITH_LOCAL 1) SET(WITH_BATCH 1) ENABLE_TESTING() -SET(VERSION "6.5.0") +SET(VERSION "7.0.0") SET(VERSION_DEV "1") INCLUDE(${CMAKE_SOURCE_DIR}/salome_adm/cmake_files/FindPLATFORM.cmake) diff --git a/bin/CMakeLists.txt b/bin/CMakeLists.txt index 2f4536803..61db93c62 100755 --- a/bin/CMakeLists.txt +++ b/bin/CMakeLists.txt @@ -52,11 +52,13 @@ SET(SCRIPTS nameserver.py NSparam.py orbmodule.py + ORBConfigFile.py runNS.py runSalome.py salomeConsole.py salome_session.py salome_utils.py + searchFreePort.py server.py setenv.py showNS.py diff --git a/bin/Makefile.am b/bin/Makefile.am index 039f9b468..b50c28136 100644 --- a/bin/Makefile.am +++ b/bin/Makefile.am @@ -20,7 +20,7 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -# -* Makefile *- +# -* Makefile *- # Author : Guillaume Boulant (CSSI) # Module : KERNEL # $Header$ @@ -68,11 +68,13 @@ dist_salomescript_PYTHON = \ nameserver.py \ NSparam.py \ orbmodule.py \ + ORBConfigFile.py \ runNS.py \ runSalome.py \ salomeConsole.py \ salome_session.py \ - salome_utils.py \ + salome_utils.py \ + searchFreePort.py \ server.py \ setenv.py \ showNS.py \ @@ -83,5 +85,5 @@ dist_salomescript_PYTHON = \ install-data-hook: @for f in $(dist_salomescript_PYTHON) ; do \ - chmod -f a+x $(DESTDIR)$(salomescriptdir)/$$f ; \ - done + chmod -f a+x $(DESTDIR)$(salomescriptdir)/$$f ; \ + done diff --git a/bin/ORBConfigFile.py b/bin/ORBConfigFile.py new file mode 100644 index 000000000..58b6c208e --- /dev/null +++ b/bin/ORBConfigFile.py @@ -0,0 +1,84 @@ +#!/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 +# + +# IMPORTANT NOTE: do not add any print call (cf. note at the bottom of the file) +def writeORBConfigFile(path, host, port, kwargs={}): + + from salome_utils import generateFileName + omniorb_config = generateFileName(path, prefix="omniORB", + extension="cfg", + hidden=True, + with_hostname=True, + with_port=port, + **kwargs) + import os + os.environ['OMNIORB_CONFIG'] = omniorb_config + os.environ['NSPORT'] = "%s"%(port) + os.environ['NSHOST'] = "%s"%(host) + + from omniORB import CORBA + prefix = "" if CORBA.ORB_ID == "omniORB4" else "ORB" + + GIOP_MaxMsgSize=2097152000 # 2 GBytes + + orbdata = [] + orbdata.append("%sInitRef = NameService=corbaname::%s:%s"%(prefix,host,port)) + orbdata.append("%sgiopMaxMsgSize = %s # 2 GBytes"%(prefix,GIOP_MaxMsgSize)) + orbdata.append("%straceLevel = 0 # critical errors only"%(prefix)) + orbdata.append("") + + f = open(omniorb_config, "w") + f.write("\n".join(orbdata)) + f.close() + + return [ omniorb_config, GIOP_MaxMsgSize ] + +# ----------------------------------------------------------------------------- + +if __name__ == "__main__": + import sys, getopt + + path = sys.argv[1] + host = sys.argv[2] + port = sys.argv[3] + argv = sys.argv[4:] + + kwargs = {} + for a in argv: + alist = str(a).split("=", 1) + opt = str(alist[0]) + arg = alist[1] + kwargs[opt] = arg + pass + + [ filename, msgSize ] = writeORBConfigFile(path, host, port, kwargs) + + # :TRICKY: print values so they can be read from caller bash script + # Example of bash script: + # RETURN_VALUES=$(python ORBConfigFile.py path host port) + # RETURN_VALUE_1=$(echo ${RETURN_VALUES} | cut -d' ' -f1) + # RETURN_VALUE_2=$(echo ${RETURN_VALUES} | cut -d' ' -f2) + # ... + # IMPORTANT NOTE: this print call MUST BE the first one!! + print filename, msgSize diff --git a/bin/appliskel/runRemote.sh b/bin/appliskel/runRemote.sh index dead646a7..717085068 100755 --- a/bin/appliskel/runRemote.sh +++ b/bin/appliskel/runRemote.sh @@ -50,15 +50,12 @@ export APPLI=`${APPLI_HOME}/getAppliPath.py` . ${HOME}/${APPLI}/envd ${HOME}/${APPLI} # --- set the OMNIORB_CONFIG file and environment relative to this run of SALOME +export NSHOST=$1 +export NSPORT=$2 -OMNIORB_CONFIG=${HOME}/${APPLI}/USERS/.omniORB_${USER}_$1_$2.cfg -export OMNIORB_CONFIG -NSHOST=$1 -export NSHOST -NSPORT=$2 -export NSPORT -initref="NameService=corbaname::"$1":$2" -echo "InitRef = $initref" > $OMNIORB_CONFIG +# Get (in bash) the configuration filename from (Python) ORBConfigFile return values +RETURN_VALUES=$(${KERNEL_ROOT_DIR}/bin/salome/envSalome.py python ${KERNEL_ROOT_DIR}/bin/salome/ORBConfigFile.py ${HOME}/${APPLI}/USERS ${NSHOST} ${NSPORT} with_username=${USER}) +export OMNIORB_CONFIG=$(echo ${RETURN_VALUES} | cut -d' ' -f1) #go to the requested working directory if any if test "x$3" == "xWORKINGDIR"; then diff --git a/bin/appliskel/runSession b/bin/appliskel/runSession index f12e53c21..e1616f18b 100755 --- a/bin/appliskel/runSession +++ b/bin/appliskel/runSession @@ -68,6 +68,23 @@ export APPLI=`${APPLI_HOME}/getAppliPath.py` . ${HOME}/${APPLI}/envd ${HOME}/${APPLI} +# --- set the OMNIORB_CONFIG file and environment relative to this run of SALOME +# Usage: writeConfigFile PORT HOST +function writeConfigFile +{ + if [ $# -ne 2 ]; then + echo "Usage: $0 PORT HOST" + return + fi + export NSPORT=$1 + export NSHOST=$2 + + # Get (in bash) the configuration filename from (Python) ORBConfigFile return values + RETURN_VALUES=$(${KERNEL_ROOT_DIR}/bin/salome/envSalome.py python ${KERNEL_ROOT_DIR}/bin/salome/ORBConfigFile.py ${HOME}/${APPLI}/USERS ${NSHOST} ${NSPORT} with_username=${USER}) + export OMNIORB_CONFIG=$(echo ${RETURN_VALUES} | cut -d' ' -f1) +} + + if test "x${NSPORT}" == "xlast"; then #PORT is not given if test "x${NSHOST}" == "xlocalhost"; then @@ -75,47 +92,28 @@ if test "x${NSPORT}" == "xlast"; then # --- set omniORB configuration to current session if any fileOmniConfig=${HOME}/${APPLI}/USERS/.omniORB_${USER}_last.cfg if [ -f $fileOmniConfig ]; then - OMNIORB_CONFIG=${HOME}/${APPLI}/USERS/.omniORB_${USER}_last.cfg - export OMNIORB_CONFIG + export OMNIORB_CONFIG=${HOME}/${APPLI}/USERS/.omniORB_${USER}_last.cfg # --- set environment variables for port and hostname of NamingService - NSHOST=`${KERNEL_ROOT_DIR}/bin/salome/NSparam.py host` - NSPORT=`${KERNEL_ROOT_DIR}/bin/salome/NSparam.py port` - export NSPORT - export NSHOST + export NSHOST=`${KERNEL_ROOT_DIR}/bin/salome/NSparam.py host` + export NSPORT=`${KERNEL_ROOT_DIR}/bin/salome/NSparam.py port` fi else #MACHINE is given PORT is not given - NSPORT=2810 - OMNIORB_CONFIG=${HOME}/${APPLI}/USERS/.omniORB_${USER}_${NSHOST}_${NSPORT}.cfg - export OMNIORB_CONFIG - #if omniorb config file exists do not override (perhaps too conservative) - if [ ! -f ${OMNIORB_CONFIG} ]; then - echo "InitRef = NameService=corbaname::${NSHOST}:${NSPORT}" > ${OMNIORB_CONFIG} - fi - export NSPORT - export NSHOST + writeConfigFile 2810 ${NSHOST} fi else #PORT is given if test "x${NSHOST}" == "xlocalhost"; then #MACHINE is not given PORT is given - NSHOST=`hostname` + NSHOST=`hostname` fi - OMNIORB_CONFIG=${HOME}/${APPLI}/USERS/.omniORB_${USER}_${NSHOST}_${NSPORT}.cfg - export OMNIORB_CONFIG - #if omniorb config file exists do not override (perhaps too conservative) - if [ ! -f ${OMNIORB_CONFIG} ]; then - echo "InitRef = NameService=corbaname::${NSHOST}:${NSPORT}" > ${OMNIORB_CONFIG} - fi - export NSPORT - export NSHOST + writeConfigFile ${NSPORT} ${NSHOST} fi # --- invoke shell with or without args if [ $# -ne 0 ] ; then - ${KERNEL_ROOT_DIR}/bin/salome/envSalome.py -exec $* + ${KERNEL_ROOT_DIR}/bin/salome/envSalome.py -exec $* else - - ${KERNEL_ROOT_DIR}/bin/salome/envSalome.py /bin/bash --rcfile ${HOME}/${APPLI}/.bashrc + ${KERNEL_ROOT_DIR}/bin/salome/envSalome.py /bin/bash --rcfile ${HOME}/${APPLI}/.bashrc fi diff --git a/bin/appliskel/runTests b/bin/appliskel/runTests index 352daad91..f7f9ad98c 100755 --- a/bin/appliskel/runTests +++ b/bin/appliskel/runTests @@ -30,44 +30,6 @@ export APPLI=`${APPLI_HOME}/getAppliPath.py` . ${HOME}/${APPLI}/envd ${HOME}/${APPLI} -# --- define port for CORBA naming service - -searchFreePort() { - echo -n "Searching for a free port for naming service: " - export NSPORT=2810 - local limit=$NSPORT - let limit=limit+100 - while [ 1 ] - do - aRes=`netstat -ltn | grep -E :${NSPORT}` - if [ -z "$aRes" ]; then - echo ${NSPORT} - Ok - local myhost=`hostname` - OMNIORB_CONFIG=${HOME}/${APPLI}/USERS/.omniORB_${USER}_${myhost}_${NSPORT}.cfg - export OMNIORB_CONFIG - export NSPORT - NSHOST=${myhost} - export NSHOST - local initref="NameService=corbaname::"`hostname`":$NSPORT" - #echo "ORBInitRef $initref" > $OMNIORB_CONFIG - echo "InitRef = $initref" > $OMNIORB_CONFIG - LAST_RUNNING_CONFIG=${HOME}/${APPLI}/USERS/.omniORB_${USER}_${myhost}_test.cfg - export LAST_RUNNING_CONFIG - rm ${LAST_RUNNING_CONFIG} - ln -s ${OMNIORB_CONFIG} ${LAST_RUNNING_CONFIG} - break - fi - echo -n "${NSPORT} " - if [[ $NSPORT -eq $limit ]] ; then - echo - echo "Can't find a free port to launch omniNames" - echo "Try to kill the running servers and then launch SALOME again." - exit - fi - let NSPORT=NSPORT+1 - done -} - # --- if mpi lam, start lam (seems safe to be done several times) # arret manuel avec lamhalt @@ -77,7 +39,7 @@ fi # --- invoque shell with or without args -searchFreePort +searchFreePort save test if [ $# -ne 0 ] ; then ${KERNEL_ROOT_DIR}/bin/salome/envSalome.py /bin/bash --rcfile ${HOME}/${APPLI}/.bashrc -c "$*" diff --git a/bin/appliskel/searchFreePort.sh b/bin/appliskel/searchFreePort.sh index 8d0346561..bda749fc7 100755 --- a/bin/appliskel/searchFreePort.sh +++ b/bin/appliskel/searchFreePort.sh @@ -23,30 +23,44 @@ # --- define port for CORBA naming service +DEFAULT=default + +# call: searchFreePort [ save [test] ] searchFreePort() { + # if not specified by optional first parameter, savemode is set to default + savemode=${1:-$DEFAULT} + # if not specified by optional second parameter, testmode is set to default + testmode=${2:-$DEFAULT} + echo -n "Searching for a free port for naming service: " - NSPORT=2810 - export NSPORT + export NSPORT=2810 local limit=$NSPORT let limit=limit+100 + while [ 1 ] do aRes=`netstat -ltn | grep -E :${NSPORT}` if [ -z "$aRes" ]; then echo ${NSPORT} - Ok - local myhost=`hostname` - OMNIORB_CONFIG=${HOME}/${APPLI}/USERS/.omniORB_${USER}_${myhost}_${NSPORT}.cfg - export OMNIORB_CONFIG - export NSPORT - NSHOST=${myhost} - export NSHOST - local initref="NameService=corbaname::"`hostname`":$NSPORT" - #echo "ORBInitRef $initref" > $OMNIORB_CONFIG - echo "InitRef = $initref" > $OMNIORB_CONFIG - LAST_RUNNING_CONFIG=${HOME}/${APPLI}/USERS/.omniORB_${USER}_last.cfg - export LAST_RUNNING_CONFIG - rm ${LAST_RUNNING_CONFIG} - ln -s ${OMNIORB_CONFIG} ${LAST_RUNNING_CONFIG} + export NSPORT + export NSHOST=`hostname` + + RETURN_VALUES=$(${KERNEL_ROOT_DIR}/bin/salome/envSalome.py python ${KERNEL_ROOT_DIR}/bin/salome/ORBConfigFile.py ${HOME}/${APPLI}/USERS ${NSHOST} ${NSPORT} with_username=${USER}) + export OMNIORB_CONFIG=$(echo ${RETURN_VALUES} | cut -d' ' -f1) + + if [ "$savemode" = save ] + then + if [ "$testmode" = test ] + then + export LAST_RUNNING_CONFIG=${HOME}/${APPLI}/USERS/.omniORB_${USER}_${NSHOST}_test.cfg + else + export LAST_RUNNING_CONFIG=${HOME}/${APPLI}/USERS/.omniORB_${USER}_last.cfg + fi + + rm ${LAST_RUNNING_CONFIG} + ln -s ${OMNIORB_CONFIG} ${LAST_RUNNING_CONFIG} + fi + break fi echo -n "${NSPORT} " @@ -59,4 +73,3 @@ searchFreePort() { let NSPORT=NSPORT+1 done } - diff --git a/bin/killSalome.py b/bin/killSalome.py index 020f7ed44..26dc0bb6f 100755 --- a/bin/killSalome.py +++ b/bin/killSalome.py @@ -96,4 +96,3 @@ def killAllPorts(): if __name__ == "__main__": killAllPorts() pass - diff --git a/bin/killSalomeWithPort.py b/bin/killSalomeWithPort.py index 57729aa88..c6c128b23 100755 --- a/bin/killSalomeWithPort.py +++ b/bin/killSalomeWithPort.py @@ -117,7 +117,7 @@ def appliCleanOmniOrbConfig(port): os.remove(omniorb_config) pass - if os.path.lexists(last_running_config):return + if os.path.lexists(last_running_config):return #try to relink last.cfg to an existing config file if any files = glob.glob(os.path.join(os.environ["HOME"],Utils_Identity.getapplipath(), @@ -137,21 +137,21 @@ def appliCleanOmniOrbConfig(port): ########## kills all salome processes with the given port ########## -def shutdownMyPort(port): +def shutdownMyPort(port, cleanup=True): """ Shutdown SALOME session running on the specified port. Parameters: - port - port number """ if not port: return - + from salome_utils import generateFileName # set OMNIORB_CONFIG variable to the proper file home = os.getenv("HOME") appli = os.getenv("APPLI") kwargs = {} - if appli is not None: + if appli is not None: home = os.path.join(os.path.realpath(home), appli,"USERS") kwargs["with_username"]=True pass @@ -162,22 +162,29 @@ def shutdownMyPort(port): with_port=port, **kwargs) os.environ['OMNIORB_CONFIG'] = omniorb_config + os.environ['NSPORT'] = str(port) # give the chance to the servers to shutdown properly try: import time - import salome_kernel - orb, lcc, naming_service, cm = salome_kernel.salome_kernel_init() + from omniORB import CORBA + from LifeCycleCORBA import LifeCycleCORBA # shutdown all + orb = CORBA.ORB_init([''], CORBA.ORB_ID) + lcc = LifeCycleCORBA(orb) lcc.shutdownServers() # give some time to shutdown to complete time.sleep(1) # shutdown omniNames and notifd - salome_kernel.LifeCycleCORBA.killOmniNames() + if cleanup: + lcc.killOmniNames() + time.sleep(1) + pass + pass except: pass pass - + def killMyPort(port): """ Kill SALOME session running on the specified port. @@ -185,12 +192,12 @@ def killMyPort(port): - port - port number """ from salome_utils import getShortHostName, getHostName - + # try to shutdown session nomally import threading, time - threading.Thread(target=shutdownMyPort, args=(port,)).start() + threading.Thread(target=shutdownMyPort, args=(port,False)).start() time.sleep(3) # wait a little, then kill processes (should be done if shutdown procedure hangs up) - + # new-style dot-prefixed pidict file filedict = getPiDict(port, hidden=True) # provide compatibility with old-style pidict file (not dot-prefixed) @@ -218,7 +225,7 @@ def killMyPort(port): suffix="Pid_omniNames", extension="log", with_port=port) - if not sys.platform == 'win32': + if not sys.platform == 'win32': cmd = 'pid=`ps -eo pid,command | egrep "[0-9] omniNames -start %s"` ; echo $pid > %s' % ( str(port), fpidomniNames ) a = os.system(cmd) pass @@ -255,7 +262,7 @@ def killMyPort(port): try: if sys.platform == "win32": import win32pm - win32pm.killpid(int(pid),0) + win32pm.killpid(int(pid),0) else: os.kill(int(pid),signal.SIGKILL) pass @@ -285,7 +292,7 @@ def killMyPort(port): # appliCleanOmniOrbConfig(port) pass - + def killNotifdAndClean(port): """ Kill notifd daemon and clean application running on the specified port. @@ -355,10 +362,19 @@ def killMyPortSpy(pid, port): return if __name__ == "__main__": + if len(sys.argv) < 2: + print "Usage: " + print " %s " % os.path.basename(sys.argv[0]) + print + print "Kills SALOME session running on specified ." + sys.exit(1) + pass if sys.argv[1] == "--spy": - pid = sys.argv[2] - port = sys.argv[3] - killMyPortSpy(pid, port) + if len(sys.argv) > 3: + pid = sys.argv[2] + port = sys.argv[3] + killMyPortSpy(pid, port) + pass sys.exit(0) pass for port in sys.argv[1:]: diff --git a/bin/launchConfigureParser.py b/bin/launchConfigureParser.py index 1bb30d33a..92b5e9aea 100755 --- a/bin/launchConfigureParser.py +++ b/bin/launchConfigureParser.py @@ -173,11 +173,11 @@ def userFile(appname, cfgname): # get app version v = version() if not v: return None # unknown version - + # get default user file name filename = defaultUserFile(appname, cfgname) if not filename: return None # default user file name is bad - + # check that default user file exists if os.path.exists(filename): return filename # user file is found @@ -186,7 +186,7 @@ def userFile(appname, cfgname): # ... calculate default version id id0 = version_id(v) if not id0: return None # bad version id -> can't detect appropriate file - + # ... get all existing user preferences files if sys.platform == "win32": files = glob.glob(os.path.join(getHomeDir(), "%s.xml.*" % appname)) @@ -301,11 +301,11 @@ class xml_parser: def startElement(self, name, attrs): self.space.append(name) self.current = None - + # if we are importing file if self.space == [doc_tag, import_tag] and nam_att in attrs.getNames(): self.importFile( attrs.getValue(nam_att) ) - + # if we are analyzing "section" element and its "name" attribute is # either "launch" or module name -- set section_name if self.space == [doc_tag, sec_tag] and nam_att in attrs.getNames(): @@ -366,14 +366,14 @@ class xml_parser: def endDocument(self): self.read = None pass - + def importFile(self, fname): # get absolute name if os.path.isabs (fname) : absfname = fname else: absfname = os.path.join(os.path.dirname(self.fileName), fname) - + # check existing and registry file for ext in ["", ".xml", ".XML"] : if os.path.exists(absfname + ext) : @@ -386,7 +386,7 @@ class xml_parser: else: if verbose(): print "Configure parser: Error : file %s does not exist" % absfname return - + # importing file try: # copy current options @@ -404,7 +404,7 @@ class xml_parser: except: if verbose(): print "Configure parser: Error : can not read configuration file %s" % absfname pass - + # ----------------------------------------------------------------------------- @@ -876,7 +876,7 @@ def get_env(theAdditionalOptions=[], appname=salomeappname, cfgname=salomecfgnam # Process --print-port option if cmd_opts.print_port: - from runSalome import searchFreePort + from searchFreePort import searchFreePort searchFreePort({}) print "port:%s"%(os.environ['NSPORT']) sys.exit(0) diff --git a/bin/launchSalome.py b/bin/launchSalome.py index 9fe2af56b..0998452da 100755 --- a/bin/launchSalome.py +++ b/bin/launchSalome.py @@ -47,10 +47,10 @@ def findFreePort(startPort, step) : except Exception, inst: print str(currentPort) + ": " + str(inst.args); currentPort = currentPort+step; - - - - + + + + if (portFound != 1) : currentPort = -1; return currentPort; @@ -68,9 +68,6 @@ hostName = socket.gethostname(); if (len(sys.argv) > 1) and sys.argv[1] == "-nothing" : print "port:" + str(freePort); sys.exit(0) - - - if freePort < 0 : print @@ -78,15 +75,10 @@ if freePort < 0 : print "Try to kill the running servers and then launch SALOME again." print sys.exit(0) - -else : - omniCfgFileContent = "InitRef = NameService=corbaname::" + str(hostName) + ":" + str(freePort); - omniCfgFilePath = os.environ.get('HOME') + "/" + ".omniORB_" + str(hostName) + "_" + str(freePort) + ".cfg"; - omni_file = file(omniCfgFilePath,'w+'); - omni_file.write(omniCfgFileContent); - omni_file.write("\n"); - omni_file.close(); +else : + from ORBConfigFile import writeORBConfigFile + writeORBConfigFile(os.environ.get('HOME'), hostName, freePort) if (len(sys.argv) > 1) and sys.argv[1] == "--save-config" : omniCfgCurrent = os.environ.get('HOME') + "/.omniORB_current.cfg"; @@ -96,11 +88,9 @@ else : else : #copy the file shutil.copy(omniCfgFilePath, omniCfgCurrent); - + omniCfgFilePath = omniCfgCurrent; - - - + ## 2. Set the OMNIORB_CONFIG environment variable os.environ['OMNIORB_CONFIG']=omniCfgFilePath; @@ -111,4 +101,3 @@ else : if os.path.isfile(runSalomePyFilePath) : execfile(runSalomePyFilePath); - diff --git a/bin/orbmodule.py b/bin/orbmodule.py index 0499db75b..507c68c39 100755 --- a/bin/orbmodule.py +++ b/bin/orbmodule.py @@ -41,10 +41,9 @@ class client: """Client for SALOME""" def __init__(self,args=None): - #set GIOP message size for bug 10560: impossible to get field values in TUI mode - sys.argv.extend(["-ORBgiopMaxMsgSize", "104857600"]) ## = 100 * 1024 * 1024 # Initialise the ORB self.orb=CORBA.ORB_init(sys.argv, CORBA.ORB_ID) + # Initialise the Naming Service self.initNS(args or {}) @@ -59,7 +58,7 @@ class client: except (CORBA.TRANSIENT,CORBA.OBJECT_NOT_EXIST,CORBA.COMM_FAILURE): self.rootContext = None if verbose(): print "Launch Naming Service++", - + # On lance le Naming Server (doit etre dans le PATH) test = True if args['wake_up_session']: @@ -142,14 +141,14 @@ class client: count += 1 if count > maxcount : raise RuntimeError, "Impossible de trouver %s" % name obj=self.Resolve(name) - if obj : + if obj : print " found in %s seconds " % ((count-1)*delta) break else: sys.stdout.write('+') sys.stdout.flush() time.sleep(delta) - + if typobj is None:return obj nobj = obj._narrow(typobj) @@ -170,7 +169,7 @@ class client: raise RuntimeError, "Process %d for %s not found" % (thePID,theName) aCount += 1 anObj = self.Resolve(theName) - if anObj: + if anObj: print " found in %s seconds " % ((aCount-1)*aDelta) break else: @@ -179,7 +178,7 @@ class client: time.sleep(aDelta) pass pass - + if theTypObj is None: return anObj @@ -206,7 +205,7 @@ class client: except (CORBA.TRANSIENT,CORBA.OBJECT_NOT_EXIST,CORBA.COMM_FAILURE): obj = None return obj - + # -------------------------------------------------------------------------- def waitLogger(self,name,typobj=None,maxcount=40): @@ -217,18 +216,17 @@ class client: count += 1 if count > maxcount : raise RuntimeError, "Impossible de trouver %s" % name obj=self.ResolveLogger(name) - if obj : + if obj : print " found in %s seconds " % ((count-1)*delta) break else: sys.stdout.write('+') sys.stdout.flush() time.sleep(delta) - + if typobj is None:return obj nobj = obj._narrow(typobj) if nobj is None: print "%s exists but is not a %s" % (name,typobj) return nobj - diff --git a/bin/runSalome.ksh b/bin/runSalome.ksh index 57804f295..2a02cf68d 100644 --- a/bin/runSalome.ksh +++ b/bin/runSalome.ksh @@ -21,46 +21,12 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -searchFreePort() { - echo -n "Searching for a free port for naming service: " - NSPORT=2810 - export NSPORT - local limit=$NSPORT - let limit=limit+100 - while [ 1 ] - do - aRes=`netstat -ltn | grep -E :${NSPORT}` - if [ -z "$aRes" ]; then - echo ${NSPORT} - Ok - local myhost=`hostname` - OMNIORB_CONFIG=${HOME}/.omniORB_${myhost}_${NSPORT}.cfg - export OMNIORB_CONFIG - local initref="NameService=corbaname::"`hostname`":$NSPORT" - export NSPORT - if [[ `python -c "import CORBA; print CORBA.ORB_ID"` = "omniORB4" ]]; then - echo "InitRef = $initref" > $OMNIORB_CONFIG - else - echo "ORBInitRef $initref" > $OMNIORB_CONFIG - fi - break - fi - echo -n "${NSPORT} " - if [[ $NSPORT -eq $limit ]] ; then - echo - echo "Can't find a free port to launch omniNames" - echo "Try to kill the running servers and then launch SALOME again." - exit - fi - let NSPORT=NSPORT+1 - done -} - searchFreePort if [[ "$*" = "-nothing" ]]; then echo "port:$NSPORT" elif [ $# -ne 0 ] ; then - python ${KERNEL_ROOT_DIR}/bin/salome/runSalome.py $* + python ${KERNEL_ROOT_DIR}/bin/salome/runSalome.py $* else python ${KERNEL_ROOT_DIR}/bin/salome/runSalome.py fi @@ -73,7 +39,7 @@ fi # - parameters for launching are taken from SalomeApp.xml; # - if the config file does not exist, it is created with default values. # -# +# # $: ${KERNEL_ROOT_DIR}/bin/salome/runSalome --modules=GEOM,SMESH,VISU,MED --embedded=registry,study,moduleCatalog,cppContainer --standalone=pyContainer --xterm --killall # # parameters from command line supersede those from SalomeApp.xml @@ -92,7 +58,7 @@ fi # par defaut, les differents serveurs ouvrent des fenêtres xterm # (cf. runSalome.py) # le serveur Logger n'est pas obligatoire (commenté dans runSalome.py) -# +# # ----------------------------------------------------------------------------- # Example on CCRT (without ihm) : # ${KERNEL_ROOT_DIR}/bin/salome/runSalome.py --terminal --modules=MED,CALCULATOR,COMPONENT --standalone=registry,study,moduleCatalog,cppContainer,pyContainer --killall diff --git a/bin/runSalome.py b/bin/runSalome.py index c56da55cf..f6e76652f 100755 --- a/bin/runSalome.py +++ b/bin/runSalome.py @@ -46,7 +46,7 @@ def killLocalPort(): kill servers from a previous SALOME exection, if needed, on the CORBA port given in args of runSalome """ - + from killSalomeWithPort import killMyPort my_port=str(args['port']) try: @@ -55,13 +55,13 @@ def killLocalPort(): print "problem in killLocalPort()" pass pass - + def givenPortKill(port): """ kill servers from a previous SALOME exection, if needed, on the same CORBA port """ - + from killSalomeWithPort import killMyPort my_port=port try: @@ -96,7 +96,7 @@ class InterpServer(Server): self.CMD=['xterm', '-e']+ env_ld_library_path + ['python'] else: self.CMD=['cmd', '/c', 'start cmd.exe', '/K', 'python'] - + def run(self): global process_id command = self.CMD @@ -152,7 +152,7 @@ class CatalogServer(Server): self.SCMD2=[] home_dir=os.getenv('HOME') if home_dir is not None: - self.SCMD2=['-personal',os.path.join(home_dir,'Salome/resources/CatalogModulePersonnel.xml')] + self.SCMD2=['-personal',os.path.join(home_dir,'Salome/resources/CatalogModulePersonnel.xml')] def setpath(self,modules_list,modules_root_dir): list_modules = modules_list[:] @@ -250,7 +250,7 @@ class SessionServer(Server): self.SCMD1+=['--with','ModuleCatalog','(','-common'] home_dir=os.getenv('HOME') if home_dir is not None: - self.SCMD2+=['-personal',os.path.join(home_dir,'Salome/resources/CatalogModulePersonnel.xml')] + self.SCMD2+=['-personal',os.path.join(home_dir,'Salome/resources/CatalogModulePersonnel.xml')] self.SCMD2+=[')'] if 'study' in self.args['embedded']: self.SCMD2+=['--with','SALOMEDS','(',')'] @@ -258,7 +258,7 @@ class SessionServer(Server): self.SCMD2+=['--with','Container','(','FactoryServer',')'] if 'SalomeAppEngine' in self.args['embedded']: self.SCMD2+=['--with','SalomeAppEngine','(',')'] - + if 'cppContainer' in self.args['standalone'] or 'cppContainer' in self.args['embedded']: self.SCMD2+=['CPP'] if 'pyContainer' in self.args['standalone'] or 'pyContainer' in self.args['embedded']: @@ -276,6 +276,10 @@ class SessionServer(Server): self.SCMD2+=['--study-hdf=%s'%self.args['study_hdf']] pass pass + if self.args.has_key('pyscript') and len(self.args['pyscript']) > 0: + self.SCMD2+=['--pyscript=%s'%(",".join(self.args['pyscript']))] + pass + pass pass if self.args['noexcepthandler']: self.SCMD2+=['noexcepthandler'] @@ -294,9 +298,8 @@ class SessionServer(Server): list_modules.insert(0,m) list_modules.reverse() self.SCMD2+=['--modules (%s)' % ":".join(list_modules)] - - if self.args.has_key('pyscript') and len(self.args['pyscript']) > 0: - self.SCMD2+=['--pyscript=%s'%(",".join(self.args['pyscript']))] + pass + pass def setpath(self,modules_list,modules_root_dir): list_modules = modules_list[:] @@ -333,7 +336,7 @@ class SessionServer(Server): self.CMD = ["xterm", "-e", "gdb", "--command=.gdbinit4salome", self.CMD[0]] pass pass - + if self.args["valgrind_session"]: l = ["valgrind"] val = os.getenv("VALGRIND_OPTIONS") @@ -342,7 +345,7 @@ class SessionServer(Server): pass self.CMD = l + self.CMD pass - + # --- class LauncherServer(Server): @@ -406,7 +409,7 @@ def startGUI(clt): import SALOME_Session_idl session=clt.waitNS("/Kernel/Session",SALOME.Session) session.GetInterface() - + # ----------------------------------------------------------------------------- def startSalome(args, modules_list, modules_root_dir): @@ -414,13 +417,13 @@ def startSalome(args, modules_list, modules_root_dir): init_time = os.times() if verbose(): print "startSalome ", args - + # # Set server launch command # if args.has_key('server_launch_mode'): Server.set_server_launch_mode(args['server_launch_mode']) - + # # Wake up session option # @@ -430,7 +433,7 @@ def startSalome(args, modules_list, modules_root_dir): home = os.getenv("HOME") appli = os.getenv("APPLI") kwargs={} - if appli is not None: + if appli is not None: home = os.path.join(os.path.realpath(home), appli,"USERS") kwargs["with_username"] = True pass @@ -442,11 +445,11 @@ def startSalome(args, modules_list, modules_root_dir): os.environ['OMNIORB_CONFIG'] = last_running_config pass pass - + # # Initialisation ORB and Naming Service # - + clt=orbmodule.client(args) # @@ -478,7 +481,7 @@ def startSalome(args, modules_list, modules_root_dir): session.GetInterface() args["session_object"] = session return clt - + # Save Naming service port name into # the file args["ns_port_log_file"] if args.has_key('ns_port_log_file'): @@ -505,7 +508,7 @@ def startSalome(args, modules_list, modules_root_dir): if sys.platform != "win32": if verbose(): print "Notify Server to launch" - + myServer=NotifyServer(args,modules_root_dir) myServer.run() @@ -563,7 +566,7 @@ def startSalome(args, modules_list, modules_root_dir): # # Launch LauncherServer # - + myCmServer = LauncherServer(args) myCmServer.setpath(modules_list,modules_root_dir) myCmServer.run() @@ -577,7 +580,7 @@ def startSalome(args, modules_list, modules_root_dir): from Utils_Identity import getShortHostName - + if os.getenv("HOSTNAME") == None: if os.getenv("HOST") == None: os.environ["HOSTNAME"]=getShortHostName() @@ -585,13 +588,13 @@ def startSalome(args, modules_list, modules_root_dir): os.environ["HOSTNAME"]=os.getenv("HOST") theComputer = getShortHostName() - + # # Launch local C++ Container (FactoryServer), # and wait until it is registered in naming service # - if ('cppContainer' in args['standalone']) | (args["gui"] == 0) : + if ('cppContainer' in args['standalone']) | (args["gui"] == 0) : myServer=ContainerCPPServer(args) myServer.run() if sys.platform == "win32": @@ -615,9 +618,9 @@ def startSalome(args, modules_list, modules_root_dir): # # Wait until Session Server is registered in naming service # - + if args["gui"]: -##---------------- +##---------------- import Engines import SALOME import SALOMEDS @@ -641,7 +644,7 @@ def startSalome(args, modules_list, modules_root_dir): # additionnal external python interpreters # nbaddi=0 - + try: if 'interp' in args: nbaddi = args['interp'] @@ -651,7 +654,7 @@ def startSalome(args, modules_list, modules_root_dir): print "-------------------------------------------------------------" print "-- to get an external python interpreter:runSalome --interp=1" print "-------------------------------------------------------------" - + if verbose(): print "additional external python interpreters: ", nbaddi if nbaddi: for i in range(nbaddi): @@ -666,7 +669,7 @@ def startSalome(args, modules_list, modules_root_dir): import readline except ImportError: pass - + return clt # ----------------------------------------------------------------------------- @@ -678,7 +681,7 @@ def useSalome(args, modules_list, modules_root_dir): show registered objects in Naming Service. """ global process_id - + clt=None try: clt = startSalome(args, modules_list, modules_root_dir) @@ -688,7 +691,7 @@ def useSalome(args, modules_list, modules_root_dir): print print print "--- Error during Salome launch ---" - + #print process_id from addToKillList import addToKillList @@ -702,28 +705,28 @@ def useSalome(args, modules_list, modules_root_dir): if verbose(): print """ Saving of the dictionary of Salome processes in %s To kill SALOME processes from a console (kill all sessions from all ports): - python killSalome.py + python killSalome.py To kill SALOME from the present interpreter, if it is not closed : killLocalPort() --> kill this session (use CORBA port from args of runSalome) - givenPortKill(port) --> kill a specific session with given CORBA port + givenPortKill(port) --> kill a specific session with given CORBA port killAllPorts() --> kill all sessions - + runSalome, with --killall option, starts with killing the processes resulting from the previous execution. """%filedict - + # # Print Naming Service directory list # - + if clt != None: if verbose(): print print " --- registered objects tree in Naming Service ---" clt.showNS() pass - + if not args['gui'] or not args['session_gui']: if args['shutdown_servers']: class __utils__(object): @@ -739,7 +742,7 @@ def useSalome(args, modules_list, modules_root_dir): args['shutdown_servers'] = __utils__(args['port']) pass pass - + # run python scripts, passed via --execute option toimport = [] if args.has_key('pyscript'): @@ -781,7 +784,7 @@ def useSalome(args, modules_list, modules_root_dir): pass pass return clt - + def execScript(script_path): print 'executing', script_path sys.path.insert(0, os.path.dirname(script_path)) @@ -809,112 +812,6 @@ def registerEnv(args, modules_list, modules_root_dir): # ----------------------------------------------------------------------------- -def searchFreePort(args, save_config=1): - print "Searching for a free port for naming service:", - # - if sys.platform == "win32": - tmp_file = os.getenv('TEMP'); - else: - tmp_file = '/tmp' - tmp_file = os.path.join(tmp_file, '.netstat_%s'%os.getpid()) - # - ###status = os.system("netstat -ltn | grep -E :%s > /dev/null 2>&1"%(NSPORT)) - os.system( "netstat -a -n > %s" % tmp_file ); - f = open( tmp_file, 'r' ); - ports = f.readlines(); - f.close(); - os.remove( tmp_file ); - # - def portIsUsed(port, data): - regObj = re.compile( ".*tcp.*:([0-9]+).*:.*listen", re.IGNORECASE ); - for item in data: - try: - p = int(regObj.match(item).group(1)) - if p == port: return True - pass - except: - pass - pass - return False - # - NSPORT=2810 - limit=NSPORT+100 - # - while 1: - if not portIsUsed(NSPORT, ports): - print "%s - OK"%(NSPORT) - # - from salome_utils import generateFileName, getHostName - hostname = getHostName() - # - home = os.getenv("HOME") - appli = os.getenv("APPLI") - kwargs={} - if appli is not None: - home = os.path.join(os.path.realpath(home), appli,"USERS") - kwargs["with_username"]=True - # - omniorb_config = generateFileName(home, prefix="omniORB", - extension="cfg", - hidden=True, - with_hostname=True, - with_port=NSPORT, - **kwargs) - orbdata = [] - initref = "NameService=corbaname::%s:%s"%(hostname, NSPORT) - from omniORB import CORBA - if CORBA.ORB_ID == "omniORB4": - orbdata.append("InitRef = %s"%(initref)) - orbdata.append("giopMaxMsgSize = 2097152000 # 2 GBytes") - orbdata.append("traceLevel = 0 # critical errors only") - else: - orbdata.append("ORBInitRef %s"%(initref)) - orbdata.append("ORBgiopMaxMsgSize = 2097152000 # 2 GBytes") - orbdata.append("ORBtraceLevel = 0 # critical errors only") - pass - orbdata.append("") - f = open(omniorb_config, "w") - f.write("\n".join(orbdata)) - f.close() - # - os.environ['OMNIORB_CONFIG'] = omniorb_config - os.environ['NSPORT'] = "%s"%(NSPORT) - os.environ['NSHOST'] = "%s"%(hostname) - args['port'] = os.environ['NSPORT'] - # - if save_config: - last_running_config = generateFileName(home, prefix="omniORB", - suffix="last", - extension="cfg", - hidden=True, - **kwargs) - try: - if sys.platform == "win32": - import shutil - shutil.copyfile(omniorb_config, last_running_config) - else: - try: - os.remove(last_running_config) - except OSError: - pass - os.symlink(omniorb_config, last_running_config) - pass - pass - except: - pass - break - print "%s"%(NSPORT), - if NSPORT == limit: - msg = "\n" - msg += "Can't find a free port to launch omniNames\n" - msg += "Try to kill the running servers and then launch SALOME again.\n" - raise RuntimeError, msg - NSPORT=NSPORT+1 - pass - return - -# ----------------------------------------------------------------------------- - def no_main(): """Salome Launch, when embedded in other application""" fileEnv = os.environ["SALOME_LAUNCH_CONFIG"] @@ -922,6 +819,7 @@ def no_main(): args, modules_list, modules_root_dir = pickle.load(fenv) fenv.close() kill_salome(args) + from searchFreePort import searchFreePort searchFreePort(args, 0) clt = useSalome(args, modules_list, modules_root_dir) return clt @@ -933,6 +831,7 @@ def main(): from salome_utils import getHostName print "runSalome running on %s" % getHostName() args, modules_list, modules_root_dir = setenv.get_config() + kill_salome(args) save_config = True if args.has_key('save_config'): @@ -943,6 +842,7 @@ def main(): test = False pass if test: + from searchFreePort import searchFreePort searchFreePort(args, save_config) pass # -- @@ -992,7 +892,7 @@ def foreGround(clt, args): server.CMD = [os.getenv("PYTHONBIN"), "-m", "killSalomeWithPort", "--spy", "%s"%(os.getpid()), "%s"%(port)] else: server.CMD = ["killSalomeWithPort.py", "--spy", "%s"%(os.getpid()), "%s"%(port)] - server.run() + server.run() # os.system("killSalomeWithPort.py --spy %s %s &"%(os.getpid(), port)) # -- dt = 1.0 diff --git a/bin/salomeConsole.py b/bin/salomeConsole.py index a8c4a60a4..be01caa68 100755 --- a/bin/salomeConsole.py +++ b/bin/salomeConsole.py @@ -67,14 +67,14 @@ else: if rep == "y": filename=f break - + if filename != "": os.environ['OMNIORB_CONFIG']=filename else: rep= raw_input("Do you want to try a local session on port 2810 ? [y|n]") if rep == "y": # Try a local session running on port 2810 - sys.argv=sys.argv+['-ORBInitRef','NameService=corbaname::localhost:2810'] + sys.argv=sys.argv+['-ORBInitRef','NameService=corbaname::localhost:2810']#+['-ORBgiopMaxMsgSize','2097152000'] # 2 GBytes else: sys.exit(1) diff --git a/bin/salome_session.py b/bin/salome_session.py index d2ca5b094..17e984b9e 100644 --- a/bin/salome_session.py +++ b/bin/salome_session.py @@ -36,6 +36,7 @@ _session = None def startSession(modules=[]): global _session if _session: return + from searchFreePort import searchFreePort searchFreePort() _session = SalomeSession(modules) return @@ -51,59 +52,6 @@ def getShortHostName(): from salome_utils import getShortHostName return getShortHostName() -def searchFreePort(): - """ - Search free port for SALOME session. - Returns first found free port number. - """ - print "Searching a free port for naming service:", - from salome_utils import generateFileName, getHostName - hostname = getHostName() - NSPORT = 2810 - limit = NSPORT+100 - while 1: - print "%s "%(NSPORT), - status = os.system("netstat -ltn | grep -E :%s"%(NSPORT)) - if status: - home = os.getenv("HOME") - appli = os.getenv("APPLI") - kwargs={} - if appli is not None: - home = os.path.join(os.path.realpath(home), appli,"USERS") - kwargs["with_username"]=True - omniorb_config = generateFileName(home, prefix="omniORB", - extension="cfg", - hidden=True, - with_hostname=True, - with_port=NSPORT, - **kwargs) - f = open(omniorb_config, "w") - f.write("ORBInitRef NameService=corbaname::%s:%s\n"%(hostname, NSPORT)) - f.close() - os.environ['OMNIORB_CONFIG'] = omniorb_config - last_running_config = generateFileName(home, prefix="omniORB", - suffix="last", - extension="cfg", - hidden=True, - **kwargs) - os.environ['LAST_RUNNING_CONFIG'] = last_running_config - if os.access(last_running_config,os.F_OK): - os.unlink(last_running_config) - pass - os.symlink(omniorb_config,last_running_config) - print "- Ok" - break - if NSPORT == limit: - msg = "" - msg += "Can not find a free port to launch omniNames\n" - msg += "Kill the running servers and try again.\n" - raise RuntimeError, msg - NSPORT = NSPORT+1 - pass - os.environ['NSHOST'] = hostname - os.environ['NSPORT'] = str(NSPORT) - return NSPORT - class SalomeSession(object): """Salome session launcher""" diff --git a/bin/salome_utils.py b/bin/salome_utils.py index 95e87f42c..295b05d24 100644 --- a/bin/salome_utils.py +++ b/bin/salome_utils.py @@ -194,8 +194,11 @@ def getPortNumber(use_default=True): return int( os.getenv( "NSPORT" ) ) except: pass - port = getPortFromORBcfg() - if port is not None: return port + try: + port = int( getPortFromORBcfg() ) + if port is not None: return port + except: + pass if use_default: return 2809 # '2809' is default port number return None diff --git a/bin/searchFreePort.py b/bin/searchFreePort.py new file mode 100644 index 000000000..32d858f31 --- /dev/null +++ b/bin/searchFreePort.py @@ -0,0 +1,111 @@ +#!/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 +# + +def searchFreePort(args={}, save_config=1): + """ + Search free port for SALOME session. + Returns first found free port number. + """ + import sys, os, re, shutil + print "Searching for a free port for naming service:", + + # :NOTE: Under windows: + # netstat options -l and -t are unavailable + # grep command is unavailable + + from subprocess import Popen, PIPE + (stdout, stderr) = Popen(['netstat','-an'], stdout=PIPE).communicate() + import StringIO + buf = StringIO.StringIO(stdout) + ports = buf.readlines() + + # + def portIsUsed(port, data): + regObj = re.compile( ".*tcp.*:([0-9]+).*:.*listen", re.IGNORECASE ); + for item in data: + try: + p = int(regObj.match(item).group(1)) + if p == port: return True + pass + except: + pass + pass + return False + # + NSPORT=2810 + limit=NSPORT+100 + # + + while 1: + if not portIsUsed(NSPORT, ports): + print "%s - OK"%(NSPORT) + # + from salome_utils import generateFileName, getHostName + hostname = getHostName() + # + home = os.getenv("HOME") + appli = os.getenv("APPLI") + kwargs={} + if appli is not None: + home = os.path.join(os.path.realpath(home), appli,"USERS") + kwargs["with_username"]=True + # + from ORBConfigFile import writeORBConfigFile + omniorb_config, giopsize = writeORBConfigFile(home, hostname, NSPORT, kwargs) + + args['port'] = os.environ['NSPORT'] + # + if save_config: + last_running_config = generateFileName(home, prefix="omniORB", + suffix="last", + extension="cfg", + hidden=True, + **kwargs) + os.environ['LAST_RUNNING_CONFIG'] = last_running_config + try: + if sys.platform == "win32": + import shutil + shutil.copyfile(omniorb_config, last_running_config) + else: + try: + if os.access(last_running_config, os.F_OK): + os.remove(last_running_config) + except OSError: + pass + os.symlink(omniorb_config, last_running_config) + pass + pass + except: + pass + # + break + print "%s"%(NSPORT), + if NSPORT == limit: + msg = "\n" + msg += "Can't find a free port to launch omniNames\n" + msg += "Try to kill the running servers and then launch SALOME again.\n" + raise RuntimeError, msg + NSPORT=NSPORT+1 + pass + return diff --git a/bin/setenv.py b/bin/setenv.py index 44ac6dbe7..46bc337be 100755 --- a/bin/setenv.py +++ b/bin/setenv.py @@ -172,7 +172,8 @@ def set_env(args, modules_list, modules_root_dir, silent=False): for module in modules_list : if modules_root_dir.has_key(module): module_root_dir = modules_root_dir[module] - modules_root_dir_list[:0] = [module_root_dir] + if module_root_dir not in modules_root_dir_list: + modules_root_dir_list[:0] = [module_root_dir] if sys.platform == "win32": add_path(os.path.join(module_root_dir,get_lib_dir(),salome_subdir), "PATH") diff --git a/bin/shutdownSalome.py b/bin/shutdownSalome.py index b7d319696..ed81e00e8 100755 --- a/bin/shutdownSalome.py +++ b/bin/shutdownSalome.py @@ -27,9 +27,12 @@ # import time -import salome_kernel -orb, lcc, naming_service, cm = salome_kernel.salome_kernel_init() +from omniORB import CORBA +from LifeCycleCORBA import * + +orb = CORBA.ORB_init([''], CORBA.ORB_ID) +lcc = LifeCycleCORBA(orb) lcc.shutdownServers() -#give some time to shutdown to complete time.sleep(1) -salome_kernel.LifeCycleCORBA.killOmniNames() +LifeCycleCORBA.killOmniNames() +time.sleep(1) diff --git a/doc/docutils/CMakeLists.txt b/doc/docutils/CMakeLists.txt new file mode 100755 index 000000000..71b6d67fb --- /dev/null +++ b/doc/docutils/CMakeLists.txt @@ -0,0 +1,66 @@ +# Copyright (C) 2012 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 +# + +SET(SPHINXOPTS +) +SET(SOURCEDIR + ${CMAKE_CURRENT_SOURCE_DIR} +) +SET(PAPEROPT_a4 + -D + latex_paper_size=a4 +) +SET(ALLSPHINXOPTS + -d + doctrees + ${PAPEROPT_a4} + ${SPHINXOPTS} + ${SOURCEDIR} +) + +SALOME_CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/conf.py.in" "${CMAKE_CURRENT_BINARY_DIR}/conf.py") + +IF(WINDOWS) + STRING(REPLACE "/" "\\" SCR "@SET PYTHONPATH=${CMAKE_INSTALL_PREFIX}\\lib\\python2.6\\site-packages\\salome\;%PYTHONPATH% + @SET PYTHONPATH=${CMAKE_INSTALL_PREFIX}\\bin\\salome\;%PYTHONPATH% + @SET PATH=${CMAKE_INSTALL_PREFIX}\\lib\\salome\;%PATH% + @SET PYTHONPATH=${OMNIORB_ROOT_USER}\\lib\\x86_win32\;%PYTHONPATH% + @SET PYTHONPATH=${OMNIORB_ROOT_USER}\\lib\\python\;%PYTHONPATH% + @SET PATH=${OMNIORB_ROOT_USER}\\lib\\x86_win32\;%PATH% + ") + SET(EXT "bat") + SET(CALL_STR "call") +ELSE(WINDOWS) + SET(SCR "export PYTHONPATH=${CMAKE_INSTALL_PREFIX}/lib/python2.6/site-packages/salome:\${PYTHONPATH} + export PYTHONPATH=${CMAKE_INSTALL_PREFIX}/bin/salome:\${PYTHONPATH} + export LD_LIBRARY_PATH=${CMAKE_INSTALL_PREFIX}/lib/salome:\${LD_LIBRARY_PATH} + export PYTHONPATH=${OMNIORB_ROOT_USER}/lib:\${PYTHONPATH} + export PYTHONPATH=${OMNIORB_ROOT_USER}/lib/python2.6/site-packages:\${PYTHONPATH} + export LD_LIBRARY_PATH=${OMNIORB_ROOT_USER}/lib:\${LD_LIBRARY_PATH} + ") + SET(EXT "sh") + SET(CALL_STR ".") +ENDIF(WINDOWS) + +FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/env_s.${EXT} "${SCR}") + +ADD_CUSTOM_TARGET(html_docs ${CALL_STR} ${CMAKE_CURRENT_BINARY_DIR}/env_s.${EXT} && ${SPHINX_EXECUTABLE} -c ${CMAKE_BINARY_DIR}/doc/docutils -b html ${ALLSPHINXOPTS} html + COMMAND ${PYTHON_EXECUTABLE} -c \"import shutil\;shutil.rmtree('''${CMAKE_INSTALL_PREFIX}/share/doc/salome/tui/KERNEL/docutils''', True)\;shutil.copytree('''${CMAKE_CURRENT_BINARY_DIR}/html''', '''${CMAKE_INSTALL_PREFIX}/share/doc/salome/tui/KERNEL/docutils''')\" + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} +) diff --git a/doc/salome/gui/CMakeLists.txt b/doc/salome/gui/CMakeLists.txt index d98151fa1..8bd8df903 100755 --- a/doc/salome/gui/CMakeLists.txt +++ b/doc/salome/gui/CMakeLists.txt @@ -25,11 +25,11 @@ SET(datadir ${CMAKE_INSTALL_PREFIX}/share) SET(docdir ${datadir}/doc/salome) CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/doxyfile) -CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/static/header.html.in ${CMAKE_CURRENT_SOURCE_DIR}/static/header.html) +CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/static/header.html.in ${CMAKE_CURRENT_BINARY_DIR}/static/header.html) ADD_CUSTOM_TARGET(usr_docs ${DOXYGEN_EXECUTABLE} COMMAND ${PYTHON_EXECUTABLE} -c "import shutil, sys; shutil.rmtree(r'''${CMAKE_INSTALL_PREFIX}/share/doc/salome/gui/KERNEL''', True); shutil.copytree(r'''${CMAKE_CURRENT_BINARY_DIR}/KERNEL''', r'''${CMAKE_INSTALL_PREFIX}/share/doc/salome/gui/KERNEL'''); shutil.copy(r'''${CMAKE_CURRENT_SOURCE_DIR}/images/head.png''', r'''${CMAKE_INSTALL_PREFIX}/share/doc/salome/gui/KERNEL''')" VERBATIM WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) - +ADD_DEPENDENCIES(usr_docs html_docs) diff --git a/doc/salome/kernel_salome.dox b/doc/salome/kernel_salome.dox index d36db176a..75deb2960 100644 --- a/doc/salome/kernel_salome.dox +++ b/doc/salome/kernel_salome.dox @@ -112,6 +112,7 @@ study = salome.myStudyManager.GetStudyByName("/home/user/MyStudy.hdf") # ... \endcode +\anchor salome_myStudy \li \b myStudy Reference to the current (active) study This variable can be used to manipulate with the date of the study: @@ -296,4 +297,37 @@ name_1 = salome.generateName() # name_1 is something like "Study682" name_1 = salome.generateName("Obj") # name_1 is something like "Obj32" \endcode +\li \b GetComponentVersion() Get version of component data stored in +the study + +This function allows to obtain the version of the component data +stored in the current study. +\note This function does not provide a current version of the +component being used but that one initially stored in the study +document. + +The first parameter specifies the name of the component. If the +specified component data is not stored in the study, the result value +is "no component data". If the version of data is undefined, the +result is "unknown". + +The second parameter (\c False by default), when set to \c True, +allows to retrieve all versions of the component data stored in the +study. This is useful to check if version information is valid (the +data might be updated and/or re-stored in %SALOME of versions different +from initial one). + +\code +# get initial version of GEOM module data stored in the study +geom_version = salome.GetComponentVersion('GEOM') +# get all versions of GEOM module data stored in the study +all_geom_versions = salome.GetComponentVersion('GEOM', True) +\endcode + +This function is introduced in %SALOME 6.6.0 (it does not work with +studies created before version 6.6.0). + +\note The study should be initialized before calling this function +(see \ref salome_myStudy "salome.myStudy"). + */ diff --git a/doc/salome/tui/CMakeLists.txt b/doc/salome/tui/CMakeLists.txt index ae05910b6..51ce739b3 100755 --- a/doc/salome/tui/CMakeLists.txt +++ b/doc/salome/tui/CMakeLists.txt @@ -25,7 +25,7 @@ SET(datadir ${CMAKE_INSTALL_PREFIX}/share) SET(docdir ${datadir}/doc/salome) CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/doxyfile) -CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/static/header.html.in ${CMAKE_CURRENT_SOURCE_DIR}/static/header.html) +CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/static/header.html.in ${CMAKE_CURRENT_BINARY_DIR}/static/header.html) ADD_CUSTOM_TARGET(dev_docs ${DOXYGEN_EXECUTABLE} -u COMMAND ${DOXYGEN_EXECUTABLE} diff --git a/doc/salome/tui/doxyfile.in b/doc/salome/tui/doxyfile.in index ae335beb4..973656204 100644 --- a/doc/salome/tui/doxyfile.in +++ b/doc/salome/tui/doxyfile.in @@ -1,32 +1,53 @@ -# Doxyfile 1.4.6 +# 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 +# #--------------------------------------------------------------------------- # Project related configuration options #--------------------------------------------------------------------------- PROJECT_NAME = "SALOME KERNEL Developer" -PROJECT_NUMBER = +PROJECT_NUMBER = OUTPUT_DIRECTORY = KERNEL CREATE_SUBDIRS = NO OUTPUT_LANGUAGE = English USE_WINDOWS_ENCODING = NO BRIEF_MEMBER_DESC = YES -REPEAT_BRIEF = NO -ABBREVIATE_BRIEF = +REPEAT_BRIEF = YES +ABBREVIATE_BRIEF = ALWAYS_DETAILED_SEC = YES INLINE_INHERITED_MEMB = YES FULL_PATH_NAMES = YES -STRIP_FROM_PATH = @top_builddir@ @top_srcdir@ -STRIP_FROM_INC_PATH = +STRIP_FROM_PATH = @top_srcdir@ @top_builddir@ +STRIP_FROM_INC_PATH = SHORT_NAMES = NO JAVADOC_AUTOBRIEF = YES +QT_AUTOBRIEF = YES MULTILINE_CPP_IS_BRIEF = NO DETAILS_AT_TOP = NO INHERIT_DOCS = YES SEPARATE_MEMBER_PAGES = NO TAB_SIZE = 5 -ALIASES = +ALIASES = OPTIMIZE_OUTPUT_FOR_C = YES -OPTIMIZE_OUTPUT_JAVA = NO +OPTIMIZE_OUTPUT_JAVA = YES BUILTIN_STL_SUPPORT = @DOXYGEN_SUPPORT_STL@ DISTRIBUTE_GROUP_DOC = NO SUBGROUPING = YES @@ -48,18 +69,18 @@ CASE_SENSE_NAMES = YES HIDE_SCOPE_NAMES = NO SHOW_INCLUDE_FILES = YES INLINE_INFO = YES -SORT_MEMBER_DOCS = NO +SORT_MEMBER_DOCS = YES SORT_BRIEF_DOCS = NO SORT_BY_SCOPE_NAME = YES -GENERATE_TODOLIST = NO -GENERATE_TESTLIST = NO -GENERATE_BUGLIST = NO -GENERATE_DEPRECATEDLIST= NO -ENABLED_SECTIONS = +GENERATE_TODOLIST = YES +GENERATE_TESTLIST = YES +GENERATE_BUGLIST = YES +GENERATE_DEPRECATEDLIST= YES +ENABLED_SECTIONS = MAX_INITIALIZER_LINES = 25 SHOW_USED_FILES = NO SHOW_DIRECTORIES = NO -FILE_VERSION_FILTER = +FILE_VERSION_FILTER = #--------------------------------------------------------------------------- # configuration options related to warning and progress messages @@ -75,39 +96,41 @@ WARN_LOGFILE = log.txt #--------------------------------------------------------------------------- # configuration options related to the input files #--------------------------------------------------------------------------- -INPUT = \ - @top_srcdir@/src/DSC \ - @srcdir@/input -FILE_PATTERNS = *.dox *.idl *.cxx *.hxx *.h *.hh *.i *c *.cc @DOXYGEN_PYTHON_EXTENSION@ +INPUT = @top_srcdir@/src \ + @top_srcdir@/bin \ + @top_srcdir@/idl \ + @top_builddir@/bin \ + @srcdir@/input +FILE_PATTERNS = *.idl *.hxx *.cxx *.h *.c *.hh *.cc @DOXYGEN_PYTHON_EXTENSION@ *.doc RECURSIVE = YES -EXCLUDE = +EXCLUDE = EXCLUDE_SYMLINKS = NO -EXCLUDE_PATTERNS = -EXAMPLE_PATH = -EXAMPLE_PATTERNS = +EXCLUDE_PATTERNS = +EXAMPLE_PATH = +EXAMPLE_PATTERNS = EXAMPLE_RECURSIVE = NO -IMAGE_PATH = -INPUT_FILTER = -FILTER_PATTERNS = -FILTER_SOURCE_FILES = NO +IMAGE_PATH = @srcdir@/images +INPUT_FILTER = +FILTER_PATTERNS = +FILTER_SOURCE_FILES = YES #--------------------------------------------------------------------------- # configuration options related to source browsing #--------------------------------------------------------------------------- -SOURCE_BROWSER = NO -INLINE_SOURCES = NO +SOURCE_BROWSER = YES +INLINE_SOURCES = YES STRIP_CODE_COMMENTS = YES -REFERENCED_BY_RELATION = NO +REFERENCED_BY_RELATION = YES REFERENCES_RELATION = YES -USE_HTAGS = NO +#USE_HTAGS = NO VERBATIM_HEADERS = YES #--------------------------------------------------------------------------- # configuration options related to the alphabetical class index #--------------------------------------------------------------------------- ALPHABETICAL_INDEX = YES -COLS_IN_ALPHA_INDEX = 3 -IGNORE_PREFIX = +COLS_IN_ALPHA_INDEX = 2 +IGNORE_PREFIX = #--------------------------------------------------------------------------- # configuration options related to the HTML output @@ -120,8 +143,8 @@ HTML_FOOTER = @srcdir@/static/footer.html HTML_STYLESHEET = @srcdir@/static/doxygen.css HTML_ALIGN_MEMBERS = YES GENERATE_HTMLHELP = NO -CHM_FILE = -HHC_LOCATION = +CHM_FILE = +HHC_LOCATION = GENERATE_CHI = NO BINARY_TOC = YES TOC_EXPAND = YES @@ -139,8 +162,8 @@ LATEX_CMD_NAME = latex MAKEINDEX_CMD_NAME = makeindex COMPACT_LATEX = NO PAPER_TYPE = a4wide -EXTRA_PACKAGES = -LATEX_HEADER = +EXTRA_PACKAGES = +LATEX_HEADER = PDF_HYPERLINKS = NO USE_PDFLATEX = NO LATEX_BATCHMODE = NO @@ -153,8 +176,8 @@ GENERATE_RTF = NO RTF_OUTPUT = rtf COMPACT_RTF = NO RTF_HYPERLINKS = NO -RTF_STYLESHEET_FILE = -RTF_EXTENSIONS_FILE = +RTF_STYLESHEET_FILE = +RTF_EXTENSIONS_FILE = #--------------------------------------------------------------------------- # configuration options related to the man page output @@ -169,8 +192,8 @@ MAN_LINKS = NO #--------------------------------------------------------------------------- GENERATE_XML = NO XML_OUTPUT = xml -XML_SCHEMA = -XML_DTD = +XML_SCHEMA = +XML_DTD = XML_PROGRAMLISTING = YES #--------------------------------------------------------------------------- @@ -184,59 +207,59 @@ GENERATE_AUTOGEN_DEF = NO GENERATE_PERLMOD = NO PERLMOD_LATEX = NO PERLMOD_PRETTY = YES -PERLMOD_MAKEVAR_PREFIX = +PERLMOD_MAKEVAR_PREFIX = #--------------------------------------------------------------------------- -# Configuration options related to the preprocessor +# Configuration options related to the preprocessor #--------------------------------------------------------------------------- ENABLE_PREPROCESSING = YES MACRO_EXPANSION = YES EXPAND_ONLY_PREDEF = NO SEARCH_INCLUDES = YES -INCLUDE_PATH = -INCLUDE_FILE_PATTERNS = -PREDEFINED = -EXPAND_AS_DEFINED = +INCLUDE_PATH = +INCLUDE_FILE_PATTERNS = +PREDEFINED = +EXPAND_AS_DEFINED = SKIP_FUNCTION_MACROS = NO #--------------------------------------------------------------------------- -# Configuration::additions related to external references +# Configuration::additions related to external references #--------------------------------------------------------------------------- -TAGFILES = -GENERATE_TAGFILE = +TAGFILES = +GENERATE_TAGFILE = ALLEXTERNALS = NO EXTERNAL_GROUPS = YES PERL_PATH = /usr/bin/perl #--------------------------------------------------------------------------- -# Configuration options related to the dot tool +# Configuration options related to the dot tool #--------------------------------------------------------------------------- CLASS_DIAGRAMS = YES HIDE_UNDOC_RELATIONS = NO HAVE_DOT = YES CLASS_GRAPH = YES -COLLABORATION_GRAPH = YES -GROUP_GRAPHS = NO -UML_LOOK = YES +COLLABORATION_GRAPH = NO +GROUP_GRAPHS = YES +UML_LOOK = NO TEMPLATE_RELATIONS = YES INCLUDE_GRAPH = YES -INCLUDED_BY_GRAPH = NO +INCLUDED_BY_GRAPH = YES CALL_GRAPH = NO GRAPHICAL_HIERARCHY = YES DIRECTORY_GRAPH = YES DOT_IMAGE_FORMAT = png DOT_FONTNAME = Arial -DOT_PATH = -DOTFILE_DIRS = +DOT_PATH = +DOTFILE_DIRS = MAX_DOT_GRAPH_WIDTH = 1024 -MAX_DOT_GRAPH_HEIGHT = 1200 +MAX_DOT_GRAPH_HEIGHT = 1000 MAX_DOT_GRAPH_DEPTH = 0 DOT_TRANSPARENT = NO DOT_MULTI_TARGETS = NO -GENERATE_LEGEND = NO +GENERATE_LEGEND = YES DOT_CLEANUP = YES #--------------------------------------------------------------------------- -# Configuration::additions related to the search engine +# Configuration::additions related to the search engine #--------------------------------------------------------------------------- SEARCHENGINE = NO diff --git a/idl/SALOMEDS_Attributes.idl b/idl/SALOMEDS_Attributes.idl index fbc70d655..9941794cb 100644 --- a/idl/SALOMEDS_Attributes.idl +++ b/idl/SALOMEDS_Attributes.idl @@ -1650,6 +1650,27 @@ module SALOMEDS \return units */ string GetUnits(); + + /*! + \brief Returns list of components which data was stored + (after previous sessions) in the study. + \return list of component names + */ + StringSeq GetStoredComponents(); + + /*! + \brief Returns version of component data stored in the study + \param comp component name + \return version of stored component data + */ + string GetComponentVersion( in string comp ); + + /*! + \brief Returns all versions of component data stored in the study + \param comp component name + \return versions of stored component data + */ + StringSeq GetComponentVersions( in string comp ); }; //========================================================================== diff --git a/idl/SALOME_Component.idl b/idl/SALOME_Component.idl index 9d55e154b..4a1701ddf 100644 --- a/idl/SALOME_Component.idl +++ b/idl/SALOME_Component.idl @@ -453,6 +453,17 @@ module Engines \return an information about the given object. */ string getObjectInfo(in long studyId, in string entry); + + //! Get version of the component + /*! + This method is supposed to be implemented in all derived classes; default implementation + returns "unknown" string that means that no version information about the component is available. + \note The version of the component is stored to the study, as a part of general persistence + mechanism; once stored, version information in the study cannot be changed. + + \return string containing component's version, e.g. "1.0" + */ + string getVersion(); } ; /*! diff --git a/salome_adm/CMakeLists.txt b/salome_adm/CMakeLists.txt index 0bc8d03f1..6085559b6 100755 --- a/salome_adm/CMakeLists.txt +++ b/salome_adm/CMakeLists.txt @@ -20,9 +20,5 @@ ADD_SUBDIRECTORY(unix) ADD_SUBDIRECTORY(cmake_files) -SET(input ${CMAKE_CURRENT_SOURCE_DIR}/SALOMEconfig.ref.in) -SET(output ${CMAKE_CURRENT_BINARY_DIR}/SALOMEconfig.h) - -MESSAGE(STATUS "Creation of ${output}") -CONFIGURE_FILE(${input} ${output}) -INSTALL(FILES ${output} DESTINATION ${KERNEL_salomeinclude_HEADERS}) \ No newline at end of file +SALOME_CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/SALOMEconfig.ref.in" "${CMAKE_CURRENT_BINARY_DIR}/SALOMEconfig.h" INSTALL ${KERNEL_salomeinclude_HEADERS}) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/SALOMEconfig.ref.in DESTINATION salome_adm/unix RENAME SALOMEconfig.h.in) \ No newline at end of file diff --git a/salome_adm/cmake_files/FindPLATFORM.cmake b/salome_adm/cmake_files/FindPLATFORM.cmake index 9266320ac..fa06d0ec3 100644 --- a/salome_adm/cmake_files/FindPLATFORM.cmake +++ b/salome_adm/cmake_files/FindPLATFORM.cmake @@ -107,6 +107,10 @@ IF(WINDOWS) SET(PLATFORM_LIBS ${PLATFORM_LIBS} Ws2_32.lib) SET(PLATFORM_LIBS ${PLATFORM_LIBS} Userenv.lib) # At least for GEOM suit + IF("${CMAKE_SIZEOF_VOID_P}" EQUAL "8") # if platform is Windows 64 bit + SET(PLATFORM_CPPFLAGS "${PLATFORM_CPPFLAGS} -D_SECURE_SCL=0 -D_SECURE_SCL_THROWS=0 -D_HAS_ITERATOR_DEBUGGING=0") # To avoid runtime error during checking iterators # to be removed + SET(PLATFORM_DEFINITIONS "${PLATFORM_DEFINITIONS} -D_SECURE_SCL=0 -D_SECURE_SCL_THROWS=0 -D_HAS_ITERATOR_DEBUGGING=0") # To avoid runtime error during checking iterators + ENDIF("${CMAKE_SIZEOF_VOID_P}" EQUAL "8") ELSE(WINDOWS) # SET(PLATFORM_CPPFLAGS ${PLATFORM_CPPFLAGS} -Wparentheses) # SET(PLATFORM_CPPFLAGS ${PLATFORM_CPPFLAGS} -Wreturn-type) @@ -117,8 +121,13 @@ ELSE(WINDOWS) SET(PLATFORM_LIBS ${PLATFORM_LIBS} -ldl) ENDIF(WINDOWS) -SET(PLATFORM_CPPFLAGS "${PLATFORM_CPPFLAGS} -DSIZEOF_FORTRAN_INTEGER=4 -DSIZEOF_LONG=${CMAKE_SIZEOF_VOID_P} -DSIZEOF_INT=4") # to be removed -SET(PLATFORM_DEFINITIONS "${PLATFORM_DEFINITIONS} -DSIZEOF_FORTRAN_INTEGER=4 -DSIZEOF_LONG=${CMAKE_SIZEOF_VOID_P} -DSIZEOF_INT=4") +SET(SIZE_OF_LONG ${CMAKE_SIZEOF_VOID_P}) # set sizeof(long) the same as size of pointers, because on all memory models (EXCLUDING WINDOWS 64 bit) it is equivalent values +IF("${CMAKE_SIZEOF_VOID_P}" EQUAL "8" AND WINDOWS) # if it platform Windows 64 bit + SET(SIZE_OF_LONG "4") # set sizeof(long) to 4 byte +ENDIF("${CMAKE_SIZEOF_VOID_P}" EQUAL "8" AND WINDOWS) + +SET(PLATFORM_CPPFLAGS "${PLATFORM_CPPFLAGS} -DSIZEOF_FORTRAN_INTEGER=4 -DSIZEOF_LONG=${SIZE_OF_LONG} -DSIZEOF_INT=4") # to be removed +SET(PLATFORM_DEFINITIONS "${PLATFORM_DEFINITIONS} -DSIZEOF_FORTRAN_INTEGER=4 -DSIZEOF_LONG=${SIZE_OF_LONG} -DSIZEOF_INT=4") SET(COMPILATION_WITH_CMAKE ON) diff --git a/salome_adm/cmake_files/SalomeMacros.cmake b/salome_adm/cmake_files/SalomeMacros.cmake index b10f468db..b96926dff 100755 --- a/salome_adm/cmake_files/SalomeMacros.cmake +++ b/salome_adm/cmake_files/SalomeMacros.cmake @@ -91,7 +91,7 @@ ENDMACRO(PARSE_ARGUMENTS) #---------------------------------------------------------------------------- # SALOME_INSTALL_SCRIPTS is a macro useful for installing scripts. # -# USAGE: SALOME_INSTALL_SCRIPTS(file_list path [DEF_PERMS]) +# USAGE: SALOME_INSTALL_SCRIPTS(file_list path [WORKING_DIRECTORY dir] [DEF_PERMS]) # # ARGUMENTS: # file_list: IN : list of files to be installed. This list should be quoted. @@ -102,13 +102,17 @@ ENDMACRO(PARSE_ARGUMENTS) # only OWNER_WRITE, OWNER_READ, GROUP_READ, and WORLD_READ. #---------------------------------------------------------------------------- MACRO(SALOME_INSTALL_SCRIPTS file_list path) - PARSE_ARGUMENTS(SALOME_INSTALL_SCRIPTS "" "DEF_PERMS" ${ARGN}) - SET(PERMS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ) + PARSE_ARGUMENTS(SALOME_INSTALL_SCRIPTS "WORKING_DIRECTORY" "DEF_PERMS" ${ARGN}) + SET(PERMS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ) IF(NOT SALOME_INSTALL_SCRIPTS_DEF_PERMS) SET(PERMS ${PERMS} OWNER_EXECUTE GROUP_EXECUTE WORLD_EXECUTE) ENDIF(NOT SALOME_INSTALL_SCRIPTS_DEF_PERMS) FOREACH(file ${file_list}) - INSTALL(FILES ${file} DESTINATION ${path} PERMISSIONS ${PERMS}) + SET(PREFIX "") + IF(SALOME_INSTALL_SCRIPTS_WORKING_DIRECTORY) + SET(PREFIX "${SALOME_INSTALL_SCRIPTS_WORKING_DIRECTORY}/") + ENDIF(SALOME_INSTALL_SCRIPTS_WORKING_DIRECTORY) + INSTALL(FILES ${PREFIX}${file} DESTINATION ${path} PERMISSIONS ${PERMS}) GET_FILENAME_COMPONENT(ext ${file} EXT) IF(ext STREQUAL .py) INSTALL(CODE "MESSAGE(STATUS \"py compiling ${CMAKE_INSTALL_PREFIX}/${path}/${file}\")") diff --git a/salome_adm/cmake_files/am2cmake.py b/salome_adm/cmake_files/am2cmake.py index 69d723fbc..afb446bb0 100644 --- a/salome_adm/cmake_files/am2cmake.py +++ b/salome_adm/cmake_files/am2cmake.py @@ -619,7 +619,7 @@ class CMakeFile(object): INCLUDE(${GEOM_ROOT_DIR}/adm_local/cmake_files/FindGEOM.cmake) INCLUDE(${MED_ROOT_DIR}/adm_local/cmake_files/FindMED.cmake) INCLUDE(${SMESH_ROOT_DIR}/adm_local/cmake_files/FindSMESH.cmake) - INCLUDE(${CMAKE_SOURCE_DIR}/adm_local/cmake_files/FindBLSURF.cmake) + INCLUDE(${CMAKE_SOURCE_DIR}/adm_local/cmake_files/FindCADSURF.cmake) """) pass if self.module in ["ghs3dplugin", "hexoticplugin"]: @@ -656,6 +656,11 @@ class CMakeFile(object): INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindSPHINX.cmake) """) pass + if self.module == "jobmanager": + newlines.append(""" + INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindSPHINX.cmake) + """) + pass if self.module == "hxx2salome": newlines.append(""" SET(MED_ROOT_DIR $ENV{MED_ROOT_DIR}) @@ -797,9 +802,10 @@ class CMakeFile(object): pass # -- newlines.append(""" - set(VERSION 6.5.0) - set(SHORT_VERSION 6.5) - set(XVERSION 0x060500) + set(VERSION 7.0.0) + set(SHORT_VERSION 7.0) + set(XVERSION 0x070000) + set(VERSION_DEV 1) """) pass # -- @@ -1113,7 +1119,7 @@ class CMakeFile(object): ) ''') self.files.append("static/header.html.in") - elif self.root[-len(mod):] == upmod and operator.contains(self.root, 'doc') or mod in ['kernel', 'gui', 'geom', 'med', 'smesh', 'visu'] and self.root[-len('tui'):] == 'tui': + elif self.root[-len(mod):] == upmod and operator.contains(self.root, 'doc') or mod in ['kernel', 'gui', 'geom', 'med', 'smesh', 'visu', 'blsurfplugin'] and self.root[-len('tui'):] == 'tui' or operator.contains(self.root, 'doc') and mod in ['pyhello']: newlines.append(r''' SET(top_builddir ${CMAKE_BINARY_DIR} @@ -1134,7 +1140,8 @@ class CMakeFile(object): ${datadir}/doc/salome ) ''') - self.files.append("static/header.html.in") + if mod not in ['blsurfplugin']: + self.files.append("static/header.html.in") if mod in ['geom', 'smesh', 'visu','netgenplugin','blsurfplugin','hexoticplugin','ghs3dplugin',"ghs3dprlplugin"] and self.root[-len(mod):] == upmod: self.files.append("static/header_py.html.in") @@ -1213,7 +1220,7 @@ class CMakeFile(object): WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} )"""%(input, doc_gui_destination, doc_source, doc_gui_destination, head_source, doc_gui_destination)) from os import path - if mod in ['geom', 'smesh', 'visu', 'netgenplugin','blsurfplugin','hexoticplugin','ghs3dplugin','ghs3dprlplugin'] and self.root[-len(mod):] == upmod and operator.contains(self.root, 'doc'): + if mod in ['geom', 'smesh', 'visu', 'netgenplugin','blsurfplugin','hexoticplugin','ghs3dplugin','ghs3dprlplugin','pyhello'] and self.root[-len(mod):] == upmod and operator.contains(self.root, 'doc') or mod in ['pyhello'] and operator.contains(self.root, 'doc'): ign = r"""'*usr_docs*', '*CMakeFiles*', '*.cmake', 'doxyfile*', '*.vcproj', 'static', 'Makefile*'""" if mod in ['geom', 'smesh']: if mod == 'geom': @@ -1236,19 +1243,20 @@ class CMakeFile(object): VERBATIM WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} )"""%(prepare_generating_doc_src, prepare_generating_doc_src, tmp, upmod, tmp, tmp, input, tmp, doc_gui_destination, doc_gui_destination, ign, head_source, doc_gui_destination)) + newlines.append(r"""ADD_DEPENDENCIES(usr_docs html_docs)""") else: config_f = "" if mod in ['netgenplugin','blsurfplugin','hexoticplugin','ghs3dplugin', "ghs3dprlplugin"] : - config_f = "doxyfile_py" - else: - config_f = "doxyfile_idl" - newlines.append("""\t ADD_CUSTOM_TARGET(usr_docs ${DOXYGEN_EXECUTABLE} %s + config_f = "${DOXYGEN_EXECUTABLE} doxyfile_py" + elif mod not in ['pyhello']: + config_f = "${DOXYGEN_EXECUTABLE} doxyfile_idl" + newlines.append("""\t ADD_CUSTOM_TARGET(usr_docs %s COMMAND ${DOXYGEN_EXECUTABLE} doxyfile COMMAND ${PYTHON_EXECUTABLE} -c "import shutil, sys; shutil.rmtree(r'''%s''',True); shutil.copytree(r'''${CMAKE_CURRENT_BINARY_DIR}''',r'''%s''', ignore=shutil.ignore_patterns(%s)); shutil.copy(r'''%s''',r'''%s''')" VERBATIM WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} )"""%(config_f, doc_gui_destination, doc_gui_destination, ign, head_source, doc_gui_destination)) - elif mod == 'yacs' and operator.contains(self.root, upmod + '_SRC'+path.sep+'doc'): + elif mod in ['yacs', 'jobmanager'] and operator.contains(self.root, upmod + '_SRC'+path.sep+'doc'): from sys import platform params = ''; if platform == "win32": @@ -1266,21 +1274,19 @@ class CMakeFile(object): params = '-Q'; ext = "bat" prf = "call" + cmd = "STRING(REPLACE \"/\" \"\\\\\" SCR" else: ext = "sh" prf = ". " + cmd = "SET(SCR" doc_gui_destination = "${CMAKE_INSTALL_PREFIX}/share/doc/salome/tui/%s/docutils"%(upmod) scr = self.writeEnvScript(upmod) newlines.append(r""" - IF(WINDOWS) - STRING(REPLACE "/" "\\" SCR "%s") - ELSE(WINDOWS) - SET(SCR "%s") - ENDIF(WINDOWS) + %s "%s") FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/env_s.%s "${SCR}") - ADD_CUSTOM_TARGET(html_docs %s ${CMAKE_CURRENT_BINARY_DIR}/env_s.%s && ${SPHINX_EXECUTABLE} %s -c ${CMAKE_BINARY_DIR}/doc/docutils -W -b html ${ALLSPHINXOPTS} html + ADD_CUSTOM_TARGET(html_docs %s ${CMAKE_CURRENT_BINARY_DIR}/env_s.%s && ${SPHINX_EXECUTABLE} %s -c ${CMAKE_BINARY_DIR}/doc/docutils -b html ${ALLSPHINXOPTS} html COMMAND ${PYTHON_EXECUTABLE} -c \"import shutil\;shutil.rmtree('''%s''', True)\;shutil.copytree('''${CMAKE_CURRENT_BINARY_DIR}/html''', '''%s''')\" - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})"""%(scr,scr,ext,prf,ext,params, doc_gui_destination, doc_gui_destination)) + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})"""%(cmd, scr, ext, prf, ext, params, doc_gui_destination, doc_gui_destination)) @@ -1290,7 +1296,7 @@ class CMakeFile(object): # -- upmod = self.module.upper() - if mod in ['kernel', 'gui', 'med', 'smesh', 'visu'] and self.root[-len('tui'):] == 'tui': + if mod in ['kernel', 'gui', 'med', 'smesh', 'visu', 'blsurfplugin'] and self.root[-len('tui'):] == 'tui': if mod == 'kernel': tmp = """\tADD_CUSTOM_TARGET(dev_docs ${DOXYGEN_EXECUTABLE} -u COMMAND ${DOXYGEN_EXECUTABLE} @@ -1301,14 +1307,15 @@ class CMakeFile(object): if mod == 'visu': tmp1= r"""\n COMMAND ${PYTHON_EXECUTABLE} -c "from shutil import copy; copy(r'''${CMAKE_CURRENT_SOURCE_DIR}/images/visuscreen.png''', r'''%s''')" """%(doc_tui_destination) elif mod == 'smesh': - extra_srcdir = "${CMAKE_CURRENT_SOURCE_DIR}/extra" - tmp1= """\n COMMAND ${PYTHON_EXECUTABLE} -c "from shutil import copy; copy(r'''${CMAKE_CURRENT_SOURCE_DIR}/images/smeshscreen.png''', r'''%s'''); copy(r'''%s/AddNetgenInSalome2.pdf''', r'''%s'''); copy(r'''%s/PluginMeshers.html''', r'''%s''')" - COMMAND ${PYTHON_EXECUTABLE} -c "from shutil import copy; copy(r'''%s/AddNetgenInSalome2.ps''', r'''%s'''); copy(r'''%s/AddNetgenInSalome2.sxw''', r'''%s''')" """%(doc_tui_destination, extra_srcdir,doc_destination, extra_srcdir,doc_destination, extra_srcdir,doc_destination,extra_srcdir,doc_destination) + tmp1= """\n COMMAND ${PYTHON_EXECUTABLE} -c "from shutil import copy; copy(r'''${CMAKE_CURRENT_SOURCE_DIR}/images/smeshscreen.png''', r'''%s''')" """%(doc_tui_destination) else: tmp1="" doc_source = "${CMAKE_CURRENT_BINARY_DIR}/%s"%(upmod) + inst_head_command="" + if mod not in ['blsurfplugin']: + inst_head_command = "; shutil.copy(r'''%s''', r'''%s''')"%(head_source, doc_tui_destination) newlines.append(tmp + """ - COMMAND ${PYTHON_EXECUTABLE} -c "import shutil, sys; shutil.rmtree(r'''%s''', True); shutil.copytree(r'''%s''', r'''%s'''); shutil.copy(r'''%s''', r'''%s''')" """%(doc_tui_destination, doc_source, doc_tui_destination, head_source, doc_tui_destination) + tmp1 + """ + COMMAND ${PYTHON_EXECUTABLE} -c "import shutil, sys; shutil.rmtree(r'''%s''', True); shutil.copytree(r'''%s''', r'''%s''')%s" """%(doc_tui_destination, doc_source, doc_tui_destination, inst_head_command) + tmp1 + """ VERBATIM WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} )""") @@ -1923,7 +1930,7 @@ class CMakeFile(object): ENDIF(WINDOWS) ''') # -- - if self.module in ["geom", "med", "hexoticplugin"]: + if self.module in ["geom", "med", "hexoticplugin", "blsurfplugin"]: newlines.append(r''' SET(var ${var} -I${CMAKE_CURRENT_SOURCE_DIR}) SET(var ${var} -I${CMAKE_CURRENT_BINARY_DIR}) @@ -2443,70 +2450,61 @@ class CMakeFile(object): f.close() return - def writeEnvScript(self, upmod): - from sys import platform, version_info - p_version = """%s.%s"""%(version_info[0],version_info[1]) - python_path ="PYTHONPATH" - path = "" - begin = "" - end = "" - delim = "" - cmd = "" - pdir = "" - omni = "" - omni_py = "" - if platform == "win32" : - path = "PATH" - begin = "%" - end = "%" - delim = ";" - cmd = "@SET " - omni = "/x86_win32" - omni_py = "/python" - pdir = "PDIR" + def writeEnvScript(self, upmod, buildmod=True): + import os, sys + p_version = sys.version[:3] + python_path = "PYTHONPATH" + root_dir = "%s_ROOT_DIR" % upmod + if sys.platform == "win32": + script_line = '@SET %(var)s=%(val)s;%%%(var)s%%\n' + var_line = '%%%s%%' + lib_path = "PATH" + omni = "x86_win32" + omni_py = "python" + pass else: - path = "LD_LIBRARY_PATH" - begin = "\${" - end = "}" - delim = ":" - cmd = "export " - omni_py = "/python" + p_version + "/" + "site-packages" - pdir = "INST_ROOT" - - - path_ = begin + path + end - root_dir_ = begin + upmod + "_ROOT_DIR" + end - python_path_ = begin + python_path + end - _python_path_ = delim + python_path_+ "\n" - _path_ = delim + path_+ "\n" - _pdir = begin + pdir + end - - - script = cmd + " " + python_path + "=" + root_dir_+"/lib/python" + p_version \ - + "/site-packages/salome" + _python_path_ - - script = script + cmd + " " + python_path + "=" + root_dir_+"/bin/salome" + \ - _python_path_ - - script = script + cmd + " "+ path + "=" + root_dir_+"/lib/salome"+ _path_ - + script_line = 'export %(var)s=%(val)s:\$%(var)s\n' + var_line = '\${%s}' + lib_path = "LD_LIBRARY_PATH" + omni = "" + omni_py = "/".join( ["python%s"%p_version , "site-packages"] ) + pass + # + script = "" + # + if buildmod: + script += script_line % { 'var':python_path, 'val':"/".join( ["${CMAKE_INSTALL_PREFIX}", "lib", "python%s"%p_version, "site-packages", "salome"] ) } + script += script_line % { 'var':python_path, 'val':"/".join( ["${CMAKE_INSTALL_PREFIX}", "bin", "salome"] ) } + script += script_line % { 'var':lib_path, 'val':"/".join( ["${CMAKE_INSTALL_PREFIX}", "lib", "salome"] ) } + pass + else: + script += script_line % { 'var':python_path, 'val':"/".join( [var_line % root_dir, "lib", "python%s"%p_version, "site-packages", "salome"] ) } + script += script_line % { 'var':python_path, 'val':"/".join( [var_line % root_dir, "bin", "salome"] ) } + script += script_line % { 'var':lib_path, 'val':"/".join( [var_line % root_dir, "lib", "salome"] ) } + pass + # if upmod == "KERNEL" : - script = script + cmd + " " + python_path + "=" + _pdir + \ - "/omniORB-4.1.5/lib" + omni + _python_path_ - - script = script + cmd + " " + python_path + "=" + _pdir + \ - "/omniORB-4.1.5/lib" + omni_py + _python_path_ - - script = script + cmd + " "+ path + "=" + _pdir+ "/omniORB-4.1.5/lib" + \ - omni + _path_ - + script += "\n" + if omni: + script += script_line % { 'var':python_path, 'val':"/".join( ["${OMNIORB_ROOT_USER}", "lib", omni] ) } + script += script_line % { 'var':lib_path, 'val':"/".join( ["${OMNIORB_ROOT_USER}", "lib", omni] ) } + pass + else: + script += script_line % { 'var':python_path, 'val':"/".join( ["${OMNIORB_ROOT_USER}", "lib"] ) } + script += script_line % { 'var':lib_path, 'val':"/".join( ["${OMNIORB_ROOT_USER}", "lib"] ) } + pass + script += script_line % { 'var':python_path, 'val':"/".join( ["${OMNIORB_ROOT_USER}", "lib", omni_py] ) } + pass + # if upmod == "GEOM" : - script = self.writeEnvScript("KERNEL") + script - script = self.writeEnvScript("GUI") + script - + script = self.writeEnvScript("KERNEL", False) + "\n" + script + script = self.writeEnvScript("GUI", False) + "\n" + script + pass + # if upmod == "SMESH" : - script = self.writeEnvScript("GEOM") + script - + script = self.writeEnvScript("GEOM", False) + "\n" + script + pass + return script pass diff --git a/salome_adm/cmake_files/prepare_generating_doc.py b/salome_adm/cmake_files/prepare_generating_doc.py index fb218237a..8a88fec81 100755 --- a/salome_adm/cmake_files/prepare_generating_doc.py +++ b/salome_adm/cmake_files/prepare_generating_doc.py @@ -18,12 +18,55 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -import sys, re -outfile = open(sys.argv[1], 'wb') -isCom = False -for line in open(sys.argv[2], 'rb').readlines(): - if re.match('class '+sys.argv[3]+'DC', line): +# ... +# Usage: prepare_generating_doc.py +# ... +# 1. myClassDC is replaced by myClass +# 2. all methods of myClassDC become global methods of Python package +# ... +# myClass is passed as command line argument +# ... + +import os, sys, re + +# check command line +if len( sys.argv ) < 4: + sys.exit("Usage: %s " % os.path.basename(sys.argv[0])) + +# open input file +try: + infile = open(sys.argv[2], 'rb') +except: + sys.exit("File %s is not found" % sys.argv[2]) + pass + +# open output file +try: + outfile = open(sys.argv[1], 'wb') +except: + sys.exit("File %s cannot be opened for write" % sys.argv[1]) + pass + +# parse input file + +isCom = False +isShift = False + +for line in infile.readlines(): + dc_class = sys.argv[3] + dc_class_dc = dc_class+'DC' + + if isShift and ( re.match('^class\s+', line) or re.match('^def\s+', line) ): + # stop shifting lines as soon as myClassDC definition is over + isShift = False + pass + if re.match('class\s+%s' % dc_class_dc, line): + # start shifting lines + isShift = True + # omit this line (to remove myClassDC from the package) continue + + # process documentation n = line.find('"""') n1 = line[(n+2):].find('"""') if (n > -1) and (n1 > -1): @@ -31,13 +74,26 @@ for line in open(sys.argv[2], 'rb').readlines(): if isCom: if n > -1: isCom = False + pass continue else: if n > -1: isCom = True - continue - line = re.sub(r'^\s+#', '#', line) - line = re.sub(r'^\s+def', 'def', line) - line = re.sub(sys.argv[3]+'DC', sys.argv[3], line) + continue + pass + + # replacements + if isShift: + line = re.sub(r'^\s+#', '#', line) + line = re.sub(r'^\s+def', 'def', line) + pass + line = re.sub(dc_class_dc, dc_class, line) + + # write resulting line outfile.write(line) -outfile.close() \ No newline at end of file + + pass # end of for + +# close input and output files +infile.close() +outfile.close() diff --git a/salome_adm/unix/CMakeLists.txt b/salome_adm/unix/CMakeLists.txt new file mode 100755 index 000000000..a0b5ec4d1 --- /dev/null +++ b/salome_adm/unix/CMakeLists.txt @@ -0,0 +1,35 @@ +# Copyright (C) 2012 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 +# + +ADD_SUBDIRECTORY(config_files) + +SET(DEPRECATED_FILES + DEPRECATED/F77config.h.in + DEPRECATED/sstream.in + DEPRECATED/envScript.in + DEPRECATED/depend.in + DEPRECATED/make_commence.in + DEPRECATED/make_conclude.in + DEPRECATED/make_module.in + DEPRECATED/make_omniorb.in +) + +# The deprecated files are deprecated for the KERNEL but not for the +# related modules (GUI, MED, ...), for now. Some files have to be installed. +INSTALL(FILES ${DEPRECATED_FILES} DESTINATION salome_adm/unix) diff --git a/salome_adm/unix/config_files/CMakeLists.txt b/salome_adm/unix/config_files/CMakeLists.txt new file mode 100755 index 000000000..e7add33e2 --- /dev/null +++ b/salome_adm/unix/config_files/CMakeLists.txt @@ -0,0 +1,84 @@ +# Copyright (C) 2012 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 +# + +# The deprecated files are deprecated for the KERNEL but not for the +# related modules (GUI, MED, ...). Some files have to be installed. +SET(DEPRECATED_FILES + DEPRECATED/ac_cc_warnings.m4 + DEPRECATED/ac_cxx_bool.m4 + DEPRECATED/ac_cxx_mutable.m4 + DEPRECATED/ac_cxx_partial_specialization.m4 + DEPRECATED/ac_cxx_typename.m4 + DEPRECATED/check_mico.m4 + DEPRECATED/check_pthreads.m4 + DEPRECATED/config.sub + DEPRECATED/config.guess + DEPRECATED/install-sh + DEPRECATED/libtool.m4 + DEPRECATED/ltconfig + DEPRECATED/ltmain.sh + DEPRECATED/check_Salome.m4 + DEPRECATED/check_java.m4 + DEPRECATED/missing + DEPRECATED/mkinstalldirs +) + +SET(m4_DATA + ac_cxx_depend_flag.m4 + ac_cxx_have_sstream.m4 + ac_cxx_namespaces.m4 + ac_cxx_option.m4 + ac_cxx_template_options.m4 + ac_cxx_use_std_iostream.m4 + ac_cxx_warnings.m4 + ac_linker_options.m4 + ac_check_sizeof_fortran.m4 + acx_pthread.m4 + check_Kernel.m4 + check_boost.m4 + check_cas.m4 + check_corba.m4 + check_cppunit.m4 + check_f77.m4 + check_calcium.m4 + check_hdf5.m4 + check_htmlgen.m4 + check_sphinx.m4 + check_lam.m4 + check_libbatch.m4 + check_mpi.m4 + check_openmpi.m4 + check_mpich.m4 + check_omniorb.m4 + check_sockets.m4 + check_swig.m4 + check_vtk.m4 + check_withihm.m4 + enable_pthreads.m4 + production.m4 + pyembed.m4 + python.m4 + check_libxml.m4 + check_paco++.m4 + local_install.m4 + hack_libtool.m4 + check_tbb.m4 +) +INSTALL(FILES ${DEPRECATED_FILES} DESTINATION salome_adm/unix/config_files/DEPRECATED) +INSTALL(FILES ${m4_DATA} DESTINATION salome_adm/unix/config_files) diff --git a/salome_adm/unix/config_files/check_cas.m4 b/salome_adm/unix/config_files/check_cas.m4 index 7646fd377..98fa0bc5d 100644 --- a/salome_adm/unix/config_files/check_cas.m4 +++ b/salome_adm/unix/config_files/check_cas.m4 @@ -240,11 +240,11 @@ else CAS_OCAF="$CAS_LDPATH -lPTKernel -lTKernel -lTKCDF -lTKLCAF -lTKPCAF -lTKStdSchema" CAS_OCAFVIS="$CAS_LDPATH -lTKCAF -lTKPLCAF -lTKPShape -lTKStdLSchema -lTKShapeSchema" - if test -f $CASROOT/$casdir/lib/libStdPlugin.so ; then + if test -f ${CAS_LIBDIR}/libStdPlugin.so ; then # standard plugin library libStdPlugin has been added in CASCADE 5.2.3 CAS_STDPLUGIN="StdPlugin" CAS_OCAFVIS="$CAS_OCAFVIS -lStdPlugin -lStdLPlugin" - elif test -f $CASROOT/$casdir/lib/libTKStdSchema.so ; then + elif test -f ${CAS_LIBDIR}/libTKStdSchema.so ; then # standard plugin has been renamed in CASCADE 6.5 CAS_STDPLUGIN=TKStdSchema CAS_OCAFVIS="$CAS_OCAFVIS -lTKStdSchema -lTKStdLSchema" diff --git a/src/Container/Component_i.cxx b/src/Container/Component_i.cxx index 3e77256aa..ed5b16b6d 100644 --- a/src/Container/Component_i.cxx +++ b/src/Container/Component_i.cxx @@ -1105,3 +1105,20 @@ void Engines_Component_i::setContainerName() name[slash]='_'; _containerName=name; } + +//============================================================================= +/*! + \brief Get version of the component + + This method is supposed to be implemented in all derived classes; default implementation + returns empty string that means that no version information about the component is available. + + \note The version of the component is stored to the study, as a part of general persistence + mechanism; once stored, version information in the study cannot be changed. + + \return string containing component's version, e.g. "1.0" +*/ +char* Engines_Component_i::getVersion() +{ + return CORBA::string_dup( "" ); +} diff --git a/src/Container/SALOME_ComponentPy.py b/src/Container/SALOME_ComponentPy.py index 55ec0ff55..66c9de634 100755 --- a/src/Container/SALOME_ComponentPy.py +++ b/src/Container/SALOME_ComponentPy.py @@ -314,3 +314,9 @@ class SALOME_ComponentPy_i (Engines__POA.EngineComponent): def getObjectInfo(self, studyId, entry): return "" + #------------------------------------------------------------------------- + + def getVersion(self): + return "" # empty string means "unknown" version + + pass # end of SALOME_ComponentPy_i diff --git a/src/Container/SALOME_Component_i.hxx b/src/Container/SALOME_Component_i.hxx index 94fd62ce8..3581cd9d2 100644 --- a/src/Container/SALOME_Component_i.hxx +++ b/src/Container/SALOME_Component_i.hxx @@ -120,6 +120,9 @@ public: virtual bool hasObjectInfo() { return false; } virtual char* getObjectInfo(CORBA::Long studyId, const char* entry) { return CORBA::string_dup(""); } + // Version information + virtual char* getVersion(); + // --- local C++ methods PortableServer::ObjectId * getId(); diff --git a/src/Container/SALOME_ContainerManager.cxx b/src/Container/SALOME_ContainerManager.cxx index a513af413..3a6cebdf7 100644 --- a/src/Container/SALOME_ContainerManager.cxx +++ b/src/Container/SALOME_ContainerManager.cxx @@ -36,6 +36,9 @@ #include #include +#include +#include CORBA_CLIENT_HEADER(SALOME_Session) + #ifdef WNT #include #define getpid _getpid @@ -187,6 +190,17 @@ void SALOME_ContainerManager::Shutdown() void SALOME_ContainerManager::ShutdownContainers() { MESSAGE("ShutdownContainers"); + + SALOME::Session_var session = SALOME::Session::_nil(); + CORBA::Long pid = 0; + CORBA::Object_var objS = _NS->Resolve("/Kernel/Session"); + if (!CORBA::is_nil(objS)) + { + session = SALOME::Session::_narrow(objS); + if (!CORBA::is_nil(session)) + pid = session->getPID(); + } + bool isOK; isOK = _NS->Change_Directory("/Containers"); if( isOK ){ @@ -199,7 +213,7 @@ void SALOME_ContainerManager::ShutdownContainers() try { Engines::Container_var cont=Engines::Container::_narrow(obj); - if(!CORBA::is_nil(cont)) + if(!CORBA::is_nil(cont) && pid != cont->getPID()) lstCont.push_back((*iter)); } catch(const CORBA::Exception& e) diff --git a/src/DSC/DSC_Python/calcium.i b/src/DSC/DSC_Python/calcium.i index 29a74ffab..5e7e7de73 100644 --- a/src/DSC/DSC_Python/calcium.i +++ b/src/DSC/DSC_Python/calcium.i @@ -888,6 +888,7 @@ int cp_cd(Superv_Component_i *component,char *instanceName); int cp_een(Superv_Component_i *component,int dep,float t,int n,char *nom,int nval,int *eval); int cp_edb(Superv_Component_i *component,int dep,double t,int n,char *nom,int nval,double *eval); int cp_ere(Superv_Component_i *component,int dep,float t,int n,char *nom,int nval,float *eval); +int cp_erd(Superv_Component_i *component,int dep,float t,int n,char *nom,int nval,float *eval); int cp_ecp(Superv_Component_i *component,int dep,float t,int n,char *nom,int nval,float *ecpval); int cp_elo(Superv_Component_i *component,int dep,float t,int n,char *nom,int nval,int *eval); int cp_ech(Superv_Component_i *component,int dep,float t,int n,char *nom,int nval,char** eval,int strSize); @@ -898,6 +899,7 @@ int cp_eln(Superv_Component_i *component,int dep,float t,int n,char *nom,int nv int cp_len(Superv_Component_i *component,int dep,float *ti,float *tf,int *niter,char *nom,int nmax,int *nval,int *lval); int cp_ldb(Superv_Component_i *component,int dep,double *ti,double *tf,int *niter,char *nom,int nmax,int *nval,double *lval); int cp_lre(Superv_Component_i *component,int dep,float *ti,float *tf,int *niter,char *nom,int nmax,int *nval,float *lval); +int cp_lrd(Superv_Component_i *component,int dep,float *ti,float *tf,int *niter,char *nom,int nmax,int *nval,float *lval); int cp_lcp(Superv_Component_i *component,int dep,float *ti,float *tf,int *niter,char *nom,int nmax,int *nval,float *lcpval); int cp_llo(Superv_Component_i *component,int dep,float *ti,float *tf,int *niter,char *nom,int nmax,int *nval,int *lval); int cp_lch(Superv_Component_i *component,int dep,float *ti,float *tf,int *niter,char *nom,int nmax,int *nval,char** lval,int strSize); diff --git a/src/DSC/DSC_User/Datastream/Calcium/CalciumC.c b/src/DSC/DSC_User/Datastream/Calcium/CalciumC.c index 24a766e73..105c2a93b 100644 --- a/src/DSC/DSC_User/Datastream/Calcium/CalciumC.c +++ b/src/DSC/DSC_User/Datastream/Calcium/CalciumC.c @@ -120,12 +120,16 @@ void ecp_lch_free (char* * data) { \ /*REVERIFIER MAINTENANT 0 COPY avec int2integer*/ CALCIUM_EXT_LECT_INTERFACE_C_(len,float,int,int2integer,); CALCIUM_EXT_LECT_INTERFACE_C_(lre,float,float,float,); +/*Permet d'envoyer/recevoir des réels sur un port Double */ +CALCIUM_EXT_LECT_INTERFACE_C_(lrd,float ,float ,float2double,); CALCIUM_EXT_LECT_INTERFACE_C_(ldb,double,double,double,); + CALCIUM_EXT_LECT_INTERFACE_C_(llo,float,int,bool,); CALCIUM_EXT_LECT_INTERFACE_C_(lcp,float,float,cplx,); /* CALCIUM_EXT_LECT_INTERFACE_C_(lch,float,char,STAR[]); */ + /**************************************/ /* INTERFACES DE LECTURE AVEC RECOPIE */ /**************************************/ @@ -204,7 +208,10 @@ CALCIUM_LECT_INTERFACE_C_(llg,float ,int,long ,long2integer,,); CALCIUM_LECT_INTERFACE_C_(lln,float ,int,long ,long,,); CALCIUM_LECT_INTERFACE_C_(lre,float ,int,float ,float,,); +/*Permet d'envoyer/recevoir des réels sur un port Double */ +CALCIUM_LECT_INTERFACE_C_(lrd,float ,int,float ,float2double,,); CALCIUM_LECT_INTERFACE_C_(ldb,double,int,double ,double,,); + CALCIUM_LECT_INTERFACE_C_(llo,float ,int,int ,bool,,); CALCIUM_LECT_INTERFACE_C_(lcp,float ,int,float ,cplx,,); #define STAR * @@ -222,6 +229,7 @@ CALCIUM_LECT_INTERFACE_C_(lin_fort_,float ,cal_int,int ,int2integer,,); CALCIUM_LECT_INTERFACE_C_(llg_fort_,float ,cal_int,long ,long2integer,,); CALCIUM_LECT_INTERFACE_C_(lre_fort_,float ,cal_int,float ,float,,); +CALCIUM_LECT_INTERFACE_C_(lrd_fort_,float ,cal_int,float ,float2double,,); CALCIUM_LECT_INTERFACE_C_(ldb_fort_,double,cal_int,double ,double,,); CALCIUM_LECT_INTERFACE_C_(llo_fort_,float ,cal_int,int ,bool,,); /*int pour bool ou cal_int */ CALCIUM_LECT_INTERFACE_C_(lcp_fort_,float ,cal_int,float ,cplx,,); @@ -305,7 +313,10 @@ CALCIUM_ECR_INTERFACE_C_(een,float ,int,int ,int2integer,,); sinon problème de conversion de 64bits vers 32bits */ CALCIUM_ECR_INTERFACE_C_(elg,float ,int,long ,long2integer,,); CALCIUM_ECR_INTERFACE_C_(ere,float ,int,float ,float,,); +/*Permet d'envoyer/recevoir des réels sur un port Double */ +CALCIUM_ECR_INTERFACE_C_(erd,float ,int,float ,float2double,,); CALCIUM_ECR_INTERFACE_C_(edb,double,int,double,double,,); + CALCIUM_ECR_INTERFACE_C_(elo,float ,int,int ,bool,,); CALCIUM_ECR_INTERFACE_C_(ecp,float ,int,float ,cplx,,); CALCIUM_ECR_INTERFACE_C_(ech,float ,int,char ,str,STAR,LCH_LAST_PARAM ); @@ -321,6 +332,7 @@ CALCIUM_ECR_INTERFACE_C_(een_fort_,float ,cal_int,cal_int,integer,,); CALCIUM_ECR_INTERFACE_C_(elg_fort_,float ,cal_int,long ,long2integer,,); CALCIUM_ECR_INTERFACE_C_(ein_fort_,float ,cal_int,int ,int2integer,,); CALCIUM_ECR_INTERFACE_C_(ere_fort_,float ,cal_int,float ,float,,); +CALCIUM_ECR_INTERFACE_C_(erd_fort_,float ,cal_int,float ,float2double,,); CALCIUM_ECR_INTERFACE_C_(edb_fort_,double,cal_int,double,double,,); CALCIUM_ECR_INTERFACE_C_(elo_fort_,float ,cal_int,int ,bool,,); CALCIUM_ECR_INTERFACE_C_(ecp_fort_,float ,cal_int,float ,cplx,,); diff --git a/src/DSC/DSC_User/Datastream/Calcium/CalciumCInterface.cxx b/src/DSC/DSC_User/Datastream/Calcium/CalciumCInterface.cxx index a9974edcf..107e5f479 100644 --- a/src/DSC/DSC_User/Datastream/Calcium/CalciumCInterface.cxx +++ b/src/DSC/DSC_User/Datastream/Calcium/CalciumCInterface.cxx @@ -66,6 +66,9 @@ CALCIUM_C2CPP_INTERFACE_CXX_(long2integer, integer, long,); CALCIUM_C2CPP_INTERFACE_CXX_(float,float,float, ); CALCIUM_C2CPP_INTERFACE_CXX_(double,double,double,); + +CALCIUM_C2CPP_INTERFACE_CXX_(float2double,double,float, ); + /* Fonnctionne mais essai suivant pour simplification de Calcium.c CALCIUM_C2CPP_INTERFACE_(bool,bool,);*/ CALCIUM_C2CPP_INTERFACE_CXX_(bool,bool,int,); CALCIUM_C2CPP_INTERFACE_CXX_(cplx,cplx,float,); diff --git a/src/DSC/DSC_User/Datastream/Calcium/CalciumCInterface.hxx b/src/DSC/DSC_User/Datastream/Calcium/CalciumCInterface.hxx index e6eca1ae3..84e117aba 100644 --- a/src/DSC/DSC_User/Datastream/Calcium/CalciumCInterface.hxx +++ b/src/DSC/DSC_User/Datastream/Calcium/CalciumCInterface.hxx @@ -80,6 +80,9 @@ CALCIUM_C2CPP_INTERFACE_HXX_(long2integer,integer, long,); CALCIUM_C2CPP_INTERFACE_HXX_(float,float,float, ); CALCIUM_C2CPP_INTERFACE_HXX_(double,double,double,); + +CALCIUM_C2CPP_INTERFACE_HXX_(float2double,double,float, ); + /* Fonctionne mais essai suivant pour simplification de Calcium.c CALCIUM_C2CPP_INTERFACE_(bool,bool,);*/ CALCIUM_C2CPP_INTERFACE_HXX_(bool,bool,int,); CALCIUM_C2CPP_INTERFACE_HXX_(cplx,cplx,float,); diff --git a/src/DSC/DSC_User/Datastream/Calcium/calcium.h b/src/DSC/DSC_User/Datastream/Calcium/calcium.h index f103fe937..4a43be266 100644 --- a/src/DSC/DSC_User/Datastream/Calcium/calcium.h +++ b/src/DSC/DSC_User/Datastream/Calcium/calcium.h @@ -169,6 +169,29 @@ extern int cp_lre( #endif ); +extern int cp_lrd( +/* ------ */ +#if CPNeedPrototype + void * component /* Pointeur de type Superv_Component_i* sur le */ + /* composant SALOME Supervisable */, + int /* E Type de dependance ou de lecture */ + /* CP_TEMPS, CP_ITERATION, CP_SEQUENTIEL */, + float * /* E/S Borne inf de l'intervalle de lecture */ + /* Retourne le pas lu dans le cas de */ + /* lecture sequentielle */, + float * /* E Borne Sup de l'intervalle de lecture */, + int * /* E/S Pas d'iteration a lire */ + /* Retourne le pas lu dans le cas de */ + /* lecture sequentielle */, + char * /* E Nom de la variable a lire */, + int /* E Nombre max de valeurs a lire */, + int * /* S Nombre de valeurs rellement lues */, + float * /* S Tableau de flottants pour stocker les */ + /* valeurs lues */ +#endif +); + + extern int cp_ldb( /* ------ */ #if CPNeedPrototype @@ -470,6 +493,22 @@ extern int cp_ere( #endif ); +extern int cp_erd( +/* ------ */ +#if CPNeedPrototype + void * component /* Pointeur de type Superv_Component_i* sur le */ + /* composant SALOME Supervisable */, + int /* E Type de dependance */ + /* CP_TEMPS, CP_ITERATION */, + float /* E Pas de temps a ecrire */, + int /* E Pas d'iteration a ecrire */, + char * /* E Nom de la variable a ecrire */, + int /* E Nombre de valeurs a ecrire */, + float * /* E Tableau de flottants a ecrire */ +#endif +); + + extern int cp_edb( /* ------ */ #if CPNeedPrototype diff --git a/src/DSC/DSC_User/Datastream/Calcium/calciumf.c b/src/DSC/DSC_User/Datastream/Calcium/calciumf.c index 5b63bb3e2..e01915c73 100644 --- a/src/DSC/DSC_User/Datastream/Calcium/calciumf.c +++ b/src/DSC/DSC_User/Datastream/Calcium/calciumf.c @@ -155,6 +155,8 @@ void F_FUNC(cpldb,CPLDB)(long *compo,cal_int *dep,double *ti,double *tf,cal_int cal_int *max,cal_int *n, double *tab,cal_int *err STR_PLEN(nom)); void F_FUNC(cplre,CPLRE)(long *compo,cal_int *dep,float *ti,float *tf,cal_int *iter,STR_PSTR(nom), cal_int *max,cal_int *n, float *tab,cal_int *err STR_PLEN(nom)); +void F_FUNC(cplrd,CPLRD)(long *compo,cal_int *dep,float *ti,float *tf,cal_int *iter,STR_PSTR(nom), + cal_int *max,cal_int *n, double *tab,cal_int *err STR_PLEN(nom)); void F_FUNC(cplcp,CPLCP)(long *compo,cal_int *dep,float *ti,float *tf,cal_int *iter,STR_PSTR(nom), cal_int *max,cal_int *n, float *tab,cal_int *err STR_PLEN(nom)); void F_FUNC(cplch,CPLCH)(long *compo,cal_int *dep,float *ti,float *tf,cal_int *iter,STR_PSTR(nom), @@ -241,6 +243,14 @@ void F_FUNC(cplre,CPLRE)(long *compo,cal_int *dep,float *ti,float *tf,cal_int *i free_str1(cnom); } +void F_FUNC(cplrd,CPLRD)(long *compo,cal_int *dep,float *ti,float *tf,cal_int *iter,STR_PSTR(nom), + cal_int *max,cal_int *n, double *tab,cal_int *err STR_PLEN(nom)) +{ + char* cnom=fstr1(STR_PTR(nom),STR_LEN(nom)); + *err=cp_lrd_fort_((void *)*compo,*dep,ti,tf,iter,cnom,*max,n,(float *)tab); + free_str1(cnom); +} + void F_FUNC(cplcp,CPLCP)(long *compo,cal_int *dep,float *ti,float *tf,cal_int *iter,STR_PSTR(nom), cal_int *max,cal_int *n, float *tab,cal_int *err STR_PLEN(nom)) { @@ -289,6 +299,7 @@ void F_FUNC(cpech,CPECH)(long *compo,cal_int *dep,float *ti,cal_int *iter,STR_PS STR_PLEN(nom) STR_PLEN(tab)); void F_FUNC(cpedb,CPEDB)(long *compo,cal_int *dep,double *ti,cal_int *iter,STR_PSTR(nom),cal_int *n, double *tab,cal_int *err STR_PLEN(nom)); void F_FUNC(cpere,CPERE)(long *compo,cal_int *dep,float *ti,cal_int *iter,STR_PSTR(nom),cal_int *n, float *tab,cal_int *err STR_PLEN(nom)); +void F_FUNC(cperd,CPERD)(long *compo,cal_int *dep,float *ti,cal_int *iter,STR_PSTR(nom),cal_int *n, double *tab,cal_int *err STR_PLEN(nom)); void F_FUNC(cpecp,CPECP)(long *compo,cal_int *dep,float *ti,cal_int *iter,STR_PSTR(nom),cal_int *n, float *tab,cal_int *err STR_PLEN(nom)); void F_FUNC(cpein,CPEIN)(long *compo,cal_int *dep,float *ti,cal_int *iter,STR_PSTR(nom),cal_int *n, int *tab,cal_int *err STR_PLEN(nom)); void F_FUNC(cpelg,CPELG)(long *compo,cal_int *dep,float *ti,cal_int *iter,STR_PSTR(nom),cal_int *n, long *tab,cal_int *err STR_PLEN(nom)); @@ -347,6 +358,15 @@ void F_FUNC(cpere,CPERE)(long *compo,cal_int *dep,float *ti,cal_int *iter,STR_PS free_str1(cnom); } +void F_FUNC(cperd,CPERD)(long *compo,cal_int *dep,float *ti,cal_int *iter,STR_PSTR(nom),cal_int *n, double *tab,cal_int *err STR_PLEN(nom)) +{ + float tti=0.; + if(*dep == CP_TEMPS)tti=*ti; + char* cnom=fstr1(STR_PTR(nom),STR_LEN(nom)); + *err=cp_erd_fort_((void *)*compo,*dep,tti,*iter,cnom,*n,(float *)tab); + free_str1(cnom); +} + void F_FUNC(cpecp,CPECP)(long *compo,cal_int *dep,float *ti,cal_int *iter,STR_PSTR(nom),cal_int *n, float *tab,cal_int *err STR_PLEN(nom)) { float tti=0.; diff --git a/src/DSC/DSC_User/Datastream/Calcium/calciumf.h b/src/DSC/DSC_User/Datastream/Calcium/calciumf.h index da9574643..07f110137 100644 --- a/src/DSC/DSC_User/Datastream/Calcium/calciumf.h +++ b/src/DSC/DSC_User/Datastream/Calcium/calciumf.h @@ -47,6 +47,7 @@ CALCIUM_ECR_INTERFACE_C_H(elg_fort_,float ,cal_int,long ,long2integer,,); CALCIUM_ECR_INTERFACE_C_H(eln_fort_,float ,cal_int,long ,long,,); CALCIUM_ECR_INTERFACE_C_H(ein_fort_,float ,cal_int,int ,int2integer,,); CALCIUM_ECR_INTERFACE_C_H(ere_fort_,float ,cal_int,float ,float,,); +CALCIUM_ECR_INTERFACE_C_H(erd_fort_,float ,cal_int,float ,float2double,,); CALCIUM_ECR_INTERFACE_C_H(edb_fort_,double,cal_int,double,double,,); CALCIUM_ECR_INTERFACE_C_H(elo_fort_,float ,cal_int,int ,bool,,); /*int pour bool ou cal_int */ CALCIUM_ECR_INTERFACE_C_H(ecp_fort_,float ,cal_int,float ,cplx,,); @@ -69,6 +70,7 @@ CALCIUM_LECT_INTERFACE_C_H(llg_fort_,float ,cal_int,long ,long2integer,,); CALCIUM_LECT_INTERFACE_C_H(lln_fort_,float ,cal_int,long ,long,,); CALCIUM_LECT_INTERFACE_C_H(lin_fort_,float ,cal_int,int ,int2integer,,); CALCIUM_LECT_INTERFACE_C_H(lre_fort_,float ,cal_int,float ,float,,); +CALCIUM_LECT_INTERFACE_C_H(lrd_fort_,float ,cal_int,float ,float2double,,); CALCIUM_LECT_INTERFACE_C_H(ldb_fort_,double,cal_int,double ,double,,); CALCIUM_LECT_INTERFACE_C_H(llo_fort_,float ,cal_int,int ,bool,,); /*int pour bool ou cal_int */ CALCIUM_LECT_INTERFACE_C_H(lcp_fort_,float ,cal_int,float ,cplx,,); diff --git a/src/KERNEL_PY/salome_study.py b/src/KERNEL_PY/salome_study.py index 5de40bc3a..f6ebc622a 100644 --- a/src/KERNEL_PY/salome_study.py +++ b/src/KERNEL_PY/salome_study.py @@ -227,6 +227,27 @@ def CheckCopyPaste(theSO, theInfo ,theComponentPaste): #-------------------------------------------------------------------------- +def GetComponentVersion(theComponent, all_versions = False): + # returns the document list tree (as list) + props = myStudy.GetProperties() + stored_components = props.GetStoredComponents() + version = "no component data" # vsr: better raise an exception in this case? + if theComponent in stored_components: + if all_versions: + version = props.GetComponentVersions(theComponent) + for i in range(len(version)): + if not version[i]: version[i] = "unknown" + pass + pass + else: + version = props.GetComponentVersion(theComponent) + if not version: version = "unknown" + pass + pass + return version + + #-------------------------------------------------------------------------- + def FindFileInDataDir(filename): import os datadir = os.getenv("DATA_DIR") diff --git a/src/Launcher/BatchTest.cxx b/src/Launcher/BatchTest.cxx index 37076b0fb..d765f51e8 100644 --- a/src/Launcher/BatchTest.cxx +++ b/src/Launcher/BatchTest.cxx @@ -478,6 +478,8 @@ BatchTest::test_jobsubmit_mpi() mpiImpl = new MpiImpl_MPICH2(); else if(mpi_type == "openmpi") mpiImpl = new MpiImpl_OPENMPI(); + else if(mpi_type == "ompi") + mpiImpl = new MpiImpl_OMPI(); else if(mpi_type == "slurmmpi") mpiImpl = new MpiImpl_SLURM(); else diff --git a/src/Launcher/Launcher.cxx b/src/Launcher/Launcher.cxx index 62bfe647b..d749f8258 100644 --- a/src/Launcher/Launcher.cxx +++ b/src/Launcher/Launcher.cxx @@ -403,6 +403,9 @@ Launcher_cpp::FactoryBatchManager(ParserResourcesType& params) case openmpi: mpi = "openmpi"; break; + case ompi: + mpi = "ompi"; + break; case slurmmpi: mpi = "slurmmpi"; break; diff --git a/src/Launcher/Launcher_Job_Command.cxx b/src/Launcher/Launcher_Job_Command.cxx index f325898ed..6f2fecebd 100644 --- a/src/Launcher/Launcher_Job_Command.cxx +++ b/src/Launcher/Launcher_Job_Command.cxx @@ -20,6 +20,7 @@ // Author: André RIBES - EDF R&D // #include "Launcher_Job_Command.hxx" +#include "Basics_DirUtils.hxx" #ifdef WITH_LIBBATCH #include @@ -54,7 +55,7 @@ Launcher::Job_Command::buildCommandScript(Batch::Parametre params, std::string l // File name std::string launch_date_port_file = launch_date; - std::string launch_script = "/tmp/runCommand_" + _job_file_name + "_" + launch_date + ".sh"; + std::string launch_script = Kernel_Utils::GetTmpDir() + "runCommand_" + _job_file_name + "_" + launch_date + ".sh"; std::ofstream launch_script_stream; launch_script_stream.open(launch_script.c_str(), std::ofstream::out); diff --git a/src/Launcher/Launcher_Job_SALOME.cxx b/src/Launcher/Launcher_Job_SALOME.cxx index b0c70f5b5..85f6e1015 100644 --- a/src/Launcher/Launcher_Job_SALOME.cxx +++ b/src/Launcher/Launcher_Job_SALOME.cxx @@ -20,6 +20,7 @@ // Author: André RIBES - EDF R&D // #include "Launcher_Job_SALOME.hxx" +#include "Basics_DirUtils.hxx" #ifdef WITH_LIBBATCH #include @@ -64,7 +65,7 @@ Launcher::Job_SALOME::buildSalomeScript(Batch::Parametre params) // parameters std::string work_directory = params[Batch::WORKDIR].str(); - std::string launch_script = "/tmp/runSalome_" + _job_file_name + "_" + _launch_date + ".sh"; + std::string launch_script = Kernel_Utils::GetTmpDir() + "runSalome_" + _job_file_name + "_" + _launch_date + ".sh"; std::ofstream launch_script_stream; launch_script_stream.open(launch_script.c_str(), std::ofstream::out diff --git a/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx b/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx index 2afca3b7f..afd7e6f63 100644 --- a/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx +++ b/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx @@ -550,6 +550,7 @@ void SALOME_LifeCycleCORBA::shutdownServers() if (!CORBA::is_nil(session)) { pid = session->getPID(); + session->Shutdown(); } } @@ -644,6 +645,7 @@ void SALOME_LifeCycleCORBA::shutdownServers() // ignore and continue } + /* // 6) Session if ( !CORBA::is_nil( session ) ) { try @@ -655,6 +657,7 @@ void SALOME_LifeCycleCORBA::shutdownServers() // ignore and continue } } + */ // 7) Logger int argc = 0; diff --git a/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.cxx b/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.cxx index f65db96c0..ae42569dd 100755 --- a/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.cxx +++ b/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.cxx @@ -248,6 +248,8 @@ SALOME_ResourcesCatalog_Handler::ProcessCluster(xmlNodePtr cluster_descr, Parser resource.mpi = mpich2; else if (anMpi == "openmpi") resource.mpi = openmpi; + else if (anMpi == "ompi") + resource.mpi = ompi; else if (anMpi == "slurmmpi") resource.mpi = slurmmpi; else if (anMpi == "prun") @@ -543,6 +545,8 @@ SALOME_ResourcesCatalog_Handler::ProcessMachine(xmlNodePtr machine_descr, Parser resource.mpi = mpich2; else if (anMpi == "openmpi") resource.mpi = openmpi; + else if (anMpi == "ompi") + resource.mpi = ompi; else if (anMpi == "slurmmpi") resource.mpi = slurmmpi; else if (anMpi == "prun") @@ -768,6 +772,9 @@ void SALOME_ResourcesCatalog_Handler::PrepareDocToXmlFile(xmlDocPtr theDoc) case openmpi: xmlNewProp(node, BAD_CAST test_mpi, BAD_CAST "openmpi"); break; + case ompi: + xmlNewProp(node, BAD_CAST test_mpi, BAD_CAST "ompi"); + break; case slurmmpi: xmlNewProp(node, BAD_CAST test_mpi, BAD_CAST "slurmmpi"); break; diff --git a/src/ResourcesManager/SALOME_ResourcesCatalog_Parser.cxx b/src/ResourcesManager/SALOME_ResourcesCatalog_Parser.cxx index 50360f72f..9cf3cfa99 100644 --- a/src/ResourcesManager/SALOME_ResourcesCatalog_Parser.cxx +++ b/src/ResourcesManager/SALOME_ResourcesCatalog_Parser.cxx @@ -263,6 +263,8 @@ ParserResourcesType::PrintMpiImplType() const return "mpich2"; else if (mpi == openmpi) return "openmpi"; + else if (mpi == ompi) + return "ompi"; else if (mpi == slurmmpi) return "slurmmpi"; else diff --git a/src/ResourcesManager/SALOME_ResourcesCatalog_Parser.hxx b/src/ResourcesManager/SALOME_ResourcesCatalog_Parser.hxx index 20a390db1..1ac87b340 100755 --- a/src/ResourcesManager/SALOME_ResourcesCatalog_Parser.hxx +++ b/src/ResourcesManager/SALOME_ResourcesCatalog_Parser.hxx @@ -47,7 +47,7 @@ enum AccessModeType {interactive, batch}; enum BatchType {none, pbs, lsf, sge, ssh_batch, ccc, ll, slurm, vishnu}; -enum MpiImplType {nompi, lam, mpich1, mpich2, openmpi, slurmmpi, prun}; +enum MpiImplType {nompi, lam, mpich1, mpich2, openmpi, ompi, slurmmpi, prun}; class RESOURCESMANAGER_EXPORT ResourceDataToSort { diff --git a/src/ResourcesManager/SALOME_ResourcesManager.cxx b/src/ResourcesManager/SALOME_ResourcesManager.cxx index eb932fdc8..30a1c1b44 100644 --- a/src/ResourcesManager/SALOME_ResourcesManager.cxx +++ b/src/ResourcesManager/SALOME_ResourcesManager.cxx @@ -237,6 +237,8 @@ SALOME_ResourcesManager::GetResourceDefinition(const char * name) p_ptr->mpiImpl = "mpich2"; else if( resource.mpi == openmpi ) p_ptr->mpiImpl = "openmpi"; + else if( resource.mpi == ompi ) + p_ptr->mpiImpl = "ompi"; else if( resource.mpi == slurmmpi ) p_ptr->mpiImpl = "slurmmpi"; else if( resource.mpi == prun ) @@ -315,6 +317,8 @@ SALOME_ResourcesManager::AddResource(const Engines::ResourceDefinition& new_reso resource.mpi = mpich2; else if (anMpi == "openmpi") resource.mpi = openmpi; + else if (anMpi == "ompi") + resource.mpi = ompi; else if (anMpi == "slurmmpi") resource.mpi = slurmmpi; else if (anMpi == "prun") @@ -499,7 +503,7 @@ SALOME_ResourcesManager::getMachineFile(std::string resource_name, cluster_it++; } } - else if (resource.mpi == openmpi) + else if ((resource.mpi == openmpi) || (resource.mpi == ompi)) { // Creating machine file machine_file_name = tmpnam(NULL); diff --git a/src/SALOMEDS/Makefile.am b/src/SALOMEDS/Makefile.am index bfc45db68..e064be049 100644 --- a/src/SALOMEDS/Makefile.am +++ b/src/SALOMEDS/Makefile.am @@ -75,7 +75,6 @@ COMMON_CPPFLAGS=\ # This local variable defines the list of dependant libraries common to all target in this package. COMMON_LIBS =\ - ../TOOLSDS/libTOOLSDS.la \ ../NamingService/libSalomeNS.la \ ../Utils/libOpUtil.la \ ../SALOMELocalTrace/libSALOMELocalTrace.la \ diff --git a/src/SALOMEDS/SALOMEDS_AttributeStudyProperties.cxx b/src/SALOMEDS/SALOMEDS_AttributeStudyProperties.cxx index af20553fa..bdb5760d7 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeStudyProperties.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeStudyProperties.cxx @@ -319,3 +319,49 @@ std::string SALOMEDS_AttributeStudyProperties::GetUnits() anUnits = ((SALOMEDS::AttributeStudyProperties_var)SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl))->GetUnits(); return anUnits; } + +std::vector SALOMEDS_AttributeStudyProperties::GetStoredComponents() +{ + std::vector aComponents; + if (_isLocal) { + SALOMEDS::Locker lock; + aComponents = dynamic_cast(_local_impl)->GetStoredComponents(); + } + else { + SALOMEDS::StringSeq_var components = ((SALOMEDS::AttributeStudyProperties_var)SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl))->GetStoredComponents(); + int length = components->length(); + for (int i = 0; i < length; i++) { + aComponents.push_back(components[i].in()); + } + } + return aComponents; +} + +std::string SALOMEDS_AttributeStudyProperties::GetComponentVersion( const std::string& theComponent ) +{ + std::string aVersion; + if (_isLocal) { + SALOMEDS::Locker lock; + aVersion = dynamic_cast(_local_impl)->GetComponentVersion(theComponent); + } + else + aVersion = ((SALOMEDS::AttributeStudyProperties_var)SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl))->GetComponentVersion(theComponent.c_str()); + return aVersion; +} + +std::vector SALOMEDS_AttributeStudyProperties::GetComponentVersions( const std::string& theComponent ) +{ + std::vector aVersions; + if (_isLocal) { + SALOMEDS::Locker lock; + aVersions = dynamic_cast(_local_impl)->GetComponentVersions(theComponent); + } + else { + SALOMEDS::StringSeq_var versions = ((SALOMEDS::AttributeStudyProperties_var)SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl))->GetComponentVersions(theComponent.c_str()); + int length = versions->length(); + for (int i = 0; i < length; i++) { + aVersions.push_back(versions[i].in()); + } + } + return aVersions; +} diff --git a/src/SALOMEDS/SALOMEDS_AttributeStudyProperties.hxx b/src/SALOMEDS/SALOMEDS_AttributeStudyProperties.hxx index 4ebd180bd..b02e0fbff 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeStudyProperties.hxx +++ b/src/SALOMEDS/SALOMEDS_AttributeStudyProperties.hxx @@ -82,7 +82,9 @@ public: virtual void SetComment(const std::string& theComment); virtual std::string GetComment(); - + virtual std::vector GetStoredComponents(); + virtual std::string GetComponentVersion( const std::string& theComponent ); + virtual std::vector GetComponentVersions( const std::string& theComponent ); }; diff --git a/src/SALOMEDS/SALOMEDS_AttributeStudyProperties_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeStudyProperties_i.cxx index a6bd88294..3c02784de 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeStudyProperties_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeStudyProperties_i.cxx @@ -218,3 +218,34 @@ char* SALOMEDS_AttributeStudyProperties_i::GetUnits() return c_s._retn(); } +SALOMEDS::StringSeq* SALOMEDS_AttributeStudyProperties_i::GetStoredComponents() +{ + SALOMEDS::Locker lock; + std::vector components = dynamic_cast(_impl)->GetStoredComponents(); + SALOMEDS::StringSeq_var c_components = new SALOMEDS::StringSeq(); + c_components->length(components.size()); + for (int i = 0; i < components.size(); i++) { + c_components[i] = CORBA::string_dup(components[i].c_str()); + } + return c_components._retn(); +} + +char* SALOMEDS_AttributeStudyProperties_i::GetComponentVersion(const char* theComponent) +{ + SALOMEDS::Locker lock; + std::string version = dynamic_cast(_impl)->GetComponentVersion(theComponent); + CORBA::String_var c_version = CORBA::string_dup(version.c_str()); + return c_version._retn(); +} + +SALOMEDS::StringSeq* SALOMEDS_AttributeStudyProperties_i::GetComponentVersions(const char* theComponent) +{ + SALOMEDS::Locker lock; + std::vector versions = dynamic_cast(_impl)->GetComponentVersions(theComponent); + SALOMEDS::StringSeq_var c_versions = new SALOMEDS::StringSeq(); + c_versions->length(versions.size()); + for (int i = 0; i < versions.size(); i++) { + c_versions[i] = CORBA::string_dup(versions[i].c_str()); + } + return c_versions._retn(); +} diff --git a/src/SALOMEDS/SALOMEDS_AttributeStudyProperties_i.hxx b/src/SALOMEDS/SALOMEDS_AttributeStudyProperties_i.hxx index 7c6198ee1..ead14d9e8 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeStudyProperties_i.hxx +++ b/src/SALOMEDS/SALOMEDS_AttributeStudyProperties_i.hxx @@ -73,6 +73,10 @@ public: virtual void SetUnits(const char* theUnits); virtual char* GetUnits(); + + virtual SALOMEDS::StringSeq* GetStoredComponents(); + virtual char* GetComponentVersion(const char* theComponent); + virtual SALOMEDS::StringSeq* GetComponentVersions(const char* theComponent); }; diff --git a/src/SALOMEDS/SALOMEDS_Driver_i.cxx b/src/SALOMEDS/SALOMEDS_Driver_i.cxx index 87bdec277..ae2db2077 100644 --- a/src/SALOMEDS/SALOMEDS_Driver_i.cxx +++ b/src/SALOMEDS/SALOMEDS_Driver_i.cxx @@ -29,9 +29,21 @@ #include "SALOMEDS.hxx" #include -SALOMEDS_Driver_i::SALOMEDS_Driver_i(SALOMEDS::Driver_ptr theDriver, CORBA::ORB_ptr theORB) +SALOMEDS_Driver_i::SALOMEDS_Driver_i(Engines::EngineComponent_ptr theEngine, CORBA::ORB_ptr theORB) { + // engine should not be null - component is supposed to be inherited from Engines::EngineComponent + _engine = Engines::EngineComponent::_duplicate(theEngine); + // driver can be null - if component interface does not inherit SALOMEDS::Driver + _driver = SALOMEDS::Driver::_narrow(theEngine); + _orb = CORBA::ORB::_duplicate(theORB); +} + +SALOMEDS_Driver_i::SALOMEDS_Driver_i(SALOMEDS::Driver_ptr theDriver, CORBA::ORB_ptr theORB) +{ + // driver can be null - if component interface does not inherit SALOMEDS::Driver _driver = SALOMEDS::Driver::_duplicate(theDriver); + // engine can be null - since it is narrowed from SALOMEDS::Driver ptr which can be null + _engine = Engines::EngineComponent::_narrow(theDriver); _orb = CORBA::ORB::_duplicate(theORB); } @@ -42,8 +54,8 @@ SALOMEDS_Driver_i::~SALOMEDS_Driver_i() std::string SALOMEDS_Driver_i::GetIOR() { std::string ior = ""; - if ( !CORBA::is_nil(_driver) ) { - CORBA::String_var cior = _orb->object_to_string(_driver); + if ( !CORBA::is_nil(_engine) ) { + CORBA::String_var cior = _orb->object_to_string(_engine); ior = cior; } return ior; @@ -163,6 +175,11 @@ std::string SALOMEDS_Driver_i::ComponentDataType() return dtype; } +std::string SALOMEDS_Driver_i::Version() +{ + return !CORBA::is_nil( _engine ) ? _engine->getVersion() : std::string(""); +} + std::string SALOMEDS_Driver_i::IORToLocalPersistentID(const SALOMEDSImpl_SObject& theSObject, const std::string& IORString, bool isMultiFile, @@ -298,9 +315,8 @@ SALOMEDSImpl_TMPFile* SALOMEDS_Driver_i::DumpPython(SALOMEDSImpl_Study* theStudy Engines::TMPFile_var aStream; CORBA::Boolean aValidScript = true; // VSR: maybe should be false by default ??? - Engines::EngineComponent_ptr aComponent = Engines::EngineComponent::_narrow(_driver); - if ( !CORBA::is_nil( aComponent ) ) - aStream = aComponent->DumpPython(st.in(), isPublished, isMultiFile, aValidScript); + if ( !CORBA::is_nil( _engine ) ) + aStream = _engine->DumpPython(st.in(), isPublished, isMultiFile, aValidScript); SALOMEDSImpl_TMPFile* aTMPFile = new Engines_TMPFile_i(aStream._retn()); theStreamLength = aTMPFile->Size(); @@ -344,8 +360,8 @@ SALOMEDSImpl_Driver* SALOMEDS_DriverFactory_i::GetDriverByType(const std::string } if (!CORBA::is_nil(obj)) { - SALOMEDS::Driver_var aDriver = SALOMEDS::Driver::_narrow(obj); - return new SALOMEDS_Driver_i(aDriver, _orb); + Engines::EngineComponent_var anEngine = Engines::EngineComponent::_narrow(obj); + return new SALOMEDS_Driver_i(anEngine, _orb); } return NULL; @@ -357,8 +373,8 @@ SALOMEDSImpl_Driver* SALOMEDS_DriverFactory_i::GetDriverByIOR(const std::string& obj = _orb->string_to_object(theIOR.c_str()); if (!CORBA::is_nil(obj)) { - SALOMEDS::Driver_var aDriver = SALOMEDS::Driver::_narrow(obj); - return new SALOMEDS_Driver_i(aDriver, _orb); + Engines::EngineComponent_var anEngine = Engines::EngineComponent::_narrow(obj); + return new SALOMEDS_Driver_i(anEngine, _orb); } return NULL; diff --git a/src/SALOMEDS/SALOMEDS_Driver_i.hxx b/src/SALOMEDS/SALOMEDS_Driver_i.hxx index a17b9b846..e4de665be 100644 --- a/src/SALOMEDS/SALOMEDS_Driver_i.hxx +++ b/src/SALOMEDS/SALOMEDS_Driver_i.hxx @@ -37,12 +37,12 @@ class Standard_EXPORT SALOMEDS_Driver_i : public virtual SALOMEDSImpl_Driver { protected: SALOMEDS::Driver_var _driver; + Engines::EngineComponent_var _engine; CORBA::ORB_var _orb; public: - + SALOMEDS_Driver_i(Engines::EngineComponent_ptr theEngine, CORBA::ORB_ptr theORB); SALOMEDS_Driver_i(SALOMEDS::Driver_ptr theDriver, CORBA::ORB_ptr theORB); - ~SALOMEDS_Driver_i(); virtual std::string GetIOR(); @@ -73,6 +73,8 @@ public: virtual std::string ComponentDataType(); + virtual std::string Version(); + virtual std::string IORToLocalPersistentID(const SALOMEDSImpl_SObject& theSObject, const std::string& IORString, bool isMultiFile, diff --git a/src/SALOMEDS/SALOMEDS_StudyBuilder.cxx b/src/SALOMEDS/SALOMEDS_StudyBuilder.cxx index 5e54ef02e..fb6ee94c0 100644 --- a/src/SALOMEDS/SALOMEDS_StudyBuilder.cxx +++ b/src/SALOMEDS/SALOMEDS_StudyBuilder.cxx @@ -194,12 +194,13 @@ void SALOMEDS_StudyBuilder::LoadWith(const _PTR(SComponent)& theSCO, const std:: SALOMEDS_SComponent* aSCO = dynamic_cast(theSCO.get()); CORBA::Object_var obj = _orb->string_to_object(theIOR.c_str()); + Engines::EngineComponent_var anEngine = Engines::EngineComponent::_narrow(obj); SALOMEDS::Driver_var aDriver = SALOMEDS::Driver::_narrow(obj); if (_isLocal) { SALOMEDS::Locker lock; - SALOMEDS_Driver_i* drv = new SALOMEDS_Driver_i(aDriver, _orb); + SALOMEDS_Driver_i* drv = new SALOMEDS_Driver_i(anEngine, _orb); SALOMEDSImpl_SComponent aSCO_impl = *(dynamic_cast(aSCO->GetLocalImpl())); bool isDone = _local_impl->LoadWith(aSCO_impl, drv); delete drv; diff --git a/src/SALOMEDS/SALOMEDS_StudyManager.cxx b/src/SALOMEDS/SALOMEDS_StudyManager.cxx index 813d0820e..814f58bc3 100644 --- a/src/SALOMEDS/SALOMEDS_StudyManager.cxx +++ b/src/SALOMEDS/SALOMEDS_StudyManager.cxx @@ -317,7 +317,7 @@ SALOMEDS_Driver_i* GetDriver(const SALOMEDSImpl_SObject& theObject, CORBA::ORB_p std::string IOREngine = aSCO.GetIOR(); if(!IOREngine.empty()) { CORBA::Object_var obj = orb->string_to_object(IOREngine.c_str()); - SALOMEDS::Driver_var Engine = SALOMEDS::Driver::_narrow(obj) ; + Engines::EngineComponent_var Engine = Engines::EngineComponent::_narrow(obj) ; driver = new SALOMEDS_Driver_i(Engine, orb); } } diff --git a/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx b/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx index c26919c8e..9ba8b7e71 100644 --- a/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx +++ b/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx @@ -451,7 +451,7 @@ SALOMEDS_Driver_i* GetDriver(const SALOMEDSImpl_SObject& theObject, CORBA::ORB_p std::string IOREngine = aSCO.GetIOR(); if(!IOREngine.empty()) { CORBA::Object_var obj = orb->string_to_object(IOREngine.c_str()); - SALOMEDS::Driver_var Engine = SALOMEDS::Driver::_narrow(obj) ; + Engines::EngineComponent_var Engine = Engines::EngineComponent::_narrow(obj) ; driver = new SALOMEDS_Driver_i(Engine, orb); } } diff --git a/src/SALOMEDS/SALOME_DriverPy.py b/src/SALOMEDS/SALOME_DriverPy.py index 7e820dd27..e879aeb69 100644 --- a/src/SALOMEDS/SALOME_DriverPy.py +++ b/src/SALOMEDS/SALOME_DriverPy.py @@ -46,6 +46,12 @@ class SALOME_DriverPy_i(SALOMEDS__POA.Driver): def ComponentDataType(self): return self._ComponentDataType + def Version(self): + try: + return self.getVersion() + except: + return "" + def Save(self, theComponent, theURL, isMultiFile): return "" diff --git a/src/SALOMEDSClient/SALOMEDSClient_AttributeStudyProperties.hxx b/src/SALOMEDSClient/SALOMEDSClient_AttributeStudyProperties.hxx index de3f9a5cb..41284ca6e 100644 --- a/src/SALOMEDSClient/SALOMEDSClient_AttributeStudyProperties.hxx +++ b/src/SALOMEDSClient/SALOMEDSClient_AttributeStudyProperties.hxx @@ -67,7 +67,9 @@ public: virtual void SetComment(const std::string& theComment) = 0; virtual std::string GetComment() = 0; - + virtual std::vector GetStoredComponents() = 0; + virtual std::string GetComponentVersion( const std::string& theComponent ) = 0; + virtual std::vector GetComponentVersions( const std::string& theComponent ) = 0; }; diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeStudyProperties.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeStudyProperties.cxx index 60e44a608..b48581b99 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeStudyProperties.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeStudyProperties.cxx @@ -60,6 +60,7 @@ void SALOMEDSImpl_AttributeStudyProperties::Init() myMonth.clear(); myYear.clear(); myMode = 0; // none + myComponentVersions.clear(); } void SALOMEDSImpl_AttributeStudyProperties::SetModification(const std::string& theUserName, @@ -102,9 +103,7 @@ void SALOMEDSImpl_AttributeStudyProperties::GetModifications std::string SALOMEDSImpl_AttributeStudyProperties::GetCreatorName() const { - if (myUserName.size() == 0) - return std::string(""); - return myUserName[0]; + return myUserName.empty() ? std::string("") : myUserName[0]; } bool SALOMEDSImpl_AttributeStudyProperties::GetCreationDate @@ -136,6 +135,7 @@ void SALOMEDSImpl_AttributeStudyProperties::ChangeCreatorName(const std::string& void SALOMEDSImpl_AttributeStudyProperties::SetCreationMode(const int theMode) { + if (theMode == myMode) return; CheckLocked(); Backup(); myMode = theMode; @@ -175,7 +175,8 @@ bool SALOMEDSImpl_AttributeStudyProperties::IsLocked() const return myLocked; } -bool SALOMEDSImpl_AttributeStudyProperties::IsLockChanged(const bool theErase) { +bool SALOMEDSImpl_AttributeStudyProperties::IsLockChanged(const bool theErase) +{ if (!myLockChanged) return false; if (theErase) myLockChanged = false; return true; @@ -204,6 +205,7 @@ void SALOMEDSImpl_AttributeStudyProperties::Restore(DF_Attribute* with) myYear.push_back(aYears[i]); } myMode = aProp->GetCreationMode(); + myComponentVersions = aProp->GetComponentsVersions(); // myModified = aProp->GetModified(); // myLocked = aProp->IsLocked(); } @@ -227,6 +229,7 @@ void SALOMEDSImpl_AttributeStudyProperties::Paste(DF_Attribute* into) } aProp->SetCreationMode(myMode); + aProp->SetComponentsVersions( myComponentVersions ); // aProp->SetModified(myModified); // aProp->SetLocked(myLocked); } @@ -244,11 +247,26 @@ std::string SALOMEDSImpl_AttributeStudyProperties::Save() std::string units = GetUnits(); std::string comment = GetComment(); + + int aLength1 = 0; + std::map versions; + versionMap::const_iterator it; + for (aLength1 = 0, it = myComponentVersions.begin(); it != myComponentVersions.end(); ++it ) { + std::string vlist = ""; + versionList vl = it->second; + versionList::const_iterator vlit; + for ( vlit = vl.begin(); vlit != vl.end(); ++vlit ) { + if ( vlist != "" ) vlist += ";"; + vlist += *vlit; + } + versions[ it->first ] = vlist; + aLength1 += it->first.size() + vlist.size() + 2; + } unitsSize = units.size(); commentSize = comment.size(); - char* aProperty = new char[3 + aLength + 12 * aNames.size() + 1 + unitsSize + 1 + commentSize]; + char* aProperty = new char[3 + aLength + 12 * aNames.size() + 1 + unitsSize + 1 + commentSize + 1 + aLength1 ]; char crMode = (char)GetCreationMode(); @@ -283,9 +301,19 @@ std::string SALOMEDSImpl_AttributeStudyProperties::Save() if(comment.size() > 0) { sprintf(&(aProperty[a]),"%s",comment.c_str()); a = strlen(aProperty); - a++; } + aProperty[a++] = 30; //delimeter of the component versions + + std::map::const_iterator versionsIt; + for ( versionsIt = versions.begin(); versionsIt != versions.end(); ++versionsIt ) { + sprintf(&(aProperty[a]),"%s=%s", + (char*)(versionsIt->first.c_str()), + (char*)(versionsIt->second.c_str())); + a = strlen(aProperty); + aProperty[a++] = 1; + } + aProperty[a] = 0; std::string prop(aProperty); delete aProperty; @@ -293,26 +321,81 @@ std::string SALOMEDSImpl_AttributeStudyProperties::Save() return prop; } -void SALOMEDSImpl_AttributeStudyProperties::SetUnits(const std::string& theUnits) { +void SALOMEDSImpl_AttributeStudyProperties::SetUnits(const std::string& theUnits) +{ if(myUnits == theUnits) return; + + CheckLocked(); + Backup(); + myUnits = theUnits; } -std::string SALOMEDSImpl_AttributeStudyProperties::GetUnits() { +std::string SALOMEDSImpl_AttributeStudyProperties::GetUnits() const +{ return myUnits; } -void SALOMEDSImpl_AttributeStudyProperties::SetComment(const std::string& theComment) { +void SALOMEDSImpl_AttributeStudyProperties::SetComment(const std::string& theComment) +{ if(myComment == theComment) return; + + CheckLocked(); + Backup(); + myComment = theComment; } -std::string SALOMEDSImpl_AttributeStudyProperties::GetComment() { +std::string SALOMEDSImpl_AttributeStudyProperties::GetComment() const +{ return myComment; } +void SALOMEDSImpl_AttributeStudyProperties::SetComponentVersion(const std::string& theComponent, const std::string& theVersion) +{ + if (!theComponent.empty()) { + CheckLocked(); + Backup(); + if (myComponentVersions.find(theComponent) == myComponentVersions.end()) myComponentVersions[theComponent] = versionList(); + if (myComponentVersions[theComponent].empty() || myComponentVersions[theComponent].back() != theVersion) + myComponentVersions[theComponent].push_back(theVersion); + } +} + +std::vector SALOMEDSImpl_AttributeStudyProperties::GetStoredComponents() const +{ + std::vector components; + versionMap::const_iterator it; + for (it = myComponentVersions.begin(); it != myComponentVersions.end(); ++it) + components.push_back(it->first); + return components; +} + +std::string SALOMEDSImpl_AttributeStudyProperties::GetComponentVersion(const std::string& theComponent) const +{ + versionList versions = GetComponentVersions(theComponent); + return versions.size() > 0 ? versions[0] : std::string(""); +} + +std::vector SALOMEDSImpl_AttributeStudyProperties::GetComponentVersions(const std::string& theComponent) const +{ + versionList versions; + versionMap::const_iterator it = myComponentVersions.find(theComponent); + if ( it != myComponentVersions.end() ) versions = it->second; + return versions; +} + +std::map< std::string, std::vector > SALOMEDSImpl_AttributeStudyProperties::GetComponentsVersions() const +{ + return myComponentVersions; +} + +void SALOMEDSImpl_AttributeStudyProperties::SetComponentsVersions( const std::map< std::string, std::vector >& theVersions ) +{ + myComponentVersions = theVersions; +} void SALOMEDSImpl_AttributeStudyProperties::Load(const std::string& value) { @@ -322,7 +405,16 @@ void SALOMEDSImpl_AttributeStudyProperties::Load(const std::string& value) SetCreationMode(crMode); int anIndex; - for (anIndex = 2; anIndex + 2 < value.size() ;) { + // number 13 below is minimal size of modification data record, which has form: + // mmhhddMMyyyyname1, where + // - mm: minute = 2 bytes + // - hh: hour = 2 bytes + // - dd: day = 2 bytes + // - MM: month = 2 bytes + // - yyyy: year = 4 bytes + // - name: user's name = arbitrary value, minimal length is 0 bytes + // - 1 : records delimiter = 1 byte + for (anIndex = 2; anIndex + 13 < value.size() ;) { char str[10]; int aMinute, aHour, aDay, aMonth, aYear; str[0] = aCopy[anIndex++]; @@ -359,7 +451,7 @@ void SALOMEDSImpl_AttributeStudyProperties::Load(const std::string& value) break; } - //Case then study contains units and comment properties + //Case when study contains units and comment properties if( anIndex < value.size() ) { anIndex++; //skip the delimeter of the sections: char(30) int unitsSize; @@ -375,7 +467,7 @@ void SALOMEDSImpl_AttributeStudyProperties::Load(const std::string& value) anIndex += unitsSize + 1; int commentSize; - for(commentSize = 0; aCopy[anIndex+commentSize] != 0; commentSize++); + for(commentSize = 0; aCopy[anIndex+commentSize] != 0 && aCopy[anIndex+commentSize] != 30; commentSize++); if(commentSize > 0) { char *aComment = new char[commentSize+1]; @@ -384,7 +476,40 @@ void SALOMEDSImpl_AttributeStudyProperties::Load(const std::string& value) SetComment(aComment); delete [] (aComment); } - anIndex += commentSize; + anIndex += commentSize + 1; + } + + //Case when study contains components versions + if( anIndex < value.size() ) { + while ( anIndex < value.size() && aCopy[anIndex] != 0 ) { + int modSize; + for(modSize = 0; aCopy[anIndex+modSize] != '='; modSize++); + int verSize; + for(verSize = 0; aCopy[anIndex+modSize+1+verSize] != 1; verSize++); + + if(modSize > 0) { + char *aModule = new char[modSize+1]; + strncpy(aModule, &(aCopy[anIndex]), modSize); + aModule[modSize] = 0; + char *aVersions = new char[verSize+1]; + if ( verSize > 0 ) + strncpy(aVersions, &(aCopy[anIndex+modSize+1]), verSize); + aVersions[verSize] = 0; + + std::string mVersions = aVersions; + int start = 0, idx = mVersions.find( ';', start ); + while ( idx != std::string::npos ) { + SetComponentVersion( aModule, mVersions.substr( start, idx-start ) ); + start = idx + 1; + idx = mVersions.find( ';', start ); + } + SetComponentVersion( aModule, mVersions.substr( start ) ); + + delete [] (aModule); + delete [] (aVersions); + anIndex += modSize + 1 + verSize + 1; + } + } } if (aCopy[1] == 'l') { diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeStudyProperties.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeStudyProperties.hxx index 4be09cd27..8cb4b69bb 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeStudyProperties.hxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeStudyProperties.hxx @@ -32,6 +32,7 @@ #include "DF_Label.hxx" #include #include +#include #include "SALOMEDSImpl_GenericAttribute.hxx" class SALOMEDSIMPL_EXPORT SALOMEDSImpl_AttributeStudyProperties : public SALOMEDSImpl_GenericAttribute @@ -73,10 +74,10 @@ public: void ChangeCreatorName(const std::string& theUserName); void SetUnits(const std::string& theUnits); - std::string GetUnits(); + std::string GetUnits() const; void SetComment(const std::string& theComment); - std::string GetComment(); + std::string GetComment() const; void SetCreationMode(const int theMode); int GetCreationMode() const; @@ -89,11 +90,20 @@ public: bool IsLocked() const; bool IsLockChanged(const bool theErase); + void SetComponentsVersions( const std::map< std::string, std::vector >& theVersions ); + void SetComponentVersion(const std::string& theComponent, const std::string& theVersion); + std::vector GetStoredComponents() const; + std::string GetComponentVersion(const std::string& theComponent) const; + std::vector GetComponentVersions(const std::string& theComponent) const; + std::map< std::string, std::vector > GetComponentsVersions() const; + void Restore(DF_Attribute* with); DF_Attribute* NewEmpty() const; void Paste(DF_Attribute* into); private: + typedef std::vector versionList; + typedef std::map versionMap; std::vector myUserName; std::vector myMinute; @@ -103,11 +113,11 @@ private: std::vector myYear; std::string myUnits; std::string myComment; - int myMode; - int myModified; - bool myLocked; - bool myLockChanged; - + int myMode; + int myModified; + bool myLocked; + bool myLockChanged; + versionMap myComponentVersions; }; #endif diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_Driver.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_Driver.hxx index 84be82bcb..b204337bb 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_Driver.hxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_Driver.hxx @@ -62,6 +62,7 @@ public: virtual std::string ComponentDataType() = 0; + virtual std::string Version() = 0; virtual std::string IORToLocalPersistentID(const SALOMEDSImpl_SObject& theSObject, const std::string& IORString, diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_StudyManager.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_StudyManager.cxx index d52b629eb..cae31faee 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_StudyManager.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_StudyManager.cxx @@ -40,6 +40,7 @@ #include "SALOMEDSImpl_SComponent.hxx" #include "SALOMEDSImpl_GenericAttribute.hxx" #include "SALOMEDSImpl_ScalarVariable.hxx" +#include "SALOMEDSImpl_IParameters.hxx" #include #include "HDFOI.hxx" @@ -56,6 +57,42 @@ static void Translate_IOR_to_persistentID (const SALOMEDSImpl_SObject&, SALOMEDSImpl_Driver*, bool isMultiFile, bool isASCII); static void ReadNoteBookVariables(SALOMEDSImpl_Study* theStudy, HDFgroup* theGroup); +namespace { + class StudyUnlocker + { + public: + StudyUnlocker( SALOMEDSImpl_Study* study ): myStudy( study ), myLocked( false ) + { + myPrevLocked = myStudy->GetProperties()->IsLocked(); + resume(); + } + ~StudyUnlocker() + { + suspend(); + } + void suspend() + { + if (myLocked) { + myStudy->GetProperties()->SetLocked(true); + myPrevLocked = myLocked; + myLocked = false; + } + } + void resume() + { + if (myPrevLocked) { + myStudy->GetProperties()->SetLocked(false); + myLocked = myPrevLocked; + myPrevLocked = false; + } + } + private: + SALOMEDSImpl_Study* myStudy; + bool myLocked; + bool myPrevLocked; + }; +} + //============================================================================ /*! Function : SALOMEDSImpl_StudyManager * Purpose : SALOMEDSImpl_StudyManager constructor @@ -209,6 +246,20 @@ SALOMEDSImpl_Study* SALOMEDSImpl_StudyManager::Open(const std::string& aUrl) delete hdf_file; // all related hdf objects will be deleted + // unlock study if it is locked, to set components versions + StudyUnlocker unlock(Study); + + //For old studies we have to add "unknown" version tag for all stored components + SALOMEDSImpl_SComponentIterator itcomponent = Study->NewComponentIterator(); + for (; itcomponent.More(); itcomponent.Next()) + { + SALOMEDSImpl_SComponent sco = itcomponent.Value(); + std::string aCompType = sco.GetComment(); + if ( aCompType == SALOMEDSImpl_IParameters::getDefaultVisualComponent() ) continue; + if ( Study->GetProperties()->GetComponentVersions( aCompType ).empty() ) + Study->GetProperties()->SetComponentVersion( aCompType, "" ); // empty version means "unknown" + } + return Study; } @@ -398,15 +449,17 @@ bool SALOMEDSImpl_StudyManager::Impl_SaveProperties(SALOMEDSImpl_Study* aStudy, // add modifications list (user and date of save) SALOMEDSImpl_AttributeStudyProperties* aProp = aStudy->GetProperties(); - int aLocked = aProp->IsLocked(); - if (aLocked) aProp->SetLocked(false); + // unlock study if it is locked, to set modification date + StudyUnlocker unlock(aStudy); + int month=0,day=0,year=0,hh=0,mn=0,ss=0; SALOMEDSImpl_Tool::GetSystemDate(year, month, day, hh, mn, ss); aProp->SetModification(SALOMEDSImpl_Tool::GetUserName(), - mn, hh, day, month, year); - - if (aLocked) aProp->SetLocked(true); + mn, hh, day, month, year); + + // lock study back if it was locked initially, to write correct value of Locked flag + unlock.suspend(); std::vector aNames; std::vector aMinutes, aHours, aDays, aMonths, aYears; @@ -416,10 +469,27 @@ bool SALOMEDSImpl_StudyManager::Impl_SaveProperties(SALOMEDSImpl_Study* aStudy, std::string units = aProp->GetUnits(); std::string comment = aProp->GetComment(); - int aLength = 0, anIndex, i, unitsSize = 0, commentSize = 0; + std::map< std::string, std::vector > allVersions = aProp->GetComponentsVersions(); + std::map versions; + + int aLength = 0, aLength1 = 0, anIndex, i, unitsSize = 0, commentSize = 0; + for(i=1; i<=aNames.size(); i++) aLength += aNames[i-1].size() + 1; - + + std::map< std::string, std::vector >::const_iterator it; + for (it = allVersions.begin(); it != allVersions.end(); ++it ) { + std::string vlist = ""; + std::vector vl = it->second; + std::vector::const_iterator vlit; + for ( vlit = vl.begin(); vlit != vl.end(); ++vlit ) { + if ( vlist != "" ) vlist += ";"; + vlist += *vlit; + } + versions[ it->first ] = vlist; + aLength1 += it->first.size() + vlist.size() + 2; + } + unitsSize = units.size(); commentSize = comment.size(); @@ -431,13 +501,16 @@ bool SALOMEDSImpl_StudyManager::Impl_SaveProperties(SALOMEDSImpl_Study* aStudy, //....................................................., //....................................................., //minutes, hours, day, months, year, user name, char(1), char(30) <- !!!! used to define end of section with modifications !!!! - //units, char(1), comment, char(0) + //units, char(1), comment, char(30) <- !!!! used to define start of section with components' versions !!!! + //component=versions, char(1), + //component=versions, char(1), + //..........................., + //component=versions, char(1), char(0) //string length: 1 byte = locked flag, 1 byte = modified flag, (12 + name length + 1) for each name and date, 1 byte (char(30) section delimeter) // unit length + 1, comment length, "zero" byte - char* aProperty = new char[3 + aLength + 12 * aNames.size() + 1 + unitsSize + 1 + commentSize ]; - + char* aProperty = new char[3 + aLength + 12 * aNames.size() + 1 + unitsSize + 1 + commentSize + 1 + aLength1 ]; sprintf(aProperty,"%c%c", (char)aProp->GetCreationMode(), (aProp->IsLocked())?'l':'u'); @@ -470,11 +543,21 @@ bool SALOMEDSImpl_StudyManager::Impl_SaveProperties(SALOMEDSImpl_Study* aStudy, if(comment.size() > 0) { sprintf(&(aProperty[a]),"%s",comment.c_str()); a = strlen(aProperty); - a++; + } + + aProperty[a++] = 30; //delimeter of the component versions + + std::map::const_iterator versionsIt; + for ( versionsIt = versions.begin(); versionsIt != versions.end(); ++versionsIt ) { + sprintf(&(aProperty[a]),"%s=%s", + (char*)(versionsIt->first.c_str()), + (char*)(versionsIt->second.c_str())); + a = a + versionsIt->first.size() + versionsIt->second.size() + 1; + aProperty[a++] = 1; } aProperty[a] = 0; - + name_len = (hdf_int32) a; size[0] = name_len + 1 ; hdf_dataset = new HDFdataset("AttributeStudyProperties",hdf_group,HDF_STRING,size,1); @@ -531,11 +614,14 @@ bool SALOMEDSImpl_StudyManager::Impl_SaveAs(const std::string& aStudyUrl, // Store previous URL std::string anOldName = aStudy->Name(); + // Map to store components' versions + std::map componentVersions; + //Create a temporary url to which the study is saved std::string aUrl = SALOMEDSImpl_Tool::GetTmpDir() + SALOMEDSImpl_Tool::GetNameFromPath(aStudyUrl); - int aLocked = aStudy->GetProperties()->IsLocked(); - if (aLocked) aStudy->GetProperties()->SetLocked(false); + // unlock study if it is locked, as some attributes need to be modified + StudyUnlocker unlock(aStudy); SALOMEDSImpl_StudyBuilder* SB= aStudy->NewBuilder(); std::map aMapTypeDriver; @@ -543,19 +629,19 @@ bool SALOMEDSImpl_StudyManager::Impl_SaveAs(const std::string& aStudyUrl, try { // mpv 15.12.2003: for saving components we have to load all data from all modules - SALOMEDSImpl_SComponentIterator itcomponent1 = aStudy->NewComponentIterator(); - for (; itcomponent1.More(); itcomponent1.Next()) + SALOMEDSImpl_SComponentIterator itcomponent = aStudy->NewComponentIterator(); + for (; itcomponent.More(); itcomponent.Next()) { - SALOMEDSImpl_SComponent sco = itcomponent1.Value(); + SALOMEDSImpl_SComponent sco = itcomponent.Value(); // if there is an associated Engine call its method for saving std::string IOREngine; try { + SALOMEDSImpl_Driver* aDriver = NULL; + std::string aCompType = sco.GetComment(); if (!sco.ComponentIOR(IOREngine)) { - std::string aCompType = sco.GetComment(); if (!aCompType.empty()) { - SALOMEDSImpl_Driver* aDriver = aFactory->GetDriverByType(aCompType); - aMapTypeDriver[aCompType] = aDriver; + aDriver = aFactory->GetDriverByType(aCompType); if (aDriver != NULL) { if(!SB->LoadWith(sco, aDriver)) { @@ -565,6 +651,10 @@ bool SALOMEDSImpl_StudyManager::Impl_SaveAs(const std::string& aStudyUrl, } } } + else { + aDriver = aFactory->GetDriverByIOR(IOREngine); + } + aMapTypeDriver[aCompType] = aDriver; } catch(...) { _errorCode = "Can not restore information to resave it"; return false; @@ -586,9 +676,7 @@ bool SALOMEDSImpl_StudyManager::Impl_SaveAs(const std::string& aStudyUrl, hdf_group_datacomponent = new HDFgroup("DATACOMPONENT",hdf_file); hdf_group_datacomponent->CreateOnDisk(); - SALOMEDSImpl_SComponentIterator itcomponent = aStudy->NewComponentIterator(); - - for (; itcomponent.More(); itcomponent.Next()) + for (itcomponent.Init(); itcomponent.More(); itcomponent.Next()) { SALOMEDSImpl_SComponent sco = itcomponent.Value(); @@ -600,20 +688,15 @@ bool SALOMEDSImpl_StudyManager::Impl_SaveAs(const std::string& aStudyUrl, std::string IOREngine; if (sco.ComponentIOR(IOREngine)) { - SALOMEDSImpl_Driver* Engine = NULL; - if(aMapTypeDriver.find(componentDataType) != aMapTypeDriver.end()) { - // we have found the associated engine to write the data - Engine = aMapTypeDriver[componentDataType]; - } - else { - Engine = aFactory->GetDriverByIOR(IOREngine); - } - + // Engine should be already in the map as it was to added before + SALOMEDSImpl_Driver* Engine = aMapTypeDriver[componentDataType]; if (Engine != NULL) { SALOMEDSImpl_TMPFile* aStream = NULL; long length = 0; + componentVersions[ componentDataType ] = Engine->Version(); + if (theASCII) aStream = Engine->SaveASCII(sco, SALOMEDSImpl_Tool::GetDirFromPath(aUrl), length, @@ -666,10 +749,9 @@ bool SALOMEDSImpl_StudyManager::Impl_SaveAs(const std::string& aStudyUrl, hdf_group_study_structure = new HDFgroup("STUDY_STRUCTURE",hdf_file); hdf_group_study_structure->CreateOnDisk(); // save component attributes - SALOMEDSImpl_SComponentIterator itcomp = aStudy->NewComponentIterator(); - for (; itcomp.More(); itcomp.Next()) + for (itcomponent.Init(); itcomponent.More(); itcomponent.Next()) { - SALOMEDSImpl_SComponent SC = itcomp.Value(); + SALOMEDSImpl_SComponent SC = itcomponent.Value(); std::string scid = SC.GetID(); hdf_sco_group2 = new HDFgroup((char*)scid.c_str(), hdf_group_study_structure); hdf_sco_group2->CreateOnDisk(); @@ -752,8 +834,15 @@ bool SALOMEDSImpl_StudyManager::Impl_SaveAs(const std::string& aStudyUrl, } hdf_notebook_vars->CloseOnDisk(); hdf_notebook_vars = 0; //will be deleted by hdf_sco_group destructor - - if (aLocked) aStudy->GetProperties()->SetLocked(true); + + // record component versions + std::map::const_iterator itVersions; + for ( itVersions = componentVersions.begin(); itVersions != componentVersions.end(); ++itVersions ) + aStudy->GetProperties()->SetComponentVersion( itVersions->first, itVersions->second ); + + // lock study back if it was locked initially, to write correct value of Locked flag + unlock.suspend(); + //----------------------------------------------------------------------- //6 - Write the Study Properties //----------------------------------------------------------------------- -- 2.39.2