SET(CALCIUM_IDL_INT_F77 long)
SET(CALCIUM_CORBA_INT_F77 CORBA::Long)
SET(LONG_OR_INT int)
-# Global definitions
-ADD_DEFINITIONS(-DSIZEOF_FORTRAN_INTEGER=4 -DSIZEOF_INT=4)
-## OmniORB already defines SIZEOF_LONG
-# ADD_DEFINITIONS(-DSIZEOF_LONG=${SIZE_OF_LONG})
# User options
# ============
# Advanced:
OPTION(SALOME_LIGHT_ONLY "Build SALOME Light only (no CORBA)" OFF)
OPTION(SALOME_USE_LIBBATCH "Use LibBatch in KERNEL" OFF)
+OPTION(SALOME_USE_SIMAN "Add SIMAN support" OFF)
OPTION(SALOME_PACO_PARALLEL "Build with PACO (implies SALOME_USE_MPI)" OFF)
OPTION(SALOME_LAUNCHER_ONLY "Build only the Launcher part" OFF)
-MARK_AS_ADVANCED(SALOME_LIGHT_ONLY SALOME_USE_LIBBATCH SALOME_PACO_PARALLEL SALOME_LAUNCHER_ONLY)
+MARK_AS_ADVANCED(SALOME_LIGHT_ONLY SALOME_USE_LIBBATCH SALOME_USE_SIMAN SALOME_PACO_PARALLEL SALOME_LAUNCHER_ONLY)
# Required prerequisites
# Find "big" prerequisites first - they reference themselves many others
# Optional prerequisites
# ======================
+IF(SALOME_USE_SIMAN)
+ FIND_PACKAGE(SalomeSIMANIO)
+ SALOME_LOG_OPTIONAL_PACKAGE(SIMANIO SALOME_USE_SIMAN)
+ ADD_DEFINITIONS(-DWITH_SIMANIO)
+ENDIF()
IF(NOT SALOME_LIGHT_ONLY)
FIND_PACKAGE(SalomeOmniORB REQUIRED)
FIND_PACKAGE(SalomeOmniORBPy REQUIRED)
MARK_AS_ADVANCED(SALOME_INSTALL_PYTHON SALOME_INSTALL_PYTHON_SHARED SALOME_KERNEL_INSTALL_RES_DATA SALOME_KERNEL_INSTALL_RES_SCRIPTS SALOME_INSTALL_DOC)
MARK_AS_ADVANCED(SALOME_INSTALL_AMCONFIG SALOME_INSTALL_AMCONFIG_LOCAL)
+# Accumulate environment variables for KERNEL module
+SALOME_ACCUMULATE_ENVIRONMENT(PYTHONPATH NOCHECK ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_BINS}
+ ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_PYTHON}
+ ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_PYTHON_SHARED})
+SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH NOCHECK ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_LIBS})
+
# Sources
# ========
IF(NOT SALOME_LIGHT_ONLY)
# List of targets in this project we want to make visible to the rest of the world.
# They all have to be INSTALL'd with the option "EXPORT ${PROJECT_NAME}TargetGroup"
-# Temporary solution for pakage src\DSC on windows
+# Temporary solution for package src\DSC on windows
IF(NOT WIN32)
SET(DSC_TGS CalciumC SalomeCalcium SalomeDatastream
SalomePalm SalomeDSCSupervBasic SalomeDSCSuperv)
SET(OMNIORB_ROOT_DIR "${OMNIORB_ROOT_DIR}")
SET(OMNIORBPY_ROOT_DIR "${OMNIORBPY_ROOT_DIR}")
SET(LIBBATCH_ROOT_DIR "${LIBBATCH_ROOT_DIR}")
-
+SET(SIMANIO_ROOT_DIR "${SIMANIO_ROOT_DIR}")
+
SET(CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/include" "${PROJECT_BINARY_DIR}/include")
-CONFIGURE_PACKAGE_CONFIG_FILE(salome_adm/cmake_files/${PROJECT_NAME}Config.cmake.in
+
+# Build variables that will be expanded when configuring Salome<MODULE>Config.cmake:
+SALOME_CONFIGURE_PREPARE(CppUnit Graphviz Doxygen Sphinx MPI omniORB LibBatch
+ PThread Boost HDF5 libXml2 Python SIMANIO HDF5)
+
+CONFIGURE_PACKAGE_CONFIG_FILE(${PROJECT_NAME}Config.cmake.in
${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
INSTALL_DESTINATION "${SALOME_INSTALL_CMAKE}"
PATH_VARS CONF_INCLUDE_DIRS SALOME_INSTALL_CMAKE CMAKE_INSTALL_PREFIX
CPPUNIT_ROOT_DIR GRAPHVIZ_ROOT_DIR DOXYGEN_ROOT_DIR
SPHINX_ROOT_DIR MPI_ROOT_DIR OMNIORB_ROOT_DIR OMNIORBPY_ROOT_DIR LIBBATCH_ROOT_DIR
- PTHREAD_ROOT_DIR BOOST_ROOT_DIR HDF5_ROOT_DIR LIBXML2_ROOT_DIR
+ SIMANIO_ROOT_DIR PTHREAD_ROOT_DIR BOOST_ROOT_DIR HDF5_ROOT_DIR LIBXML2_ROOT_DIR
PYTHON_ROOT_DIR SWIG_ROOT_DIR)
# - in the install tree (VSR 16/08/2013: TEMPORARILY COMMENT THIS - TO REMOVE?):
# PATH_VARS CONF_INCLUDE_DIRS SALOME_INSTALL_CMAKE CMAKE_INSTALL_PREFIX
# CPPUNIT_ROOT_DIR GRAPHVIZ_ROOT_DIR DOXYGEN_ROOT_DIR
# SPHINX_ROOT_DIR MPI_ROOT_DIR OMNIORB_ROOT_DIR OMNIORBPY_ROOT_DIR LIBBATCH_ROOT_DIR
-# PTHREAD_ROOT_DIR BOOST_ROOT_DIR HDF5_ROOT_DIR LIBXML2_ROOT_DIR
+# SIMANIO_ROOT_DIR PTHREAD_ROOT_DIR BOOST_ROOT_DIR HDF5_ROOT_DIR LIBXML2_ROOT_DIR
# PYTHON_ROOT_DIR SWIG_ROOT_DIR)
WRITE_BASIC_PACKAGE_VERSION_FILE(${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
--- /dev/null
+# - Config file for the @PROJECT_NAME@ package
+# It defines the following variables.
+# Specific to the pacakge @PROJECT_NAME@ itself:
+# @PROJECT_NAME_UC@_ROOT_DIR_EXP - the root path of the installation providing this CMake file
+#
+# Other stuff specific to this package:
+# SALOME_USE_MPI - ON if KERNEL is built with MPI support
+# SALOME_KERNEL_BUILD_DOC - ON if documentation for KERNEL module has been built
+# SALOME_KERNEL_BUILD_TESTS - ON if tests for KERNEL module has been built
+# SALOME_LIGHT_ONLY - ON if SALOME is built in Light mode (no CORBA)
+
+###############################################################
+# Copyright (C) 2007-2013 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
+###############################################################
+
+### Initialisation performed by CONFIGURE_PACKAGE_CONFIG_FILE:
+@PACKAGE_INIT@
+
+# Load the dependencies for the libraries of @PROJECT_NAME@
+# (contains definitions for IMPORTED targets). This is only
+# imported if we are not built as a subproject (in this case targets are already there)
+IF(NOT TARGET SALOMEBasics AND NOT @PROJECT_NAME@_BINARY_DIR)
+ INCLUDE("@PACKAGE_SALOME_INSTALL_CMAKE@/@PROJECT_NAME@Targets.cmake")
+ENDIF()
+
+# Package root dir:
+SET_AND_CHECK(KERNEL_ROOT_DIR_EXP "@PACKAGE_CMAKE_INSTALL_PREFIX@")
+
+# Include directories and definitions
+SET_AND_CHECK(KERNEL_INCLUDE_DIRS "${KERNEL_ROOT_DIR_EXP}/@SALOME_INSTALL_HEADERS@")
+SET(KERNEL_INCLUDE_DIRS "${KERNEL_INCLUDE_DIRS};@_SalomeKERNEL_EXTRA_HEADERS@")
+SET(KERNEL_DEFINITIONS)
+
+# Package specific environment variables
+@_SalomeKERNEL_EXTRA_ENV_FULL@
+
+#### Now the specificities
+
+# Options exported by the package:
+SET(SALOME_USE_MPI @SALOME_USE_MPI@)
+IF(SALOME_USE_MPI)
+ LIST(APPEND KERNEL_INCLUDE_DIRS "@MPI_INCLUDE_DIRS@")
+ LIST(APPEND KERNEL_DEFINITIONS "@MPI_DEFINITIONS@")
+ENDIF()
+
+SET(SALOME_KERNEL_BUILD_DOC @SALOME_BUILD_DOC@)
+SET(SALOME_KERNEL_BUILD_TESTS @SALOME_BUILD_TESTS@)
+SET(SALOME_LIGHT_ONLY @SALOME_LIGHT_ONLY@)
+SET(SALOME_USE_LIBBATCH @SALOME_USE_LIBBATCH@)
+
+SET(SALOME_USE_SIMAN @SALOME_USE_SIMAN@)
+IF(SALOME_USE_SIMAN)
+ LIST(APPEND KERNEL_DEFINITIONS "-DWITH_SIMANIO")
+ENDIF()
+
+# Prerequisites:
+IF(SALOME_KERNEL_BUILD_TESTS)
+ SET_AND_CHECK(CPPUNIT_ROOT_DIR_EXP "@PACKAGE_CPPUNIT_ROOT_DIR@")
+ENDIF()
+IF(SALOME_KERNEL_BUILD_DOC)
+ SET_AND_CHECK(GRAPHVIZ_ROOT_DIR_EXP "@PACKAGE_GRAPHVIZ_ROOT_DIR@")
+ SET_AND_CHECK(DOXYGEN_ROOT_DIR_EXP "@PACKAGE_DOXYGEN_ROOT_DIR@")
+ SET_AND_CHECK(SPHINX_ROOT_DIR_EXP "@PACKAGE_SPHINX_ROOT_DIR@")
+ENDIF()
+IF(SALOME_USE_MPI)
+ SET_AND_CHECK(MPI_ROOT_DIR_EXP "@PACKAGE_MPI_ROOT_DIR@")
+ENDIF()
+IF(NOT SALOME_LIGHT_ONLY)
+ SET_AND_CHECK(OMNIORB_ROOT_DIR_EXP "@PACKAGE_OMNIORB_ROOT_DIR@")
+ SET_AND_CHECK(OMNIORBPY_ROOT_DIR_EXP "@PACKAGE_OMNIORBPY_ROOT_DIR@")
+ENDIF()
+IF(SALOME_USE_LIBBATCH)
+ SET_AND_CHECK(LIBBATCH_ROOT_DIR_EXP "@PACKAGE_LIBBATCH_ROOT_DIR@")
+ENDIF()
+IF(SALOME_USE_SIMAN)
+ SET_AND_CHECK(SIMANIO_ROOT_DIR_EXP "@PACKAGE_SIMANIO_ROOT_DIR@")
+ENDIF()
+
+SET_AND_CHECK(PTHREAD_ROOT_DIR_EXP "@PACKAGE_PTHREAD_ROOT_DIR@")
+SET_AND_CHECK(HDF5_ROOT_DIR_EXP "@PACKAGE_HDF5_ROOT_DIR@")
+SET_AND_CHECK(LIBXML2_ROOT_DIR_EXP "@PACKAGE_LIBXML2_ROOT_DIR@")
+SET_AND_CHECK(PYTHON_ROOT_DIR_EXP "@PACKAGE_PYTHON_ROOT_DIR@")
+SET_AND_CHECK(SWIG_ROOT_DIR_EXP "@PACKAGE_SWIG_ROOT_DIR@")
+
+# For all prerequisites, load the corresponding targets if the package was used
+# in CONFIG mode. This ensures dependent projects link correctly
+# without having to set LD_LIBRARY_PATH:
+SET(_PREREQ @_PREREQ_LIST@)
+SET(_PREREQ_CONFIG_DIR @_PREREQ_DIR_LIST@)
+SET(_PREREQ_COMPONENTS "@_PREREQ_COMPO_LIST@")
+LIST(LENGTH _PREREQ_CONFIG_DIR _list_len)
+IF(NOT _list_len EQUAL 0)
+ # Another CMake stupidity - FOREACH(... RANGE r) generates r+1 numbers ...
+ MATH(EXPR _range "${_list_len}-1")
+ FOREACH(_p RANGE ${_range})
+ LIST(GET _PREREQ ${_p} _pkg )
+ LIST(GET _PREREQ_CONFIG_DIR ${_p} _pkg_dir)
+ LIST(GET _PREREQ_COMPONENTS ${_p} _pkg_compo)
+ MESSAGE(STATUS "===> Reloading targets from ${_pkg} ...")
+ IF(NOT _pkg_compo)
+ FIND_PACKAGE(${_pkg} REQUIRED NO_MODULE
+ PATHS "${_pkg_dir}"
+ NO_DEFAULT_PATH)
+ ELSE()
+ STRING(REPLACE "," ";" _compo_lst "${_pkg_compo}")
+ MESSAGE(STATUS "===> (components: ${_pkg_compo})")
+ FIND_PACKAGE(${_pkg} REQUIRED NO_MODULE
+ COMPONENTS ${_compo_lst}
+ PATHS "${_pkg_dir}"
+ NO_DEFAULT_PATH)
+ ENDIF()
+ ENDFOREACH()
+ENDIF()
+
+# Installation directories
+SET(SALOME_INSTALL_BINS "@SALOME_INSTALL_BINS@")
+SET(SALOME_INSTALL_LIBS "@SALOME_INSTALL_LIBS@")
+SET(SALOME_INSTALL_IDLS "@SALOME_INSTALL_IDLS@")
+SET(SALOME_INSTALL_HEADERS "@SALOME_INSTALL_HEADERS@")
+SET(SALOME_INSTALL_SCRIPT_SCRIPTS "@SALOME_INSTALL_SCRIPT_SCRIPTS@")
+SET(SALOME_INSTALL_SCRIPT_DATA "@SALOME_INSTALL_SCRIPT_DATA@")
+SET(SALOME_INSTALL_SCRIPT_PYTHON "@SALOME_INSTALL_SCRIPT_PYTHON@")
+SET(SALOME_INSTALL_APPLISKEL_SCRIPTS "@SALOME_INSTALL_APPLISKEL_SCRIPTS@")
+SET(SALOME_INSTALL_APPLISKEL_PYTHON "@SALOME_INSTALL_APPLISKEL_PYTHON@")
+SET(SALOME_INSTALL_CMAKE "@SALOME_INSTALL_CMAKE@")
+SET(SALOME_INSTALL_CMAKE_LOCAL "@SALOME_INSTALL_CMAKE_LOCAL@")
+SET(SALOME_INSTALL_PYTHON "@SALOME_INSTALL_PYTHON@")
+SET(SALOME_INSTALL_PYTHON_SHARED "@SALOME_INSTALL_PYTHON_SHARED@")
+SET(SALOME_INSTALL_RES "@SALOME_INSTALL_RES@")
+SET(SALOME_INSTALL_DOC "@SALOME_INSTALL_DOC@")
+SET(SALOME_INSTALL_AMCONFIG "@SALOME_INSTALL_AMCONFIG@") # to be removed
+SET(SALOME_INSTALL_AMCONFIG_LOCAL "@SALOME_INSTALL_AMCONFIG_LOCAL@") # to be removed
+
+# Exposed targets:
+SET(KERNEL_CalciumC CalciumC)
+SET(KERNEL_DF DF)
+SET(KERNEL_Launcher Launcher)
+SET(KERNEL_LifeCycleCORBATest LifeCycleCORBATest)
+SET(KERNEL_NamingServiceTest NamingServiceTest)
+SET(KERNEL_OpUtil OpUtil)
+SET(KERNEL_Registry Registry)
+SET(KERNEL_ResourcesManager ResourcesManager)
+SET(KERNEL_SALOMEBasics SALOMEBasics)
+SET(KERNEL_SalomeCatalog SalomeCatalog)
+SET(KERNEL_SalomeCommunication SalomeCommunication)
+SET(KERNEL_SalomeContainer SalomeContainer)
+SET(KERNEL_SalomeDatastream SalomeDatastream)
+SET(KERNEL_SalomeDSCContainer SalomeDSCContainer)
+SET(KERNEL_SalomeDSClient SalomeDSClient)
+SET(KERNEL_SalomeDSCSupervBasic SalomeDSCSupervBasic)
+SET(KERNEL_SalomeDSCSuperv SalomeDSCSuperv)
+SET(KERNEL_SalomeDSImpl SalomeDSImpl)
+SET(KERNEL_SALOMEDSImplTest SALOMEDSImplTest)
+SET(KERNEL_SalomeDS SalomeDS)
+SET(KERNEL_SALOMEDSTest SALOMEDSTest)
+SET(KERNEL_SalomeGenericObj SalomeGenericObj)
+SET(KERNEL_SalomeHDFPersist SalomeHDFPersist)
+SET(KERNEL_SalomeIDLKernel SalomeIDLKernel)
+SET(KERNEL_SalomeLauncher SalomeLauncher)
+SET(KERNEL_SalomeLifeCycleCORBA SalomeLifeCycleCORBA)
+SET(KERNEL_SALOMELocalTrace SALOMELocalTrace)
+SET(KERNEL_SALOMELocalTraceTest SALOMELocalTraceTest)
+SET(KERNEL_SalomeLoggerServer SalomeLoggerServer)
+SET(KERNEL_SalomeMPIContainer SalomeMPIContainer)
+SET(KERNEL_SalomeNotification SalomeNotification)
+SET(KERNEL_SalomeNS SalomeNS)
+SET(KERNEL_SalomeResourcesManager SalomeResourcesManager)
+SET(KERNEL_SalomeTestComponentEngine SalomeTestComponentEngine)
+SET(KERNEL_SalomeTestMPIComponentEngine SalomeTestMPIComponentEngine)
+SET(KERNEL_SALOMETraceCollectorTest SALOMETraceCollectorTest)
+SET(KERNEL_TOOLSDS TOOLSDS)
+SET(KERNEL_UtilsTest UtilsTest)
+SET(KERNEL_with_loggerTraceCollector with_loggerTraceCollector)
+SET(KERNEL_SalomeKernelHelpers SalomeKernelHelpers)
pm.releasePort(port)
response = "%s" % (RELEASE_PORT_ACK_MSG)
_send(self.request, response)
- #print "RELEASE_PORT:", port
+ print "RELEASE_PORT:", port
if not pm.isBusy():
- #print "Close server"
+ print "Close server"
self.server.shutdown()
#print pm
elif data == STOP_SERVER_MSG:
- #print "Close server"
+ print "Close server"
self.server.shutdown()
#
#server_thread.setDaemon(True)
server_thread.start()
#print "Server loop running in thread:", server_thread.getName()
- #print "Server address:", pm_address
+ print "Server address:", pm_address
#return address
except:
- #print "Server already started"
+ print "Server already started"
#print "Server address:", pm_address
#return pm_address
pass
response = _receive(sock)
if response.startswith(GET_PORT_ACK_MSG):
port = int(response[len(GET_PORT_ACK_MSG)+1:])
- #print "GET_PORT:", port
+ print "GET_PORT:", port
return port
elif response == RELEASE_PORT_ACK_MSG:
#print "Received: %s" % response
pass
sock.close()
except socket.error:
- #print "Unable to connect to server"
+ print "Unable to connect to server"
return -1
#
os.environ['APPLI'] = appliPath # needed to convert .sh environment files
os.environ['ABSOLUTE_APPLI_PATH'] = absoluteAppliPath
- # define folder to store omniorb config (initially in virtual application folder)
- #omniorbUserPath = os.path.join(homePath, ".salomeConfig/USERS")
- omniorbUserPath = os.path.join(homePath, appliPath, "USERS")
- os.environ['OMNIORB_USER_PATH'] = omniorbUserPath
- if not os.path.exists(omniorbUserPath):
- os.makedirs(omniorbUserPath)
-
sys.path[:0] = [absoluteAppliPath+'/bin/salome']
+
+ # define folder to store omniorb config (initially in virtual application folder)
+ try:
+ from salomeLauncherUtils import setOmniOrbUserPath
+ setOmniOrbUserPath()
+ except Exception, e:
+ print e
+ sys.exit(1)
# End of preliminary work
def main(args):
usage()
sys.exit(0)
-
from salomeLauncherUtils import getConfigFileNames
- configFileNames, args = getConfigFileNames(args)
-
- # WHY? Incorrect/Inexisting files are supposed to be ignored by SalomeRunner.
- # Might simply need bug fix; please provide test case.
- error=False
- for aFile in configFileNames:
- if not os.path.isfile(aFile):
- print "ERROR: inexisting file: "+aFile
- error=True
- if error:
+ configFileNames, args, unexisting = getConfigFileNames(args, checkExistence=True)
+ if len(unexisting) > 0:
+ print "ERROR: unexisting configuration file(s): " + ', '.join(unexisting)
sys.exit(1)
-
# Create a SalomeRunner which parses configFileNames to initialize environment
try:
from salomeRunner import SalomeRunner, SalomeRunnerException
# runner.addToPythonPath('mypythonpath')
# runner.setEnviron('myvarname', 'value')
- kernel_root_dir = os.getenv("KERNEL_ROOT_DIR")
- if kernel_root_dir:
- runner.addToLdLibraryPath(os.path.join(kernel_root_dir, "lib/salome"))
-
- gui_root_dir = os.getenv("GUI_ROOT_DIR")
- if gui_root_dir:
- runner.addToLdLibraryPath(os.path.join(gui_root_dir, "lib/salome"))
-
- paravis_root_dir = os.getenv("PARAVIS_ROOT_DIR")
- if paravis_root_dir:
- runner.addToLdLibraryPath(os.path.join(paravis_root_dir, "lib/salome"))
-
-
# Start SALOME, parsing command line arguments
runner.go(args)
print 'Thank you for using SALOME!'
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
-ADD_SUBDIRECTORY(concurrentSession)
+#ADD_SUBDIRECTORY(concurrentSession)
ADD_SUBDIRECTORY(launcher)
shutdown_servers_nam = "shutdown_servers"
foreground_nam = "foreground"
wake_up_session_nam = "wake_up_session"
+siman_nam = "siman"
+siman_study_nam = "siman_study"
+siman_scenario_nam = "siman_scenario"
+siman_user_nam = "siman_user"
# values in XML configuration file giving specific module parameters (<module_name> section)
# which are stored in opts with key <module_name>_<parameter> (eg SMESH_plugins)
o_port = optparse.Option("--port",
metavar="<port>",
type="int",
- action="store",
+ action="store",
dest="use_port",
- help=help_str)
+ help=help_str)
+
+ # SIMAN launch mode
+ help_str = "Special mode for interacting with SIMAN."
+ o_siman = optparse.Option("--siman",
+ action="store_true",
+ dest="siman",
+ help=help_str)
+
+ # SIMAN study
+ help_str = "SIMAN study identifier."
+ o_siman_study = optparse.Option("--siman-study",
+ metavar="<id>",
+ type="string",
+ action="store",
+ dest="siman_study",
+ help=help_str)
+
+ # SIMAN scenario
+ help_str = "SIMAN scenario identifier."
+ o_siman_scenario = optparse.Option("--siman-scenario",
+ metavar="<id>",
+ type="string",
+ action="store",
+ dest="siman_scenario",
+ help=help_str)
+
+ # SIMAN user
+ help_str = "SIMAN user identifier."
+ o_siman_user = optparse.Option("--siman-user",
+ metavar="<id>",
+ type="string",
+ action="store",
+ dest="siman_user",
+ help=help_str)
# All options
opt_list = [o_t,o_g, # GUI/Terminal
o_wake_up,
o_slm, # Server launch mode
o_port, # Use port
+ o_siman, # Siman launch mode
+ o_siman_study, # Siman study
+ o_siman_scenario,# Siman scenario
+ o_siman_user, # Siman user
]
#std_options = ["gui", "desktop", "log_file", "resources",
if cmd_opts.wake_up_session is not None:
args[wake_up_session_nam] = cmd_opts.wake_up_session
+ # siman options
+ if cmd_opts.siman is not None:
+ args[siman_nam] = cmd_opts.siman
+ if cmd_opts.siman_study is not None:
+ args[siman_study_nam] = cmd_opts.siman_study
+ if cmd_opts.siman_scenario is not None:
+ args[siman_scenario_nam] = cmd_opts.siman_scenario
+ if cmd_opts.siman_user is not None:
+ args[siman_user_nam] = cmd_opts.siman_user
+
####################################################
# Add <theAdditionalOptions> values to args
for add_opt in theAdditionalOptions:
logConfigParser.error("No section found in file: %s"%(filename))
return []
- return _processConfigFile(config, reserved, filename)
+ return __processConfigFile(config, reserved, filename)
#
-def _processConfigFile(config, reserved = [], filename="UNKNOWN FILENAME"):
+def __processConfigFile(config, reserved = [], filename="UNKNOWN FILENAME"):
# :TODO: may detect duplicated variables in the same section (raise a warning)
# or even duplicate sections
break
while "clean " in line[0:6]: #skip clean calls with ending ";" crash
line = self.fp.readline()
+ # Extract variable=value
if "=" in line:
try:
variable, value = line.split('=')
except: #avoid error for complicated sh line xx=`...=...`, but warning
print "WARNING: parseConfigFile.py: line with multiples '=' character are hazardous: '"+line+"'"
variable, value = line.split('=',1)
+ pass
+
+ # Self-extending variables that are not in reserved keywords
+ # Example: FOO=something:${FOO}
+ # In this case, remove the ${FOO} in value
+ if variable in value:
+ value = self._purgeValue(value, variable)
+ line = "%s=%s"%(variable,value)
+
self.allParsedVariableNames.append(variable)
- # Self-extending variables that are not in reserved keywords
- # Example: FOO=something:${FOO}
- # :TODO:
+ # End of extraction
+
+ if not line:
+ return line
+
#
# replace "${FOO}" and "$FOO" and ${FOO} and $FOO by %(FOO)s if FOO is
# defined in current file (i.e. it is not an external environment variable)
key = r'\$\{?'+k+'\}?'
pattern = re.compile(key, re.VERBOSE)
line = pattern.sub(r'%('+k+')s', line)
- # Remove quotes
- pattern = re.compile(r'\"', re.VERBOSE)
- line = pattern.sub(r'', line)
+ # Remove quotes (if line does not contain whitespaces)
+ try:
+ variable, value = line.split('=', 1)
+ except ValueError:
+ variable, value = line.split(':', 1)
+ if not ' ' in value.strip():
+ pattern = re.compile(r'\"', re.VERBOSE)
+ line = pattern.sub(r'', line)
#
+
# Replace `shell_command` by its result
def myrep(obj):
obj = re.sub('`', r'', obj.group(0)) # remove quotes
#
# Convert .sh environment file to configuration file format
-def convertEnvFileToConfigFile(envFilename, configFilename):
- #reserved=['PATH', 'LD_LIBRARY_PATH', 'PYTHONPATH']
+def convertEnvFileToConfigFile(envFilename, configFilename, reserved=[]):
logConfigParser.debug('convert env file %s to %s'%(envFilename, configFilename))
- reserved=['PATH', 'LD_LIBRARY_PATH', 'PYTHONPATH', 'MANPATH', 'R_LIBS', 'PV_PLUGIN_PATH', 'TCLLIBPATH', 'TKLIBPATH']
fileContents = open(envFilename, 'r').read()
pattern = re.compile('\n[\n]+', re.VERBOSE) # multiple '\n'
from launchConfigureParser import verbose
from server import process_id, Server
import json
-from salomeLauncherUtils import formatScriptsAndArgs
import subprocess
# -----------------------------------------------------------------------------
return cata_path
-
+_siman_name = None
+def simanStudyName(args):
+ global _siman_name
+ if _siman_name is None:
+ # siman session paramenters and checkout processing
+ _siman_name = ""
+ if 'siman' in args:
+ siman_data = []
+ for param in [ 'study', 'scenario', 'user']:
+ siman_param = "siman_%s"%param
+ if siman_param in args:
+ siman_data.append(args[siman_param])
+ else:
+ print "SIMAN %s must be defined using parameter --siman-%s=XXX" % (siman_param, siman_param)
+ pass
+ pass
+ if len(siman_data) == 3:
+ _siman_name = "_".join(siman_data)
+ pass
+ pass
+ pass
+ return _siman_name
class CatalogServer(Server):
def __init__(self,args):
if self.args['study_hdf'] is not None:
self.SCMD2+=['--study-hdf=%s'%self.args['study_hdf']]
pass
+ if simanStudyName(self.args):
+ self.SCMD2+=['--siman-study=%s'%simanStudyName(self.args)]
+ pass
pass
if self.args.has_key('pyscript') and len(self.args['pyscript']) > 0:
msg = json.dumps(self.args['pyscript'])
myServer=NotifyServer(args,modules_root_dir)
myServer.run()
+ # set siman python path before the session server launching to import scripts inside python console
+ if simanStudyName(args):
+ # MPV: use os.environ here because session server is launched in separated process and sys.path is missed in this case
+ os.environ["PYTHONPATH"] = "/tmp/SimanSalome/" + args['siman_study'] + "/" + \
+ args['siman_scenario'] + "/" + args['siman_user'] + os.pathsep + os.environ["PYTHONPATH"];
+
# Launch Session Server (to show splash ASAP)
#
except ImportError:
pass
+ # siman session paramenters and checkout processing
+ if simanStudyName(args):
+ print '**********************************************'
+ print "Siman study name= '" + simanStudyName(args) + "'"
+ import SALOMEDS
+ obj = clt.Resolve('myStudyManager')
+ myStudyManager = obj._narrow(SALOMEDS.StudyManager)
+ aNewStudy = myStudyManager.NewStudy(simanStudyName(args))
+ aSimS = myStudyManager.GetSimanStudy()
+ aSimS._set_StudyId(args['siman_study'])
+ aSimS._set_ScenarioId(args['siman_scenario'])
+ aSimS._set_UserId(args['siman_user'])
+ aSimS.CheckOut(aNewStudy)
+ # if session server is enabled, activate the created study
+ if args["gui"]:
+ print "Activate the SIMAN study in the SALOME GUI"
+ obj = clt.Resolve('/Kernel/Session')
+ mySession = obj._narrow(SALOME.Session)
+ mySession.emitMessage("simanCheckoutDone " + simanStudyName(args))
+ print '**********************************************'
+
return clt
# -----------------------------------------------------------------------------
if not args['gui'] or not args['session_gui']:
toimport = args['pyscript']
+ from salomeLauncherUtils import formatScriptsAndArgs
command = formatScriptsAndArgs(toimport)
if command:
proc = subprocess.Popen(command, shell=True)
- proc.wait()
+ res = proc.wait()
+ if res: sys.exit(1) # if there's an error when executing script, we should explicitly exit
return clt
def main():
"""Salome launch as a main application"""
- ### TEMP >>> ###
- if not os.getenv("OMNIORB_USER_PATH"):
- homePath = os.path.realpath(os.path.expanduser('~'))
- #defaultOmniorbUserPath = os.path.join(homePath, ".salomeConfig/USERS")
- defaultOmniorbUserPath = homePath
- if os.getenv("APPLI"):
- defaultOmniorbUserPath = os.path.join(homePath, os.getenv("APPLI"), "USERS")
- os.environ["OMNIORB_USER_PATH"] = defaultOmniorbUserPath
- pass
- ### <<< TEMP ###
+ # define folder to store omniorb config (initially in virtual application folder)
+ try:
+ from salomeLauncherUtils import setOmniOrbUserPath
+ setOmniOrbUserPath()
+ except Exception, e:
+ print e
+ sys.exit(1)
from salome_utils import getHostName
print "runSalome running on %s" % getHostName()
return __listDirectory(envdDir)
#
-def getConfigFileNames(args):
+def getConfigFileNames(args, checkExistence=False):
# special case: configuration files are provided by user
# Search for command-line argument(s) --config=file1,file2,..., filen
# Search for command-line argument(s) --config=dir1,dir2,..., dirn
configArgs = [ str(x) for x in args if str(x).startswith(configOptionPrefix) ]
if len(configArgs) == 0:
- return __getConfigFileNamesDefault(), args
+ return __getConfigFileNamesDefault(), args, []
args = [ x for x in args if not x.startswith(configOptionPrefix) ]
allLists = [ x.replace(configOptionPrefix, '') for x in configArgs ]
configFileNames = []
+ unexisting = []
for currentList in allLists:
elements = currentList.split(',')
for elt in elements:
if os.path.isdir(elt):
configFileNames += __listDirectory(elt)
else:
- configFileNames += [elt]
+ if checkExistence and not os.path.isfile(elt):
+ unexisting += [elt]
+ else:
+ configFileNames += [elt]
- return configFileNames, args
+ return configFileNames, args, unexisting
#
# Return an array of dictionaries {script_name: [list_of_its_args]}
command = "; ".join(["%s"%x for x in commands])
return command
#
+
+# Ensure OMNIORB_USER_PATH is defined. This variable refers to a the folder in which
+# SALOME will write omniOrb configuration files.
+# If OMNIORB_USER_PATH is already set, only checks write access to associated directory ;
+# an exception is raised if check fails. It allows users for choosing a specific folder.
+# Else the function sets OMNIORB_USER_PATH this way:
+# - If APPLI environment variable is set, OMNIORB_USER_PATH is set to ${APPLI}/USERS.
+# The function does not check USERS folder existence or wrute access. This folder
+# must exist ; this is the case if SALOME virtual application has been create using
+# appli_gen.py script.
+# - Else OMNIORB_USER_PATH is set to user home directory.
+def setOmniOrbUserPath():
+ omniorbUserPath = os.getenv("OMNIORB_USER_PATH")
+ if omniorbUserPath:
+ if not os.access(omniorbUserPath, os.W_OK):
+ raise Exception("Unable to get write access to directory: %s"%omniorbUserPath)
+ pass
+ else:
+ homePath = os.path.realpath(os.path.expanduser('~'))
+ #defaultOmniorbUserPath = os.path.join(homePath, ".salomeConfig/USERS")
+ defaultOmniorbUserPath = homePath
+ if os.getenv("APPLI"):
+ defaultOmniorbUserPath = os.path.join(homePath, os.getenv("APPLI"), "USERS")
+ pass
+ os.environ["OMNIORB_USER_PATH"] = defaultOmniorbUserPath
+#
if len(configFileNames) == 0:
raise SalomeRunnerException("No configuration files given")
+ reserved=['PATH', 'LD_LIBRARY_PATH', 'PYTHONPATH', 'MANPATH', 'PV_PLUGIN_PATH']
for filename in configFileNames:
basename, extension = os.path.splitext(filename)
if extension == ".cfg":
- self.__setEnvironmentFromConfigFile(filename)
+ self.__setEnvironmentFromConfigFile(filename, reserved)
elif extension == ".sh":
#new convert procedures, temporary could be use not to be automatically deleted
#temp = tempfile.NamedTemporaryFile(suffix='.cfg', delete=False)
temp = tempfile.NamedTemporaryFile(suffix='.cfg')
try:
- convertEnvFileToConfigFile(filename, temp.name)
- self.__setEnvironmentFromConfigFile(temp.name)
+ convertEnvFileToConfigFile(filename, temp.name, reserved)
+ self.__setEnvironmentFromConfigFile(temp.name, reserved)
except ConfigParser.ParsingError, e:
self.getLogger().warning("Invalid token found when parsing file: %s\n"%(filename))
print e
"""Append value to PATH environment variable"""
def addToPath(self, value):
- self.__addToReserved('PATH', value)
+ self.addToEnviron('PATH', value)
#
"""Append value to LD_LIBRARY_PATH environment variable"""
def addToLdLibraryPath(self, value):
- self.__addToReserved('LD_LIBRARY_PATH', value)
+ self.addToEnviron('LD_LIBRARY_PATH', value)
#
"""Append value to PYTHONPATH environment variable"""
def addToPythonPath(self, value):
- self.__addToReserved('PYTHONPATH', value)
- #
-
- """Append value to TCLLIBPATH environment variable"""
- def addToTclLibPath(self, value):
- self.__addToReservedTclTk('TCLLIBPATH', value)
- #
-
- """Append value to TKLIBPATH environment variable"""
- def addToTkLibPath(self, value):
- self.__addToReservedTclTk('TKLIBPATH', value)
+ self.addToEnviron('PYTHONPATH', value)
#
"""Set environment variable to value"""
del os.environ[name]
#
+ """Append value to environment variable"""
+ def addToEnviron(self, name, value, separator=os.pathsep):
+ if value == '':
+ return
+
+ value = os.path.expandvars(value) # expand environment variables
+ self.getLogger().debug("Add to %s: %s", name, value)
+ env = os.getenv(name, None)
+ if env is None:
+ os.environ[name] = value
+ else:
+ os.environ[name] = value + separator + env
+ #
+
###################################
# This begins the private section #
###################################
sys.exit(1)
#
- def __setEnvironmentFromConfigFile(self, filename):
- unsetVars, configVars, reservedDict = parseConfigFile(filename, reserved=['PATH', 'LD_LIBRARY_PATH', 'PYTHONPATH'])
+ def __setEnvironmentFromConfigFile(self, filename, reserved=[]):
+ unsetVars, configVars, reservedDict = parseConfigFile(filename, reserved)
# unset variables
for var in unsetVars:
for reserved in reservedDict:
a = filter(None, reservedDict[reserved]) # remove empty elements
reformattedVals = ':'.join(a)
- self.__addToReserved(reserved, reformattedVals)
+ self.addToEnviron(reserved, reformattedVals)
pass
for key,val in configVars:
sys.path[:0] = os.getenv('PYTHONPATH','').split(':')
#
- def __addToReserved(self, name, value):
- if value == '':
- return
-
- value = os.path.expandvars(value) # expand environment variables
- self.getLogger().debug("Add to %s: %s", name, value)
- env = os.getenv(name, None)
- if env is None:
- os.environ[name] = value
- else:
- os.environ[name] = value + os.pathsep + env
- #
-
- def __addToReservedTclTk(self, name, value):
- if value == '':
- return
-
- value = os.path.expandvars(value) # expand environment variables
- self.getLogger().debug("Add to %s: %s", name, value)
- env = os.getenv(name, None)
- #http://computer-programming-forum.com/57-tcl/1dfddc136afccb94.htm
- #Tcl treats the contents of that variable as a list. Be happy, for you can now use drive letters on windows.
- if env is None:
- os.environ[name] = value
- else:
- os.environ[name] = value + " " + env #explicitely whitespace
- #
-
def _runAppli(self, args=[]):
# Initialize SALOME environment
sys.argv = ['runSalome'] + args
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
-# This file mainly prepares the environment in which sphinx should run:
-# this sets the PYTHONPATH and LD_LIBRARY_PATH to include OMNIORB, DOCUTILS, SETUPTOOLS, etc ...
+SALOME_CONFIGURE_FILE(conf.py.in conf.py)
-# Prepare Sphinx options
-SET(SPHINXOPTS
-)
-SET(SOURCEDIR
- ${CMAKE_CURRENT_SOURCE_DIR}
-)
-SET(PAPEROPT_a4
- -D
- latex_paper_size=a4
-)
-SET(ALLSPHINXOPTS
- -d
- doctrees
- ${PAPEROPT_a4}
- ${SPHINXOPTS}
- ${SOURCEDIR}
-)
+SET(_cmd_options -c ${CMAKE_CURRENT_BINARY_DIR} -b html -d doctrees -D latex_paper_size=a4 ${CMAKE_CURRENT_SOURCE_DIR} docutils)
-SALOME_CONFIGURE_FILE(conf.py.in conf.py)
+# This macro mainly prepares the environment in which sphinx should run:
+# this sets the PYTHONPATH and LD_LIBRARY_PATH to include OMNIORB, DOCUTILS, SETUPTOOLS, etc ...
+SALOME_GENERATE_ENVIRONMENT_SCRIPT(_cmd env_script "${SPHINX_EXECUTABLE}" "${_cmd_options}")
-# Write the shell file preparing the env for the Sphinx run:
-# This uses the paths to SPHINX, DOCUTILS and SETUPTOOLS:
-# Their root dir were found when looking for Sphinx (FindSalomeSphinx.cmake):
-
-SET(_pydir python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR})
-IF(WIN32)
- STRING(REPLACE "/" "\\" SCR "@SET PYTHONPATH=${CMAKE_INSTALL_PREFIX}\\lib\\${_pydir}\\site-packages\\salome\;%PYTHONPATH%
- @SET PYTHONPATH=${CMAKE_INSTALL_PREFIX}\\bin\\salome\;%PYTHONPATH%
- @SET PATH=${CMAKE_INSTALL_PREFIX}\\lib\\salome\;%PATH%
- @SET PYTHONPATH=${OMNIORB_ROOT_DIR}\\lib\\x86_win32\;%PYTHONPATH%
- @SET PYTHONPATH=${OMNIORB_ROOT_DIR}\\lib\\python\;%PYTHONPATH%
- @SET PATH=${OMNIORB_ROOT_DIR}\\lib\\x86_win32\;%PATH%
- ")
- SET(EXT "bat")
- SET(CALL_STR "call")
-ELSE(WIN32)
- SET(SCR " export PYTHONPATH=${CMAKE_INSTALL_PREFIX}/lib/${_pydir}/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_DIR}/lib:\${PYTHONPATH}
- export PYTHONPATH=${OMNIORB_ROOT_DIR}/lib/${_pydir}/site-packages:\${PYTHONPATH}
- export PYTHONPATH=${OMNIORB_ROOT_DIR}/lib64/${_pydir}/site-packages:\${PYTHONPATH}
- export PYTHONPATH=${OMNIORBPY_ROOT_DIR}/lib:\${PYTHONPATH}
- export PYTHONPATH=${OMNIORBPY_ROOT_DIR}/lib/${_pydir}/site-packages:\${PYTHONPATH}
- export PYTHONPATH=${OMNIORBPY_ROOT_DIR}/lib64/${_pydir}/site-packages:\${PYTHONPATH}
- export LD_LIBRARY_PATH=${OMNIORB_ROOT_DIR}/lib:\${LD_LIBRARY_PATH}
- export PYTHONPATH=${SETUPTOOLS_ROOT_DIR}/lib/${_pydir}/site-packages:\${PYTHONPATH}
- export PYTHONPATH=${DOCUTILS_ROOT_DIR}/lib/${_pydir}/site-packages:\${PYTHONPATH}
- export PYTHONPATH=${SPHINX_ROOT_DIR}/lib/${_pydir}/site-packages:\${PYTHONPATH}"
- )
- IF(SALOME_PACO_PARALLEL)
- SET(SCR "${SCR}
- export LD_LIBRARY_PATH=${PACO_ROOT_DIR}/lib:\${LD_LIBRARY_PATH}
- export PYTHONPATH=${PACO_ROOT_DIR}/lib/${_pydir}:\${PYTHONPATH}")
- ENDIF()
- SET(EXT "sh")
- SET(CALL_STR ".")
-ENDIF(WIN32)
-
-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 ${PROJECT_BINARY_DIR}/doc/docutils -b html ${ALLSPHINXOPTS} docutils
-)
+ADD_CUSTOM_TARGET(html_docs COMMAND ${_cmd})
INSTALL(CODE "EXECUTE_PROCESS(COMMAND \"${CMAKE_COMMAND}\" --build ${PROJECT_BINARY_DIR} --target html_docs)")
INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/docutils DESTINATION ${SALOME_INSTALL_DOC}/tui/KERNEL)
INSTALL(FILES ${PROJECT_SOURCE_DIR}/doc/salome/tui/images/head.png DESTINATION ${SALOME_INSTALL_DOC}/tui/KERNEL)
+
+SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES docutils)
INSTALL(CODE "EXECUTE_PROCESS(COMMAND \"${CMAKE_COMMAND}\" --build ${PROJECT_BINARY_DIR} --target usr_docs)")
INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/KERNEL DESTINATION ${SALOME_INSTALL_DOC}/gui)
INSTALL(FILES images/head.png DESTINATION ${SALOME_INSTALL_DOC}/gui/KERNEL)
+
+SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES KERNEL)
SALOME_CONFIGURE_FILE(doxyfile.in doxyfile)
SALOME_CONFIGURE_FILE(static/header.html.in static/header.html)
-ADD_CUSTOM_TARGET(dev_docs ${DOXYGEN_EXECUTABLE} -u
- COMMAND ${DOXYGEN_EXECUTABLE}
- COMMAND ${PYTHON_EXECUTABLE} -c "import os; os.remove(r'''${CMAKE_CURRENT_BINARY_DIR}/doxyfile.bak''')"
- COMMAND ${PYTHON_EXECUTABLE} -c "import shutil, sys; shutil.rmtree(r'''${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_DOC}/tui/KERNEL''', True); shutil.copytree(r'''${CMAKE_CURRENT_BINARY_DIR}/KERNEL''', r'''${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_DOC}/tui/KERNEL'''); shutil.copy(r'''${CMAKE_CURRENT_SOURCE_DIR}/images/head.png''', r'''${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_DOC}/tui/KERNEL''')"
- VERBATIM
- WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
-)
+ADD_CUSTOM_TARGET(dev_docs ${DOXYGEN_EXECUTABLE})
-# TODO
-# - Stop using shutil.rmtree() to clear installation directory - this is not safe
-# (as the directory can potentically point to custom location)! Moreover, currently, it remove
-# the documentation generated with Sphinx (from docutils)!
-# - Redesign dev_docs rule: 'make dev_docs' should generate documentation and 'make install'
-# should the install it. Other solution: split dev_docs to two steps: dev_docs and install_dev_docs.
+INSTALL(CODE "FILE(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/KERNEL)")
+INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/KERNEL DESTINATION ${SALOME_INSTALL_DOC}/tui)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/images/head.png DESTINATION ${SALOME_INSTALL_DOC}/tui/KERNEL)
+
+SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES KERNEL)
void attach(in SALOMEDS::Observer theObserver, in boolean modify);
};
+ //===========================================================================
+ /*! \brief %SimanStudy Interface
+
+ The Siman (simulation management) study is an interface extension to the %Study
+ with functions for working with SIMAN server. Is allows to get data from SIMAN (check-out operation)
+ and to store it back (check-in operation).
+ This interface is correctly working if SALOME is compiled with SimanIO library, launched with siman
+ option and connection to SIMAN server is established and alive. Only one study per application,
+ checked out from the SIMAN is SimanStudy. For other studies all functionality is unaccessible.
+*/
+
+ interface SimanStudy
+ {
+
+//! No connection with SIMAN server
+ exception SimanStudyNoConnection {};
+//! There is no SimanStudy with: study with checked out data.
+ exception SimanStudyNotExists {};
+
+/*! \brief The ID of the study in SIMAN server
+
+ This is equivalent to the methods setStudyId() & getStudyId()
+*/
+ attribute string StudyId;
+
+/*! \brief The ID of the scenario in SIMAN server
+
+ This is equivalent to the methods setScenarioId() & getScenarioId()
+*/
+ attribute string ScenarioId;
+/*! \brief The ID of the user in SIMAN server
+
+ This is equivalent to the methods setUserId() & getUserId()
+*/
+ attribute string UserId;
+
+/*! \brief Get data from SIMAN and put it to the given study
+
+ This method is called for just created study to make it referenced
+ by this Siman study. Also it fills this study by the checked out
+ data from SIMAN server.
+ Warning: StudyID, ScenarioID and User Id must be set before calling of this method!
+
+ \param theTarget referenced study for checking out
+*/
+ void CheckOut(in Study theTarget);
+
+/*! \brief Get data from the source study and store in SIMAN
+
+ It works only with already checked out study.
+ \param theModuleName name of the module the check in must be perfrormed for. If empty, check in is performed for all modules.
+*/
+ void CheckIn(in string theModuleName);
+
+/*! \brief Returns the %Study with checked out data
+
+ If study is null, there is no such study in this application instance, or Salome was
+ launched without siman option.
+*/
+ Study getReferencedStudy();
+
+};
+
//==========================================================================
/*! \brief %Study Builder Interface
*/
long long GetLocalImpl(in string theHostname, in long thePID, out boolean isLocal);
+/*! \brief Returns the siman study based on the given study.
+
+ Creates a new Siman study, or returns just a previously created.
+ \return Siman study, or none if it is not siman mode
+*/
+ SimanStudy GetSimanStudy();
};
};
typedef sequence<KeyValuePair> FieldsDict;
+ typedef sequence<string> ListOfOptions;
+ typedef sequence<string> ListOfIdentifiers;
interface EngineComponent ;
interface fileRef ;
interface fileTransfer ;
interface Salome_file;
+ interface DataContainer;
+ typedef sequence<DataContainer> ListOfData;
+
/*! \brief Interface of the %Container.
This interface defines the process of loading and registration
of new components in %SALOME application
PyScriptNode createPyScriptNode(in string nodeName, in string code) raises(SALOME::SALOME_Exception);
};
+ /*! \brief Interface to pass data files from the client side to the SALOME Container.
+ Passes data from client side to the SALOME container (where component engine is running)
+ size via the CORBA bus as a stream of bytes.
+ */
+
+ interface DataContainer
+ {
+ //! This operation returns the stream with the data file content.
+ TMPFile get();
+
+ //! Returns the name of the document corresponding to this data container.
+ string name();
+
+ //! Returns the identifier of the document corresponding to this data container.
+ string identifier();
+
+ //! Returns the extension (type) of the document corresponding to this data container.
+ //! It is taked from the SIMAN URL.
+ string extension();
+
+ //! Defines the extension. It is required is extension of the file is not
+ //! matched with a read extension: archived file, for example.
+ void setExtension(in string extension);
+ };
+
+
/*! \brief Interface of the %component.
This interface is used for interaction between the %container and the
%component and between the components inside the container.
\return string containing component's version, e.g. "1.0"
*/
string getVersion();
- } ;
+
+ //! Generic Import operation to let the component to import data, corresponding to it.
+ /*!
+ \param studyId indentifier of the study where the data must be placed
+ \param data data for import: usually this is just imported file content
+ \param options additional options for Importat operation
+ \return the sequence of identifiers of the importedData in the component (to use later in the export function)
+ */
+ ListOfIdentifiers importData(in long studyId, in DataContainer data, in ListOfOptions options);
+
+ //! Generic Export operation to ket the component export all modified data corresponding to it.
+ /*!
+ \param studyId identifier of the study that contains the exported data
+ */
+ ListOfData getModifiedData(in long studyId);
+ };
/*!
\brief Base interface of the %component that supports exporting data.
FindSalomePython.cmake
FindSalomeSphinx.cmake
FindSalomeSWIG.cmake
- FindSphinx.cmake
+ FindSphinx.cmake
+ FindSalomeVTK.cmake
FindMEDFile.cmake
InstallAndCompilePythonFile.cmake
UseOmniORB.cmake
SalomeMacros.cmake
- SalomeSetupPlatform.cmake
+ SalomeSetupPlatform.cmake
)
INSTALL(FILES ${DATA} DESTINATION ${SALOME_INSTALL_CMAKE})
# - Graphviz detection
#
-# Output variable: GRAPHVIZ_EXECUTABLE
-#
-# The executable 'dot' is looked for and returned in the above variable.
+# Output variables: GRAPHVIZ_EXECUTABLE - where is executable 'dot' takes place.
+# GRAPHVIZ_INCLUDE_DIRS - where to find headers.
+# GRAPHVIZ_LIBRARIES - where to get libraries.
+# GRAPHVIZ_FOUND - True if Graphiz was found.
#
-
###########################################################################
# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
#
FIND_PROGRAM(GRAPHVIZ_EXECUTABLE dot)
+FIND_PATH(GRAPHVIZ_INCLUDE_DIR NAMES graphviz/graph.h)
+SET(GRAPHVIZ_INCLUDE_DIRS ${GRAPHVIZ_INCLUDE_DIR} ${GRAPHVIZ_INCLUDE_DIR}/graphviz)
+
+FIND_LIBRARY(GRAPHVIZ_cdt_LIBRARY NAMES cdt PATH_SUFFIXES bin)
+FIND_LIBRARY(GRAPHVIZ_cgraph_LIBRARY NAMES cgraph PATH_SUFFIXES bin)
+FIND_LIBRARY(GRAPHVIZ_graph_LIBRARY NAMES graph PATH_SUFFIXES bin)
+FIND_LIBRARY(GRAPHVIZ_gvc_LIBRARY NAMES gvc PATH_SUFFIXES bin)
+FIND_LIBRARY(GRAPHVIZ_pathplan_LIBRARY NAMES pathplan PATH_SUFFIXES bin)
+
+SET(GRAPHVIZ_LIBRARIES
+ ${GRAPHVIZ_cdt_LIBRARY}
+ ${GRAPHVIZ_cgraph_LIBRARY}
+ ${GRAPHVIZ_graph_LIBRARY}
+ ${GRAPHVIZ_gvc_LIBRARY}
+ ${GRAPHVIZ_pathplan_LIBRARY}
+ )
+
# Handle the standard arguments of the find_package() command:
INCLUDE(FindPackageHandleStandardArgs)
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(Graphviz REQUIRED_VARS GRAPHVIZ_EXECUTABLE)
-
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(Graphviz REQUIRED_VARS
+ GRAPHVIZ_EXECUTABLE
+ GRAPHVIZ_LIBRARIES
+ GRAPHVIZ_INCLUDE_DIRS)
# OMNIORB_VERSION - OmniORB4 version
# OMNIORB_IDL_COMPILER - OmniORB4 idl compiler command (omniidl)
# OMNIORB_NAMESERVER - OmniORB4 CORBA naming service (omniNames)
+# OMNIORB_PYTHONPATH - path to the OmniORB Python modules
# and many other mainly used in UseOmniORB.cmake
#
# Detection is made through calls to
##############################################################################
# find libraries
##############################################################################
+
+# Win release / debug specific stuff:
+IF (WIN32)
+ IF(CMAKE_BUILD_TYPE STREQUAL Debug)
+ SET(OMNIORB_RD_SUFFIX d)
+ ELSE()
+ SET(OMNIORB_RD_SUFFIX)
+ ENDIF()
+ENDIF()
+
IF (WIN32)
FIND_LIBRARY(OMNIORB_LIBRARY_omniORB4
- NAMES ${CMAKE_STATIC_LIBRARY_PREFIX}omniORB4_rt${CMAKE_STATIC_LIBRARY_SUFFIX})
+ NAMES ${CMAKE_STATIC_LIBRARY_PREFIX}omniORB4_rt${OMNIORB_RD_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX})
FIND_LIBRARY( OMNIORB_LIBRARY_omnithread
- NAMES ${CMAKE_STATIC_LIBRARY_PREFIX}omnithread_rt${CMAKE_STATIC_LIBRARY_SUFFIX})
+ NAMES ${CMAKE_STATIC_LIBRARY_PREFIX}omnithread_rt${OMNIORB_RD_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX})
FIND_LIBRARY( OMNIORB_LIBRARY_omniDynamic4
- NAMES ${CMAKE_STATIC_LIBRARY_PREFIX}omniDynamic4_rt${CMAKE_STATIC_LIBRARY_SUFFIX})
+ NAMES ${CMAKE_STATIC_LIBRARY_PREFIX}omniDynamic4_rt${OMNIORB_RD_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX})
ELSE (WIN32)
FIND_LIBRARY(OMNIORB_LIBRARY_omniORB4 NAMES omniORB4)
FIND_LIBRARY(OMNIORB_LIBRARY_omnithread NAMES omnithread)
IF (WIN32)
FIND_LIBRARY( OMNIORB_LIBRARY_COS4
- NAMES ${CMAKE_STATIC_LIBRARY_PREFIX}COS4_rt${CMAKE_STATIC_LIBRARY_SUFFIX})
+ NAMES ${CMAKE_STATIC_LIBRARY_PREFIX}COS4_rt${OMNIORB_RD_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX})
FIND_LIBRARY( OMNIORB_LIBRARY_COSDynamic4
- NAMES ${CMAKE_STATIC_LIBRARY_PREFIX}COSDynamic4_rt${CMAKE_STATIC_LIBRARY_SUFFIX})
+ NAMES ${CMAKE_STATIC_LIBRARY_PREFIX}COSDynamic4_rt${OMNIORB_RD_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX})
ELSE (WIN32)
FIND_LIBRARY(OMNIORB_LIBRARY_COS4 NAMES COS4)
FIND_LIBRARY(OMNIORB_LIBRARY_COSDynamic4 NAMES COSDynamic4)
##############################################################################
IF (WIN32)
FIND_PROGRAM( OMNIORB_IDL_COMPILER
- NAMES omniidl PATHS bin/x86_win32
+ NAMES omniidl
+ PATH_SUFFIXES x86_win32
DOC "What is the path where omniidl (the idl compiler) can be found")
FIND_PROGRAM( OMNIORB_OMNINAMES_COMMAND
- NAMES omniNames PATHS bin/x86_win32
+ NAMES omniNames
+ PATH_SUFFIXES x86_win32
DOC "What is the path where omniNames (the ORB server) can be found")
ELSE(WIN32)
FIND_PROGRAM(OMNIORB_IDL_COMPILER NAMES omniidl)
LIST(APPEND OMNIORB_LIBRARIES ${OMNIORB_LIBRARY_COSDynamic4})
ENDIF()
+# Set path to the OmniORB Python modules
+GET_FILENAME_COMPONENT(_tmp_ROOT_DIR "${OMNIORB_LIBRARIES}" PATH)
+SET(OMNIORB_PYTHONPATH "${_tmp_ROOT_DIR}/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages")
+
# Optionaly, extract the the version number from the acconfig.h file:
# The version check is done at the very bottom of this file.
IF( EXISTS ${OMNIORB_INCLUDE_DIR}/omniORB4/acconfig.h )
SET(IDL_SRV_H .hh)
SET(OMNIORB_DEFINITIONS "-D__x86__ -DCOMP_CORBA_DOUBLE -DCOMP_CORBA_LONG")
IF(WIN32)
- SET(OMNIORB_DEFINITIONS "${OMNIORB_DEFINITIONS} -D__WIN32__")
+ ## OmniORB isn`t defines SIZEOF_LONG and SIZEOF_INT on WIN32 platform
+ ## Note SIZE_OF_LONG calculates in the SalomeSetupPlatform.cmake
+ SET(OMNIORB_DEFINITIONS "${OMNIORB_DEFINITIONS} -D__WIN32__ -DSIZEOF_INT=4 -DSIZEOF_LONG=${SIZE_OF_LONG}")
ENDIF()
IF(APPLE)
SET(OMNIORB_DEFINITIONS "${OMNIORB_DEFINITIONS} -D__macos__")#for omnithread.h to be checked...
##############################################################################
MARK_AS_ADVANCED(OMNIORB_PYTHON_BACKEND)
-SET(OMNIORB_IDLPYFLAGS -bpython)
+SET(OMNIORB_IDLPYFLAGS)
IF (OMNIORB_PYTHON_BACKEND)
- LIST(APPEND OMNIORB_IDLPYFLAGS -p${OMNIORB_PYTHON_BACKEND})
+ LIST(APPEND OMNIORB_IDLPYFLAGS -bpython -p${OMNIORB_PYTHON_BACKEND})
ENDIF()
SET(IDLPYFLAGS ${OMNIORB_IDLPYFLAGS})
--- /dev/null
+# - Find SIMANIO installation
+#
+# The following variable are set:
+# SIMANIO_FOUND - TRUE if SIMANIO installation has been found
+# SIMANIO_INCLUDE_DIR - SIMANIO headers path
+# SIMANIO_LIBRARIES - SIMANIO libraries
+#
+# The CMake (or environment) variable SIMANIO_ROOT_DIR can be set to
+# guide the detection and indicate a root directory to look into.
+#
+############################################################################
+# Copyright (C) 2012-2013 CEA/DEN, EDF R&D, OPEN CASCADE
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+# ------
+
+IF(NOT SIMANIO_FIND_QUIETLY)
+ MESSAGE(STATUS "Check for SimanIO ...")
+ENDIF()
+
+# ------
+
+SET(SIMANIO_ROOT_DIR $ENV{SIMANIO_ROOT_DIR} CACHE PATH "Path to the SIMANIO.")
+IF(SIMANIO_ROOT_DIR)
+ LIST(APPEND CMAKE_PREFIX_PATH "${SIMANIO_ROOT_DIR}")
+ENDIF()
+
+FIND_PATH(SIMANIO_INCLUDE_DIR SimanIO_Link.hxx)
+FIND_LIBRARY(SIMANIO_LIBRARIES NAMES SimanIO)
+
+INCLUDE(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(SIMANIO REQUIRED_VARS SIMANIO_INCLUDE_DIR SIMANIO_LIBRARIES)
+
+IF(SIMANIO_FOUND)
+ IF(NOT SIMANIO_FIND_QUIETLY)
+ MESSAGE(STATUS "SIMANIO library: ${SIMANIO_LIBRARIES}")
+ ENDIF()
+ENDIF()
SET(Boost_USE_MULTITHREADED ON)
SET(Boost_USE_STATIC_RUNTIME OFF)
SET(Boost_NO_BOOST_CMAKE ON)
-SET(SalomeBoost_FIND_COMPONENTS filesystem regex signals system thread)
+SET(SalomeBoost_FIND_COMPONENTS filesystem regex signals system thread date_time chrono)
IF(WIN32)
# Under windows, one extra sub-directory in the boost installation hierarchy:
## Specific definitions:
IF(WIN32)
- SET(BOOST_DEFINITIONS -DBOOST_DISABLE_ASSERTS)
+ SET(BOOST_DEFINITIONS -DBOOST_DISABLE_ASSERTS -DBOOST_ALL_DYN_LINK)
ENDIF()
-#SALOME_ACCUMULATE_HEADERS(Boost_INCLUDE_DIRS)
+IF(Boost_FOUND OR BOOST_FOUND)
+ SALOME_ACCUMULATE_HEADERS(Boost_INCLUDE_DIRS)
+ SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH ${Boost_LIBRARIES})
+ENDIF()
\ No newline at end of file
SET(CAS_STDPLUGIN TKStdSchema)
ENDIF()
ENDIF()
+
+IF(CAS_FOUND)
+ SALOME_ACCUMULATE_HEADERS(CAS_INCLUDE_DIRS)
+ SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH ${CAS_TKernel})
+ENDIF()
SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS(CppUnit CPPUNIT_INCLUDE_DIRS 1)
MARK_AS_ADVANCED(CPPUNIT_INCLUDE_DIRS CPPUNIT_LIBRARIES CPPUNIT_CONFIG_BIN CPPUNIT_SUBLIB_cppunit CPPUNIT_SUBLIB_dl)
-#SALOME_ACCUMULATE_HEADERS(CPPUNIT_INCLUDE_DIRS)
+IF(CPPUNIT_FOUND)
+ SALOME_ACCUMULATE_HEADERS(CPPUNIT_INCLUDE_DIRS)
+ SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH ${CPPUNIT_LIBRARIES})
+ENDIF()
ENDIF()
ENDIF()
MARK_AS_ADVANCED(DOXYGEN_SUPPORT_STL)
+
+IF(DOXYGEN_FOUND)
+ SALOME_ACCUMULATE_ENVIRONMENT(PATH ${DOXYGEN_EXECUTABLE})
+ENDIF()
# !! Please read the generic detection procedure in SalomeMacros.cmake !!
#
-SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS(Graphviz GRAPHVIZ_EXECUTABLE 2)
-MARK_AS_ADVANCED(GRAPHVIZ_EXECUTABLE)
+SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS(Graphviz GRAPHVIZ_EXECUTABLE GRAPHVIZ_LIBRARIES GRAPHVIZ_INCLUDE_DIRS 2)
+MARK_AS_ADVANCED(GRAPHVIZ_EXECUTABLE GRAPHVIZ_LIBRARIES GRAPHVIZ_INCLUDE_DIRS)
+
+IF(GRAPHVIZ_FOUND)
+ SALOME_ACCUMULATE_ENVIRONMENT(PATH ${GRAPHVIZ_EXECUTABLE})
+ SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH ${GRAPHVIZ_LIBRARIES})
+ENDIF()
\ No newline at end of file
# MPI root directory used for HDF5 compilation is exposed into MPI_ROOT_DIR_EXP
#
+SET(HDF5_ROOT_DIR $ENV{HDF5_ROOT_DIR} CACHE PATH "Path to the HDF5.")
+
if(WIN32)
set(PREV_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
set(CMAKE_FIND_LIBRARY_SUFFIXES dll${CMAKE_IMPORT_LIBRARY_SUFFIX})
+ set(CMAKE_LIBRARY_PATH ${HDF5_ROOT_DIR}/dll)
endif()
SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS(HDF5 HDF5_INCLUDE_DIR 1)
SET(HDF5_LIBRARIES hdf5)
ENDIF()
-#SALOME_ACCUMULATE_HEADERS(HDF5_INCLUDE_DIRS)
-
##
## 7. Specific to HDF5 only:
## Expose MPI configuration to the rest of the world
if(WIN32)
set(CMAKE_FIND_LIBRARY_SUFFIXES ${PREV_CMAKE_FIND_LIBRARY_SUFFIXES})
endif()
+
+IF(HDF5_FOUND)
+ SALOME_ACCUMULATE_HEADERS(HDF5_INCLUDE_DIRS)
+ SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH ${HDF5_LIBRARIES})
+ENDIF()
IF(NOT SalomeKERNEL_FIND_QUIETLY)
MESSAGE(STATUS "Found Salome KERNEL: ${KERNEL_ROOT_DIR}")
ENDIF()
+
+FOREACH(_res ${SalomeKERNEL_EXTRA_ENV})
+ SALOME_ACCUMULATE_ENVIRONMENT(${_res} "${SalomeKERNEL_EXTRA_ENV_${_res}}")
+ENDFOREACH()
# Author: Adrien Bruneton
#
-# LibBatch detection dor Salome
+# LibBatch detection for Salome
#
# !! Please read the generic detection procedure in SalomeMacros.cmake !!
#
SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS(LibBatch LIBBATCH_ROOT_DIR_EXP 0)
#MARK_AS_ADVANCED()
-#SALOME_ACCUMULATE_HEADERS(LIBBATCH_INCLUDE_DIRS)
-
+IF(SALOMELIBBATCH_FOUND)
+ SALOME_ACCUMULATE_HEADERS(LIBBATCH_INCLUDE_DIRS)
+ SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH ${LIBBATCH_LIBRARIES})
+ENDIF()
\ No newline at end of file
ENDIF()
#MARK_AS_ADVANCED()
-#SALOME_ACCUMULATE_HEADERS(LIBXML2_INCLUDE_DIR)
+IF(LIBXML2_FOUND)
+ SALOME_ACCUMULATE_HEADERS(LIBXML2_INCLUDE_DIR)
+ SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH ${LIBXML2_LIBRARIES})
+ENDIF()
# Author: Adrien Bruneton
#
-# Medfile detection dor Salome
+# Medfile detection for Salome
#
# !! Please read the generic detection procedure in SalomeMacros.cmake !!
#
SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS(MEDFile MEDFILE_INCLUDE_DIRS 1)
#MARK_AS_ADVANCED()
+
+IF(MEDFILE_FOUND)
+ SALOME_ACCUMULATE_HEADERS(MEDFILE_INCLUDE_DIRS)
+ SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH ${MEDFILE_LIBRARIES})
+ENDIF()
\ No newline at end of file
SET(MPI_INCLUDE_DIRS ${MPI_C_INCLUDE_PATH} ${MPI_CXX_INCLUDE_PATH})
SET(MPI_LIBRARIES ${MPI_C_LIBRARIES} ${MPI_CXX_LIBRARIES})
+
+IF(MPI_FOUND)
+ SALOME_ACCUMULATE_HEADERS(MPI_INCLUDE_DIRS)
+ SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH ${MPI_LIBRARIES})
+ENDIF()
SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS(OmniORB OMNIORB_INCLUDE_DIR 1)
#MARK_AS_ADVANCED()
-#SALOME_ACCUMULATE_HEADERS(OMNIORB_INCLUDE_DIR)
\ No newline at end of file
+IF(OMNIORB_FOUND)
+ SALOME_ACCUMULATE_HEADERS(OMNIORB_INCLUDE_DIR)
+ SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH ${OMNIORB_LIBRARIES})
+ SALOME_ACCUMULATE_ENVIRONMENT(PYTHONPATH ${OMNIORB_LIBRARIES}
+ ${OMNIORB_PYTHONPATH})
+ENDIF()
\ No newline at end of file
MESSAGE(STATUS "OmniORB Python backend needs OmniORB, and OmniORB was not found!")
ENDIF()
ENDIF()
+
+IF(OMNIORBPY_FOUND)
+ SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH ${OMNIORBPY_LIBRARIES})
+ SALOME_ACCUMULATE_ENVIRONMENT(PYTHONPATH ${OMNIORBPY_LIBRARIES}
+ ${OMNIORBPY_PYTHONPATH})
+ENDIF()
#
SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS(PThread PTHREAD_INCLUDE_DIR 1)
MARK_AS_ADVANCED(PTHREAD_LIBRARIES PTHREAD_INCLUDE_DIR)
+
+IF(SALOMEPTHREAD_FOUND)
+ SALOME_ACCUMULATE_HEADERS(PTHREAD_INCLUDE_DIR)
+ SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH ${PTHREAD_LIBRARIES})
+ENDIF()
+
#
SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS(Paco PACO_INCLUDE_DIRS 1)
#MARK_AS_ADVANCED()
+
+IF(SALOMEPACO_FOUND)
+ SALOME_ACCUMULATE_HEADERS(PACO_INCLUDE_DIRS)
+ SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH ${PACO_LIBRARIES})
+ENDIF()
## 6. Save the final detected installation
##
SET(PYTHON_ROOT_DIR "${_tmp_ROOT_DIR}")
+ SET(PYTHON_PYTHONPATH "${_tmp_ROOT_DIR}/lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}")
## 7. Specifics
##
MESSAGE(STATUS "Python was only partially (or not at all) found .")
ENDIF()
-
-#SALOME_ACCUMULATE_HEADERS(PYTHON_INCLUDE_DIR)
-
+IF(SALOMEPYTHON_FOUND)
+ SALOME_ACCUMULATE_HEADERS(PYTHON_INCLUDE_DIR)
+ SALOME_ACCUMULATE_ENVIRONMENT(PATH ${PYTHON_EXECUTABLE})
+ SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH ${PYTHON_LIBRARIES})
+ SALOME_ACCUMULATE_ENVIRONMENT(PYTHONPATH ${PYTHON_PYTHONPATH})
+ENDIF()
--- /dev/null
+# Copyright (C) 2013 CEA/DEN, EDF R&D, OPEN CASCADE
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+# Author: Vadim SANDLER
+#
+
+# SIMANIO detection dor Salome
+#
+# !! Please read the generic detection procedure in SalomeMacros.cmake !!
+#
+
+SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS(SIMANIO SIMANIO_INCLUDE_DIR 1)
+#MARK_AS_ADVANCED()
+
+IF(SIMANIO_FOUND)
+ SALOME_ACCUMULATE_HEADERS(SIMANIO_INCLUDE_DIR)
+ SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH ${SIMANIO_LIBRARIES})
+ENDIF()
\ No newline at end of file
#
SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS(SWIG SWIG_EXECUTABLE 2)
MARK_AS_ADVANCED(SWIG_EXECUTABLE SWIG_VERSION)
+
+IF(SWIG_FOUND)
+ SALOME_ACCUMULATE_ENVIRONMENT(PATH ${SWIG_EXECUTABLE})
+ENDIF()
#
# !! Please read the generic detection procedure in SalomeMacros.cmake !!
#
-# The caller of this macro might set SPHINX_PYTHONPATH to provide a path to be added in front
-# of the PYTHONPATH with which the sphinx command should be ran.
-#
-# Note the environment is also overriden in
-# doc/docutils/CMakeLists.txt
-# with the creation of a dedicated launcher script.
-#
SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS(Sphinx SPHINX_EXECUTABLE 2)
# Also retrieve paths to DOCUTILS and SETUPTOOLS:
SET(SETUPTOOLS_ROOT_DIR "$ENV{SETUPTOOLS_ROOT_DIR}" CACHE PATH "Path to the Setuptools installation")
-SET(DOCUTILS_ROOT_DIR "$ENV{DOCUTILS_ROOT_DIR}" CACHE PATH "Path to the Setuptools installation")
+SET(DOCUTILS_ROOT_DIR "$ENV{DOCUTILS_ROOT_DIR}" CACHE PATH "Path to the Docutils installation")
# Ensure the command is run with the given PYTHONPATH
IF(WIN32 AND NOT CYGWIN)
ENDIF()
MARK_AS_ADVANCED(SPHINX_EXECUTABLE)
+
+IF(SPHINX_FOUND)
+ SALOME_ACCUMULATE_ENVIRONMENT(PATH ${SPHINX_EXECUTABLE})
+ SALOME_ACCUMULATE_ENVIRONMENT(PYTHONPATH ${SPHINX_PYTHONPATH})
+ENDIF()
--- /dev/null
+# Copyright (C) 2013 CEA/DEN, EDF R&D, OPEN CASCADE
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+# Author: Adrien Bruneton
+#
+
+# VTK detection for Salome (see http://www.vtk.org/Wiki/VTK/Build_System_Migration)
+#
+# !! Please read the generic detection procedure in SalomeMacros.cmake !!
+#
+
+# List the required components:
+SET(SalomeVTK_COMPONENTS
+ vtkRenderingFreeTypeOpenGL
+ vtkRenderingLOD
+ vtkRenderingAnnotation
+ vtkFiltersParallel
+ vtkIOExport
+ #vtkWrappingPythonCore ## ParaView 4.0.1
+ vtkWrappingPython
+ vtkIOXML
+ vtkFiltersVerdict
+ vtkRenderingLabel
+ vtkInteractionWidgets
+)
+
+# Seting the following variable is equivalent to having passed the components
+# when calling the FIND_PACKAGE() command.
+SET(SalomeVTK_FIND_COMPONENTS ${SalomeVTK_COMPONENTS})
+
+# If no VTK root dir is specified, try the ParaView root dir:
+SET(PARAVIEW_ROOT_DIR "$ENV{PARAVIEW_ROOT_DIR}" CACHE PATH "Path to the ParaView installation")
+IF(EXISTS "${PARAVIEW_ROOT_DIR}" AND (NOT VTK_ROOT_DIR))
+ MESSAGE(STATUS "Looking for VTK in the ParaView installation (PARAVIEW_ROOT_DIR exists and VTK_ROOT_DIR is not defined) ...")
+
+ # Extract sub-directory "paraview-x.xx":
+ FILE(GLOB VTK_DIR "${PARAVIEW_ROOT_DIR}/lib/cmake/paraview-*")
+ MESSAGE(STATUS "Setting VTK_DIR to: ${VTK_DIR}")
+ENDIF()
+
+SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS(VTK VTK_INCLUDE_DIRS 2)
+MARK_AS_ADVANCED(VTK_DIR)
+
+IF(VTK_FOUND)
+ MESSAGE(STATUS "VTK version is ${VTK_MAJOR_VERSION}.${VTK_MINOR_VERSION}")
+ #MESSAGE(STATUS "VTK libraries are: ${VTK_LIBRARIES}")
+ENDIF()
+
+IF(VTK_FOUND)
+ SALOME_ACCUMULATE_HEADERS(VTK_INCLUDE_DIRS)
+ SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH ${VTK_LIBRARIES})
+ SALOME_ACCUMULATE_ENVIRONMENT(PYTHONPATH ${VTK_LIBRARIES})
+ SALOME_ACCUMULATE_ENVIRONMENT(PV_PLUGIN_PATH ${VTK_LIBRARIES})
+ENDIF()
# - Sphinx detection
#
-# Output variable: SPHINX_EXECUTABLE
-#
+# Output variables:
+# SPHINX_EXECUTABLE - path to the Sphinx executable
+# SPHINX_PYTHONPATH - path to the Sphinx Python modules
#
-# The executable 'sphinx-build' is looked for and returned in the above variable.
-#
-
###########################################################################
# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
#
#
###########################################################################
-FIND_PROGRAM(SPHINX_EXECUTABLE sphinx-build)
+FIND_PROGRAM(SPHINX_EXECUTABLE sphinx-build PATH_SUFFIXES Scripts)
+# Get root dir locally, going up two levels from the exec:
+GET_FILENAME_COMPONENT(_tmp_ROOT_DIR "${SPHINX_EXECUTABLE}" PATH)
+GET_FILENAME_COMPONENT(_tmp_ROOT_DIR "${_tmp_ROOT_DIR}" PATH)
+IF(WIN32)
+ SET(SPHINX_PYTHONPATH "${_tmp_ROOT_DIR}/lib/site-packages")
+ELSE()
+ SET(SPHINX_PYTHONPATH "${_tmp_ROOT_DIR}/lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages")
+ENDIF()
# Handle the standard arguments of the find_package() command:
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Sphinx REQUIRED_VARS SPHINX_EXECUTABLE)
+++ /dev/null
-# - Config file for the @PROJECT_NAME@ package
-# It defines the following variables.
-# Specific to the pacakge @PROJECT_NAME@ itself:
-# @PROJECT_NAME_UC@_ROOT_DIR_EXP - the root path of the installation providing this CMake file
-#
-# Other stuff specific to this package:
-# SALOME_USE_MPI -
-# SALOME_BUILD_DOC -
-# SALOME_BUILD_TESTS -
-# SALOME_LIGHT_ONLY -
-
-###############################################################
-# Copyright (C) 2007-2013 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
-###############################################################
-
-### Initialisation performed by CONFIGURE_PACKAGE_CONFIG_FILE:
-@PACKAGE_INIT@
-
-# Load the dependencies for the libraries of @PROJECT_NAME@
-# (contains definitions for IMPORTED targets). This is only
-# imported if we are not built as a subproject (in this case targets are already there)
-IF(NOT TARGET SALOMEBasics AND NOT @PROJECT_NAME@_BINARY_DIR)
- INCLUDE("@PACKAGE_SALOME_INSTALL_CMAKE@/@PROJECT_NAME@Targets.cmake")
-ENDIF()
-
-# Package root dir:
-SET_AND_CHECK(KERNEL_ROOT_DIR_EXP "@PACKAGE_CMAKE_INSTALL_PREFIX@")
-
-# Include directories and definitions
-SET_AND_CHECK(KERNEL_INCLUDE_DIRS "${KERNEL_ROOT_DIR_EXP}/@SALOME_INSTALL_HEADERS@")
-#SET(KERNEL_INCLUDE_DIRS "${KERNEL_INCLUDE_DIRS};@_SalomeKERNEL_EXTRA_HEADERS@")
-SET(KERNEL_DEFINITIONS)
-
-#### Now the specificities
-
-# Options exported by the package:
-SET(SALOME_USE_MPI @SALOME_USE_MPI@)
-IF(SALOME_USE_MPI)
- SET(KERNEL_INCLUDE_DIRS "${KERNEL_INCLUDE_DIRS};@MPI_INCLUDE_DIRS@")
- SET(KERNEL_DEFINITIONS "@MPI_DEFINITIONS@")
-ENDIF()
-
-SET(SALOME_BUILD_DOC @SALOME_BUILD_DOC@)
-SET(SALOME_BUILD_TESTS @SALOME_BUILD_TESTS@)
-SET(SALOME_LIGHT_ONLY @SALOME_LIGHT_ONLY@)
-SET(SALOME_USE_LIBBATCH @SALOME_USE_LIBBATCH@)
-
-# Prerequisites:
-IF(SALOME_BUILD_TESTS)
- SET_AND_CHECK(CPPUNIT_ROOT_DIR_EXP "@PACKAGE_CPPUNIT_ROOT_DIR@")
-ENDIF()
-IF(SALOME_BUILD_DOC)
- SET_AND_CHECK(GRAPHVIZ_ROOT_DIR_EXP "@PACKAGE_GRAPHVIZ_ROOT_DIR@")
- SET_AND_CHECK(DOXYGEN_ROOT_DIR_EXP "@PACKAGE_DOXYGEN_ROOT_DIR@")
- SET_AND_CHECK(SPHINX_ROOT_DIR_EXP "@PACKAGE_SPHINX_ROOT_DIR@")
-ENDIF()
-IF(SALOME_USE_MPI)
- SET_AND_CHECK(MPI_ROOT_DIR_EXP "@PACKAGE_MPI_ROOT_DIR@")
-ENDIF()
-IF(NOT SALOME_LIGHT_ONLY)
- SET_AND_CHECK(OMNIORB_ROOT_DIR_EXP "@PACKAGE_OMNIORB_ROOT_DIR@")
- SET_AND_CHECK(OMNIORBPY_ROOT_DIR_EXP "@PACKAGE_OMNIORBPY_ROOT_DIR@")
-ENDIF()
-IF(SALOME_USE_LIBBATCH)
- SET_AND_CHECK(LIBBATCH_ROOT_DIR_EXP "@PACKAGE_LIBBATCH_ROOT_DIR@")
-ENDIF()
-
-# We need to export Boost_INCLUDE_DIRS because dependent projects may use header file
-# SALOMEDSClient_definitions.hxx that depends on Boost shared pointers
-SET_AND_CHECK(BOOST_ROOT_DIR_EXP "@PACKAGE_BOOST_ROOT_DIR@")
-SET(KERNEL_INCLUDE_DIRS "${KERNEL_INCLUDE_DIRS};@Boost_INCLUDE_DIRS@")
-SET(KERNEL_DEFINITIONS "${KERNEL_DEFINITIONS};@BOOST_DEFINITIONS@")
-
-SET_AND_CHECK(PTHREAD_ROOT_DIR_EXP "@PACKAGE_PTHREAD_ROOT_DIR@")
-SET_AND_CHECK(HDF5_ROOT_DIR_EXP "@PACKAGE_HDF5_ROOT_DIR@")
-SET_AND_CHECK(LIBXML2_ROOT_DIR_EXP "@PACKAGE_LIBXML2_ROOT_DIR@")
-SET_AND_CHECK(PYTHON_ROOT_DIR_EXP "@PACKAGE_PYTHON_ROOT_DIR@")
-SET_AND_CHECK(SWIG_ROOT_DIR_EXP "@PACKAGE_SWIG_ROOT_DIR@")
-
-# For all prerequisites, load the corresponding targets if the package was used
-# in CONFIG mode. This ensures dependent projects link correctly
-# without having to set LD_LIBRARY_PATH:
-SET(_PREREQ CppUnit Graphviz Doxygen Sphinx MPI omniORB LibBatch PThread Boost HDF5 libXml2 Python)
-SET(_PREREQ_CONFIG_DIR "@CppUnit_DIR@" "@Graphviz_DIR@" "@Doxygen_DIR@" "@Sphinx_DIR@"
- "@MPI_DIR@" "@omniORB_DIR@" "@LibBatch_DIR@" "@PThread_DIR@" "@Boost_DIR@" "@HDF5_DIR@"
- "@libXml2_DIR@" "@Python_DIR@")
-LIST(LENGTH _PREREQ_CONFIG_DIR _list_len)
-# Another CMake stupidity - FOREACH(... RANGE r) generates r+1 numbers ...
-MATH(EXPR _range "${_list_len}-1")
-FOREACH(_p RANGE ${_range})
- LIST(GET _PREREQ ${_p} _pkg )
- LIST(GET _PREREQ_CONFIG_DIR ${_p} _pkg_dir)
- IF(_pkg_dir)
- MESSAGE(STATUS "===> Reloading targets from ${_pkg} ...")
- FIND_PACKAGE(${_pkg} REQUIRED NO_MODULE
- PATHS "${_pkg_dir}"
- NO_DEFAULT_PATH)
- ENDIF()
-ENDFOREACH()
-
-# Installation directories
-SET(SALOME_INSTALL_BINS "@SALOME_INSTALL_BINS@")
-SET(SALOME_INSTALL_LIBS "@SALOME_INSTALL_LIBS@")
-SET(SALOME_INSTALL_IDLS "@SALOME_INSTALL_IDLS@")
-SET(SALOME_INSTALL_HEADERS "@SALOME_INSTALL_HEADERS@")
-SET(SALOME_INSTALL_SCRIPT_SCRIPTS "@SALOME_INSTALL_SCRIPT_SCRIPTS@")
-SET(SALOME_INSTALL_SCRIPT_DATA "@SALOME_INSTALL_SCRIPT_DATA@")
-SET(SALOME_INSTALL_SCRIPT_PYTHON "@SALOME_INSTALL_SCRIPT_PYTHON@")
-SET(SALOME_INSTALL_APPLISKEL_SCRIPTS "@SALOME_INSTALL_APPLISKEL_SCRIPTS@")
-SET(SALOME_INSTALL_APPLISKEL_PYTHON "@SALOME_INSTALL_APPLISKEL_PYTHON@")
-SET(SALOME_INSTALL_CMAKE "@SALOME_INSTALL_CMAKE@")
-SET(SALOME_INSTALL_CMAKE_LOCAL "@SALOME_INSTALL_CMAKE_LOCAL@")
-SET(SALOME_INSTALL_PYTHON "@SALOME_INSTALL_PYTHON@")
-SET(SALOME_INSTALL_PYTHON_SHARED "@SALOME_INSTALL_PYTHON_SHARED@")
-SET(SALOME_INSTALL_RES "@SALOME_INSTALL_RES@")
-SET(SALOME_INSTALL_DOC "@SALOME_INSTALL_DOC@")
-SET(SALOME_INSTALL_AMCONFIG "@SALOME_INSTALL_AMCONFIG@") # to be removed
-SET(SALOME_INSTALL_AMCONFIG_LOCAL "@SALOME_INSTALL_AMCONFIG_LOCAL@") # to be removed
-
-# Exposed targets:
-SET(KERNEL_CalciumC CalciumC)
-SET(KERNEL_DF DF)
-SET(KERNEL_Launcher Launcher)
-SET(KERNEL_LifeCycleCORBATest LifeCycleCORBATest)
-SET(KERNEL_NamingServiceTest NamingServiceTest)
-SET(KERNEL_OpUtil OpUtil)
-SET(KERNEL_Registry Registry)
-SET(KERNEL_ResourcesManager ResourcesManager)
-SET(KERNEL_SALOMEBasics SALOMEBasics)
-SET(KERNEL_SalomeCatalog SalomeCatalog)
-SET(KERNEL_SalomeCommunication SalomeCommunication)
-SET(KERNEL_SalomeContainer SalomeContainer)
-SET(KERNEL_SalomeDatastream SalomeDatastream)
-SET(KERNEL_SalomeDSCContainer SalomeDSCContainer)
-SET(KERNEL_SalomeDSClient SalomeDSClient)
-SET(KERNEL_SalomeDSCSupervBasic SalomeDSCSupervBasic)
-SET(KERNEL_SalomeDSCSuperv SalomeDSCSuperv)
-SET(KERNEL_SalomeDSImpl SalomeDSImpl)
-SET(KERNEL_SALOMEDSImplTest SALOMEDSImplTest)
-SET(KERNEL_SalomeDS SalomeDS)
-SET(KERNEL_SALOMEDSTest SALOMEDSTest)
-SET(KERNEL_SalomeGenericObj SalomeGenericObj)
-SET(KERNEL_SalomeHDFPersist SalomeHDFPersist)
-SET(KERNEL_SalomeIDLKernel SalomeIDLKernel)
-SET(KERNEL_SalomeLauncher SalomeLauncher)
-SET(KERNEL_SalomeLifeCycleCORBA SalomeLifeCycleCORBA)
-SET(KERNEL_SALOMELocalTrace SALOMELocalTrace)
-SET(KERNEL_SALOMELocalTraceTest SALOMELocalTraceTest)
-SET(KERNEL_SalomeLoggerServer SalomeLoggerServer)
-SET(KERNEL_SalomeMPIContainer SalomeMPIContainer)
-SET(KERNEL_SalomeNotification SalomeNotification)
-SET(KERNEL_SalomeNS SalomeNS)
-SET(KERNEL_SalomeResourcesManager SalomeResourcesManager)
-SET(KERNEL_SalomeTestComponentEngine SalomeTestComponentEngine)
-SET(KERNEL_SalomeTestMPIComponentEngine SalomeTestMPIComponentEngine)
-SET(KERNEL_SALOMETraceCollectorTest SALOMETraceCollectorTest)
-SET(KERNEL_TOOLSDS TOOLSDS)
-SET(KERNEL_UtilsTest UtilsTest)
-SET(KERNEL_with_loggerTraceCollector with_loggerTraceCollector)
-SET(KERNEL_SalomeKernelHelpers SalomeKernelHelpers)
-
-
IF(SALOME_PACKAGE_REPORT_JUSTIFY)
SET(_length ${SALOME_PACKAGE_REPORT_JUSTIFY})
ELSE()
- SET(_length 10)
+ SET(_length 23)
ENDIF()
MESSAGE(STATUS "")
MESSAGE(STATUS " Optional packages - Detection report ")
MESSAGE(STATUS " ==================================== ")
MESSAGE(STATUS "")
- LIST(LENGTH _SALOME_OPTIONAL_PACKAGES_names _list_len)
- # Another CMake stupidity - FOREACH(... RANGE r) generates r+1 numbers ...
- MATH(EXPR _range "${_list_len}-1")
- FOREACH(_idx RANGE ${_range})
- LIST(GET _SALOME_OPTIONAL_PACKAGES_names ${_idx} _pkg_name)
- LIST(GET _SALOME_OPTIONAL_PACKAGES_found ${_idx} _pkg_found)
- LIST(GET _SALOME_OPTIONAL_PACKAGES_flags ${_idx} _pkg_flag)
- SALOME_JUSTIFY_STRING(${_pkg_name} ${_length} _pkg_name)
- IF(_pkg_found)
- SET(_found_msg "Found")
- SET(_flag_msg "")
- ELSE()
- SET(_will_fail ON)
- SET(_found_msg "NOT Found")
- SET(_flag_msg " - ${_pkg_flag} can be switched OFF to skip this prerequisite.")
- ENDIF()
+ IF(DEFINED _SALOME_OPTIONAL_PACKAGES_names)
+ LIST(LENGTH _SALOME_OPTIONAL_PACKAGES_names _list_len)
+ # Another CMake stupidity - FOREACH(... RANGE r) generates r+1 numbers ...
+ MATH(EXPR _range "${_list_len}-1")
+ FOREACH(_idx RANGE ${_range})
+ LIST(GET _SALOME_OPTIONAL_PACKAGES_names ${_idx} _pkg_name)
+ LIST(GET _SALOME_OPTIONAL_PACKAGES_found ${_idx} _pkg_found)
+ LIST(GET _SALOME_OPTIONAL_PACKAGES_flags ${_idx} _pkg_flag)
+ SALOME_JUSTIFY_STRING(${_pkg_name} ${_length} _pkg_name)
+ IF(_pkg_found)
+ SET(_found_msg "Found")
+ SET(_flag_msg "")
+ ELSE()
+ SET(_will_fail ON)
+ SET(_found_msg "NOT Found")
+ SET(_flag_msg " - ${_pkg_flag} can be switched OFF to skip this prerequisite.")
+ ENDIF()
- MESSAGE(STATUS " * ${_pkg_name} -> ${_found_msg}${_flag_msg}")
- ENDFOREACH()
+ MESSAGE(STATUS " * ${_pkg_name} -> ${_found_msg}${_flag_msg}")
+ ENDFOREACH()
+ ENDIF(DEFINED _SALOME_OPTIONAL_PACKAGES_names)
MESSAGE(STATUS "")
MESSAGE(STATUS "")
FOREACH(l IN LISTS ${lst})
LIST(FIND _${PROJECT_NAME}_EXTRA_HEADERS "${l}" _res)
IF(_res EQUAL "-1")
- LIST(APPEND _${PROJECT_NAME}_EXTRA_HEADERS "${l}")
+ IF(NOT "${l}" STREQUAL "/usr/include")
+ LIST(APPEND _${PROJECT_NAME}_EXTRA_HEADERS "${l}")
+ ENDIF()
ENDIF()
ENDFOREACH()
ENDMACRO(SALOME_ACCUMULATE_HEADERS)
+
+#########################################################################
+# SALOME_ACCUMULATE_ENVIRONMENT()
+#
+# USAGE: SALOME_ACCUMULATE_ENVIRONMENT(envvar value [value ...])
+#
+# ARGUMENTS:
+# envvar [in] environment variable name, e.g. PATH
+# value [in] value(s) to be added to environment variable
+#
+# This macro is called in the various FindSalomeXYZ.cmake modules to
+# accumulate environment variables, to be used later to run some command
+# in proper environment.
+#
+# 1. Each envrironment variable is stored in specific CMake variable
+# _${PROJECT_NAME}_EXTRA_ENV_<var>, where <var> is name of variable.
+# 2. Full list of environment variable names is stored in CMake variable
+# _${PROJECT_NAME}_EXTRA_ENV.
+#
+# Notes:
+# - The arguments list can include optional CHECK or NOCHECK keywords:
+# * For all arguments following CHECK keyword the macro perform an
+# additional check (see below); this is the default mode, it is suitable
+# for path variables (PATH, LD_LIBRARY_PATH, etc).
+# * For all arguments following NOCHECK keyword, no additional check is
+# performed.
+# Checking an argument means that we check:
+# - That the path actually exists
+# - That this is not a standard system path (starting with "/usr"); this avoids
+# polluting LD_LIBRARY_PATH or PATH with things like "/usr/lib64" ...
+#
+MACRO(SALOME_ACCUMULATE_ENVIRONMENT envvar)
+ SET(_is_check ON)
+ FOREACH(_item ${ARGN})
+ IF(${_item} STREQUAL "NOCHECK")
+ SET(_is_check OFF)
+ ELSEIF(${_item} STREQUAL "CHECK")
+ SET(_is_check ON)
+ ELSE()
+ IF(_is_check)
+ IF(NOT IS_DIRECTORY ${_item})
+ IF(TARGET ${_item})
+ GET_TARGET_PROPERTY(_item ${_item} LOCATION)
+ ENDIF()
+ GET_FILENAME_COMPONENT(_item ${_item} PATH)
+ ENDIF()
+ IF(EXISTS ${_item})
+ STRING(REGEX MATCH "^(/usr|/lib|/bin)" _usr_find ${_item})
+ LIST(FIND _${PROJECT_NAME}_EXTRA_ENV_${envvar} ${_item} _res)
+ IF(NOT _usr_find AND _res EQUAL -1)
+ LIST(APPEND _${PROJECT_NAME}_EXTRA_ENV_${envvar} ${_item})
+ ENDIF()
+ ENDIF()
+ ELSE(_is_check)
+ LIST(FIND _${PROJECT_NAME}_EXTRA_ENV_${envvar} ${_item} _res)
+ IF( _res EQUAL -1)
+ LIST(APPEND _${PROJECT_NAME}_EXTRA_ENV_${envvar} ${_item})
+ ENDIF()
+ ENDIF(_is_check)
+ ENDIF()
+ ENDFOREACH()
+
+ LIST(FIND _${PROJECT_NAME}_EXTRA_ENV ${envvar} _res)
+ IF(_res EQUAL -1)
+ LIST(APPEND _${PROJECT_NAME}_EXTRA_ENV ${envvar})
+ ENDIF()
+ SET(_${PROJECT_NAME}_EXTRA_ENV_FULL "SET\(${PROJECT_NAME}_EXTRA_ENV ${_${PROJECT_NAME}_EXTRA_ENV}\)")
+ FOREACH(_res ${_${PROJECT_NAME}_EXTRA_ENV})
+ SET(_${PROJECT_NAME}_EXTRA_ENV_FULL "${_${PROJECT_NAME}_EXTRA_ENV_FULL}\nSET\(${PROJECT_NAME}_EXTRA_ENV_${_res} ${_${PROJECT_NAME}_EXTRA_ENV_${_res}}\)")
+ ENDFOREACH()
+ENDMACRO(SALOME_ACCUMULATE_ENVIRONMENT)
+
+#########################################################################
+# SALOME_GENERATE_ENVIRONMENT_SCRIPT()
+#
+# USAGE: SALOME_GENERATE_ENVIRONMENT_SCRIPT(output script cmd opts)
+#
+# ARGUMENTS:
+# output [out] output command, e.g. for creation of target.
+# script [in] output environement script name
+# cmd [in] input command, e.g. sphinx or python command.
+# opts [in] options for input command (cmd).
+#
+# This macro is called when it's necessary to use given environment to run some command.
+# Macro generates environement script using previously created variables
+# _${PROJECT_NAME}_EXTRA_ENV_<var>, where <var> is name of variable and
+# _${PROJECT_NAME}_EXTRA_ENV (see marco SALOME_ACCUMULATE_ENVIRONMENT);
+# and puts generated command in proper environment into <output> argument.
+#
+# Notes:
+# - If <script> is specified as relative path, it is computed from the current build
+# directory.
+#
+MACRO(SALOME_GENERATE_ENVIRONMENT_SCRIPT output script cmd opts)
+ IF(IS_ABSOLUTE ${script})
+ SET(_script ${script})
+ ELSE()
+ SET(_script ${CMAKE_CURRENT_BINARY_DIR}/${script})
+ ENDIF()
+
+ SET(_env)
+ FOREACH(_item ${_${PROJECT_NAME}_EXTRA_ENV})
+ FOREACH(_val ${_${PROJECT_NAME}_EXTRA_ENV_${_item}})
+ IF(WIN32)
+ IF(${_item} STREQUAL "LD_LIBRARY_PATH")
+ SET(_item PATH)
+ ENDIF()
+ STRING(REPLACE "/" "\\" _env "${_env} @SET ${_item}=${_val};%${_item}%\n")
+ SET(_ext "bat")
+ SET(_call_cmd "call")
+ ELSE(WIN32)
+ SET(_env "${_env} export ${_item}=${_val}:\${${_item}}\n")
+ SET(_ext "sh")
+ SET(_call_cmd ".")
+ ENDIF(WIN32)
+ ENDFOREACH()
+ ENDFOREACH()
+
+ SET(_script ${_script}.${_ext})
+ FILE(WRITE ${_script} "${_env}")
+
+ SET(${output} ${_call_cmd} ${_script} && ${cmd} ${opts})
+
+ENDMACRO(SALOME_GENERATE_ENVIRONMENT_SCRIPT)
+
+#########################################################################
+# SALOME_GENERATE_TESTS_ENVIRONMENT()
+#
+# USAGE: SALOME_GENERATE_TESTS_ENVIRONMENT(output)
+#
+# ARGUMENTS:
+# output [out] output environement variable.
+#
+# This macro generates <output> variable to use given environment to run some tests.
+# Macro generates environement variable using previously created variables
+# _${PROJECT_NAME}_EXTRA_ENV_<var>, where <var> is name of variable and
+# _${PROJECT_NAME}_EXTRA_ENV (see marco SALOME_ACCUMULATE_ENVIRONMENT);
+# and puts this variable into <output> argument.
+#
+MACRO(SALOME_GENERATE_TESTS_ENVIRONMENT output)
+ SET(_env)
+ FOREACH(_item ${_${PROJECT_NAME}_EXTRA_ENV})
+ FOREACH(_val ${_${PROJECT_NAME}_EXTRA_ENV_${_item}})
+ IF(WIN32)
+ SET(_env "${_val};${_env}")
+ ELSE()
+ SET(_env "${_val}:${_env}")
+ ENDIF()
+ ENDFOREACH()
+ SET(_env " ${_item}=${_env}")
+ ENDFOREACH()
+ SET(${output} ${_env})
+ENDMACRO(SALOME_GENERATE_TESTS_ENVIRONMENT)
+
+#########################################################################
+# SALOME_APPEND_LIST_OF_LIST()
+#
+# USAGE: SALOME_APPEND_LIST_OF_LIST(result element_list)
+#
+# Build a list of lists. The element_list is first parsed to convert it
+# from
+# a;b;c;d;e
+# to
+# a,b,c,d,e
+#
+# It is then added to the big list 'result'. Hence 'result' looks like:
+# a,b,c,d,e;f,g,h; ...
+#
+MACRO(SALOME_APPEND_LIST_OF_LIST result element_list)
+ SET(_tmp_res)
+ STRING(REPLACE ";" "," _tmp_res "${${element_list}}")
+ SET(${result} "${${result}};${_tmp_res}") # LIST(APPEND ...) doesn't handle well empty elements!?
+ENDMACRO(SALOME_APPEND_LIST_OF_LIST)
+
+#########################################################################
+# SALOME_CONFIGURE_PREPARE()
+#
+# USAGE: SALOME_CONFIGURE_PREPARE(pkg1 pkg2 ...)
+#
+# Prepare the variable that will be used to configure the file Salome<MODULE>Config.cmake,
+# namely:
+# - _PREREQ_LIST : the list of level 1 external prerequisites
+# - _PREREQ_DIR_LIST : their corresponding CMake directories (i.e. where the CMake configuration
+# file for this package can be found, if there is any!)
+# - _PREREQ_COMPO_LIST: the list of components requested when this package was invoked
+#
+# All this information is built from the package_list, the list of level 1 packages for this module.
+# Only the packages found in CONFIG mode are retained.
+#
+MACRO(SALOME_CONFIGURE_PREPARE)
+ SET(_tmp_prereq "${ARGV}")
+ SET(_PREREQ_LIST)
+ SET(_PREREQ_DIR_LIST)
+ SET(_PREREQ_COMPO_LIST)
+ FOREACH(_prereq IN LISTS _tmp_prereq)
+ IF(${_prereq}_DIR)
+ SET(_PREREQ_LIST "${_PREREQ_LIST} ${_prereq}")
+ SET(_PREREQ_DIR_LIST "${_PREREQ_DIR_LIST} \"${${_prereq}_DIR}\"")
+ SALOME_APPEND_LIST_OF_LIST(_PREREQ_COMPO_LIST Salome${_prereq}_COMPONENTS)
+ ENDIF()
+ ENDFOREACH()
+ENDMACRO(SALOME_CONFIGURE_PREPARE)
# ENDIF(CMAKE_BUILD_TYPE STREQUAL Release)
#ENDIF()
-
IF(WIN32)
## Windows specific:
ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS) # To disable windows warnings for strcpy, fopen, ...
SET(PLATFORM_LIBS Ws2_32.lib)
LIST(APPEND PLATFORM_LIBS Userenv.lib) # At least for GEOM suit
-
- IF(MACHINE_IS_64)
+
+ # Disable iterator debugging on WINDOWS in Debug Mode
+ IF(NOT CMAKE_BUILD_TYPE STREQUAL "RELEASE" AND NOT CMAKE_BUILD_TYPE STREQUAL "Release")
ADD_DEFINITIONS(-D_SECURE_SCL=0 -D_SECURE_SCL_THROWS=0)
ADD_DEFINITIONS(-D_HAS_ITERATOR_DEBUGGING=0) # To avoid runtime error during checking iterators
- SET(SIZE_OF_LONG "4") # set sizeof(long) to 4 byte
+ ENDIF(NOT CMAKE_BUILD_TYPE STREQUAL "RELEASE" AND NOT CMAKE_BUILD_TYPE STREQUAL "Release")
+
+ IF(MACHINE_IS_64)
+ SET(SIZE_OF_LONG 4) # set sizeof(long) to 4 byte
+ ELSE()
+ SET(SIZE_OF_LONG ${CMAKE_SIZEOF_VOID_P}) # set sizeof(long) the same as size of pointers
ENDIF()
ELSE()
## Linux specific:
SET(PLATFORM_LIBS dl) # Dynamic loading (dlopen, dlsym)
+ IF(MACHINE_IS_64)
+ ADD_DEFINITIONS(-DPCLINUX64)
+ ENDIF(MACHINE_IS_64)
ENDIF()
## define _DEBUG_ macro
#
# ARGUMENTS:
# module : module name
-# idlfiles : list of IDL files to be compiled into module
+# idlfiles : list of IDL files to be compiled into module. If just a file name is given, the source
+# tree is first inspected. If not found there, the macro assumes the file will be built
+# in the build tree (CMAKE_CURRENT_BINARY_DIR) thanks to some ADD_CUSTOM_COMMAND() call
+# (used in PARAVIS).
# incdirs : additional include dirs for IDL staff
# linklibs : additional libraries the module to be linked to (optional)
#
# - From FindOmniORBPy.cmake
# OMNIORB_IDLPYFLAGS : the options to give to omniidl generator for Python backend
# OMNIORB_PYTHON_BACKEND : Python backend
-#
+#
+# The macro automatically adds a target "omniorb_module_<module>" which can be used to set up
+# dependencies on the generation of the files produced by omniidl (typically the header files).
+#
# TODO:
# 1. Replace hardcoded dirpaths bin/salome, idl/salome, etc by corresponding configuration options.
# 2. Revise/improve OMNIORB_COMPILE_IDL_FORPYTHON_ON_INSTALL macro usage.
# module sources
SET(_sources)
+ # module produced files
+ SET(_all_outputs)
# type of the libraries: SHARED for Linux, STATIC for Windows
SET(_type SHARED)
IF(WIN32)
GET_FILENAME_COMPONENT(_base ${_input} NAME_WE)
GET_FILENAME_COMPONENT(_path ${_input} PATH)
IF(NOT _path)
- SET(_input ${CMAKE_CURRENT_SOURCE_DIR}/${_input})
+ IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${_input})
+ SET(_input_cmd ${CMAKE_CURRENT_SOURCE_DIR}/${_input})
+ ELSE()
+ SET(_input_cmd ${CMAKE_CURRENT_BINARY_DIR}/${_input})
+ ENDIF()
+ ELSE()
+ SET(_input_cmd ${_input})
ENDIF()
SET(_inc ${CMAKE_CURRENT_BINARY_DIR}/${_base}.hh)
LIST(APPEND _sources ${_src})
LIST(APPEND _sources ${_dynsrc})
SET(_outputs ${_inc} ${_src} ${_dynsrc})
+ LIST(APPEND _all_outputs ${_outputs})
ADD_CUSTOM_COMMAND(OUTPUT ${_outputs}
- COMMAND ${OMNIORB_IDL_COMPILER} ${_cxx_flags} ${_input}
- MAIN_DEPENDENCY ${_input})
+ COMMAND ${OMNIORB_IDL_COMPILER} ${_cxx_flags} ${_input_cmd}
+ DEPENDS ${_input_cmd})
- INSTALL(FILES ${_input} DESTINATION idl/salome)
+ INSTALL(FILES ${_input_cmd} DESTINATION idl/salome)
INSTALL(FILES ${_inc} DESTINATION include/salome)
IF(OMNIORB_PYTHON_BACKEND)
STRING(REPLACE ";" " " _tmp "${_py_flags}")
- INSTALL(CODE "OMNIORB_COMPILE_IDL_FORPYTHON_ON_INSTALL( \"${OMNIORB_IDL_COMPILER}\" \"${_tmp}\" \"${_input}\" \"${CMAKE_INSTALL_PREFIX}/\${INSTALL_PYIDL_DIR}\" )")
+ INSTALL(CODE "OMNIORB_COMPILE_IDL_FORPYTHON_ON_INSTALL( \"${OMNIORB_IDL_COMPILER}\" \"${_tmp}\" \"${_input_cmd}\" \"${CMAKE_INSTALL_PREFIX}/\${INSTALL_PYIDL_DIR}\" )")
ENDIF()
ENDFOREACH()
ADD_LIBRARY(${module} ${_type} ${_sources})
TARGET_LINK_LIBRARIES(${module} ${_linklibs})
SET_TARGET_PROPERTIES(${module} PROPERTIES COMPILE_FLAGS "${OMNIORB_DEFINITIONS}")
-
+ ADD_CUSTOM_TARGET(omniorb_module_${module} DEPENDS ${_all_outputs})
ENDMACRO(OMNIORB_ADD_MODULE)
AC_CHECK_FILE(${BOOSTDIR}/lib${LIB_SUFFIX}/libboost_regex${BOOST_LIBSUFFIX}.so,
BOOST_LIB_REGEX="${BOOST_LIBS} -lboost_regex${BOOST_LIBSUFFIX}",
BOOST_LIB_REGEX="")
+ AC_CHECK_FILE(${BOOSTDIR}/lib${LIB_SUFFIX}/libboost_filesystem${BOOST_LIBSUFFIX}.so,
+ BOOST_LIB_FILESYSTEM="${BOOST_LIBS} -lboost_filesystem${BOOST_LIBSUFFIX}",
+ BOOST_LIB_FILESYSTEM="")
fi
AC_MSG_RESULT(for boost binaries: $boost_binaries_ok)
AC_SUBST(BOOST_LIB_SIGNALS)
AC_SUBST(BOOST_LIB_SYSTEM)
AC_SUBST(BOOST_LIB_REGEX)
+AC_SUBST(BOOST_LIB_FILESYSTEM)
AC_SUBST(BOOST_PROGRAM_OPTIONS_LIB)
AC_LANG_RESTORE
--- /dev/null
+`dnl Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
+dnl
+dnl Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+dnl CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+dnl
+dnl This library is free software; you can redistribute it and/or
+dnl modify it under the terms of the GNU Lesser General Public
+dnl License as published by the Free Software Foundation; either
+dnl version 2.1 of the License.
+dnl
+dnl This library is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+dnl Lesser General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU Lesser General Public
+dnl License along with this library; if not, write to the Free Software
+dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+dnl
+dnl See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+dnl
+
+AC_DEFUN([CHECK_SIMANIO],[
+
+SIMANIO_CPPFLAGS=""
+SIMANIO_LIBS=""
+
+AC_CHECKING(for SimanIO location)
+AC_ARG_WITH(simanio,
+ [AC_HELP_STRING([--with-simanio=DIR],[root directory path to SimanIO installation])],
+ [SIMANIODIR="$withval"
+ AC_MSG_RESULT("select $withval as path to SimanIO installation")
+ ])
+
+if test "x$SIMANIODIR" = "x" ; then
+ # no --with-simanio option used
+ if test "x$SIMANIO_ROOT_DIR" != "x" ; then
+ # SIMANIO_ROOT_DIR environment variable defined
+ SIMANIODIR=$SIMANIO_ROOT_DIR
+ fi
+fi
+
+AC_MSG_RESULT(\$SIMANIODIR = ${SIMANIODIR})
+
+CPPFLAGS_old="${CPPFLAGS}"
+LIBS_old=$LIBS
+
+LIB_SUFFIX="${LIB_LOCATION_SUFFIX}"
+
+if test "x${SIMANIODIR}" != "x" ; then
+ SIMANIO_CPPFLAGS="-I${SIMANIODIR}/include"
+ SIMANIO_LIBS="-L${SIMANIODIR}/lib"
+fi
+
+if test "x${SIMANIODIR}" = "x/usr" ; then
+ SIMANIO_CPPFLAGS=""
+ SIMANIO_LIBS=""
+fi
+
+simanio_ok=no
+simanio_headers_ok=no
+simanio_binaries_ok=no
+
+dnl SIMANIO headers
+#AC_CHECKING(for SimanIO headers)
+
+simanio_headers_ok=yes
+if test "x${SIMANIODIR}" != "x" ; then
+ AC_CHECK_FILE(${SIMANIODIR}/include/SimanIO_Link.hxx,
+ simanio_headers_ok=yes,
+ simanio_headers_ok=no)
+fi
+
+if test "x${simanio_headers_ok}" = "xno" ; then
+ SIMANIO_CPPFLAGS="SIMANIO_CPPFLAGS_NOT_DEFINED"
+else
+ #AC_MSG_RESULT(\$SIMANIO_CPPFLAGS = ${SIMANIO_CPPFLAGS})
+ AC_CHECK_FILE(${SIMANIODIR}/lib/libSimanIO.so,
+ simanio_lib_ok=yes,
+ simanio_lib_ok=no)
+fi
+#AC_MSG_RESULT(for SimanIO libraries: $simanio_lib_ok)
+
+if test "x${simanio_headers_ok}" = "xyes" ; then
+ if test "x${simanio_lib_ok}" = "xyes" ; then
+ SIMANIO_LIBS="-L${SIMANIODIR}/lib -lSimanIO"
+ simanio_ok=yes
+ fi
+fi
+
+AC_MSG_RESULT(for simanio: $simanio_ok)
+
+AC_SUBST(SIMANIO_CPPFLAGS)
+AC_SUBST(SIMANIO_LIBS)
+
+])dnl
#define DEVTRACE(msg)
#endif
-#ifdef WNT
+#ifdef WIN32
#pragma warning(disable:4251) // Warning DLL Interface ...
#endif
// ============================================================================
/*!
- * The PROTECTED_DELETE base class provides a protected destructor.
+ * The PROTECTED_DELETE base class provides a protected destructor.
* The only way to use PROTECTED_DELETE is inheritance:
* example: class LocalTraceBufferPool : public PROTECTED_DELETE
* Herited class destructor must stay protected.
* - use addObj(instance) to store the instance on the static list _objList,
* - delete instance with deleteInstance(instance)
*
- * This class is utilised with GENERIC_DESTRUCTOR and DESTRUCTOR_OF,
+ * This class is utilised with GENERIC_DESTRUCTOR and DESTRUCTOR_OF,
* to program automatic deletion of objects at the end of the process, while
* keeping the possibility of an early destruction, if required. This is used
* for unit testing and trace mecanism.
- */
+ */
// ============================================================================
class BASICS_EXPORT PROTECTED_DELETE
*
* The only way to use the GENERIC_DESTRUCTOR class is inheritance:
* class SPECIFIC_DESTRUCTOR : public GENERIC_DESTRUCTOR
- *
+ *
* A generic destructor provides two methods:
* -# a static method to add a destruction (object) to be performed:
* GENERIC_DESTRUCTOR::Add(GENERIC_DESTRUCTOR &anObject);
* The Destruction object is stored in a list of pointer to
* GENERIC_DESTRUCTOR objects.
* -# an object method to execute the destruction : operator()().
- */
+ */
// ============================================================================
class BASICS_EXPORT GENERIC_DESTRUCTOR
};
// ============================================================================
-/*!
+/*!
* The DESTRUCTOR_OF class allows the user to program - at any moment - the
* destruction of an object at the end of the process.
*
* POINT *ptrPoint = new POINT ;
*
* DESTRUCTOR_OF<POINT> *ptrDestruct = new DESTRUCTOR_OF<POINT>(*ptrPoint);
- *
+ *
* Note that neither ptrPoint, nor ptrDestruct should be destroyed by the user.
- *
+ *
* The destruction object must be created dynamically because it suscribes
* itself in the list of destruction to be performed at the end of the process.
- */
+ */
// ============================================================================
template <class TYPE> class DESTRUCTOR_OF : public GENERIC_DESTRUCTOR
public:
/*!
Programs the destruction at the end of the process, of the object anObject.
- This method records in _objectPtr the address of an object to be destroyed
+ This method records in _objectPtr the address of an object to be destroyed
at the end of the process
*/
DESTRUCTOR_OF(TYPE &anObject):
_objectPtr(&anObject)
{
- DEVTRACE(" DESTRUCTOR_OF " << typeid(anObject).name()
+ DEVTRACE(" DESTRUCTOR_OF " << typeid(anObject).name()
<< " " << _objectPtr << " " << this );
PROTECTED_DELETE::addObj(_objectPtr);
assert(GENERIC_DESTRUCTOR::Add(*this) >= 0);
/*!
Performs the destruction of the object.
- This method really destroys the object pointed by _objectPtr.
+ This method really destroys the object pointed by _objectPtr.
It should be called at the end of the process (i.e. at exit).
*/
virtual void operator()(void)
LifeCycleCORBA_SWIG
SALOMEDSClient
TOOLSDS
+ KernelHelpers
SALOMEDSImpl
SALOMEDS
- KernelHelpers
ModuleGenerator
Communication
Communication_SWIG
${OMNIORB_INCLUDE_DIR}
${PTHREAD_INCLUDE_DIR}
${HDF5_INCLUDE_DIRS}
- ${LIBXML2_INCLUDE_DIR}
${PYTHON_INCLUDE_DIRS}
${PROJECT_BINARY_DIR}/salome_adm
${CMAKE_CURRENT_SOURCE_DIR}/../Basics
SALOME_ComponentPy.py
SALOME_PyNode.py
SALOME_Container.py
+ SALOME_DataContainerPy.py
)
-ADD_DEFINITIONS(${HDF5_DEFINITIONS} ${LIBXML2_DEFINITIONS} ${OMNIORB_DEFINITIONS})
+ADD_DEFINITIONS(${HDF5_DEFINITIONS} ${OMNIORB_DEFINITIONS})
SET(COMMON_LIBS
Registry
SalomeNotification
SET(SalomeContainer_SOURCES
Component_i.cxx
Container_i.cxx
+ SALOME_DataContainer_i.cxx
SALOME_FileTransfer_i.cxx
SALOME_FileRef_i.cxx
Container_init_python.cxx
*/
//=============================================================================
-/*!
+/*!
* Default constructor, not for use
*/
//=============================================================================
//=============================================================================
Engines_Component_i::Engines_Component_i(CORBA::ORB_ptr orb,
- PortableServer::POA_ptr poa,
- PortableServer::ObjectId * contId,
+ PortableServer::POA_ptr poa,
+ PortableServer::ObjectId * contId,
const char *instanceName,
const char *interfaceName,
bool notif,
//=============================================================================
-/*!
+/*!
* Destructor: call Container for decrement of instances count.
* When instances count falls to 0, the container tries to remove the
* component library (dlclose)
}
//=============================================================================
-/*!
+/*!
* CORBA method: return name of the instance, unique in this Container
*/
//=============================================================================
}
//=============================================================================
-/*!
+/*!
* CORBA method: return name of the component class
*/
//=============================================================================
}
//=============================================================================
-/*!
+/*!
* CORBA method: Get study Id
* \return -1: not initialised (Internal Error)
* 0: multistudy component instance
}
//=============================================================================
-/*!
+/*!
* CORBA method: Test if instance is alive and responds
*/
//=============================================================================
}
//=============================================================================
-/*!
+/*!
* CORBA method: Deactivate this instance. CORBA object is deactivated (do not
* respond any more to CORBA calls), the connection to Regsitry is removed
* (Registry informed of deactivation), internal server reference counter on
}
//=============================================================================
-/*!
+/*!
* CORBA method: return CORBA reference of the Container
*
*/
}
//=============================================================================
-/*!
- * CORBA method:
- * Gives a sequence of (key=string,value=any) to the component.
+/*!
+ * CORBA method:
+ * Gives a sequence of (key=string,value=any) to the component.
* Base class component stores the sequence in a map.
* The map is cleared before.
- * This map is for use by derived classes.
+ * This map is for use by derived classes.
* \param dico sequence of (key=string,value=any)
*/
//=============================================================================
}
//=============================================================================
-/*!
- * CORBA method:
+/*!
+ * CORBA method:
* returns a previously stored map (key=string,value=any) as a sequence.
* (see setProperties)
*/
}
//=============================================================================
-/*!
- * CORBA method:
+/*!
+ * CORBA method:
* This method is to set an option specific to a certain EngineComponent.
*/
//=============================================================================
}
//=============================================================================
-/*!
- * CORBA method:
+/*!
+ * CORBA method:
* This method is to get value of an option specific to a certain EngineComponent.
*/
//=============================================================================
}
//=============================================================================
-/*!
+/*!
* CORBA method: used by Supervision to give names to this instance
*/
//=============================================================================
}
//=============================================================================
-/*!
+/*!
* CORBA method: used in Supervision
*/
//=============================================================================
-bool Engines_Component_i::Kill_impl()
+bool Engines_Component_i::Kill_impl()
{
// MESSAGE("Engines_Component_i::Kill_i() pthread_t "<< pthread_self()
// << " pid " << getpid() << " instanceName "
}
//=============================================================================
-/*!
+/*!
* CORBA method: used in Supervision
*/
//=============================================================================
<< " machineName " << Kernel_Utils::GetHostname().c_str()<< " _id " << std::hex << _id
<< std::dec << " _ThreadId " << _ThreadId );
#endif
-
+
bool RetVal = false ;
#ifndef WIN32
}
//=============================================================================
-/*!
+/*!
* CORBA method: used in Supervision
*/
//=============================================================================
{
return false ;
}
- else
+ else
{
#ifndef WIN32
RetVal = Killer( _ThreadId ,SIGINT ) ;
}
//=============================================================================
-/*!
+/*!
* CORBA method: used in Supervision
*/
//=============================================================================
if ( _ThreadId > 0 && pthread_self().p != _ThreadId->p )
#endif
{
- if ( _Sleeping )
+ if ( _Sleeping )
{
_Sleeping = false ;
RetVal = true ;
}
//=============================================================================
-/*!
- * CORBA method:
+/*!
+ * CORBA method:
*/
//=============================================================================
// << _serviceName << " " << cpu << endl ;
}
}
- else
+ else
{
cpu = _ThreadCpuUsed ;
// cout << pthread_self() << " Engines_Component_i::CpuUsed_impl "
//=============================================================================
-/*!
+/*!
* C++ method: return Container Servant
*/
//=============================================================================
}
//=============================================================================
-/*!
+/*!
* C++ method: set study Id
- * \param studyId 0 if instance is not associated to a study,
+ * \param studyId 0 if instance is not associated to a study,
* >0 otherwise (== study id)
* \return true if the set of study Id is OK
* must be set once by Container, at instance creation,
{
ASSERT( studyId >= 0);
CORBA::Boolean ret = false;
- if (_studyId < 0) // --- not yet initialized
+ if (_studyId < 0) // --- not yet initialized
{
_studyId = studyId;
ret = true;
}
//=============================================================================
-/*!
+/*!
* C++ method: return CORBA instance id, the id is set in derived class
* constructor, when instance is activated.
*/
}
//=============================================================================
-/*!
+/*!
* C++ method: used by derived classes for supervision
*/
//=============================================================================
}
//=============================================================================
-/*!
+/*!
* C++ method: used by derived classes for supervision
*/
//=============================================================================
}
//=============================================================================
-/*!
+/*!
* C++ method: -- CHECK IF USED --
*/
//=============================================================================
}
//=============================================================================
-/*!
+/*!
* C++ method: -- CHECK IF USED --
*/
//=============================================================================
}
//=============================================================================
-/*!
+/*!
* C++ method: used in Supervision (see kill_impl)
*/
//=============================================================================
}
else
{
-#ifdef WNT
+#ifdef WIN32
MESSAGE("Killer : ThreadId " << ThreadId.p << " pthread_canceled") ;
#else
MESSAGE("Killer : ThreadId " << ThreadId << " pthread_canceled") ;
perror("Killer pthread_kill error") ;
return false ;
}
- else
+ else
{
-#ifdef WNT
+#ifdef WIN32
MESSAGE("Killer : ThreadId " << ThreadId.p << " pthread_killed(" << signum << ")") ;
#else
MESSAGE("Killer : ThreadId " << ThreadId << " pthread_killed(" << signum << ")") ;
void CallCancelThread();
//=============================================================================
-/*!
+/*!
* C++ method:
- */
+ */
//=============================================================================
void SetCpuUsed()
}
//=============================================================================
-/*!
+/*!
* C++ method:
*/
//=============================================================================
void Engines_Component_i::SetCurCpu()
{
_ThreadCpuUsed = CpuUsed() ;
- // MESSAGE(pthread_self() <<
+ // MESSAGE(pthread_self() <<
// " Engines_Component_i::SetCurCpu() _ThreadCpuUsed " << _ThreadCpuUsed) ;
}
//=============================================================================
-/*!
+/*!
* C++ method:
*/
//=============================================================================
else
{
// std::cout << pthread_self() << "Engines_Component_i::CpuUsed _ThreadId "
- // << _ThreadId << " " << _serviceName<< " _StartUsed "
+ // << _ThreadId << " " << _serviceName<< " _StartUsed "
// << _StartUsed << std::endl ;
}
-#else
+#else
// NOT implementet yet
#endif
}
//=============================================================================
-/*!
+/*!
* C++ method: Send message to event channel
*/
//=============================================================================
}
//=============================================================================
-/*!
+/*!
* C++ method: return standard library name built on component name
*/
//=============================================================================
}
//=============================================================================
-/*!
+/*!
* C++ method: DumpPython default implementation
*/
//=============================================================================
-Engines::TMPFile* Engines_Component_i::DumpPython(CORBA::Object_ptr theStudy,
- CORBA::Boolean isPublished,
- CORBA::Boolean isMultiFile,
+Engines::TMPFile* Engines_Component_i::DumpPython(CORBA::Object_ptr theStudy,
+ CORBA::Boolean isPublished,
+ CORBA::Boolean isMultiFile,
CORBA::Boolean& isValidScript)
{
const char* aScript = isMultiFile ? "def RebuildData(theStudy): pass" : "";
strcpy(aBuffer, aScript);
CORBA::Octet* anOctetBuf = (CORBA::Octet*)aBuffer;
int aBufferSize = strlen(aBuffer)+1;
- Engines::TMPFile_var aStreamFile = new Engines::TMPFile(aBufferSize, aBufferSize, anOctetBuf, 1);
+ Engines::TMPFile_var aStreamFile = new Engines::TMPFile(aBufferSize, aBufferSize, anOctetBuf, 1);
isValidScript = true;
- return aStreamFile._retn();
+ return aStreamFile._retn();
}
-Engines::Salome_file_ptr
-Engines_Component_i::getInputFileToService(const char* service_name,
- const char* Salome_file_name)
+Engines::Salome_file_ptr
+Engines_Component_i::getInputFileToService(const char* service_name,
+ const char* Salome_file_name)
{
// Try to find the service, if it doesn't exist, we throw an exception.
_Service_file_map_it = _Input_Service_file_map.find(service_name);
return Sfile->_this();
}
-Engines::Salome_file_ptr
-Engines_Component_i::setInputFileToService(const char* service_name,
- const char* Salome_file_name)
+Engines::Salome_file_ptr
+Engines_Component_i::setInputFileToService(const char* service_name,
+ const char* Salome_file_name)
{
// Try to find the service, if it doesn't exist, we add it.
_Service_file_map_it = _Input_Service_file_map.find(service_name);
_Input_Service_file_map[service_name] = _map;
}
_t_Salome_file_map * _map = _Input_Service_file_map[service_name];
-
+
// Try to find the Salome_file ...
_Salome_file_map_it = _map->find(Salome_file_name);
if (_Salome_file_map_it == _map->end()) {
return Sfile->_this();
}
-void
-Engines_Component_i::checkInputFilesToService(const char* service_name)
+void
+Engines_Component_i::checkInputFilesToService(const char* service_name)
{
// Try to find the service, if it doesn't exist, nothing to do.
_Service_file_map_it = _Input_Service_file_map.find(service_name);
}
}
-Engines::Salome_file_ptr
-Engines_Component_i::getOutputFileToService(const char* service_name,
- const char* Salome_file_name)
+Engines::Salome_file_ptr
+Engines_Component_i::getOutputFileToService(const char* service_name,
+ const char* Salome_file_name)
{
// Try to find the service, if it doesn't exist, we throw an exception.
_Service_file_map_it = _Output_Service_file_map.find(service_name);
return Sfile->_this();
}
-Engines::Salome_file_ptr
-Engines_Component_i::setOutputFileToService(const char* service_name,
- const char* Salome_file_name)
+Engines::Salome_file_ptr
+Engines_Component_i::setOutputFileToService(const char* service_name,
+ const char* Salome_file_name)
{
// Try to find the service, if it doesn't exist, we add it.
_Service_file_map_it = _Output_Service_file_map.find(service_name);
_Output_Service_file_map[service_name] = _map;
}
_t_Salome_file_map * _map = _Output_Service_file_map[service_name];
-
+
// Try to find the Salome_file ...
_Salome_file_map_it = _map->find(Salome_file_name);
if (_Salome_file_map_it == _map->end()) {
return Sfile->_this();
}
-void
-Engines_Component_i::checkOutputFilesToService(const char* service_name)
+void
+Engines_Component_i::checkOutputFilesToService(const char* service_name)
{
// Try to find the service, if it doesn't exist, nothing to do.
_Service_file_map_it = _Output_Service_file_map.find(service_name);
}
//=============================================================================
-/*!
+/*!
* C++ method: used to configure the Salome_file into the runtime.
* \param service_name name of the service that use this Salome_file
* \param file_port_name name of the Salome_file
void
Engines_Component_i::configureSalome_file(std::string service_name,
std::string file_port_name,
- Salome_file_i * file)
+ Salome_file_i * file)
{
// By default this method does nothing
}
//=============================================================================
-/*!
+/*!
+ * C++ method: allows to import data file into the Component internal data
+ structure (like import operation of BRep file in GEOM module).
+ * \param studyId identifier of the working study
+ * \param data container of the file content
+ * \param options additional options for import (if needed)
+ */
+//=============================================================================
+Engines::ListOfIdentifiers* Engines_Component_i::importData(CORBA::Long studyId,
+ Engines::DataContainer_ptr data,
+ const Engines::ListOfOptions& options)
+{
+ // By default this method does nothing
+ Engines::ListOfIdentifiers_var aList = new Engines::ListOfIdentifiers;
+ return aList._retn();
+}
+
+//=============================================================================
+/*!
+ * C++ method: allows to export data files from the Component internal data
+ structure (like Export operation of Step file in GEOM module).
+ * \param studyId identifier of the working study
+ */
+//=============================================================================
+Engines::ListOfData* Engines_Component_i::getModifiedData(CORBA::Long studyId)
+{
+ // By default this method does nothing
+ Engines::ListOfData_var aList = new Engines::ListOfData;
+ return aList._retn();
+}
+
+//=============================================================================
+/*!
* C++ method: return the name of the container associated with this component
* This name does not contains the "/Containers" string and all "/" are replaced by "_"
* \return the container name (reformatted)
return _containerName;
}
//=============================================================================
-/*!
+/*!
* C++ method: set the name of the container associated with this component (attribute _containerName)
* This name does not contains the "/Containers" string and all "/" are replaced by "_"
* \return the container name (reformatted)
\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()
## define an implementation of the component interface Engines::Component
#
-#
+#
class SALOME_ComponentPy_i (Engines__POA.EngineComponent):
_orb = None
_poa = None
_fieldsDict = []
_studyId = -1
-
+
#-------------------------------------------------------------------------
def __init__ (self, orb, poa, contID, containerName,
def _get_instanceName(self):
MESSAGE( "SALOME_ComponentPy_i::_get_instanceName" )
return self._instanceName
-
+
#-------------------------------------------------------------------------
def _get_interfaceName(self):
def ping(self):
MESSAGE( "SALOME_ComponentPy_i::ping() pid " + str(os.getpid()) )
-
+
#-------------------------------------------------------------------------
def setProperties(self, dico):
self._fieldsDict = dico
-
+
#-------------------------------------------------------------------------
def getProperties(self):
id = self._poa.servant_to_id(self)
self._poa.deactivate_object(id)
return
-
+
#-------------------------------------------------------------------------
def GetContainerRef(self):
MESSAGE( "SALOME_ComponentPy_i::GetContainerRef" )
return self._contId._narrow(Engines.Container)
-
+
#-------------------------------------------------------------------------
def beginService(self , serviceName ):
value=any.from_any(e.value)
if isinstance(value,str):
os.environ[key]=value
-
+
#-------------------------------------------------------------------------
MESSAGE( "SALOME_ComponentPy_i::Names" + str(GraphName) + str(NodeName) )
self._graphName = GraphName
self._nodeName = NodeName
-
+
#-------------------------------------------------------------------------
def graphName(self):
# return 0
#else:
# MESSAGE()
- return 1
-
+ return 1
+
#-------------------------------------------------------------------------
def Kill_impl(self):
return 0
#-------------------------------------------------------------------------
-
+
def DumpPython(self, theStudy, isPublished, isMultiFile):
aBuffer = "\0"
if isMultiFile :
aBuffer = "def RebuildData(theStudy): pass\n\0"
return (aBuffer, 1)
- #-------------------------------------------------------------------------
+ #-------------------------------------------------------------------------
def getStudyId(self):
return self._studyId
- #-------------------------------------------------------------------------
+ #-------------------------------------------------------------------------
def hasObjectInfo(self):
return 0
- #-------------------------------------------------------------------------
+ #-------------------------------------------------------------------------
def getObjectInfo(self, studyId, entry):
return ""
- #-------------------------------------------------------------------------
+ #-------------------------------------------------------------------------
def getVersion(self):
return "" # empty string means "unknown" version
+ #-------------------------------------------------------------------------
+
+ def importData(self, studyId, dataContainer, options):
+ return [] # no implmenetation by default
+
+ #-------------------------------------------------------------------------
+
+ def getModifiedData(self, studyId):
+ return [] # no implmenetation by default
+
pass # end of SALOME_ComponentPy_i
class RegistryConnexion;
class Engines_Container_i;
-class CONTAINER_EXPORT Engines_Component_i:
+class CONTAINER_EXPORT Engines_Component_i:
public virtual POA_Engines::EngineComponent,
public virtual PortableServer::ServantBase
{
Engines_Component_i();
Engines_Component_i(CORBA::ORB_ptr orb,
PortableServer::POA_ptr poa,
- PortableServer::ObjectId * contId,
- const char *instanceName,
+ PortableServer::ObjectId * contId,
+ const char *instanceName,
const char *interfaceName,
bool notif = false,
bool regist = true);
//Constructor for standalone component
Engines_Component_i(CORBA::ORB_ptr orb,
PortableServer::POA_ptr poa,
- Engines::Container_ptr container,
- const char *instanceName,
+ Engines::Container_ptr container,
+ const char *instanceName,
const char *interfaceName,
bool notif = false,
bool regist = true);
CORBA::Boolean& isValidScript);
// CORBA operations for Salome_file
- virtual Engines::Salome_file_ptr getInputFileToService(const char* service_name,
+ virtual Engines::Salome_file_ptr getInputFileToService(const char* service_name,
const char* Salome_file_name);
- virtual Engines::Salome_file_ptr getOutputFileToService(const char* service_name,
+ virtual Engines::Salome_file_ptr getOutputFileToService(const char* service_name,
const char* Salome_file_name);
virtual void checkInputFilesToService(const char* service_name);
- virtual Engines::Salome_file_ptr setInputFileToService(const char* service_name,
+ virtual Engines::Salome_file_ptr setInputFileToService(const char* service_name,
const char* Salome_file_name);
virtual void checkOutputFilesToService(const char* service_name);
- virtual Engines::Salome_file_ptr setOutputFileToService(const char* service_name,
+ virtual Engines::Salome_file_ptr setOutputFileToService(const char* service_name,
const char* Salome_file_name);
// Object information
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();
+ PortableServer::ObjectId * getId();
Engines_Container_i *GetContainerPtr();
std::string getContainerName();
void setContainerName();
std::string file_port_name,
Salome_file_i * file);
+ virtual Engines::ListOfIdentifiers* importData(CORBA::Long studyId,
+ Engines::DataContainer_ptr data,
+ const Engines::ListOfOptions& options);
+ virtual Engines::ListOfData* getModifiedData(CORBA::Long studyId);
protected:
int _studyId; // -1: not initialised; 0: multiStudy; >0: study
typedef std::map<std::string, Salome_file_i*> _t_Salome_file_map;
// Map Service_name to _Salome_file_map
typedef std::map<std::string, Engines_Component_i::_t_Salome_file_map*> _t_Service_file_map;
-
+
_t_Service_file_map _Input_Service_file_map;
_t_Service_file_map _Output_Service_file_map;
_t_Service_file_map::iterator _Service_file_map_it;
#include <SALOMEconfig.h>
#include CORBA_CLIENT_HEADER(SALOME_Session)
-#ifdef WNT
+#ifdef WIN32
#include <process.h>
#define getpid _getpid
#endif
command = BuildCommandToLaunchRemoteContainer(resource_selected, params, container_exe);
//redirect stdout and stderr in a file
-#ifdef WNT
+#ifdef WIN32
std::string logFilename=getenv("TEMP");
logFilename += "\\";
std::string user = getenv( "USERNAME" );
logFilename += tmp.str();
logFilename += ".log" ;
command += " > " + logFilename + " 2>&1";
-#ifdef WNT
+#ifdef WIN32
command = "%PYTHONBIN% -c \"import win32pm ; win32pm.spawnpid(r'" + command + "', '')\"";
#else
command += " &";
--- /dev/null
+#! /usr/bin/env python
+# -*- coding: iso-8859-1 -*-
+# Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
+#
+# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+# SALOME DataContainer : implementation of data container
+# File : SALOME_DataContainerPy.py
+# Author : Mikhail PONIKARIOV
+# Module : SALOME
+# $Header$
+#
+import os
+import sys
+import string
+
+from omniORB import CORBA, PortableServer
+import Engines, Engines__POA
+from SALOME_ComponentPy import *
+
+#=============================================================================
+
+#define an implementation of the data container interface for the data transfer implemented in Python
+
+class SALOME_DataContainerPy_i (Engines__POA.DataContainer):
+ _url = ""
+ _name = ""
+ _identifier = ""
+ _ext = -1
+ _removeAfterGet = True;
+
+ #-------------------------------------------------------------------------
+
+ def __init__(self, urlorstream, name, identifier, removeAfterGet, isStream = False):
+ self._urlorstream = urlorstream
+ self._name = name
+ self._identifier = identifier
+ self._removeAfterGet = removeAfterGet
+ self._isStream = isStream
+ if isStream:
+ self._ext = ""
+ else:
+ self._ext = urlorstream[urlorstream.rfind(".") + 1 : ]
+
+ #-------------------------------------------------------------------------
+
+ def get(self):
+ if self._isStream:
+ return self._urlorstream
+
+ f = open(self._urlorstream, 'r')
+ stream = f.read()
+ f.close()
+ if self._removeAfterGet:
+ os.remove(self._urlorstream)
+ try: # try to remove directory if it is empty
+ index = max(self._urlorstream.rfind("\\"), self._url.rfind("/"))
+ if index > 0:
+ os.rmdir(self._urlorstream[:index])
+ except:
+ pass
+ return stream
+
+ #-------------------------------------------------------------------------
+
+ def name(self):
+ return self._name
+
+ #-------------------------------------------------------------------------
+
+ def identifier(self):
+ return self._identifier
+
+ def extension(self):
+ return self._ext
+
+ def setExtension(self, ext):
+ self._ext = ext
--- /dev/null
+// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+// SALOME DataContainer : implementation of data container
+// File : SALOME_DataContainer_i.cxx
+// Author : Mikhail PONIKAROV
+// Module : SALOME
+// $Header$
+//
+
+#include "SALOME_DataContainer_i.hxx"
+
+#include <fstream>
+#include <iostream>
+#ifndef WIN32
+#include <unistd.h>
+#endif
+using namespace std;
+
+Engines_DataContainer_i::Engines_DataContainer_i()
+{
+}
+
+Engines_DataContainer_i::Engines_DataContainer_i(const char* url,
+ const char* name, const char* identifier, const bool removeAfterGet)
+ : myName(name), myIdentifier(identifier), myURL(url), myRemoveAfterGet(removeAfterGet),
+ myStream(0)
+{
+ std::string anExtension(url);
+ if (anExtension.rfind(".") != std::string::npos) { // keep only extension
+ myExt = anExtension.substr(anExtension.rfind(".") + 1);
+ } else myExt = "";
+}
+
+Engines_DataContainer_i::Engines_DataContainer_i(char* stream,
+ const int streamSize, const char* name, const char* identifier, const bool removeAfterGet)
+ : myName(name), myIdentifier(identifier), myRemoveAfterGet(removeAfterGet),
+ myStream(stream), myStreamSize(streamSize), myExt("")
+{
+}
+
+Engines_DataContainer_i::~Engines_DataContainer_i()
+{
+}
+
+Engines::TMPFile* Engines_DataContainer_i::get()
+{
+ char* aBuffer = NULL;
+ int aFileSize = 0;
+ if (myStream) { // send from stream
+ aBuffer = myStream;
+ aFileSize = myStreamSize;
+ } else { // send from file
+ // open file to make stream from its content
+#ifdef WIN32
+ ifstream aFile(myURL.c_str(), std::ios::binary);
+#else
+ ifstream aFile(myURL.c_str());
+#endif
+ if (!aFile.good()) {
+ std::cerr<<"File "<<myURL.c_str()<<" can not be opened for reading"<<std::endl;
+ } else {
+ aFile.seekg(0, std::ios::end);
+ aFileSize = aFile.tellg();
+ aBuffer = new char[aFileSize];
+
+ aFile.seekg(0, std::ios::beg);
+ aFile.read(aBuffer, aFileSize);
+ aFile.close();
+
+ // remove file after it converted to a stream
+ // also remove directory of the file if it is empty
+ if (myRemoveAfterGet) {
+ string aDirName = myURL.substr(0, myURL.find_last_of("/\\"));
+#ifdef WIN32
+ DeleteFile(myURL.c_str());
+ RemoveDirectory(aDirName.c_str());
+#else
+ unlink(myURL.c_str());
+ rmdir(aDirName.c_str());
+#endif
+ }
+ }
+ }
+
+ // make CORBA TMP file from the buffer
+ CORBA::Octet* anOctetBuf = (CORBA::Octet*)aBuffer;
+ Engines::TMPFile_var aStreamFile = new Engines::TMPFile(aFileSize, aFileSize, anOctetBuf, 1);
+
+ if (myStream && myRemoveAfterGet)
+ delete [] myStream;
+
+ return aStreamFile._retn();
+}
+
+char* Engines_DataContainer_i::name()
+{
+ return CORBA::string_dup(myName.c_str());
+}
+
+char* Engines_DataContainer_i::identifier()
+{
+ return CORBA::string_dup(myIdentifier.c_str());
+}
+
+char* Engines_DataContainer_i::extension()
+{
+ return CORBA::string_dup(myExt.c_str());
+}
+
+void Engines_DataContainer_i::setExtension(const char* theExt)
+{
+ myExt = theExt;
+}
--- /dev/null
+// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+// SALOME DataContainer : implementation of data container
+// File : SALOME_DataContainer_i.hxx
+// Author : Mikhail PONIKAROV
+// Module : SALOME
+// $Header$
+//
+#ifndef _SALOME_DATACONTAINER_I_HXX_
+#define _SALOME_DATACONTAINER_I_HXX_
+
+#include "SALOME_Container.hxx"
+
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SALOME_Component)
+
+#include <string>
+
+class CONTAINER_EXPORT Engines_DataContainer_i:
+ public POA_Engines::DataContainer
+{
+public:
+ Engines_DataContainer_i();
+ Engines_DataContainer_i(const char* url,
+ const char* name,
+ const char* identifier,
+ const bool removeAfterGet);
+
+ Engines_DataContainer_i(char* stream,
+ const int streamSize,
+ const char* name,
+ const char* identifier,
+ const bool removeAfterGet);
+ virtual ~Engines_DataContainer_i();
+
+ // --- CORBA methods
+ virtual Engines::TMPFile* get();
+ virtual char* name();
+ virtual char* identifier();
+ virtual char* extension();
+ virtual void setExtension(const char* theExt);
+
+protected:
+
+ std::string myExt; ///< extension (type) of the file
+ std::string myName; ///< name of the document corresponding to this data
+ std::string myIdentifier; ///< module identifier of the document corresponding to this data
+ std::string myURL; ///< path to the locally located file
+ bool myRemoveAfterGet; ///< if this flag is true, file must be removed after the first "get" method call
+ char* myStream; ///< if it is not NULL, data must be get from this stream, not from the file
+ int myStreamSize; ///< size (in bytes) if the stream in myStream
+};
+
+#endif
//
#include <string>
#include "DSC_interface.hxx"
-#ifdef WNT
+#ifdef WIN32
#else
#include <sys/time.h>
#endif
{
//trace in file
traceType=1;
-#ifdef WNT
+#ifdef WIN32
std::string logFilename=getenv("TEMP");
logFilename += "\\";
#else
initTrace(containerName);
if(traceLevel == 0)return;
-#ifdef WNT
+#ifdef WIN32
#else
struct timeval tv;
gettimeofday(&tv,0);
# define GENERICOBJ_EXPORT
#endif
-#ifdef WNT
+#ifdef WIN32
#pragma warning(disable:4275) // Disable warning interface non dll
#pragma warning(disable:4251) // Warning DLL Interface ...
#endif
#include <cstring>
#include <stdlib.h>
-#ifdef WNT
+#ifdef WIN32
#define strdup _strdup
#endif
Launcher_Job_PythonSALOME.cxx
Launcher_Job_YACSFile.cxx
Launcher.cxx
+ Launcher_XML_Persistence.cxx
)
ADD_LIBRARY(Launcher ${Launcher_SOURCES})
INSTALL(TARGETS SALOME_LauncherServer EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_BINS})
ENDIF()
-FILE(GLOB COMMON_HEADERS_HXX "${CMAKE_CURRENT_SOURCE_DIR}/*.hxx")
+SET(COMMON_HEADERS_HXX
+ BatchTest.hxx
+ Launcher.hxx
+ Launcher_Job.hxx
+ Launcher_Job_Command.hxx
+ Launcher_Job_PythonSALOME.hxx
+ Launcher_Job_SALOME.hxx
+ Launcher_Job_YACSFile.hxx
+ Launcher_Utils.hxx
+ SALOME_Launcher.hxx
+ SALOME_Launcher_Parser.hxx
+ SALOME_Launcher_defs.hxx
+)
INSTALL(FILES ${COMMON_HEADERS_HXX} DESTINATION ${SALOME_INSTALL_HEADERS})
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
+#include <list>
+#include <iostream>
+#include <sstream>
+#include <sys/stat.h>
+#include <time.h>
+
#ifdef WITH_LIBBATCH
#include <libbatch/BatchManagerCatalog.hxx>
#include <libbatch/FactBatchManager.hxx>
#include "SALOME_Launcher_Handler.hxx"
#include "Launcher.hxx"
#include "Launcher_Job_Command.hxx"
-#include <iostream>
-#include <sstream>
-#include <sys/stat.h>
-#include <time.h>
+#include "Launcher_XML_Persistence.hxx"
+
+using namespace std;
//=============================================================================
/*!
Batch::JobId batch_manager_job_id = _batchmap[job_id]->submitJob(*(job->getBatchJob()));
job->setBatchManagerJobId(batch_manager_job_id);
job->setState("QUEUED");
+ job->setReference(batch_manager_job_id.getReference());
}
catch(const Batch::GenericException &ex)
{
}
void
-Launcher_cpp::addJobDirectlyToMap(Launcher::Job * new_job, const std::string job_reference)
+Launcher_cpp::addJobDirectlyToMap(Launcher::Job * new_job)
{
// Step 0: Calculated job_id
pthread_mutex_lock(_job_cpt_mutex);
try
{
Batch::JobId batch_manager_job_id = _batchmap[job_id]->addJob(*(new_job->getBatchJob()),
- job_reference);
+ new_job->getReference());
new_job->setBatchManagerJobId(batch_manager_job_id);
}
catch(const Batch::GenericException &ex)
LAUNCHER_MESSAGE("New job added");
#endif
}
+
+list<int>
+Launcher_cpp::loadJobs(const char* jobs_file)
+{
+ list<int> new_jobs_id_list;
+
+ // Load the jobs from XML file
+ list<Launcher::Job *> jobs_list = Launcher::XML_Persistence::loadJobs(jobs_file);
+
+ // Create each job in the launcher
+ list<Launcher::Job *>::const_iterator it_job;
+ for (it_job = jobs_list.begin(); it_job != jobs_list.end(); it_job++)
+ {
+ Launcher::Job * new_job = *it_job;
+ string job_state = new_job->getState();
+
+ try
+ {
+ if (job_state == "CREATED")
+ {
+ // In this case, we ignore run_part informations
+ createJob(new_job);
+ new_jobs_id_list.push_back(new_job->getNumber());
+ }
+ else if (job_state == "QUEUED" ||
+ job_state == "RUNNING" ||
+ job_state == "IN_PROCESS" ||
+ job_state == "PAUSED")
+ {
+ addJobDirectlyToMap(new_job);
+ new_jobs_id_list.push_back(new_job->getNumber());
+
+ // Step 4: We check that the BatchManager could resume
+ // the job
+#ifdef WITH_LIBBATCH
+ if (new_job->getBatchManagerJobId().getReference() != new_job->getReference())
+ {
+ LAUNCHER_INFOS("BatchManager type cannot resume a job - job state is set to ERROR");
+ new_job->setState("ERROR");
+ }
+#endif
+ }
+ else if (job_state == "FINISHED" ||
+ job_state == "FAILED" ||
+ job_state == "ERROR")
+ {
+ // Step 2: We add run_part informations
+ addJobDirectlyToMap(new_job);
+ new_jobs_id_list.push_back(new_job->getNumber());
+ }
+ else
+ {
+ LAUNCHER_INFOS("A bad job is found, state unknown " << job_state);
+ delete new_job;
+ }
+ }
+ catch(const LauncherException &ex)
+ {
+ LAUNCHER_INFOS("Cannot load the job. Exception: " << ex.msg.c_str());
+ delete new_job;
+ }
+ }
+
+ return new_jobs_id_list;
+}
+
+void
+Launcher_cpp::saveJobs(const char* jobs_file)
+{
+ // Create a sorted list from the internal job map
+ list<const Launcher::Job *> jobs_list;
+ for (int i=0; i<_job_cpt; i++)
+ {
+ map<int, Launcher::Job *>::const_iterator it_job = _launcher_job_map.find(i);
+ if (it_job != _launcher_job_map.end())
+ jobs_list.push_back(it_job->second);
+ }
+
+ // Save the jobs in XML file
+ Launcher::XML_Persistence::saveJobs(jobs_file, jobs_list);
+}
#include <string>
#include <vector>
+#include <list>
#include <pthread.h>
void stopJob(int job_id);
void removeJob(int job_id);
+ /*! Load the jobs from the file "jobs_file" and add them to the Launcher.
+ * Return a list with the IDs of the jobs that were successfully loaded.
+ */
+ std::list<int> loadJobs(const char* jobs_file);
+
+ //! Save the jobs of the Launcher to the file "jobs_file".
+ void saveJobs(const char* jobs_file);
+
// Useful methods
long createJobWithFile(std::string xmlExecuteFile, std::string clusterName);
std::map<int, Launcher::Job *> getJobs();
void createBatchManagerForJob(Launcher::Job * job);
- void addJobDirectlyToMap(Launcher::Job * new_job, const std::string job_reference);
+ void addJobDirectlyToMap(Launcher::Job * new_job);
// Lib methods
void SetResourcesManager( ResourcesManager_cpp* rm ) {_ResManager = rm;}
}
std::string
-Launcher::Job::getJobType()
+Launcher::Job::getJobType() const
{
return _job_type;
}
}
std::string
-Launcher::Job::getJobName()
+Launcher::Job::getJobName() const
{
return _job_name;
}
}
std::string
-Launcher::Job::getState()
+Launcher::Job::getState() const
{
return _state;
}
}
ParserResourcesType
-Launcher::Job::getResourceDefinition()
+Launcher::Job::getResourceDefinition() const
{
return _resource_definition;
}
}
std::string
-Launcher::Job::getJobFile()
+Launcher::Job::getJobFile() const
{
return _job_file;
}
}
std::string
-Launcher::Job::getEnvFile()
+Launcher::Job::getEnvFile() const
{
return _env_file;
}
_mem_per_cpu = mem_per_cpu;
}
+void
+Launcher::Job::setReference(const std::string & reference)
+{
+ _reference = reference;
+}
+
std::string
-Launcher::Job::getWorkDirectory()
+Launcher::Job::getWorkDirectory() const
{
return _work_directory;
}
std::string
-Launcher::Job::getLocalDirectory()
+Launcher::Job::getLocalDirectory() const
{
return _local_directory;
}
std::string
-Launcher::Job::getResultDirectory()
+Launcher::Job::getResultDirectory() const
{
return _result_directory;
}
const std::list<std::string> &
-Launcher::Job::get_in_files()
+Launcher::Job::get_in_files() const
{
return _in_files;
}
const std::list<std::string> &
-Launcher::Job::get_out_files()
+Launcher::Job::get_out_files() const
{
return _out_files;
}
std::string
-Launcher::Job::getMaximumDuration()
+Launcher::Job::getMaximumDuration() const
{
return _maximum_duration;
}
// For COORM
std::string
-Launcher::Job::getLauncherFile()
+Launcher::Job::getLauncherFile() const
{
return _launcher_file;
}
std::string
-Launcher::Job::getLauncherArgs()
+Launcher::Job::getLauncherArgs() const
{
return _launcher_args;
}
resourceParams
-Launcher::Job::getResourceRequiredParams()
+Launcher::Job::getResourceRequiredParams() const
{
return _resource_required_params;
}
std::string
-Launcher::Job::getQueue()
+Launcher::Job::getQueue() const
{
return _queue;
}
bool
-Launcher::Job::getExclusive()
+Launcher::Job::getExclusive() const
{
return _exclusive;
}
return _mem_per_cpu;
}
+std::string
+Launcher::Job::getReference() const
+{
+ return _reference;
+}
+
void
Launcher::Job::checkMaximumDuration(const std::string & maximum_duration)
{
}
std::string
-Launcher::Job::getLaunchDate()
+Launcher::Job::getLaunchDate() const
{
time_t rawtime;
time(&rawtime);
}
Batch::JobId
-Launcher::Job::getBatchManagerJobId()
+Launcher::Job::getBatchManagerJobId() const
{
return _batch_job_id;
}
#endif
-void
-Launcher::Job::addToXmlDocument(xmlNodePtr root_node)
-{
- // Begin job
- xmlNodePtr job_node = xmlNewChild(root_node, NULL, xmlCharStrdup("job"), NULL);
- xmlNewProp(job_node, xmlCharStrdup("type"), xmlCharStrdup(getJobType().c_str()));
- xmlNewProp(job_node, xmlCharStrdup("name"), xmlCharStrdup(getJobName().c_str()));
-
- // Add user part
- xmlNodePtr node = xmlNewChild(job_node, NULL, xmlCharStrdup("user_part"), NULL);
-
- xmlNewChild(node, NULL, xmlCharStrdup("job_file"), xmlCharStrdup(getJobFile().c_str()));
- xmlNewChild(node, NULL, xmlCharStrdup("env_file"), xmlCharStrdup(getEnvFile().c_str()));
- xmlNewChild(node, NULL, xmlCharStrdup("work_directory"), xmlCharStrdup(getWorkDirectory().c_str()));
- xmlNewChild(node, NULL, xmlCharStrdup("local_directory"), xmlCharStrdup(getLocalDirectory().c_str()));
- xmlNewChild(node, NULL, xmlCharStrdup("result_directory"), xmlCharStrdup(getResultDirectory().c_str()));
-
- // Parameters for COORM
- xmlNewChild(node, NULL, xmlCharStrdup("launcher_file"), xmlCharStrdup(getLauncherFile().c_str()));
-
- // Files
- xmlNodePtr files_node = xmlNewChild(node, NULL, xmlCharStrdup("files"), NULL);
- std::list<std::string> in_files = get_in_files();
- std::list<std::string> out_files = get_out_files();
- for(std::list<std::string>::iterator it = in_files.begin(); it != in_files.end(); it++)
- xmlNewChild(files_node, NULL, xmlCharStrdup("in_file"), xmlCharStrdup((*it).c_str()));
- for(std::list<std::string>::iterator it = out_files.begin(); it != out_files.end(); it++)
- xmlNewChild(files_node, NULL, xmlCharStrdup("out_file"), xmlCharStrdup((*it).c_str()));
-
- // Resource part
- resourceParams resource_params = getResourceRequiredParams();
- xmlNodePtr res_node = xmlNewChild(node, NULL, xmlCharStrdup("resource_params"), NULL);
- xmlNewChild(res_node, NULL, xmlCharStrdup("name"), xmlCharStrdup(resource_params.name.c_str()));
- xmlNewChild(res_node, NULL, xmlCharStrdup("hostname"), xmlCharStrdup(resource_params.hostname.c_str()));
- xmlNewChild(res_node, NULL, xmlCharStrdup("OS"), xmlCharStrdup(resource_params.OS.c_str()));
- std::ostringstream nb_proc_stream;
- std::ostringstream nb_node_stream;
- std::ostringstream nb_proc_per_node_stream;
- std::ostringstream cpu_clock_stream;
- std::ostringstream mem_mb_stream;
- nb_proc_stream << resource_params.nb_proc;
- nb_node_stream << resource_params.nb_node;
- nb_proc_per_node_stream << resource_params.nb_proc_per_node;
- cpu_clock_stream << resource_params.cpu_clock;
- mem_mb_stream << resource_params.mem_mb;
- xmlNewChild(res_node, NULL, xmlCharStrdup("nb_proc"), xmlCharStrdup(nb_proc_stream.str().c_str()));
- xmlNewChild(res_node, NULL, xmlCharStrdup("nb_node"), xmlCharStrdup(nb_node_stream.str().c_str()));
- xmlNewChild(res_node, NULL, xmlCharStrdup("nb_proc_per_node"), xmlCharStrdup(nb_proc_per_node_stream.str().c_str()));
- xmlNewChild(res_node, NULL, xmlCharStrdup("cpu_clock"), xmlCharStrdup(cpu_clock_stream.str().c_str()));
- xmlNewChild(res_node, NULL, xmlCharStrdup("mem_mb"), xmlCharStrdup(mem_mb_stream.str().c_str()));
-
- xmlNewChild(node, NULL, xmlCharStrdup("maximum_duration"), xmlCharStrdup(getMaximumDuration().c_str()));
- xmlNewChild(node, NULL, xmlCharStrdup("queue"), xmlCharStrdup(getQueue().c_str()));
- xmlNewChild(node, NULL, xmlCharStrdup("exclusive"), xmlCharStrdup(getExclusiveStr().c_str()));
- ostringstream mem_per_cpu_stream;
- mem_per_cpu_stream << _mem_per_cpu;
- xmlNewChild(node, NULL, xmlCharStrdup("mem_per_cpu"), xmlCharStrdup(mem_per_cpu_stream.str().c_str()));
-
- // For COORM
- xmlNewChild(node, NULL, xmlCharStrdup("launcher_args"), xmlCharStrdup(getLauncherArgs().c_str()));
-
- // Specific parameters part
- xmlNodePtr specific_parameters_node = xmlNewChild(node, NULL, xmlCharStrdup("specific_parameters"), NULL);
- std::map<std::string, std::string> specific_parameters = getSpecificParameters();
- for(std::map<std::string, std::string>::iterator it = specific_parameters.begin(); it != specific_parameters.end(); it++)
- {
- xmlNodePtr specific_parameter_node = xmlNewChild(specific_parameters_node, NULL, xmlCharStrdup("specific_parameter"), NULL);
- xmlNewChild(specific_parameter_node, NULL, xmlCharStrdup("name"), xmlCharStrdup((it->first).c_str()));
- xmlNewChild(specific_parameter_node, NULL, xmlCharStrdup("value"), xmlCharStrdup((it->second).c_str()));
- }
-
- // Run part
- xmlNodePtr run_node = xmlNewChild(job_node, NULL, xmlCharStrdup("run_part"), NULL);
- xmlNewChild(run_node, NULL, xmlCharStrdup("job_state"), xmlCharStrdup(getState().c_str()));
- ParserResourcesType resource_definition = getResourceDefinition();
- xmlNewChild(run_node, NULL, xmlCharStrdup("resource_choosed_name"), xmlCharStrdup(resource_definition.Name.c_str()));
-
-#ifdef WITH_LIBBATCH
- Batch::JobId job_id = getBatchManagerJobId();
- xmlNewChild(run_node, NULL, xmlCharStrdup("job_reference"), xmlCharStrdup(job_id.getReference().c_str()));
-#endif
-}
-
void
Launcher::Job::addSpecificParameter(const std::string & name,
const std::string & value)
}
const std::map<std::string, std::string> &
-Launcher::Job::getSpecificParameters()
+Launcher::Job::getSpecificParameters() const
{
return _specific_parameters;
}
#include <libbatch/GenericException.hxx>
#endif
-#include <libxml/parser.h>
-
namespace Launcher
{
class LAUNCHER_EXPORT Job
// Launcher managing parameters
// State of a Job: CREATED, IN_PROCESS, QUEUED, RUNNING, PAUSED, FINISHED, ERROR
void setState(const std::string & state);
- std::string getState();
+ std::string getState() const;
// Get names or ids of hosts assigned to the job
std::string getAssignedHostnames();
int getNumber();
virtual void setResourceDefinition(const ParserResourcesType & resource_definition);
- ParserResourcesType getResourceDefinition();
+ ParserResourcesType getResourceDefinition() const;
// Common parameters
void setJobName(const std::string & job_name);
void setExclusive(bool exclusive);
void setExclusiveStr(const std::string & exclusiveStr);
void setMemPerCpu(unsigned long mem_per_cpu);
+ void setReference(const std::string & reference);
// For COORM
void setLauncherFile(const std::string & launcher_file);
void setLauncherArgs(const std::string & launcher_args);
- std::string getJobName();
- std::string getJobFile();
- std::string getWorkDirectory();
- std::string getLocalDirectory();
- std::string getResultDirectory();
- const std::list<std::string> & get_in_files();
- const std::list<std::string> & get_out_files();
- std::string getMaximumDuration();
- resourceParams getResourceRequiredParams();
- std::string getQueue();
- std::string getEnvFile();
- std::string getJobType();
- bool getExclusive();
+ std::string getJobName() const;
+ std::string getJobFile() const;
+ std::string getWorkDirectory() const;
+ std::string getLocalDirectory() const;
+ std::string getResultDirectory() const;
+ const std::list<std::string> & get_in_files() const;
+ const std::list<std::string> & get_out_files() const;
+ std::string getMaximumDuration() const;
+ resourceParams getResourceRequiredParams() const;
+ std::string getQueue() const;
+ std::string getEnvFile() const;
+ std::string getJobType() const;
+ bool getExclusive() const;
std::string getExclusiveStr() const;
unsigned long getMemPerCpu() const;
+ std::string getReference() const;
// For COORM
- std::string getLauncherFile();
- std::string getLauncherArgs();
+ std::string getLauncherFile() const;
+ std::string getLauncherArgs() const;
std::string updateJobState();
void addSpecificParameter(const std::string & name,
const std::string & value);
- const std::map<std::string, std::string> & getSpecificParameters();
+ const std::map<std::string, std::string> & getSpecificParameters() const;
virtual void checkSpecificParameters();
// Checks
// Helps
long convertMaximumDuration(const std::string & maximum_duration);
- std::string getLaunchDate();
-
- // Xml method
- void addToXmlDocument(xmlNodePtr root_node);
+ std::string getLaunchDate() const;
void stopJob();
void removeJob();
std::string _queue;
bool _exclusive;
unsigned long _mem_per_cpu;
+ std::string _reference; //! Reference of the job for the batch manager
// Parameters for COORM
std::string _launcher_file;
Batch::Job * getBatchJob();
Batch::Parametre common_job_params();
void setBatchManagerJobId(Batch::JobId batch_manager_job_id);
- Batch::JobId getBatchManagerJobId();
+ Batch::JobId getBatchManagerJobId() const;
protected:
Batch::Job * _batch_job;
}
#endif
-
#include <libbatch/Constants.hxx>
#endif
-#ifdef WNT
+#ifdef WIN32
#include <io.h>
#define _chmod chmod
#endif
#include <libbatch/Constants.hxx>
#endif
-#ifdef WNT
+#ifdef WIN32
#include <io.h>
#define _chmod chmod
#endif
--- /dev/null
+// Copyright (C) 2007-2013 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
+//
+
+#include <libxml/parser.h>
+
+#include "Launcher_XML_Persistence.hxx"
+#include "Launcher_Job_Command.hxx"
+#include "Launcher_Job_YACSFile.hxx"
+#include "Launcher_Job_PythonSALOME.hxx"
+
+using namespace std;
+
+namespace Launcher
+{
+
+list<Job *>
+XML_Persistence::loadJobs(const char* jobs_file)
+{
+ // Step 1: check jobs_file read access
+ FILE* xml_file = fopen(jobs_file, "r");
+ if (xml_file == NULL)
+ {
+ std::string error = "Error opening jobs_file in SALOME_Launcher::loadJobs: " + std::string(jobs_file);
+ LAUNCHER_INFOS(error);
+ throw LauncherException(error);
+ }
+
+ // Step 2: read xml file
+ xmlDocPtr doc = xmlReadFile(jobs_file, NULL, 0);
+ if (doc == NULL)
+ {
+ std::string error = "Error in xmlReadFile in SALOME_Launcher::loadJobs, could not parse file: " + std::string(jobs_file);
+ LAUNCHER_INFOS(error);
+ fclose(xml_file);
+ throw LauncherException(error);
+ }
+
+ // Step 3: Find jobs
+ list<Job *> jobs_list;
+ xmlNodePtr root_node = xmlDocGetRootElement(doc);
+ if (xmlStrToString(root_node->name) == "jobs")
+ {
+ xmlNodePtr xmlCurrentNode = root_node->xmlChildrenNode;
+ while(xmlCurrentNode != NULL)
+ {
+ if (xmlStrToString(xmlCurrentNode->name) == "job")
+ {
+ LAUNCHER_INFOS("A job is found");
+ Job * new_job = createJobFromXmlNode(xmlCurrentNode);
+ jobs_list.push_back(new_job);
+ }
+ xmlCurrentNode = xmlCurrentNode->next;
+ }
+ }
+ else
+ {
+ xmlFreeDoc(doc);
+ fclose(xml_file);
+ std::string error = "Error in xml file, could not find root_node named jobs: " + std::string(jobs_file);
+ LAUNCHER_INFOS(error);
+ throw LauncherException(error);
+ }
+
+ // Clean
+ xmlFreeDoc(doc);
+ fclose(xml_file);
+
+ return jobs_list;
+}
+
+void
+XML_Persistence::saveJobs(const char* jobs_file, const list<const Job *> & jobs_list)
+{
+ // Step 1: check jobs_file write access
+ FILE* xml_file = fopen(jobs_file, "w");
+ if (xml_file == NULL)
+ {
+ std::string error = "Error opening jobs_file in SALOME_Launcher::saveJobs: " + std::string(jobs_file);
+ LAUNCHER_INFOS(error);
+ throw LauncherException(error);
+ }
+
+ // Step 2: First lines
+ xmlKeepBlanksDefault(0);
+ xmlDocPtr doc = xmlNewDoc(xmlCharStrdup("1.0"));
+ xmlNodePtr root_node = xmlNewNode(NULL, xmlCharStrdup("jobs"));
+ xmlDocSetRootElement(doc, root_node);
+ xmlNodePtr doc_comment = xmlNewDocComment(doc, xmlCharStrdup("SALOME Launcher save jobs file"));
+ xmlAddPrevSibling(root_node, doc_comment);
+
+ // Step 3: For each job write it on the xml document
+ // We could put a mutex but are not foing to do that currently
+ list<const Job *>::const_iterator it_job;
+ for (it_job = jobs_list.begin(); it_job != jobs_list.end(); it_job++)
+ {
+ addJobToXmlDocument(root_node, **it_job);
+ }
+
+ // Final step: write file
+ int isOk = xmlSaveFormatFile(jobs_file, doc, 1);
+ if (!isOk)
+ {
+ std::string error = "Error during xml file saving in SALOME_Launcher::saveJobs: " + std::string(jobs_file);
+ LAUNCHER_INFOS(error);
+ xmlFreeDoc(doc);
+ fclose(xml_file);
+ throw LauncherException(error);
+ }
+
+ // Clean
+ xmlFreeDoc(doc);
+ fclose(xml_file);
+ LAUNCHER_MESSAGE("SALOME_Launcher::saveJobs : WRITING DONE!");
+}
+
+void
+XML_Persistence::addJobToXmlDocument(xmlNodePtr root_node, const Job & job)
+{
+ // Begin job
+ xmlNodePtr job_node = addNode(root_node, "job", "");
+ addAttr(job_node, "type", job.getJobType());
+ addAttr(job_node, "name", job.getJobName());
+
+ // Add user part
+ xmlNodePtr node = addNode(job_node, "user_part", "");
+
+ addNode(node, "job_file", job.getJobFile());
+ if (!job.getEnvFile().empty())
+ addNode(node, "env_file", job.getEnvFile());
+ if (!job.getWorkDirectory().empty())
+ addNode(node, "work_directory", job.getWorkDirectory());
+ if (!job.getLocalDirectory().empty())
+ addNode(node, "local_directory", job.getLocalDirectory());
+ if (!job.getResultDirectory().empty())
+ addNode(node, "result_directory", job.getResultDirectory());
+
+ // Parameters for COORM
+ if (!job.getLauncherFile().empty())
+ addNode(node, "launcher_file", job.getLauncherFile());
+ if (!job.getLauncherArgs().empty())
+ addNode(node, "launcher_args", job.getLauncherArgs());
+
+ // Files
+ if ( ! (job.get_in_files().empty() && job.get_out_files().empty()) )
+ {
+ xmlNodePtr files_node = addNode(node, "files", "");
+ list<string> in_files = job.get_in_files();
+ list<string> out_files = job.get_out_files();
+ for(list<string>::iterator it = in_files.begin(); it != in_files.end(); it++)
+ addNode(files_node, "in_file", *it);
+ for(list<string>::iterator it = out_files.begin(); it != out_files.end(); it++)
+ addNode(files_node, "out_file", *it);
+ }
+
+ // Resource part
+ resourceParams resource_params = job.getResourceRequiredParams();
+ xmlNodePtr res_node = addNode(node, "resource_params", "");
+ addNode(res_node, "name", resource_params.name);
+ if (!resource_params.hostname.empty())
+ addNode(res_node, "hostname", resource_params.hostname);
+ if (!resource_params.OS.empty())
+ addNode(res_node, "OS", resource_params.OS);
+ if (resource_params.nb_proc > 0)
+ addNumericalNode(res_node, "nb_proc", resource_params.nb_proc);
+ if (resource_params.nb_node > 0)
+ addNumericalNode(res_node, "nb_node", resource_params.nb_node);
+ if (resource_params.nb_proc_per_node > 0)
+ addNumericalNode(res_node, "nb_proc_per_node", resource_params.nb_proc_per_node);
+ if (resource_params.cpu_clock > 0)
+ addNumericalNode(res_node, "cpu_clock", resource_params.cpu_clock);
+ if (resource_params.mem_mb > 0)
+ addNumericalNode(res_node, "mem_mb", resource_params.mem_mb);
+
+ if (!job.getMaximumDuration().empty())
+ addNode(node, "maximum_duration", job.getMaximumDuration());
+ if (!job.getQueue().empty())
+ addNode(node, "queue", job.getQueue());
+ if (job.getExclusive())
+ addNode(node, "exclusive", job.getExclusiveStr());
+ if (job.getMemPerCpu() > 0)
+ addNumericalNode(res_node, "mem_per_cpu", job.getMemPerCpu());
+
+ // Specific parameters part
+ map<string, string> specific_parameters = job.getSpecificParameters();
+ if (!specific_parameters.empty())
+ {
+ xmlNodePtr specific_parameters_node = addNode(node, "specific_parameters", "");
+ for(map<string, string>::iterator it = specific_parameters.begin();
+ it != specific_parameters.end();
+ it++)
+ {
+ xmlNodePtr specific_parameter_node = addNode(specific_parameters_node,
+ "specific_parameter", "");
+ addNode(specific_parameter_node, "name", it->first);
+ addNode(specific_parameter_node, "value", it->second);
+ }
+ }
+
+ // Run part
+ xmlNodePtr run_node = addNode(job_node, "run_part", "");
+ addNode(run_node, "job_state", job.getState());
+ addNode(run_node, "job_reference", job.getReference());
+}
+
+Job *
+XML_Persistence::createJobFromXmlNode(xmlNodePtr job_node)
+{
+ Launcher::Job * new_job;
+
+ // Begin Job
+ string job_name = getAttrValue(job_node, "name");
+ if (job_name.empty())
+ throw LauncherException("Invalid job: name is not defined");
+ string job_type = getAttrValue(job_node, "type");
+ if (job_type.empty())
+ throw LauncherException(string("Invalid job \"") + job_name + "\": type is not defined");
+ if (job_type == "command")
+ new_job = new Launcher::Job_Command();
+ else if (job_type == "yacs_file")
+ new_job = new Launcher::Job_YACSFile();
+ else if (job_type == "python_salome")
+ new_job = new Launcher::Job_PythonSALOME();
+ else
+ {
+ string error = string("Invalid job \"") + job_name + "\": invalid type \"" + job_type + "\"";
+ throw LauncherException(error);
+ }
+ new_job->setJobName(job_name);
+
+ try
+ {
+ xmlNodePtr current_node = xmlFirstElementChild(job_node);
+ bool user_ok = false;
+ bool run_ok = false;
+ while (current_node != NULL)
+ {
+ string node_name = xmlStrToString(current_node->name);
+ if (node_name == "user_part")
+ {
+ parseUserNode(new_job, current_node);
+ user_ok = true;
+ }
+ else if (node_name == "run_part")
+ {
+ parseRunNode(new_job, current_node);
+ run_ok = true;
+ }
+ else
+ throw LauncherException(string("invalid node \"") + node_name + "\"");
+ current_node = xmlNextElementSibling(current_node);
+ }
+ if (!user_ok) throw LauncherException("missing user part");
+ if (!run_ok) throw LauncherException("missing run part");
+ }
+ catch (const LauncherException & exc)
+ {
+ delete new_job;
+ string error = string("Invalid job \"") + job_name + "\": " + exc.msg;
+ throw LauncherException(error);
+ }
+
+ return new_job;
+}
+
+void
+XML_Persistence::parseUserNode(Job * new_job, xmlNodePtr user_node)
+{
+ xmlNodePtr current_node = xmlFirstElementChild(user_node);
+ bool job_file_ok = false;
+ while (current_node != NULL)
+ {
+ string node_name = xmlStrToString(current_node->name);
+ if (node_name == "job_file")
+ {
+ new_job->setJobFile(getNodeContent(current_node));
+ job_file_ok = true;
+ }
+ else if (node_name == "env_file")
+ new_job->setEnvFile(getNodeContent(current_node));
+ else if (node_name == "work_directory")
+ new_job->setWorkDirectory(getNodeContent(current_node));
+ else if (node_name == "local_directory")
+ new_job->setLocalDirectory(getNodeContent(current_node));
+ else if (node_name == "result_directory")
+ new_job->setResultDirectory(getNodeContent(current_node));
+ else if (node_name == "launcher_file") // For COORM
+ new_job->setLauncherFile(getNodeContent(current_node));
+ else if (node_name == "launcher_args") // For COORM
+ new_job->setLauncherArgs(getNodeContent(current_node));
+ else if (node_name == "files")
+ {
+ // Get in and out files
+ xmlNodePtr file_node = xmlFirstElementChild(current_node);
+ while (file_node != NULL)
+ {
+ string file_node_name = xmlStrToString(file_node->name);
+ if (file_node_name == "in_file")
+ new_job->add_in_file(getNodeContent(file_node));
+ else if (file_node_name == "out_file")
+ new_job->add_out_file(getNodeContent(file_node));
+ else
+ throw LauncherException(string("invalid node \"") + file_node_name + "\"");
+ file_node = xmlNextElementSibling(file_node);
+ }
+ }
+ else if (node_name == "resource_params")
+ new_job->setResourceRequiredParams(parseResourceNode(current_node));
+ else if (node_name == "maximum_duration")
+ new_job->setMaximumDuration(getNodeContent(current_node));
+ else if (node_name == "queue")
+ new_job->setQueue(getNodeContent(current_node));
+ else if (node_name == "exclusive")
+ new_job->setExclusiveStr(getNodeContent(current_node));
+ else if (node_name == "mem_per_cpu")
+ new_job->setMemPerCpu(getNumericalNodeContent<unsigned long>(current_node));
+ else if (node_name == "specific_parameters")
+ {
+ // Get specific parameters
+ xmlNodePtr parameter_node = xmlFirstElementChild(current_node);
+ while (parameter_node != NULL)
+ {
+ string parameter_node_name = xmlStrToString(parameter_node->name);
+ if (parameter_node_name == "specific_parameter")
+ {
+ xmlNodePtr inparam_node = xmlFirstElementChild(parameter_node);
+ string name;
+ string value;
+ while (inparam_node != NULL)
+ {
+ string inparam_node_name = xmlStrToString(inparam_node->name);
+ if (inparam_node_name == "name")
+ name = getNodeContent(inparam_node);
+ else if (inparam_node_name == "value")
+ value = getNodeContent(inparam_node);
+ else
+ throw LauncherException(string("invalid node \"") + inparam_node_name + "\"");
+ inparam_node = xmlNextElementSibling(inparam_node);
+ }
+ if (name.empty()) throw LauncherException("missing parameter name");
+ if (value.empty()) throw LauncherException("missing parameter value");
+ new_job->addSpecificParameter(name, value);
+ }
+ else
+ throw LauncherException(string("invalid node \"") + parameter_node_name + "\"");
+ parameter_node = xmlNextElementSibling(parameter_node);
+ }
+ }
+ else
+ throw LauncherException(string("invalid node \"") + node_name + "\"");
+ current_node = xmlNextElementSibling(current_node);
+ }
+ if (!job_file_ok) throw LauncherException("missing job file");
+}
+
+resourceParams
+XML_Persistence::parseResourceNode(xmlNodePtr res_node)
+{
+ resourceParams p;
+ xmlNodePtr current_node = xmlFirstElementChild(res_node);
+ while (current_node != NULL)
+ {
+ string node_name = xmlStrToString(current_node->name);
+ if (node_name == "name")
+ p.name = getNodeContent(current_node);
+ else if (node_name == "hostname")
+ p.hostname = getNodeContent(current_node);
+ else if (node_name == "OS")
+ p.OS = getNodeContent(current_node);
+ else if (node_name == "nb_proc")
+ p.nb_proc = getNumericalNodeContent<long>(current_node);
+ else if (node_name == "nb_node")
+ p.nb_node = getNumericalNodeContent<long>(current_node);
+ else if (node_name == "nb_proc_per_node")
+ p.nb_proc_per_node = getNumericalNodeContent<long>(current_node);
+ else if (node_name == "cpu_clock")
+ p.cpu_clock = getNumericalNodeContent<long>(current_node);
+ else if (node_name == "mem_mb")
+ p.mem_mb = getNumericalNodeContent<long>(current_node);
+ else
+ throw LauncherException(string("invalid node \"") + node_name + "\"");
+ current_node = xmlNextElementSibling(current_node);
+ }
+ return p;
+}
+
+void
+XML_Persistence::parseRunNode(Job * new_job, xmlNodePtr run_node)
+{
+ xmlNodePtr current_node = xmlFirstElementChild(run_node);
+ while (current_node != NULL)
+ {
+ string node_name = xmlStrToString(current_node->name);
+ if (node_name == "job_state")
+ new_job->setState(getNodeContent(current_node));
+ else if (node_name == "resource_choosed_name")
+ {
+ // This parameter was present in older versions of Salome. Now we just silently ignore it.
+ }
+ else if (node_name == "job_reference")
+ new_job->setReference(getNodeContent(current_node));
+ else
+ throw LauncherException(string("invalid node \"") + node_name + "\"");
+ current_node = xmlNextElementSibling(current_node);
+ }
+}
+
+string
+XML_Persistence::getAttrValue(xmlNodePtr node, const string & attrName)
+{
+ string attrValue;
+ xmlChar * xmlAttrName = xmlCharStrdup(attrName.c_str());
+ xmlChar * xmlAttrValue = xmlGetProp(node, xmlAttrName);
+ if (xmlAttrValue != NULL) attrValue = (const char *)xmlAttrValue;
+ xmlFree(xmlAttrName);
+ xmlFree(xmlAttrValue);
+ return attrValue;
+}
+
+inline string
+XML_Persistence::xmlStrToString(const xmlChar * xmlStr)
+{
+ return string((const char *)xmlStr);
+}
+
+string
+XML_Persistence::getNodeContent(xmlNodePtr node)
+{
+ string nodeContent;
+ xmlChar * xmlStrContent = xmlNodeGetContent(node);
+ if (xmlStrContent != NULL) nodeContent = (const char *)xmlStrContent;
+ xmlFree(xmlStrContent);
+ return nodeContent;
+}
+
+template<typename T>
+T
+XML_Persistence::getNumericalNodeContent(xmlNodePtr node)
+{
+ T result;
+ istringstream nodeContentStream(getNodeContent(node));
+ if (!(nodeContentStream >> result))
+ throw LauncherException(xmlStrToString(node->name) + " parameter is not correct");
+ return result;
+}
+
+xmlNodePtr
+XML_Persistence::addNode(xmlNodePtr father, const string & name, const string & content)
+{
+ xmlChar * xmlStrName = xmlCharStrdup(name.c_str());
+ xmlChar * xmlStrContent = NULL;
+ if (!content.empty())
+ xmlStrContent = xmlCharStrdup(content.c_str());
+ xmlNodePtr node = xmlNewChild(father, NULL, xmlStrName, xmlStrContent);
+ xmlFree(xmlStrName);
+ xmlFree(xmlStrContent);
+ return node;
+}
+
+template<typename T>
+xmlNodePtr
+XML_Persistence::addNumericalNode(xmlNodePtr father, const string & name, T content)
+{
+ ostringstream nodeContentStream;
+ nodeContentStream << content;
+ return addNode(father, name, nodeContentStream.str());
+}
+
+void
+XML_Persistence::addAttr(xmlNodePtr node, const string & name, const string & value)
+{
+ xmlChar * xmlStrName = xmlCharStrdup(name.c_str());
+ xmlChar * xmlStrValue = xmlCharStrdup(value.c_str());
+ xmlNewProp(node, xmlStrName, xmlStrValue);
+ xmlFree(xmlStrName);
+ xmlFree(xmlStrValue);
+}
+
+}
--- /dev/null
+// Copyright (C) 2007-2013 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
+//
+
+#ifndef __LAUNCHER_XML_PERSISTENCE_HXX__
+#define __LAUNCHER_XML_PERSISTENCE_HXX__
+
+#include <list>
+
+#include "Launcher_Utils.hxx"
+#include "Launcher_Job.hxx"
+
+namespace Launcher
+{
+ typedef struct _xmlNode xmlNode;
+ typedef xmlNode *xmlNodePtr;
+ typedef unsigned char xmlChar;
+
+ class LAUNCHER_EXPORT XML_Persistence
+ {
+ public:
+ virtual ~XML_Persistence() {}
+
+ /*! Load the jobs from the XML file "jobs_file".
+ * Return a list with the jobs that were successfully loaded.
+ * The ownership of the created jobs is transferred to the caller.
+ */
+ static std::list<Job *> loadJobs(const char* jobs_file);
+
+ //! Save the jobs in the list "jobs_list" to the XML file "jobs_file".
+ static void saveJobs(const char* jobs_file, const std::list<const Job *> & jobs_list);
+
+ private:
+ // This class is static only, not instanciable
+ XML_Persistence() {}
+
+ static void addJobToXmlDocument(xmlNodePtr root_node, const Job & job);
+ static Job * createJobFromXmlNode(xmlNodePtr job_node);
+ static void parseUserNode(Job * new_job, xmlNodePtr user_node);
+ static void parseRunNode(Job * new_job, xmlNodePtr run_node);
+ static resourceParams parseResourceNode(xmlNodePtr res_node);
+
+
+ // Useful wrappers around libxml2 functions
+
+ // Return the value of the attribute, or an empty string if it is not defined
+ static std::string getAttrValue(xmlNodePtr node, const std::string & attrName);
+ static inline std::string xmlStrToString(const xmlChar * xmlStr);
+ static std::string getNodeContent(xmlNodePtr node);
+ template<typename T> static T getNumericalNodeContent(xmlNodePtr node);
+ static xmlNodePtr addNode(xmlNodePtr father, const std::string & name,
+ const std::string & content);
+ template<typename T> static xmlNodePtr addNumericalNode(xmlNodePtr father,
+ const std::string & name,
+ T content);
+ static void addAttr(xmlNodePtr node, const std::string & name, const std::string & value);
+ };
+
+}
+
+#endif
#endif
#include <sys/types.h>
#include <vector>
+#include <list>
-#include <libxml/parser.h>
#include <stdio.h>
#include <sstream>
+using namespace std;
+
const char *SALOME_Launcher::_LauncherNameInNS = "/SalomeLauncher";
//=============================================================================
void
SALOME_Launcher::loadJobs(const char* jobs_file)
{
- // Step 1: check jobs_file read access
- FILE* xml_file = fopen(jobs_file, "r");
- if (xml_file == NULL)
+ list<int> new_jobs_id_list;
+ try
{
- std::string error = "Error opening jobs_file in SALOME_Launcher::loadJobs: " + std::string(jobs_file);
- INFOS(error);
- THROW_SALOME_CORBA_EXCEPTION(error.c_str(), SALOME::INTERNAL_ERROR);
+ // Load the jobs in Launcher
+ new_jobs_id_list = _l.loadJobs(jobs_file);
}
-
- // Step 2: read xml file
- xmlDocPtr doc = xmlReadFile(jobs_file, NULL, 0);
- if (doc == NULL)
+ catch (const LauncherException & ex)
{
- std::string error = "Error in xmlReadFile in SALOME_Launcher::loadJobs, could not parse file: " + std::string(jobs_file);
- INFOS(error);
- fclose(xml_file);
- THROW_SALOME_CORBA_EXCEPTION(error.c_str(), SALOME::INTERNAL_ERROR);
+ INFOS(ex.msg.c_str());
+ THROW_SALOME_CORBA_EXCEPTION(ex.msg.c_str(), SALOME::INTERNAL_ERROR);
}
- // Step 3: Find jobs
- xmlNodePtr root_node = xmlDocGetRootElement(doc);
- xmlNodePtr xmlCurrentNode = root_node->xmlChildrenNode;
- if (!xmlStrcmp(root_node->name, xmlCharStrdup("jobs")))
+ // Notify observers of the new jobs
+ list<int>::const_iterator it_jobs_id;
+ for (it_jobs_id = new_jobs_id_list.begin(); it_jobs_id != new_jobs_id_list.end(); it_jobs_id++)
{
- while(xmlCurrentNode != NULL)
- {
- if (!xmlStrcmp(xmlCurrentNode->name, xmlCharStrdup("job")))
- {
- INFOS("A job is found");
- Launcher::Job * new_job; // It is Launcher_cpp that is going to destroy it
- xmlNodePtr job_node = xmlCurrentNode;
-
- // Begin Job
- if (!xmlHasProp(job_node, xmlCharStrdup("type")) ||
- !xmlHasProp(job_node, xmlCharStrdup("name")))
- {
- INFOS("A bad job is found, type or name not found");
- break;
- }
- xmlChar* type = xmlGetProp(job_node, xmlCharStrdup("type"));
- xmlChar* name = xmlGetProp(job_node, xmlCharStrdup("name"));
- std::string job_type((const char*) type);
- if (job_type == "command")
- new_job = new Launcher::Job_Command();
- else if (job_type == "yacs_file")
- new_job = new Launcher::Job_YACSFile();
- else if (job_type == "python_salome")
- new_job = new Launcher::Job_PythonSALOME();
- new_job->setJobName(std::string((const char *)name));
- xmlFree(type);
- xmlFree(name);
-
- xmlNodePtr user_node = xmlFirstElementChild(job_node);
- xmlNodePtr run_node = xmlNextElementSibling(user_node);
- if (user_node == NULL || run_node == NULL)
- {
- INFOS("A bad job is found, user_part or run_part not found");
- delete new_job;
- break;
- }
- if (xmlStrcmp(user_node->name, xmlCharStrdup("user_part")) ||
- xmlStrcmp(run_node->name, xmlCharStrdup("run_part")))
- {
- INFOS("A bad job is found, cannot get a correct user_part or run_part node");
- delete new_job;
- break;
- }
-
- // Add user part
-
- // Get job_file env_file work_directory local_directory result_directory
- xmlNodePtr job_file_node = xmlFirstElementChild(user_node);
- xmlNodePtr env_file_node = xmlNextElementSibling(job_file_node);
- xmlNodePtr work_directory_node = xmlNextElementSibling(env_file_node);
- xmlNodePtr local_directory_node = xmlNextElementSibling(work_directory_node);
- xmlNodePtr result_directory_node = xmlNextElementSibling(local_directory_node);
-
- // Parameters for COORM
- xmlNodePtr launcher_file_node = xmlNextElementSibling(result_directory_node);
-
- if (job_file_node == NULL ||
- env_file_node == NULL ||
- work_directory_node == NULL ||
- local_directory_node == NULL ||
- result_directory_node == NULL ||
- // For COORM
- launcher_file_node == NULL
- )
- {
- INFOS("A bad job is found, some user_part are not found");
- delete new_job;
- break;
- }
- if (xmlStrcmp(job_file_node->name, xmlCharStrdup("job_file")) ||
- xmlStrcmp(env_file_node->name, xmlCharStrdup("env_file")) ||
- xmlStrcmp(work_directory_node->name, xmlCharStrdup("work_directory")) ||
- xmlStrcmp(local_directory_node->name, xmlCharStrdup("local_directory")) ||
- xmlStrcmp(result_directory_node->name, xmlCharStrdup("result_directory")) ||
- // For COORM
- xmlStrcmp(launcher_file_node->name, xmlCharStrdup("launcher_file"))
- )
- {
- INFOS("A bad job is found, some user part node are not in the rigth or does not have a correct name");
- delete new_job;
- break;
- }
- xmlChar* job_file = xmlNodeGetContent(job_file_node);
- try
- {
- new_job->setJobFile(std::string((const char *)job_file));
- }
- catch(const LauncherException &ex)
- {
- INFOS("Exception receice for job_file, cannot add the job" << ex.msg.c_str());
- delete new_job;
- xmlFree(job_file);
- break;
- }
- xmlChar* env_file = xmlNodeGetContent(env_file_node);
- xmlChar* work_directory = xmlNodeGetContent(work_directory_node);
- xmlChar* local_directory = xmlNodeGetContent(local_directory_node);
- xmlChar* result_directory = xmlNodeGetContent(result_directory_node);
-
- // Parameters for COORM
- xmlChar* launcher_file = xmlNodeGetContent(launcher_file_node);
-
- new_job->setEnvFile(std::string((const char *)env_file));
- new_job->setWorkDirectory(std::string((const char *)work_directory));
- new_job->setLocalDirectory(std::string((const char *)local_directory));
- new_job->setResultDirectory(std::string((const char *)result_directory));
-
- // Parameters for COORM
- new_job->setLauncherFile(std::string((const char *)launcher_file));
-
- xmlFree(job_file);
- xmlFree(env_file);
- xmlFree(work_directory);
- xmlFree(local_directory);
- xmlFree(result_directory);
-
- // Parameters for COORM
- xmlFree(launcher_file);
-
- // Get in and out files
- xmlNodePtr files_node = xmlNextElementSibling(launcher_file_node);
- if (files_node == NULL)
- {
- INFOS("A bad job is found, user_part files is not found");
- delete new_job;
- break;
- }
- if (xmlStrcmp(files_node->name, xmlCharStrdup("files")))
- {
- INFOS("A bad job is found, files node are not in the rigth place or does not have a correct name or does not exist");
- delete new_job;
- break;
- }
- xmlNodePtr file_node = xmlFirstElementChild(files_node);
- while (file_node != NULL)
- {
- if (!xmlStrcmp(file_node->name, xmlCharStrdup("in_file")))
- {
- xmlChar* in_file = xmlNodeGetContent(file_node);
- new_job->add_in_file(std::string((const char *)in_file));
- xmlFree(in_file);
- }
- else if (!xmlStrcmp(file_node->name, xmlCharStrdup("out_file")))
- {
- xmlChar* out_file = xmlNodeGetContent(file_node);
- new_job->add_out_file(std::string((const char *)out_file));
- xmlFree(out_file);
- }
- file_node = xmlNextElementSibling(file_node);
- }
-
- // Get resource part
- xmlNodePtr res_node = xmlNextElementSibling(files_node);
- xmlNodePtr maximum_duration_node = xmlNextElementSibling(res_node);
- xmlNodePtr queue_node = xmlNextElementSibling(maximum_duration_node);
- xmlNodePtr exclusive_node = xmlNextElementSibling(queue_node);
- xmlNodePtr mem_per_cpu_node = xmlNextElementSibling(exclusive_node);
- xmlNodePtr launcher_args_node = xmlNextElementSibling(mem_per_cpu_node);
- if (res_node == NULL ||
- maximum_duration_node == NULL ||
- queue_node == NULL ||
- exclusive_node == NULL ||
- mem_per_cpu_node == NULL ||
- // For COORM
- launcher_args_node == NULL
- )
- {
- INFOS("A bad job is found, some user_part are not found");
- delete new_job;
- break;
- }
- if (xmlStrcmp(res_node->name, xmlCharStrdup("resource_params")) ||
- xmlStrcmp(maximum_duration_node->name, xmlCharStrdup("maximum_duration")) ||
- xmlStrcmp(queue_node->name, xmlCharStrdup("queue")) ||
- xmlStrcmp(exclusive_node->name, xmlCharStrdup("exclusive")) ||
- xmlStrcmp(mem_per_cpu_node->name, xmlCharStrdup("mem_per_cpu")) ||
- // For COORM
- xmlStrcmp(launcher_args_node->name, xmlCharStrdup("launcher_args"))
- )
- {
- INFOS("A bad job is found, some user part node are not in the rigth or does not have a correct name");
- delete new_job;
- break;
- }
- xmlChar* maximum_duration = xmlNodeGetContent(maximum_duration_node);
- try
- {
- new_job->setMaximumDuration(std::string((const char *)maximum_duration));
- }
- catch(const LauncherException &ex)
- {
- INFOS("Exception receice for maximum_duration, cannot add the job" << ex.msg.c_str());
- delete new_job;
- xmlFree(maximum_duration);
- break;
- }
- xmlChar* queue = xmlNodeGetContent(queue_node);
- new_job->setQueue(std::string((const char *)queue));
- xmlFree(maximum_duration);
- xmlFree(queue);
-
- xmlChar* exclusive = xmlNodeGetContent(exclusive_node);
- try
- {
- new_job->setExclusiveStr(std::string((const char *)exclusive));
- }
- catch(const LauncherException &ex)
- {
- INFOS("Exception received for exclusive, cannot add the job. " << ex.msg.c_str());
- delete new_job;
- xmlFree(exclusive);
- break;
- }
- xmlFree(exclusive);
-
- xmlChar* mem_per_cpu_str = xmlNodeGetContent(mem_per_cpu_node);
- std::istringstream mem_per_cpu_stream((const char *)mem_per_cpu_str);
- unsigned long mem_per_cpu = 0;
- if (!(mem_per_cpu_stream >> mem_per_cpu))
- {
- INFOS("A bad job is found, mem_per_cpu parameter is not correct");
- delete new_job;
- break;
- }
- else
- new_job->setMemPerCpu(mem_per_cpu);
-
- // For COORM
- xmlChar* launcher_args = xmlNodeGetContent(launcher_args_node);
- new_job->setLauncherArgs(std::string((const char *)launcher_args));
- xmlFree(launcher_args);
-
- xmlNodePtr specific_node = xmlNextElementSibling(launcher_args_node);
- if (specific_node == NULL)
- {
- INFOS("A bad job is found, specific_parameters part is not found");
- delete new_job;
- break;
- }
- xmlNodePtr parameter_node = xmlFirstElementChild(specific_node);
- while (parameter_node != NULL)
- {
- if (!xmlStrcmp(parameter_node->name, xmlCharStrdup("specific_parameter")))
- {
- xmlNodePtr name_node = xmlFirstElementChild(parameter_node);
- xmlNodePtr value_node = xmlNextElementSibling(name_node);
- if (name_node == NULL ||
- value_node == NULL)
- {
- INFOS("A bad job is found, specific_parameter parts are not found");
- delete new_job;
- break;
- }
- if (xmlStrcmp(name_node->name, xmlCharStrdup("name")) ||
- xmlStrcmp(value_node->name, xmlCharStrdup("value")))
- {
- INFOS("A bad job is found, specific_parameter bad parts are found");
- delete new_job;
- break;
- }
-
- xmlChar* name = xmlNodeGetContent(name_node);
- xmlChar* value = xmlNodeGetContent(value_node);
- try
- {
- new_job->addSpecificParameter(std::string((const char*)name), std::string((const char*)value));
- xmlFree(name);
- xmlFree(value);
- }
- catch(const LauncherException &ex)
- {
- INFOS("Exception receice for a specific parameter, cannot add the job" << ex.msg.c_str());
- delete new_job;
- xmlFree(name);
- xmlFree(value);
- break;
- }
- }
- else
- {
- INFOS("A bad job is found, specific_parameters part is bad, a node that is not a specific parameter is found");
- delete new_job;
- break;
- }
- parameter_node = xmlNextElementSibling(parameter_node);
- }
-
- xmlNodePtr res_name_node = xmlFirstElementChild(res_node);
- xmlNodePtr res_hostname_node = xmlNextElementSibling(res_name_node);
- xmlNodePtr res_os_node = xmlNextElementSibling(res_hostname_node);
- xmlNodePtr res_nb_proc_node = xmlNextElementSibling(res_os_node);
- xmlNodePtr res_nb_node_node = xmlNextElementSibling(res_nb_proc_node);
- xmlNodePtr res_nb_proc_per_node_node = xmlNextElementSibling(res_nb_node_node);
- xmlNodePtr res_cpu_clock_node = xmlNextElementSibling(res_nb_proc_per_node_node);
- xmlNodePtr res_mem_mb_node = xmlNextElementSibling(res_cpu_clock_node);
- if (res_name_node == NULL ||
- res_hostname_node == NULL ||
- res_os_node == NULL ||
- res_nb_proc_node == NULL ||
- res_nb_node_node == NULL ||
- res_nb_proc_per_node_node == NULL ||
- res_cpu_clock_node == NULL ||
- res_mem_mb_node == NULL
- )
- {
- INFOS("A bad job is found, some resource_params user_part are not found");
- delete new_job;
- break;
- }
- if (xmlStrcmp(res_name_node->name, xmlCharStrdup("name")) ||
- xmlStrcmp(res_hostname_node->name, xmlCharStrdup("hostname")) ||
- xmlStrcmp(res_os_node->name, xmlCharStrdup("OS")) ||
- xmlStrcmp(res_nb_proc_node->name, xmlCharStrdup("nb_proc")) ||
- xmlStrcmp(res_nb_node_node->name, xmlCharStrdup("nb_node")) ||
- xmlStrcmp(res_nb_proc_per_node_node->name, xmlCharStrdup("nb_proc_per_node")) ||
- xmlStrcmp(res_cpu_clock_node->name, xmlCharStrdup("cpu_clock")) ||
- xmlStrcmp(res_mem_mb_node->name, xmlCharStrdup("mem_mb"))
- )
- {
- INFOS("A bad job is found, some resource_params user_part node are not in the rigth or does not have a correct name");
- delete new_job;
- break;
- }
- xmlChar* res_name = xmlNodeGetContent(res_name_node);
- xmlChar* res_hostname = xmlNodeGetContent(res_hostname_node);
- xmlChar* res_os = xmlNodeGetContent(res_os_node);
- resourceParams p;
- p.name = std::string((const char*) res_name);
- p.hostname = std::string((const char*) res_hostname);
- p.OS = std::string((const char*) res_os);
- xmlFree(res_name);
- xmlFree(res_hostname);
- xmlFree(res_os);
- xmlChar* res_nb_proc = xmlNodeGetContent(res_nb_proc_node);
- xmlChar* res_nb_node = xmlNodeGetContent(res_nb_node_node);
- xmlChar* res_nb_proc_per_node = xmlNodeGetContent(res_nb_proc_per_node_node);
- xmlChar* res_cpu_clock = xmlNodeGetContent(res_cpu_clock_node);
- xmlChar* res_mem_mb = xmlNodeGetContent(res_mem_mb_node);
- bool import_value = true;
- std::istringstream nb_proc_stream((const char *) res_nb_proc);
- if (!(nb_proc_stream >> p.nb_proc))
- import_value = false;
- std::istringstream nb_node_stream((const char *) res_nb_node);
- if (!(nb_node_stream >> p.nb_node))
- import_value = false;
- std::istringstream nb_proc_per_node_stream((const char *) res_nb_proc_per_node);
- if (!(nb_proc_per_node_stream >> p.nb_proc_per_node))
- import_value = false;
- std::istringstream cpu_clock_stream((const char *) res_cpu_clock);
- if (!(cpu_clock_stream >> p.cpu_clock))
- import_value = false;
- std::istringstream mem_mb_stream((const char *) res_mem_mb);
- if (!(mem_mb_stream >> p.mem_mb))
- import_value = false;
- xmlFree(res_nb_proc);
- xmlFree(res_nb_node);
- xmlFree(res_nb_proc_per_node);
- xmlFree(res_cpu_clock);
- xmlFree(res_mem_mb);
- if (!import_value)
- {
- INFOS("A bad job is found, some resource_params value are not correct");
- delete new_job;
- break;
- }
- try
- {
- new_job->setResourceRequiredParams(p);
- }
- catch(const LauncherException &ex)
- {
- INFOS("A bad job is found, an error when inserting resource_params:" << ex.msg.c_str());
- delete new_job;
- break;
- }
-
- // We finally get run part to figure out what to do
- xmlNodePtr job_state_node = xmlFirstElementChild(run_node);
- xmlNodePtr resource_choosed_name_node = xmlNextElementSibling(job_state_node);
- xmlNodePtr job_reference_node = xmlNextElementSibling(resource_choosed_name_node);
- if (job_state_node == NULL ||
- resource_choosed_name_node == NULL ||
- job_reference_node == NULL
- )
- {
- INFOS("A bad job is found, some run_part are not found");
- delete new_job;
- break;
- }
- if (xmlStrcmp(job_state_node->name, xmlCharStrdup("job_state")) ||
- xmlStrcmp(resource_choosed_name_node->name, xmlCharStrdup("resource_choosed_name")) ||
- xmlStrcmp(job_reference_node->name, xmlCharStrdup("job_reference"))
- )
- {
- INFOS("A bad job is found, some run_part nodes are not in the rigth or does not have a correct name");
- delete new_job;
- break;
- }
- xmlChar* job_state_xml = xmlNodeGetContent(job_state_node);
- xmlChar* resource_choosed_name_xml = xmlNodeGetContent(resource_choosed_name_node);
- xmlChar* job_reference_xml = xmlNodeGetContent(job_reference_node);
- std::string job_state((const char *) job_state_xml);
- std::string resource_choosed_name((const char *) resource_choosed_name_xml);
- std::string job_reference((const char *) job_reference_xml);
- xmlFree(job_state_xml);
- xmlFree(resource_choosed_name_xml);
- xmlFree(job_reference_xml);
-
- if (job_state == "CREATED")
- {
- // In this case, we ignore run_part informations
- try
- {
- _l.createJob(new_job);
- std::ostringstream job_id;
- job_id << new_job->getNumber();
- notifyObservers("NEW_JOB", job_id.str());
- }
- catch(const LauncherException &ex)
- {
- INFOS("Load failed: " << ex.msg.c_str());
- }
- }
- else if (job_state == "QUEUED" ||
- job_state == "RUNNING" ||
- job_state == "IN_PROCESS" ||
- job_state == "PAUSED")
- {
- try
- {
- new_job->setState(job_state);
- _l.addJobDirectlyToMap(new_job, job_reference);
-
- // Step 4: We check that the BatchManager could resume
- // the job
-#ifdef WITH_LIBBATCH
- if (new_job->getBatchManagerJobId().getReference() != job_reference)
- {
- INFOS("BatchManager type cannot resume a job - job state is set to ERROR");
- new_job->setState("ERROR");
- }
-#endif
- std::ostringstream job_id;
- job_id << new_job->getNumber();
- notifyObservers("NEW_JOB", job_id.str());
- }
- catch(const LauncherException &ex)
- {
- INFOS("Cannot load the job! Exception: " << ex.msg.c_str());
- delete new_job;
- }
- }
- else if (job_state == "FINISHED" ||
- job_state == "FAILED" ||
- job_state == "ERROR")
- {
- try
- {
- // Step 2: We add run_part informations
- new_job->setState(job_state);
- _l.addJobDirectlyToMap(new_job, job_reference);
- std::ostringstream job_id;
- job_id << new_job->getNumber();
- notifyObservers("NEW_JOB", job_id.str());
- }
- catch(const LauncherException &ex)
- {
- INFOS("Cannot load the job! Exception: " << ex.msg.c_str());
- delete new_job;
- }
- }
- else
- {
- INFOS("A bad job is found, state unknown " << job_state);
- delete new_job;
- }
-
- }
- xmlCurrentNode = xmlCurrentNode->next;
- }
- }
- else
- {
- xmlFreeDoc(doc);
- fclose(xml_file);
- std::string error = "Error in xml file, could not find root_node named jobs: " + std::string(jobs_file);
- INFOS(error);
- THROW_SALOME_CORBA_EXCEPTION(error.c_str(), SALOME::INTERNAL_ERROR);
+ ostringstream job_id_sstr;
+ job_id_sstr << *it_jobs_id;
+ notifyObservers("NEW_JOB", job_id_sstr.str());
}
-
- // Clean
- xmlFreeDoc(doc);
- fclose(xml_file);
notifyObservers("LOAD_JOBS", jobs_file);
}
void
SALOME_Launcher::saveJobs(const char* jobs_file)
{
-
- // Step 1: check jobs_file write access
- FILE* xml_file = fopen(jobs_file, "w");
- if (xml_file == NULL)
- {
- std::string error = "Error opening jobs_file in SALOME_Launcher::saveJobs: " + std::string(jobs_file);
- INFOS(error);
- THROW_SALOME_CORBA_EXCEPTION(error.c_str(), SALOME::INTERNAL_ERROR);
- }
-
- // Step 2: First lines
- xmlKeepBlanksDefault(0);
- xmlDocPtr doc = xmlNewDoc(xmlCharStrdup("1.0"));
- xmlNodePtr root_node = xmlNewNode(NULL, xmlCharStrdup("jobs"));
- xmlDocSetRootElement(doc, root_node);
- xmlNodePtr doc_comment = xmlNewDocComment(doc, xmlCharStrdup("SALOME Launcher save jobs file"));
- xmlAddPrevSibling(root_node, doc_comment);
-
- // Step 3: For each job write it on the xml document
- // We could put a mutex but are not foing to do that currently
- std::map<int, Launcher::Job *> jobs_list = _l.getJobs();
- std::map<int, Launcher::Job *>::const_iterator it_job;
- for(it_job = jobs_list.begin(); it_job != jobs_list.end(); it_job++)
- {
- it_job->second->addToXmlDocument(root_node);
- }
-
- // Final step: write file
- int isOk = xmlSaveFormatFile(jobs_file, doc, 1);
- if (!isOk)
- {
- std::string error = "Error during xml file saving in SALOME_Launcher::saveJobs: " + std::string(jobs_file);
- INFOS(error);
- xmlFreeDoc(doc);
- fclose(xml_file);
- THROW_SALOME_CORBA_EXCEPTION(error.c_str(), SALOME::INTERNAL_ERROR);
- }
-
- // Clean
- xmlFreeDoc(doc);
- fclose(xml_file);
- MESSAGE("SALOME_Launcher::saveJobs : WRITING DONE!");
+ _l.saveJobs(jobs_file);
notifyObservers("SAVE_JOBS", jobs_file);
}
#
INCLUDE_DIRECTORIES(
- ${LIBXML2_INCLUDE_DIR}
${OMNIORB_INCLUDE_DIR}
${PTHREAD_INCLUDE_DIR}
${PYTHON_INCLUDE_DIRS}
SalomeIDLKernel
)
-ADD_DEFINITIONS(${LIBXML2_DEFINITIONS} ${OMNIORB_DEFINITIONS})
+ADD_DEFINITIONS(${OMNIORB_DEFINITIONS})
ADD_LIBRARY(SalomeLifeCycleCORBA SALOME_LifeCycleCORBA.cxx SALOME_FileTransferCORBA.cxx)
TARGET_LINK_LIBRARIES(SalomeLifeCycleCORBA ${COMMON_LIBS})
std::string portNumber (::getenv ("NSPORT") );
if ( !portNumber.empty() )
{
-#ifdef WNT
+#ifdef WIN32
#else
std::string cmd ;
cmd = std::string( "ps -eo pid,command | grep -v grep | grep -E \"omniNames.*")
//
#include "utilities.h"
#include <iostream>
-#ifndef WNT
+#ifndef WIN32
#include <unistd.h>
#endif
#include <SALOMEconfig.h>
# define LOGGER_EXPORT
#endif
-#ifdef WNT
+#ifdef WIN32
#pragma warning(disable:4275) // Disable warning interface non dll
#endif
# Executable scripts to be installed
SALOME_INSTALL_SCRIPTS(TestModuleCatalog.py ${SALOME_INSTALL_SCRIPT_PYTHON})
-FILE(GLOB COMMON_HEADERS_HXX "${CMAKE_CURRENT_SOURCE_DIR}/*.hxx")
+SET(COMMON_HEADERS_HXX
+ SALOME_ModuleCatalog.hxx
+ SALOME_ModuleCatalog_Acomponent_impl.hxx
+ SALOME_ModuleCatalog_impl.hxx
+ )
+
INSTALL(FILES ${COMMON_HEADERS_HXX} DESTINATION ${SALOME_INSTALL_HEADERS})
#include "SALOME_ModuleCatalog.hxx"
-#include "SALOME_ModuleCatalog_Parser.hxx"
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SALOME_ModuleCatalog)
-#ifdef WNT
+#ifdef WIN32
#pragma warning(disable:4275) // Disable warning interface non dll
#pragma warning(disable:4290) // Warning Exception ...
#endif
//! method to get a list of the interfaces name of a component
/*!
- \return a list of the interfaces of a component
+ \return a list of the interfaces of a component
*/
virtual SALOME_ModuleCatalog::ListOfInterfaces* GetInterfaceList() ;
\param interface name const car* arguments
\return the wanted interface
*/
- virtual SALOME_ModuleCatalog::DefinitionInterface*
+ virtual SALOME_ModuleCatalog::DefinitionInterface*
GetInterface(const char* interfacename)
throw(SALOME_ModuleCatalog::NotFound);
//! method to get a list of the services name of an interface of a component
/*!If the specified interface doesn't exist, the Notfound exception is thrown
- \param interfacename const char* arguments
+ \param interfacename const char* arguments
\return a list of the services of the wanted interface
*/
- virtual SALOME_ModuleCatalog::ListOfServices*
+ virtual SALOME_ModuleCatalog::ListOfServices*
GetServiceList(const char* interfacename)
throw(SALOME_ModuleCatalog::NotFound);
-
+
//! method to get one service of an interface of a component
- /*! If the wanted service or the specified interface don't exist,
+ /*! If the wanted service or the specified interface don't exist,
* the Notfound exception is thrown
- \param interfacename const char* arguments
+ \param interfacename const char* arguments
\param servicename const char* arguments
\return the wanted service
*/
- virtual SALOME_ModuleCatalog::Service*
- GetService(const char* interfacename,
- const char* servicename)
+ virtual SALOME_ModuleCatalog::Service*
+ GetService(const char* interfacename,
+ const char* servicename)
throw(SALOME_ModuleCatalog::NotFound);
//! method to get the default service of an interface of a component
/*! If the specified interface doesn't exist, the Notfound exception is thrown
- \param interfacename const char* arguments
+ \param interfacename const char* arguments
\return the default service of the interface
*/
- virtual SALOME_ModuleCatalog::Service*
- GetDefaultService(const char* interfacename)
+ virtual SALOME_ModuleCatalog::Service*
+ GetDefaultService(const char* interfacename)
throw(SALOME_ModuleCatalog::NotFound);
//! method to get the PathPrefix of a computer
/*! If the wanted computer doesn't exist, the Notfound exception is thrown
- \param machinename const char* arguments
+ \param machinename const char* arguments
\return the prefix path
*/
- virtual char* GetPathPrefix(const char* machinename)
+ virtual char* GetPathPrefix(const char* machinename)
throw(SALOME_ModuleCatalog::NotFound);
//! method to obtain the constraint affected to a component
#include <libxml/parser.h>
-#ifdef WNT
+#ifdef WIN32
#pragma warning(disable:4251) // Warning DLL Interface ...
#endif
virtual ~SALOME_ModuleCatalog_Handler();
void ProcessXmlDocument(xmlDocPtr theDoc);
-
+
private:
const char *test_path_prefix_name ;
const char *test_component_implname;
const char *test_component_version;
const char *test_component_comment;
-
+
const char *test_interface_name;
-
+
const char *test_service_name;
const char *test_defaultservice;
const char *test_typeofnode;
-
+
const char *test_inParameter_type;
const char *test_inParameter_name;
const char *test_inParameter;
const char *test_inParameter_list;
-
+
const char *test_outParameter_type;
const char *test_outParameter_name;
const char *test_outParameter;
const char *test_outParameter_list;
-
+
const char *test_inDataStreamParameter_type;
const char *test_inDataStreamParameter_name;
const char *test_inDataStreamParameter_dependency;
const char *test_inDataStreamParameter;
const char *test_inDataStreamParameter_list;
-
+
const char *test_outDataStreamParameter_type;
const char *test_outDataStreamParameter_name;
const char *test_outDataStreamParameter_dependency;
const char *test_outDataStreamParameter;
const char *test_outDataStreamParameter_list;
-
+
const char *test_service;
const char *test_service_list;
const char *test_interface_list;
const char *test_constraint;
-
+
const char *test_component_list;
const char *test_component;
-
+
ParserPathPrefix _pathPrefix;
-
+
ParserComponent _aModule;
-
+
ParserPathPrefixes& _pathList;
ParserComponents& _moduleList;
-
+
ParserInterfaces _interfaceList;
ParserInterface _aInterface;
-
+
ParserServices _serviceList;
ParserService _aService;
ParserParameters _inParamList;
ParserParameter _inParam;
-
+
ParserParameters _outParamList;
ParserParameter _outParam;
-
+
ParserDataStreamParameters _inDataStreamParamList;
ParserDataStreamParameter _inDataStreamParam;
-
+
ParserDataStreamParameters _outDataStreamParamList;
ParserDataStreamParameter _outDataStreamParam;
//
#include "SALOME_ModuleCatalog_impl.hxx"
#include "SALOME_ModuleCatalog_Acomponent_impl.hxx"
+#include "SALOME_ModuleCatalog_Handler.hxx"
#include <libxml/parser.h>
#include <fstream>
#include <map>
return aList;
}
+class SALOME_ModuleCatalogImpl::Private
+{
+ friend class SALOME_ModuleCatalogImpl;
+public:
+ //! method to parse one module catalog
+ /*!
+ \param file const char* arguments
+ \param modulelist ParserComponents arguments
+ \param pathlist ParserPathPrefixes arguments
+ \param typeMap ParserTypes arguments
+ */
+ virtual void _parse_xml_file(const char* file,
+ ParserComponents & modulelist,
+ ParserPathPrefixes & pathlist,
+ ParserTypes& typeMap,
+ TypeList& typeList);
+
+ //! method to find component in the parser list
+ /*!
+ \param name string argument
+ \return pointer on a component, NULL if not found
+ */
+ ParserComponent *findComponent(const std::string & name);
+
+ //! method to create a CORBA component description from parser
+ /*!
+ \param C_corba Component argument
+ \param C_parser const ParserComponent argument
+ */
+ void duplicate(SALOME_ModuleCatalog::ComponentDef & C_corba,
+ const ParserComponent & C_parser);
+
+ //! method to create a CORBA interface description from parser
+ /*!
+ \param I_corba DefinitionInterface argument
+ \param I_parser const ParserInterface argument
+ */
+ void duplicate(SALOME_ModuleCatalog::DefinitionInterface & I_corba,
+ const ParserInterface & I_parser);
+
+ //! method to create a CORBA service description from parser
+ /*!
+ \param S_corba Service argument
+ \param S_parser const ParserService argument
+ */
+ void duplicate(SALOME_ModuleCatalog::Service & S_corba,
+ const ParserService & service);
+
+ //! method to create a CORBA parameter description from parser
+ /*!
+ \param P_corba ServicesParameter argument
+ \param P_parser const ParserParameter argument
+ */
+ void duplicate(SALOME_ModuleCatalog::ServicesParameter & P_corba,
+ const ParserParameter & P_parser);
+
+ //! method to create a CORBA datastream parameter description from parser
+ /*!
+ \param P_corba ServicesDataStreamParameter argument
+ \param P_parser const ParserDataStreamParameter argument
+ */
+ void duplicate(SALOME_ModuleCatalog::ServicesDataStreamParameter & P_corba,
+ const ParserDataStreamParameter & P_parser);
+
+ //! method to create the path prefix structures from the catalog parsing
+ /*!
+ \param pathes ParserPathPrefixes arguments
+ \return the pathes
+ */
+ void duplicate(ParserPathPrefixes & p_out, const ParserPathPrefixes & P_in);
+
+ //! method to verify path prefix content
+ /*!
+ \param pathlist ListOfParserPathPrefix arguments
+ \return true if verfication is OK
+ */
+ virtual bool _verify_path_prefix(ParserPathPrefixes & pathlist);
+
+ // Theses variables will contain the path to the general and personal catalogs
+ char* _general_path;
+ char* _personal_path;
+
+ // These variables will contain the informations on the general common catalog
+ ParserComponents _general_module_list ;
+ ParserPathPrefixes _general_path_list ;
+ ParserTypes _typeMap;
+ TypeList _typeList;
+
+ // These variables will contain the informations on the personal catalog
+ ParserComponents _personal_module_list ;
+ ParserPathPrefixes _personal_path_list ;
+
+ std::map <std::string, SALOME_ModuleCatalog::DataStreamDependency>
+ DataStreamDepConvert;
+
+ std::map <ParserComponentType, SALOME_ModuleCatalog::ComponentType>
+ ComponentTypeConvert;
+};
+
//----------------------------------------------------------------------
// Function : SALOME_ModuleCatalogImpl
-// Purpose : Constructor
+// Purpose : Constructor
//----------------------------------------------------------------------
SALOME_ModuleCatalogImpl::SALOME_ModuleCatalogImpl(int argc, char** argv, CORBA::ORB_ptr orb) : _orb(orb)
{
+ myPrivate = new Private;
if(MYDEBUG) MESSAGE("Catalog creation");
/* Init libxml */
xmlInitParser();
// Conversion rules for component types
- ComponentTypeConvert[GEOM]
+ myPrivate->ComponentTypeConvert[GEOM]
= SALOME_ModuleCatalog::GEOM;
- ComponentTypeConvert[MESH]
+ myPrivate->ComponentTypeConvert[MESH]
= SALOME_ModuleCatalog::MESH;
- ComponentTypeConvert[Med]
+ myPrivate->ComponentTypeConvert[Med]
= SALOME_ModuleCatalog::Med;
- ComponentTypeConvert[SOLVER]
+ myPrivate->ComponentTypeConvert[SOLVER]
= SALOME_ModuleCatalog::SOLVER;
- ComponentTypeConvert[DATA]
+ myPrivate->ComponentTypeConvert[DATA]
= SALOME_ModuleCatalog::DATA;
- ComponentTypeConvert[VISU]
+ myPrivate->ComponentTypeConvert[VISU]
= SALOME_ModuleCatalog::VISU;
- ComponentTypeConvert[SUPERV]
+ myPrivate->ComponentTypeConvert[SUPERV]
= SALOME_ModuleCatalog::SUPERV;
- ComponentTypeConvert[OTHER]
+ myPrivate->ComponentTypeConvert[OTHER]
= SALOME_ModuleCatalog::OTHER;
// Conversion rules for datastream parameters dependency
- DataStreamDepConvert["UNDEFINED"]
+ myPrivate->DataStreamDepConvert["UNDEFINED"]
= SALOME_ModuleCatalog::DATASTREAM_UNDEFINED;
- DataStreamDepConvert["T"]
+ myPrivate->DataStreamDepConvert["T"]
= SALOME_ModuleCatalog::DATASTREAM_TEMPORAL;
- DataStreamDepConvert["I"]
+ myPrivate->DataStreamDepConvert["I"]
= SALOME_ModuleCatalog::DATASTREAM_ITERATIVE;
// Empty used variables
- _general_module_list.resize(0);
- _general_path_list.resize(0);
+ myPrivate->_general_module_list.resize(0);
+ myPrivate->_general_path_list.resize(0);
- _personal_module_list.resize(0);
- _personal_path_list.resize(0);
+ myPrivate->_personal_module_list.resize(0);
+ myPrivate->_personal_path_list.resize(0);
// Parse the arguments given at server run
- if (!_parseArguments(argc, argv,&_general_path,&_personal_path))
+ if (!_parseArguments(argc, argv,&myPrivate->_general_path,&myPrivate->_personal_path))
if(MYDEBUG) MESSAGE( "Error while argument parsing" );
// Test existency of files
- if (_general_path == NULL)
+ if (myPrivate->_general_path == NULL)
{
if(MYDEBUG) MESSAGE( "Error the general catalog should be indicated" );
}
std::list<std::string> dirList;
#ifdef WIN32
- dirList = splitStringToList(_general_path, SEPARATOR);
+ dirList = splitStringToList(myPrivate->_general_path, SEPARATOR);
#else
//check for new format
- bool isNew = (std::string( _general_path ).find(SEPARATOR) != std::string::npos);
+ bool isNew = (std::string( myPrivate->_general_path ).find(SEPARATOR) != std::string::npos);
if ( isNew ) {
//using new format
- dirList = splitStringToList(_general_path, SEPARATOR);
+ dirList = splitStringToList(myPrivate->_general_path, SEPARATOR);
} else {
//support old format
- dirList = splitStringToList(_general_path, OLD_SEPARATOR);
+ dirList = splitStringToList(myPrivate->_general_path, OLD_SEPARATOR);
}
#endif
while (aPath.find('\"') != std::string::npos)
aPath.erase(aPath.find('\"'), 1);
- _parse_xml_file(aPath.c_str(),
- _general_module_list,
- _general_path_list,
- _typeMap,
- _typeList);
+ myPrivate->_parse_xml_file(aPath.c_str(),
+ myPrivate->_general_module_list,
+ myPrivate->_general_path_list,
+ myPrivate->_typeMap,
+ myPrivate->_typeList);
}
// Verification of _general_path_list content
- if (!_verify_path_prefix(_general_path_list)) {
+ if (!myPrivate->_verify_path_prefix(myPrivate->_general_path_list)) {
if(MYDEBUG) MESSAGE( "Error while parsing the general path list, "
- "differents paths are associated to the same computer,"
+ "differents paths are associated to the same computer,"
"the first one will be choosen");
} else {
if(MYDEBUG) MESSAGE("General path list OK");
}
- if (_personal_path != NULL) {
- // Initialize the _personal_module_list and
+ if (myPrivate->_personal_path != NULL) {
+ // Initialize the _personal_module_list and
// _personal_path_list members with the personal catalog files
- _parse_xml_file(_personal_path,
- _personal_module_list,
- _personal_path_list,
- _typeMap,
- _typeList);
-
+ myPrivate->_parse_xml_file(myPrivate->_personal_path,
+ myPrivate->_personal_module_list,
+ myPrivate->_personal_path_list,
+ myPrivate->_typeMap,
+ myPrivate->_typeList);
+
// Verification of _general_path_list content
- if(!_verify_path_prefix(_personal_path_list)){
+ if(!myPrivate->_verify_path_prefix(myPrivate->_personal_path_list)){
if(MYDEBUG) MESSAGE("Error while parsing the personal path list, "
"differents paths are associated to the same computer, "
"the first one will be choosen" );
}else {
if(MYDEBUG) MESSAGE("Personal path list OK");
}
- }else
+ }else
if(MYDEBUG) MESSAGE("No personal catalog indicated or error while "
"opening the personal catalog");
}
//----------------------------------------------------------------------
// Function : ~SALOME_ModuleCatalogImpl
-// Purpose : Destructor
+// Purpose : Destructor
//----------------------------------------------------------------------
SALOME_ModuleCatalogImpl::~SALOME_ModuleCatalogImpl()
{
if(MYDEBUG) MESSAGE("Catalog Destruction");
+ delete myPrivate;
}
SALOME_ModuleCatalog::ListOfTypeDefinition* SALOME_ModuleCatalogImpl::GetTypes()
{
SALOME_ModuleCatalog::ListOfTypeDefinition_var type_list = new SALOME_ModuleCatalog::ListOfTypeDefinition();
- type_list->length(_typeList.size());
+ type_list->length(myPrivate->_typeList.size());
- for (unsigned int ind = 0 ; ind < _typeList.size() ; ind++)
+ for (unsigned int ind = 0 ; ind < myPrivate->_typeList.size() ; ind++)
{
//no real need to call string_dup, omniorb calls it on operator= (const char *) but it is safer
- type_list[ind].name=CORBA::string_dup(_typeList[ind].name.c_str());
+ type_list[ind].name=CORBA::string_dup(myPrivate->_typeList[ind].name.c_str());
type_list[ind].kind=SALOME_ModuleCatalog::NONE;
- if(_typeList[ind].kind=="double")
+ if(myPrivate->_typeList[ind].kind=="double")
type_list[ind].kind=SALOME_ModuleCatalog::Dble;
- else if(_typeList[ind].kind=="int")
+ else if(myPrivate->_typeList[ind].kind=="int")
type_list[ind].kind=SALOME_ModuleCatalog::Int;
- else if(_typeList[ind].kind=="bool")
+ else if(myPrivate->_typeList[ind].kind=="bool")
type_list[ind].kind=SALOME_ModuleCatalog::Bool;
- else if(_typeList[ind].kind=="string")
+ else if(myPrivate->_typeList[ind].kind=="string")
type_list[ind].kind=SALOME_ModuleCatalog::Str;
- else if(_typeList[ind].kind=="objref")
+ else if(myPrivate->_typeList[ind].kind=="objref")
{
type_list[ind].kind=SALOME_ModuleCatalog::Objref;
- type_list[ind].id=CORBA::string_dup(_typeList[ind].id.c_str());
+ type_list[ind].id=CORBA::string_dup(myPrivate->_typeList[ind].id.c_str());
//bases
- type_list[ind].bases.length(_typeList[ind].bases.size());
+ type_list[ind].bases.length(myPrivate->_typeList[ind].bases.size());
std::vector<std::string>::const_iterator miter;
- miter=_typeList[ind].bases.begin();
+ miter=myPrivate->_typeList[ind].bases.begin();
int n_memb=0;
- while(miter != _typeList[ind].bases.end())
+ while(miter != myPrivate->_typeList[ind].bases.end())
{
type_list[ind].bases[n_memb]=CORBA::string_dup(miter->c_str());
miter++;
n_memb++;
}
}
- else if(_typeList[ind].kind=="sequence")
+ else if(myPrivate->_typeList[ind].kind=="sequence")
{
type_list[ind].kind=SALOME_ModuleCatalog::Seq;
- type_list[ind].content=CORBA::string_dup(_typeList[ind].content.c_str());
+ type_list[ind].content=CORBA::string_dup(myPrivate->_typeList[ind].content.c_str());
}
- else if(_typeList[ind].kind=="array")
+ else if(myPrivate->_typeList[ind].kind=="array")
{
type_list[ind].kind=SALOME_ModuleCatalog::Array;
- type_list[ind].content=CORBA::string_dup(_typeList[ind].content.c_str());
+ type_list[ind].content=CORBA::string_dup(myPrivate->_typeList[ind].content.c_str());
}
- else if(_typeList[ind].kind=="struct")
+ else if(myPrivate->_typeList[ind].kind=="struct")
{
type_list[ind].kind=SALOME_ModuleCatalog::Struc;
//members
- type_list[ind].members.length(_typeList[ind].members.size());
+ type_list[ind].members.length(myPrivate->_typeList[ind].members.size());
std::vector< std::pair<std::string,std::string> >::const_iterator miter;
- miter=_typeList[ind].members.begin();
+ miter=myPrivate->_typeList[ind].members.begin();
int n_memb=0;
- while(miter != _typeList[ind].members.end())
+ while(miter != myPrivate->_typeList[ind].members.end())
{
type_list[ind].members[n_memb].name=CORBA::string_dup(miter->first.c_str());
type_list[ind].members[n_memb].type=CORBA::string_dup(miter->second.c_str());
// Function : GetComputerList
// Purpose : get a computer list
//----------------------------------------------------------------------
-SALOME_ModuleCatalog::ListOfComputers*
+SALOME_ModuleCatalog::ListOfComputers*
SALOME_ModuleCatalogImpl::GetComputerList()
{
- SALOME_ModuleCatalog::ListOfComputers_var _list_computers =
+ SALOME_ModuleCatalog::ListOfComputers_var _list_computers =
new SALOME_ModuleCatalog::ListOfComputers;
return _list_computers._retn();
}
// Function : GetPathPrefix
// Purpose : get the PathPrefix of a computer
//----------------------------------------------------------------------
-char *
+char *
SALOME_ModuleCatalogImpl::GetPathPrefix(const char* machinename) {
if(MYDEBUG) MESSAGE("Begin of GetPathPrefix");
// Variables initialisation
// Parse all the path prefixes
// looking for the wanted computer
- for (unsigned int ind = 0 ; ind < _personal_path_list.size() ; ind++)
+ for (unsigned int ind = 0 ; ind < myPrivate->_personal_path_list.size() ; ind++)
{
- for (unsigned int ind1 = 0 ; ind1 < _personal_path_list[ind].listOfComputer.size() ; ind1++)
+ for (unsigned int ind1 = 0 ; ind1 < myPrivate->_personal_path_list[ind].listOfComputer.size() ; ind1++)
{
- if (strcmp(machinename, _personal_path_list[ind].listOfComputer[ind1].c_str()) == 0)
+ if (strcmp(machinename, myPrivate->_personal_path_list[ind].listOfComputer[ind1].c_str()) == 0)
{
_find = true ;
// Wanted computer
// affect the path to be returned
- const char* _temp = _personal_path_list[ind].path.c_str() ;
+ const char* _temp = myPrivate->_personal_path_list[ind].path.c_str() ;
_path = new char[strlen(_temp)+1];
strcpy(_path,_temp);
}
if (!_find)
{
- for (unsigned int ind = 0 ; ind < _general_path_list.size() ; ind++)
+ for (unsigned int ind = 0 ; ind < myPrivate->_general_path_list.size() ; ind++)
{
- for (unsigned int ind1 = 0 ; ind1 < _general_path_list[ind].listOfComputer.size() ; ind1++)
+ for (unsigned int ind1 = 0 ; ind1 < myPrivate->_general_path_list[ind].listOfComputer.size() ; ind1++)
{
- if (strcmp(machinename, _general_path_list[ind].listOfComputer[ind1].c_str()) == 0)
+ if (strcmp(machinename, myPrivate->_general_path_list[ind].listOfComputer[ind1].c_str()) == 0)
{
_find = true ;
// Wanted computer
// affect the path to be returned
- const char* _temp = _general_path_list[ind].path.c_str() ;
+ const char* _temp = myPrivate->_general_path_list[ind].path.c_str() ;
_path = new char[strlen(_temp)+1];
strcpy(_path,_temp);
}
//----------------------------------------------------------------------
// Function : GetComponentList
// Purpose : get a component list
-// If a component is defined in the personal catalog and
+// If a component is defined in the personal catalog and
// in the general catalog (same name), the component defined
// in the personal catalog is used
//----------------------------------------------------------------------
-SALOME_ModuleCatalog::ListOfComponents*
+SALOME_ModuleCatalog::ListOfComponents*
SALOME_ModuleCatalogImpl::GetComponentList()
{
if(MYDEBUG) MESSAGE("Begin of GetComponentList");
- SALOME_ModuleCatalog::ListOfComponents_var _list_components =
+ SALOME_ModuleCatalog::ListOfComponents_var _list_components =
new SALOME_ModuleCatalog::ListOfComponents;
- _list_components->length(_personal_module_list.size());
+ _list_components->length(myPrivate->_personal_module_list.size());
// All the components defined in the personal catalog are taken
- for(unsigned int ind=0; ind < _personal_module_list.size();ind++){
- _list_components[ind]=(_personal_module_list[ind].name).c_str();
+ for(unsigned int ind=0; ind < myPrivate->_personal_module_list.size();ind++){
+ _list_components[ind]=(myPrivate->_personal_module_list[ind].name).c_str();
if(MYDEBUG) SCRUTE(_list_components[ind]) ;
}
- int indice = _personal_module_list.size() ;
+ int indice = myPrivate->_personal_module_list.size() ;
bool _find = false;
-
+
// The components in the general catalog are taken only if they're
// not defined in the personal catalog
- for(unsigned int ind=0; ind < _general_module_list.size();ind++){
+ for(unsigned int ind=0; ind < myPrivate->_general_module_list.size();ind++){
_find = false;
- for(unsigned int ind1=0; ind1 < _personal_module_list.size();ind1++){
- // searching if the component is already defined in
+ for(unsigned int ind1=0; ind1 < myPrivate->_personal_module_list.size();ind1++){
+ // searching if the component is already defined in
// the personal catalog
- if ((_general_module_list[ind].name.compare(_personal_module_list[ind1].name)) == 0)
+ if ((myPrivate->_general_module_list[ind].name.compare(myPrivate->_personal_module_list[ind1].name)) == 0)
_find = true;
}
if(!_find){
- if(MYDEBUG) MESSAGE("A new component " << _general_module_list[ind].name
+ if(MYDEBUG) MESSAGE("A new component " << myPrivate->_general_module_list[ind].name
<< " has to be to added in the list");
_list_components->length(indice+1);
// The component is not already defined => has to be taken
- _list_components[indice]=(_general_module_list[ind].name).c_str();
+ _list_components[indice]=(myPrivate->_general_module_list[ind].name).c_str();
if(MYDEBUG) SCRUTE(_list_components[indice]) ;
-
+
indice++;
}else{
- if(MYDEBUG) MESSAGE("The component " <<_general_module_list[ind].name
+ if(MYDEBUG) MESSAGE("The component " <<myPrivate->_general_module_list[ind].name
<< " was already defined in the personal catalog") ;
}
}
-
+
if(MYDEBUG) MESSAGE ( "End of GetComponentList" );
return _list_components._retn();
}
//----------------------------------------------------------------------
// Function : GetComponentIconeList
// Purpose : get a component list of component name and component icone
-// If a component is defined in the personal catalog and
+// If a component is defined in the personal catalog and
// in the general catalog (same name), the component defined
// in the personal catalog is used
//----------------------------------------------------------------------
-SALOME_ModuleCatalog::ListOfIAPP_Affich*
+SALOME_ModuleCatalog::ListOfIAPP_Affich*
SALOME_ModuleCatalogImpl::GetComponentIconeList()
{
if(MYDEBUG) MESSAGE("Begin of GetComponentIconeList");
- SALOME_ModuleCatalog::ListOfIAPP_Affich_var _list_components_icone =
+ SALOME_ModuleCatalog::ListOfIAPP_Affich_var _list_components_icone =
new SALOME_ModuleCatalog::ListOfIAPP_Affich;
- _list_components_icone->length(_personal_module_list.size());
+ _list_components_icone->length(myPrivate->_personal_module_list.size());
// All the components defined in the personal catalog are taken
- for(unsigned int ind=0; ind < _personal_module_list.size();ind++){
- _list_components_icone[ind].modulename=(_personal_module_list[ind].name).c_str();
- _list_components_icone[ind].moduleusername=(_personal_module_list[ind].username).c_str();
- _list_components_icone[ind].moduleicone=(_personal_module_list[ind].icon).c_str();
- _list_components_icone[ind].moduleversion=(_personal_module_list[ind].version).c_str();
- _list_components_icone[ind].modulecomment=(_personal_module_list[ind].comment).c_str();
- //if(MYDEBUG) SCRUTE(_list_components_icone[ind].modulename);
+ for(unsigned int ind=0; ind < myPrivate->_personal_module_list.size();ind++){
+ _list_components_icone[ind].modulename=(myPrivate->_personal_module_list[ind].name).c_str();
+ _list_components_icone[ind].moduleusername=(myPrivate->_personal_module_list[ind].username).c_str();
+ _list_components_icone[ind].moduleicone=(myPrivate->_personal_module_list[ind].icon).c_str();
+ _list_components_icone[ind].moduleversion=(myPrivate->_personal_module_list[ind].version).c_str();
+ _list_components_icone[ind].modulecomment=(myPrivate->_personal_module_list[ind].comment).c_str();
+ //if(MYDEBUG) SCRUTE(_list_components_icone[ind].modulename);
//if(MYDEBUG) SCRUTE(_list_components_icone[ind].moduleicone);
}
-
- int indice = _personal_module_list.size() ;
+
+ int indice = myPrivate->_personal_module_list.size() ;
bool _find = false;
-
+
// The components in the general catalog are taken only if they're
// not defined in the personal catalog
- for(unsigned int ind=0; ind < _general_module_list.size();ind++){
+ for(unsigned int ind=0; ind < myPrivate->_general_module_list.size();ind++){
_find = false;
- for(unsigned int ind1=0; ind1 < _personal_module_list.size();ind1++){
- // searching if the component is aleready defined in
+ for(unsigned int ind1=0; ind1 < myPrivate->_personal_module_list.size();ind1++){
+ // searching if the component is aleready defined in
// the personal catalog
- if((_general_module_list[ind].name.compare(_personal_module_list[ind1].name)) == 0)
+ if((myPrivate->_general_module_list[ind].name.compare(myPrivate->_personal_module_list[ind1].name)) == 0)
_find = true;
}
if(!_find){
// if(MYDEBUG) MESSAGE("A new component " << _general_module_list[ind].name << " has to be to added in the list");
_list_components_icone->length(indice+1);
// The component is not already defined => has to be taken
- _list_components_icone[indice].modulename=_general_module_list[ind].name.c_str();
- _list_components_icone[indice].moduleusername=_general_module_list[ind].username.c_str();
- _list_components_icone[indice].moduleicone=_general_module_list[ind].icon.c_str();
- _list_components_icone[indice].moduleversion=_general_module_list[ind].version.c_str();
- _list_components_icone[indice].modulecomment=_general_module_list[ind].comment.c_str();
+ _list_components_icone[indice].modulename=myPrivate->_general_module_list[ind].name.c_str();
+ _list_components_icone[indice].moduleusername=myPrivate->_general_module_list[ind].username.c_str();
+ _list_components_icone[indice].moduleicone=myPrivate->_general_module_list[ind].icon.c_str();
+ _list_components_icone[indice].moduleversion=myPrivate->_general_module_list[ind].version.c_str();
+ _list_components_icone[indice].modulecomment=myPrivate->_general_module_list[ind].comment.c_str();
//if(MYDEBUG) SCRUTE(_list_components_icone[indice].modulename) ;
//if(MYDEBUG) SCRUTE(_list_components_icone[indice].moduleicone);
-
+
indice++;
}
- // else
- //if(MYDEBUG) MESSAGE("The component " <<_general_module_list[ind].name << " was already defined in the personal catalog");
+ // else
+ //if(MYDEBUG) MESSAGE("The component " <<_general_module_list[ind].name << " was already defined in the personal catalog");
}
-
+
return _list_components_icone._retn() ;
}
//----------------------------------------------------------------------
// Function : GetTypedComponentList
// Purpose : get a component list of a wanted type
-// If a component is defined in the personal catalog and
+// If a component is defined in the personal catalog and
// in the general catalog (same name), the component defined
// in the personal catalog is used
//----------------------------------------------------------------------
-SALOME_ModuleCatalog::ListOfComponents*
+SALOME_ModuleCatalog::ListOfComponents*
SALOME_ModuleCatalogImpl::GetTypedComponentList(SALOME_ModuleCatalog::ComponentType component_type)
{
if(MYDEBUG) MESSAGE("Begin of GetTypedComponentList");
- SALOME_ModuleCatalog::ListOfComponents_var _list_typed_component =
+ SALOME_ModuleCatalog::ListOfComponents_var _list_typed_component =
new SALOME_ModuleCatalog::ListOfComponents;
int _j = 0;
break;
case SALOME_ModuleCatalog::MESH:
_temp_component_type = MESH;
- break;
+ break;
case SALOME_ModuleCatalog::Med:
_temp_component_type = Med;
- break;
- case SALOME_ModuleCatalog::SOLVER:
+ break;
+ case SALOME_ModuleCatalog::SOLVER:
_temp_component_type = SOLVER;
break;
case SALOME_ModuleCatalog::DATA:
break;
case SALOME_ModuleCatalog::VISU:
_temp_component_type = VISU;
- break;
+ break;
case SALOME_ModuleCatalog::SUPERV:
_temp_component_type = SUPERV;
break;
}
// All the components in the personal catalog are taken
- for (unsigned int ind=0; ind < _personal_module_list.size();ind++)
+ for (unsigned int ind=0; ind < myPrivate->_personal_module_list.size();ind++)
{
- if (_personal_module_list[ind].type == _temp_component_type)
+ if (myPrivate->_personal_module_list[ind].type == _temp_component_type)
{
- _list_typed_component->length(_j + 1);
- _list_typed_component[_j] = _personal_module_list[ind].name.c_str();
+ _list_typed_component->length(_j + 1);
+ _list_typed_component[_j] = myPrivate->_personal_module_list[ind].name.c_str();
//if(MYDEBUG) SCRUTE(_list_typed_component[_j]);
_j++;
}
int indice = _list_typed_component->length() ;
bool _find = false;
-
+
// The components in the general catalog are taken only if they're
// not defined in the personal catalog
- for (unsigned int ind=0; ind < _general_module_list.size();ind++)
+ for (unsigned int ind=0; ind < myPrivate->_general_module_list.size();ind++)
{
_find = false;
- if(_general_module_list[ind].type == _temp_component_type)
+ if(myPrivate->_general_module_list[ind].type == _temp_component_type)
{
- for (unsigned int ind1=0; ind1 < _personal_module_list.size();ind1++)
+ for (unsigned int ind1=0; ind1 < myPrivate->_personal_module_list.size();ind1++)
{
- // searching if the component is aleready defined in
+ // searching if the component is aleready defined in
// the personal catalog
- if ((_general_module_list[ind].name.compare(_personal_module_list[ind1].name)) == 0)
+ if ((myPrivate->_general_module_list[ind].name.compare(myPrivate->_personal_module_list[ind1].name)) == 0)
_find = true;
}
if (!_find)
//if(MYDEBUG) MESSAGE("A new component " << _general_module_list[ind].name << " has to be to added in the list");
_list_typed_component->length(indice+1);
// The component is not already defined => has to be taken
- _list_typed_component[indice]=(_general_module_list[ind].name).c_str();
+ _list_typed_component[indice]=(myPrivate->_general_module_list[ind].name).c_str();
//if(MYDEBUG) SCRUTE(_list_typed_component[indice]) ;
indice++;
}
- //else
+ //else
//if(MYDEBUG) MESSAGE("The component " <<_general_module_list[ind].name << " was already defined in the personal catalog") ;
}
}
//----------------------------------------------------------------------
// Function : GetComponent
-// Purpose : get a component
-// If a component is defined in the personal catalog and
+// Purpose : get a component
+// If a component is defined in the personal catalog and
// in the general catalog (same name), the component defined
// in the personal catalog is used
//----------------------------------------------------------------------
-SALOME_ModuleCatalog::Acomponent_ptr
+SALOME_ModuleCatalog::Acomponent_ptr
SALOME_ModuleCatalogImpl::GetComponent(const char* name)
{
// Looking for component named "componentname" in the personal catalog
SALOME_ModuleCatalog::Acomponent_ptr compo
= SALOME_ModuleCatalog::Acomponent::_nil();
- C_parser = findComponent(s);
+ C_parser = myPrivate->findComponent(s);
if (C_parser) {
-
+
// DebugParserComponent(*C_parser);
SALOME_ModuleCatalog::ComponentDef C_corba;
- duplicate(C_corba, *C_parser);
+ myPrivate->duplicate(C_corba, *C_parser);
-
- SALOME_ModuleCatalog_AcomponentImpl * aComponentImpl =
+
+ SALOME_ModuleCatalog_AcomponentImpl * aComponentImpl =
new SALOME_ModuleCatalog_AcomponentImpl(C_corba);
-
+
compo = aComponentImpl->_this();
}
else {
// Not found in the personal catalog and in the general catalog
// return NULL object
- if(MYDEBUG) MESSAGE("Component with name " << name
+ if(MYDEBUG) MESSAGE("Component with name " << name
<< " not found in catalog");
}
-
+
return compo;
}
{
std::string s(name);
- ParserComponent * C_parser = findComponent(s);
-
+ ParserComponent * C_parser = myPrivate->findComponent(s);
+
if (C_parser) {
-
- SALOME_ModuleCatalog::ComponentDef * C_corba
- = new SALOME_ModuleCatalog::ComponentDef;
- duplicate(*C_corba, *C_parser);
+
+ SALOME_ModuleCatalog::ComponentDef * C_corba
+ = new SALOME_ModuleCatalog::ComponentDef;
+ myPrivate->duplicate(*C_corba, *C_parser);
return C_corba;
}
return NULL;
}
+void SALOME_ModuleCatalogImpl::ping()
+{
+}
+
CORBA::Long SALOME_ModuleCatalogImpl::getPID()
-{
- return
+{
+ return
#ifndef WIN32
(CORBA::Long)getpid();
#else
exit( EXIT_SUCCESS );
}
+void SALOME_ModuleCatalogImpl::shutdown()
+{
+ if (!CORBA::is_nil(_orb)) _orb->shutdown(0);
+};
+
+
+
+//----------------------------------------------------------------------
+// Function : _parseArguments
+// Purpose : parse arguments to get general and personal catalog files
+//----------------------------------------------------------------------
+bool
+SALOME_ModuleCatalogImpl::_parseArguments(int argc, char **argv,
+ char **_general,
+ char** _personal)
+{
+ bool _return_value = true;
+ *_general = NULL;
+ *_personal = NULL ;
+ for (int ind = 0; ind < argc ; ind++)
+ {
+
+ if (strcmp(argv[ind],"-help") == 0)
+ {
+ INFOS( "Usage: " << argv[0]
+ << " -common 'path to general catalog' "
+ " -personal 'path to personal catalog' "
+ " -ORBInitRef NameService=corbaname::localhost");
+ _return_value = false ;
+ }
+
+ if (strcmp(argv[ind],"-common") == 0)
+ {
+ if (ind + 1 < argc)
+ {
+ // General catalog file
+ *_general = argv[ind + 1] ;
+ }
+ }
+ else if (strcmp(argv[ind],"-personal") == 0)
+ {
+ if (ind + 1 < argc)
+ {
+ // Personal catalog file
+ *_personal = argv[ind + 1] ;
+ }
+ }
+ }
+ return _return_value;
+}
+
ParserComponent *
-SALOME_ModuleCatalogImpl::findComponent(const std::string & name)
+SALOME_ModuleCatalogImpl::Private::findComponent(const std::string & name)
{
ParserComponent * C_parser = NULL;
{
if (name.compare(_personal_module_list[ind].name) == 0)
{
- if(MYDEBUG) MESSAGE("Component named " << name
+ if(MYDEBUG) MESSAGE("Component named " << name
<< " found in the personal catalog");
C_parser = &(_personal_module_list[ind]);
break;
{
if (name.compare(_general_module_list[ind].name) == 0)
{
- // if(MYDEBUG) MESSAGE("Component named " << name
+ // if(MYDEBUG) MESSAGE("Component named " << name
// << " found in the general catalog");
C_parser = &(_general_module_list[ind]);
break;
//----------------------------------------------------------------------
// Function : _parse_xml_file
-// Purpose : parse one module catalog
-//----------------------------------------------------------------------
-void
-SALOME_ModuleCatalogImpl::_parse_xml_file(const char* file,
- ParserComponents& modulelist,
- ParserPathPrefixes& pathList,
- ParserTypes& typeMap,
- TypeList& typeList)
+// Purpose : parse one module catalog
+//----------------------------------------------------------------------
+void
+SALOME_ModuleCatalogImpl::Private::_parse_xml_file(const char* file,
+ ParserComponents& modulelist,
+ ParserPathPrefixes& pathList,
+ ParserTypes& typeMap,
+ TypeList& typeList)
{
if(MYDEBUG) BEGIN_OF("_parse_xml_file");
if(MYDEBUG) SCRUTE(file);
//Local path and module list for the file to parse
ParserPathPrefixes _pathList;
ParserComponents _moduleList;
-
+
SALOME_ModuleCatalog_Handler* handler = new SALOME_ModuleCatalog_Handler(_pathList,_moduleList,typeMap,typeList);
FILE* aFile = fopen(file, "r");
if (aFile != NULL)
{
xmlDocPtr aDoc = xmlReadFile(file, NULL, 0);
-
- if (aDoc != NULL)
+
+ if (aDoc != NULL)
handler->ProcessXmlDocument(aDoc);
else
MESSAGE("ModuleCatalog: could not parse file "<<file);
}
else
MESSAGE("ModuleCatalog: file "<<file<<" is not readable.");
-
+
delete handler;
-
+
unsigned int i, j;
for ( i = 0; i < _moduleList.size(); i++) {
modulelist[j].prefixes = pathList;
}
-void
+void
SALOME_ModuleCatalogImpl::ImportXmlCatalogFile(const char* file)
{
- _parse_xml_file(file, _personal_module_list, _personal_path_list,_typeMap,_typeList);
+ myPrivate->_parse_xml_file(file, myPrivate->_personal_module_list, myPrivate->_personal_path_list,myPrivate->_typeMap,myPrivate->_typeList);
}
//
// Duplicate functions create a Corba structure (component,
-// interface, service, parameter) from the corresponding C++
+// interface, service, parameter) from the corresponding C++
// parser structure
//
// Function : duplicate
// Purpose : create a component from the catalog parsing
//----------------------------------------------------------------------
-void SALOME_ModuleCatalogImpl::duplicate
-(SALOME_ModuleCatalog::ComponentDef & C_corba,
+void SALOME_ModuleCatalogImpl::Private::duplicate
+(SALOME_ModuleCatalog::ComponentDef & C_corba,
const ParserComponent & C_parser)
{
C_corba.name = CORBA::string_dup(C_parser.name.c_str());
unsigned int _length = C_parser.interfaces.size();
C_corba.interfaces.length(_length);
-
+
for (unsigned int ind = 0; ind < _length; ind++)
duplicate(C_corba.interfaces[ind], C_parser.interfaces[ind]);
}
// Function : duplicate
// Purpose : create an interface from the catalog parsing
//----------------------------------------------------------------------
-void SALOME_ModuleCatalogImpl::duplicate
+void SALOME_ModuleCatalogImpl::Private::duplicate
(SALOME_ModuleCatalog::DefinitionInterface & I_corba,
const ParserInterface & I_parser)
{
//duplicate interface name
I_corba.interfacename = CORBA::string_dup(I_parser.name.c_str());
-
+
// duplicate service list
unsigned int _length = I_parser.services.size();
// if(MYDEBUG) SCRUTE(_length);
- // I_corba.interfaceservicelist
+ // I_corba.interfaceservicelist
// = new SALOME_ModuleCatalog::ListOfInterfaceService;
I_corba.interfaceservicelist.length(_length);
-
+
for (unsigned int ind1 = 0; ind1 < _length ; ind1 ++)
duplicate(I_corba.interfaceservicelist[ind1],
I_parser.services[ind1]);
// Function : duplicate
// Purpose : create a service from the catalog parsing
//----------------------------------------------------------------------
-void SALOME_ModuleCatalogImpl::duplicate
+void SALOME_ModuleCatalogImpl::Private::duplicate
(SALOME_ModuleCatalog::Service & S_corba,
const ParserService & S_parser)
{
// duplicate service name
S_corba.ServiceName = CORBA::string_dup(S_parser.name.c_str());
-
+
// duplicate service by default
S_corba.Servicebydefault = S_parser.byDefault;
for (unsigned int ind2 = 0; ind2 < _length ; ind2 ++)
duplicate(S_corba.ServiceinParameter[ind2],
S_parser.inParameters[ind2]);
-
+
// duplicate out Parameters
_length = S_parser.outParameters.size();
S_corba.ServiceoutParameter.length(_length);
for (unsigned int ind2 = 0; ind2 < _length ; ind2 ++)
duplicate(S_corba.ServiceoutParameter[ind2],
S_parser.outParameters[ind2]);
-
+
// duplicate in DataStreamParameters
_length = S_parser.inDataStreamParameters.size();
S_corba.ServiceinDataStreamParameter.length(_length);
for (unsigned int ind2 = 0; ind2 < _length ; ind2 ++)
duplicate(S_corba.ServiceinDataStreamParameter[ind2],
S_parser.inDataStreamParameters[ind2]);
-
+
// duplicate out DataStreamParameters
_length = S_parser.outDataStreamParameters.size();
// if(MYDEBUG) SCRUTE(_length);
// Function : duplicate
// Purpose : create a service parameter from the catalog parsing
//----------------------------------------------------------------------
-void SALOME_ModuleCatalogImpl::duplicate
+void SALOME_ModuleCatalogImpl::Private::duplicate
(SALOME_ModuleCatalog::ServicesParameter & P_corba,
const ParserParameter & P_parser)
{
// duplicate parameter name
P_corba.Parametername = CORBA::string_dup(P_parser.name.c_str());
-
+
// duplicate parameter type
P_corba.Parametertype = CORBA::string_dup(P_parser.type.c_str());
}
// Function : duplicate
// Purpose : create a service datastream parameter from the catalog parsing
//----------------------------------------------------------------------
-void SALOME_ModuleCatalogImpl::duplicate
+void SALOME_ModuleCatalogImpl::Private::duplicate
(SALOME_ModuleCatalog::ServicesDataStreamParameter & P_corba,
const ParserDataStreamParameter & P_parser)
{
- std::map < std::string,
+ std::map < std::string,
SALOME_ModuleCatalog::DataStreamDependency >::const_iterator it_dep;
// duplicate parameter name
P_corba.Parametername = CORBA::string_dup(P_parser.name.c_str());
-
+
// duplicate parameter type
- // doesn't work ???
+ // doesn't work ???
// it_type = DataStreamTypeConvert.find(P_parser.type);
// P_corba.Parametertype
- // = (it_type == DataStreamTypeConvert.end())
+ // = (it_type == DataStreamTypeConvert.end())
// ? it_type->second : SALOME_ModuleCatalog::DATASTREAM_UNKNOWN;
P_corba.Parametertype = CORBA::string_dup(P_parser.type.c_str());
// duplicate parameter dependency
-
+
if(MYDEBUG) SCRUTE(P_parser.dependency);
P_corba.Parameterdependency = SALOME_ModuleCatalog::DATASTREAM_UNDEFINED;
- for (it_dep = DataStreamDepConvert.begin();
- it_dep != DataStreamDepConvert.end();
+ for (it_dep = DataStreamDepConvert.begin();
+ it_dep != DataStreamDepConvert.end();
it_dep++)
if (P_parser.dependency.compare(it_dep->first) == 0) {
P_corba.Parameterdependency = it_dep->second;
// Purpose : create the path prefix structures from the catalog parsing
//----------------------------------------------------------------------
void
-SALOME_ModuleCatalogImpl::duplicate(ParserPathPrefixes &L_out,
- const ParserPathPrefixes &L_in)
+SALOME_ModuleCatalogImpl::Private::duplicate(ParserPathPrefixes &L_out,
+ const ParserPathPrefixes &L_in)
{
L_out = L_in;
}
//----------------------------------------------------------------------
// Function : _verify_path_prefix
// Purpose : verify the path prefix structures from the catalog parsing
-// Verify that there only one path prefix associated to a
+// Verify that there only one path prefix associated to a
// particular computer
//----------------------------------------------------------------------
bool
-SALOME_ModuleCatalogImpl::_verify_path_prefix(ParserPathPrefixes & pathList)
+SALOME_ModuleCatalogImpl::Private::_verify_path_prefix(ParserPathPrefixes & pathList)
{
bool _return_value = true;
std::vector<std::string> _machine_list;
// Fill a list of all computers indicated in the path list
for (unsigned int ind = 0; ind < pathList.size(); ind++)
- {
+ {
for (unsigned int ind1 = 0 ; ind1 < pathList[ind].listOfComputer.size(); ind1++)
{
_machine_list.push_back(pathList[ind].listOfComputer[ind1]);
if(_machine_list[ind].compare(_machine_list[ind1]) == 0)
{
if(MYDEBUG) MESSAGE( "The computer " << _machine_list[ind] << " is indicated more than once in the path list");
- _return_value = false;
+ _return_value = false;
}
}
}
return _return_value;
}
-
-
-//----------------------------------------------------------------------
-// Function : _parseArguments
-// Purpose : parse arguments to get general and personal catalog files
-//----------------------------------------------------------------------
-bool
-SALOME_ModuleCatalogImpl::_parseArguments(int argc, char **argv,
- char **_general,
- char** _personal)
-{
- bool _return_value = true;
- *_general = NULL;
- *_personal = NULL ;
- for (int ind = 0; ind < argc ; ind++)
- {
-
- if (strcmp(argv[ind],"-help") == 0)
- {
- INFOS( "Usage: " << argv[0]
- << " -common 'path to general catalog' "
- " -personal 'path to personal catalog' "
- " -ORBInitRef NameService=corbaname::localhost");
- _return_value = false ;
- }
-
- if (strcmp(argv[ind],"-common") == 0)
- {
- if (ind + 1 < argc)
- {
- // General catalog file
- *_general = argv[ind + 1] ;
- }
- }
- else if (strcmp(argv[ind],"-personal") == 0)
- {
- if (ind + 1 < argc)
- {
- // Personal catalog file
- *_personal = argv[ind + 1] ;
- }
- }
- }
- return _return_value;
-}
#include <string>
#include <map>
-#include "SALOME_ModuleCatalog_Handler.hxx"
-
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SALOME_ModuleCatalog)
-#ifdef WNT
+#ifdef WIN32
#pragma warning(disable:4275) // Disable warning interface non dll
#pragma warning(disable:4290) // Warning Exception ...
#endif
class MODULECATALOG_EXPORT SALOME_ModuleCatalogImpl: public POA_SALOME_ModuleCatalog::ModuleCatalog
{
+ class Private;
+
public:
//! standard constructor
SALOME_ModuleCatalogImpl(int artgc, char** argv, CORBA::ORB_ptr orb = NULL);
//! method to get a component list
/*!
- \return a component list
- */
+ * \return a component list
+ */
virtual SALOME_ModuleCatalog::ListOfComputers* GetComputerList();
//! method to get the list of all types of the catalog
virtual SALOME_ModuleCatalog::ListOfTypeDefinition* GetTypes();
//! method to get the PathPrefix of a computer
- /*! If the wanted computer doesn't exist, the Notfound exception is thrown
- \param machinename const char* arguments
- \return the prefix path
- */
+ /*! If the wanted computer doesn't exist, the Notfound exception is thrown
+ * \param machinename const char* arguments
+ * \return the prefix path
+ */
virtual char* GetPathPrefix(const char* machinename);
//! method to read a XML file and import new components into the component list
- /*! If the XML file doesn't exist or is not readable, the Notfound exception is thrown
- \param const char* xmlFileName
- */
+ /*! If the XML file doesn't exist or is not readable, the Notfound exception is thrown
+ * \param const char* xmlFileName
+ */
virtual void ImportXmlCatalogFile(const char* xmlFileName);
//! method to get a component list
/*!
- \return a component list
- */
+ * \return a component list
+ */
virtual SALOME_ModuleCatalog::ListOfComponents* GetComponentList();
//! method to get a component list of component name and component icone
/*!
- \return a list of couple (component name, component icone)
- */
+ * \return a list of couple (component name, component icone)
+ */
virtual SALOME_ModuleCatalog::ListOfIAPP_Affich* GetComponentIconeList();
//! method to get a component list of a wanted type
/*!
- \return a component list
- */
- virtual SALOME_ModuleCatalog::ListOfComponents*
+ * \return a component list
+ */
+ virtual SALOME_ModuleCatalog::ListOfComponents*
GetTypedComponentList(SALOME_ModuleCatalog::ComponentType component_type);
//! method to get a component
/*!
- \param componentname const char* arguments
- \return the wanted component
- */
- virtual SALOME_ModuleCatalog::Acomponent_ptr
+ * \param componentname const char* arguments
+ * \return the wanted component
+ */
+ virtual SALOME_ModuleCatalog::Acomponent_ptr
GetComponent(const char* componentname);
-
+
//! method to get a component description
/*!
- \param componentname const char* arguments
- \return the wanted component description
- */
- virtual SALOME_ModuleCatalog::ComponentDef *
+ * \param componentname const char* arguments
+ * \return the wanted component description
+ */
+ virtual SALOME_ModuleCatalog::ComponentDef*
GetComponentInfo(const char *name);
- void ping(){};
+ //! method to check the server is alive
+ void ping();
+
+ //! get PID of the server
CORBA::Long getPID();
+
+ //! shutdown server and exit
void ShutdownWithExit();
- void shutdown() { if(!CORBA::is_nil(_orb)) _orb->shutdown(0); };
+ //! shutdown server
+ void shutdown();
private:
- //! method to parse one module catalog
- /*!
- \param file const char* arguments
- \param modulelist ParserComponents arguments
- \param pathlist ParserPathPrefixes arguments
- \param typeMap ParserTypes arguments
- */
- virtual void _parse_xml_file(const char* file,
- ParserComponents & modulelist,
- ParserPathPrefixes & pathlist,
- ParserTypes& typeMap,
- TypeList& typeList);
-
- //! method to find component in the parser list
- /*!
- \param name string argument
- \return pointer on a component, NULL if not found
- */
- ParserComponent *findComponent(const std::string & name);
-
- //! method to create a CORBA component description from parser
+ //! method to parse arguments to get general and personal catalog files
/*!
- \param C_corba Component argument
- \param C_parser const ParserComponent argument
- */
- void duplicate(SALOME_ModuleCatalog::ComponentDef & C_corba,
- const ParserComponent & C_parser);
-
- //! method to create a CORBA interface description from parser
- /*!
- \param I_corba DefinitionInterface argument
- \param I_parser const ParserInterface argument
- */
- void duplicate(SALOME_ModuleCatalog::DefinitionInterface & I_corba,
- const ParserInterface & I_parser);
-
- //! method to create a CORBA service description from parser
- /*!
- \param S_corba Service argument
- \param S_parser const ParserService argument
- */
- void duplicate(SALOME_ModuleCatalog::Service & S_corba,
- const ParserService & service);
-
- //! method to create a CORBA parameter description from parser
- /*!
- \param P_corba ServicesParameter argument
- \param P_parser const ParserParameter argument
- */
- void duplicate(SALOME_ModuleCatalog::ServicesParameter & P_corba,
- const ParserParameter & P_parser);
-
- //! method to create a CORBA datastream parameter description from parser
- /*!
- \param P_corba ServicesDataStreamParameter argument
- \param P_parser const ParserDataStreamParameter argument
- */
- void duplicate(SALOME_ModuleCatalog::ServicesDataStreamParameter & P_corba,
- const ParserDataStreamParameter & P_parser);
-
- //! method to create the path prefix structures from the catalog parsing
- /*!
- \param pathes ParserPathPrefixes arguments
- \return the pathes
- */
- void duplicate(ParserPathPrefixes & p_out, const ParserPathPrefixes & P_in);
-
- //! method to verify path prefix content
- /*!
- \param pathlist ListOfParserPathPrefix arguments
- \return true if verfication is OK
- */
- virtual bool _verify_path_prefix(ParserPathPrefixes & pathlist);
-
-
- //! method to parse arguments to get general and personal catalog files
- /*!
- \param argc int arguments
- \param argv char** arguments
- \param _general char** arguments
- \return true if parsing is OK
- */
- virtual bool _parseArguments(int argc, char **argv,
+ * \param argc int arguments
+ * \param argv char** arguments
+ * \param _general char** arguments
+ * \return true if parsing is OK
+ */
+ virtual bool _parseArguments(int argc, char **argv,
char **_general, char** _personal);
- // Theses variables will contain the path to the general and personal catalogs
- char* _general_path;
- char* _personal_path;
-
-
- // These variables will contain the informations on the general common catalog
- ParserComponents _general_module_list ;
- ParserPathPrefixes _general_path_list ;
- ParserTypes _typeMap;
- TypeList _typeList;
-
- // These variables will contain the informations on the personal catalog
- ParserComponents _personal_module_list ;
- ParserPathPrefixes _personal_path_list ;
-
- std::map <std::string, SALOME_ModuleCatalog::DataStreamDependency>
- DataStreamDepConvert;
-
- std::map <ParserComponentType, SALOME_ModuleCatalog::ComponentType>
- ComponentTypeConvert;
-
CORBA::ORB_ptr _orb;
+ Private* myPrivate;
};
#endif // MODULECATALOG_IMPL_H
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
-ROOT_SRCDIR=@ROOT_SRCDIR@
+ROOT_SRCDIR=@CMAKE_SOURCE_DIR@
export ROOT_SRCDIR
-ROOT_BUILDDIR=@ROOT_BUILDDIR@
+ROOT_BUILDDIR=@CMAKE_BINARY_DIR@
export ROOT_BUILDDIR
SRCDIR=${ROOT_SRCDIR}/src/ModuleGenerator
export SRCDIR
#include <string>
#include <cstdio>
-#ifdef WNT
+#ifdef WIN32
#define strdup _strdup
#endif
*
* After Default Constructor, one needs to initialize ORB.
* \sa init_orb(CORBA::ORB_ptr orb), SALOME_NamingService(CORBA::ORB_ptr orb)
- */
+ */
// ============================================================================
SALOME_NamingService::SALOME_NamingService()
}
// ============================================================================
-/*! \brief Standard Constructor, with ORB reference.
- *
+/*! \brief Standard Constructor, with ORB reference.
+ *
* Initializes the naming service root context
* \param orb CORBA::ORB_ptr arguments
- */
+ */
// ============================================================================
SALOME_NamingService::SALOME_NamingService(CORBA::ORB_ptr orb)
/*! \brief Standard destructor.
*
* The standard destructor does nothing special.
- */
+ */
// ============================================================================
SALOME_NamingService::~SALOME_NamingService()
// ============================================================================
/*! \brief initializes ORB reference and naming service root context.
- *
+ *
* Initializes ORB reference and naming service root context.
* For use after default constructor.
* If param orb is null, the orb is initialized
* \param orb CORBA::ORB_ptr arguments
- */
+ */
// ============================================================================
void SALOME_NamingService::init_orb(CORBA::ORB_ptr orb)
* as an absolute pathname. Else, pathname is taken as a relative
* path, to current context. Prefer absolute pathname, relative
* pathname are not safe, when SALOME_NamingService object is
- * shared or use in multithreaded context.
+ * shared or use in multithreaded context.
* If the path ends with '/', only a directory is created.
* \sa Change_Directory(const char* Path),
* Create_Directory(const char* Path)
* CORBA::Object_ptr Resolve(const char* Path)
- */
+ */
// ============================================================================
void SALOME_NamingService::Register(CORBA::Object_ptr ObjRef,
// A directory is treated (not only an object name)
// test if the directory where ObjRef should be recorded already exists
// If not, create the new context
-
+
try{
CORBA::Object_var obj = _current_context->resolve(context_name);
_current_context = CosNaming::NamingContext::_narrow(obj);
// ============================================================================
/*! \brief get the CORBA object reference associated to a name.
- *
+ *
* get the CORBA object reference associated to a complete name with a path.
- * If the NamingService is out, the exception ServiceUnreachable is thrown
+ * If the NamingService is out, the exception ServiceUnreachable is thrown
* \param Path pathname. If the pathname begins with a '/', pathname is taken
* as an absolute pathname. Else, pathname is taken as a relative
* path, to current context. Prefer absolute pathname, relative
* or nil reference in other cases.
* \sa Register(CORBA::Object_ptr ObjRef, const char* Path),
* Change_Directory(const char* Path)
- */
+ */
// ============================================================================
CORBA::Object_ptr SALOME_NamingService::Resolve(const char* Path)
*
* get the CORBA object reference associated to an uncomplete name with a
* path. Look for the first occurence of name*.
- * If the NamingService is out, the exception ServiceUnreachable is thrown
+ * If the NamingService is out, the exception ServiceUnreachable is thrown
* \param Path pathname under the form "/path/name" (Absolute reference !)
* search the fist reference like "/path(.dir)/name*(.kind)"
* \return the object reference if found, or nil reference.
isOk =true;
else
isOk = Change_Directory(basePath.c_str());
-
+
if (isOk)
{
std::vector<std::string> listElem = list_directory();
std::vector<std::string>::iterator its = listElem.begin();
-
+
while (its != listElem.end())
{
MESSAGE(*its);
-
+
if ((*its).find(name) == 0)
{
return Resolve((*its).c_str());
}
-
+
its++;
}
}
* \param hostname name of the machine on which the component is searched.
* \param containerName name of the container in which the component is
instanciated.
- * \param componentName name of the component we are looking for an existing
+ * \param componentName name of the component we are looking for an existing
instance.
* \param nbproc in case of multi processor machine, container name is
* suffixed with _nbproc.
* \return the object reference
- */
+ */
// ============================================================================
CORBA::Object_ptr
*/
// ============================================================================
-std::string
+std::string
SALOME_NamingService::ContainerName(const Engines::ContainerParameters& params)
{
int nbproc;
* \param name the name to search.
* \return number of occurences found.
* \sa Change_Directory(const char* Path)
- */
+ */
// ============================================================================
int SALOME_NamingService::Find(const char* name)
// ============================================================================
/*! \brief Creates a directory (context_name)
*
- * Creates a directory (context_name) relative to the current directory
+ * Creates a directory (context_name) relative to the current directory
* (current context) or relative to the root directory (root context), if
* the path given begins with a '/'.
* If the NamingService is out, the exception ServiceUnreachable is thrown.
* as an absolute pathname. Else, pathname is taken as a relative
* path, to current context. Prefer absolute pathname, relative
* pathname are not safe, when SALOME_NamingService object is
- * shared or use in multithreaded context.
+ * shared or use in multithreaded context.
* \return true if successfull
* (creation not strictly garanteed if true, because Register may
* catch some specific unlikely exception without throw anything
* --- to be corrected ---)
* \sa RegisterCORBA::Object_ptr ObjRef, const char* Path)
- */
+ */
// ============================================================================
bool SALOME_NamingService::Create_Directory(const char* Path)
}
// --- path must end with '/'
-
+
if (path[path.length()-1] != '/') path += '/';
Register(CORBA::Object::_nil(), path.c_str());
* If the NamingService is out, the exception ServiceUnreachable is thrown.
* \param Path the new current directory
* \return true if the change succeeded
- */
+ */
// ============================================================================
bool SALOME_NamingService::Change_Directory(const char* Path)
// --- need to resolve directory path
ASSERT(!CORBA::is_nil(current_context));
-
+
if (path[path.length()-1] != '/') path += '/';
// SCRUTE(path);
CosNaming::Name context_name;
context_name,
splitPath,
true);
-
+
// --- Context creation
-
+
try
{
CORBA::Object_var obj = current_context->resolve(context_name);
_current_context = current_context;
changeOK = true;
}
-
+
catch (CosNaming::NamingContext::NotFound& ex)
{
CosNaming::Name n = ex.rest_of_name;
-
+
if (ex.why == CosNaming::NamingContext::missing_node)
MESSAGE( "Change_Directory() : " << (char *) n[0].id
<< " (" << (char *) n[0].kind << ") not found");
<< " (" << (char *) n[0].kind
<< ") is not an object" );
}
-
+
catch (CosNaming::NamingContext::CannotProceed&)
{
INFOS("Change_Directory(): CosNaming::NamingContext::CannotProceed");
}
-
+
catch (CosNaming::NamingContext::InvalidName&)
{
INFOS("Change_Directory(): CosNaming::NamingContext::InvalidName");
}
-
+
catch (CORBA::SystemException&)
{
INFOS("Change_Directory():CORBA::SystemException : unable to contact"
* If the NamingService is out, the exception ServiceUnreachable is thrown.
* \return the path of the current_context
* \sa _current_directory
- */
+ */
// ============================================================================
char* SALOME_NamingService::Current_Directory()
* List and print via trace all directories and objects in the current
* context. Trace must be activated: compile option _DEBUG_
* If the NamingService is out, the exception ServiceUnreachable is thrown
- */
+ */
// ============================================================================
void SALOME_NamingService::list()
* If the NamingService is out, the exception ServiceUnreachable is thrown.
* \return list of strings with objects found.
* \sa vector<string> list_directory_recurs()
- */
+ */
// ============================================================================
std::vector<std::string> SALOME_NamingService::list_directory()
* If the NamingService is out, the exception ServiceUnreachable is thrown.
* \return list of strings with directories found.
* \sa vector<string> list_directory()
- */
+ */
// ============================================================================
std::vector<std::string> SALOME_NamingService::list_subdirs()
* If the NamingService is out, the exception ServiceUnreachable is thrown.
* \return list of strings with objects found.
* \sa vector<string> list_directory()
- */
+ */
// ============================================================================
std::vector<std::string> SALOME_NamingService::list_directory_recurs()
/*! \brief destroy an entry in naming service.
*
* Destroy an association Path - Object Reference.
- * If the NamingService is out, the exception ServiceUnreachable is thrown
+ * If the NamingService is out, the exception ServiceUnreachable is thrown
* \param Path object path
- */
+ */
// ============================================================================
void SALOME_NamingService::Destroy_Name(const char* Path)
CORBA::string_dup(splitPath[dimension_resultat].c_str());
context_name[0].kind = CORBA::string_dup("object");
SCRUTE(context_name[0].id);
-
+
_current_context->unbind(context_name);
MESSAGE("The object " << context_name[0].id << " has been deleted");
}
* Destroy an empty directory in Naming Service.
* If the NamingService is out, the exception ServiceUnreachable is thrown.
* \param Path directory path
- */
+ */
// ============================================================================
void SALOME_NamingService::Destroy_Directory(const char* Path)
/*! \brief Destroy a directory with its contents.
*
* Destroy the objects associations in a directory, and the directory itself,
- * if there is no subdirectories.
+ * if there is no subdirectories.
* If the NamingService is out, the exception ServiceUnreachable is thrown.
* \param Path the directory path.
- */
+ */
// ============================================================================
void SALOME_NamingService::Destroy_FullDirectory(const char* Path)
for (unsigned int ind = 0; ind < contList.size(); ind++)
Destroy_Name(contList[ind].c_str());
-
+
Destroy_Directory(Path);
}
}
*
* the root context initialisation must be done when the SALOME_NamingService
* instance is created and before any othe call. See constructors.
- */
+ */
// ============================================================================
void SALOME_NamingService::_initialize_root_context()
* if false, final object (if any) is included in
* context_name.
* \return dimension of context_name
- */
+ */
// ============================================================================
int
if (onlyDir) // only directory part
{
dim = splitPath.size()-1; // omit final object
- if (endWithDelim) // unless the path ends with a delimiter
+ if (endWithDelim) // unless the path ends with a delimiter
dim++;
endWithDelim = true;
}
*
* \param name the name to search.
* \param occurence_number number of occurence already found (incremented)
- */
+ */
// ============================================================================
void SALOME_NamingService::_Find(const char* name,
while (binding_iterator->next_one(binding))
{
CosNaming::Name bindingName = binding->binding_name;
-
+
if (binding->binding_type == CosNaming::ncontext)
{
// --- We work on a directory,
// the search should be done in this directory
-
+
Change_Directory(bindingName[0].id);
_Find(name, occurence_number);
-
+
// --- We'll go back to the initial context
-
+
_current_context = ref_context ;
}
-
+
else if (binding->binding_type == CosNaming::nobject)
{
// --- We work on an object...
-
+
if (!strcmp( bindingName[0].id, name))
{
//MESSAGE("One occurence was found");
occurence_number++;
-
+
// --- We keep in memory the directory where
// one occurence was found
-
+
found_context = _current_context ;
}
}
}
-
+
binding_iterator->destroy();
}
// --- We go to the last directory where an occurence was found
// ============================================================================
/*! \brief find the current directory path.
- *
+ *
* Parse the naming service tree to find the current context and give the
* associated directory path (relative to root context).
- * \param splitPath
+ * \param splitPath
* \param lengthResult
* \param contextToFind
* \param notFound
- */
+ */
// ============================================================================
void
* \param relativeSubDir The directory relative to absCurDirectory in which
* the objects are found.
* \param absCurDirectory The current directory, absolute path
- */
+ */
// ============================================================================
void SALOME_NamingService::_list_directory_recurs(std::vector<std::string>& myList,
#include "SALOME_NamingService_defs.hxx"
-#ifdef WNT
+#ifdef WIN32
#pragma warning(disable:4290) // Warning Exception ...
#endif
void init_orb(CORBA::ORB_ptr orb=0);
void Register(CORBA::Object_ptr ObjRef,
- const char* Path)
+ const char* Path)
throw(ServiceUnreachable);
CORBA::Object_ptr Resolve(const char* Path)
- throw( ServiceUnreachable);
+ throw( ServiceUnreachable);
CORBA::Object_ptr ResolveFirst(const char* Path)
- throw( ServiceUnreachable);
+ throw( ServiceUnreachable);
CORBA::Object_ptr ResolveComponent(const char* hostname,
const char* containerName,
const char* componentName,
std::string ContainerName(const Engines::ContainerParameters& params);
std::string BuildContainerNameForNS(const char *ContainerName,
const char *hostname);
- std::string
+ std::string
BuildContainerNameForNS(const Engines::ContainerParameters& params,
const char *hostname);
#include "SALOME_NOTIFICATION.hxx"
-#ifdef WNT
+#ifdef WIN32
#pragma warning(disable:4275) // Disable warning interface non dll
#endif
# include <map>
-#ifdef WNT
+#ifdef WIN32
#pragma warning(disable:4275) // Disable warning interface non dll
#pragma warning(disable:4251) // Warning DLL Interface ...
#endif
client_infos( const Registry::Infos &infos );
~client_infos();
- };
+ };
DESTINATION ${SALOME_INSTALL_LIBS})
ENDIF()
-FILE(GLOB COMMON_HEADERS_HXX "${CMAKE_CURRENT_SOURCE_DIR}/*.hxx")
+SET(COMMON_HEADERS_HXX
+ ResourcesManager.hxx
+ ResourcesManager_Defs.hxx
+ SALOME_LoadRateManager.hxx
+ SALOME_ResourcesCatalog_Parser.hxx
+ SALOME_ResourcesManager.hxx
+ )
INSTALL(FILES ${COMMON_HEADERS_HXX} DESTINATION ${SALOME_INSTALL_HEADERS})
//
#include "ResourcesManager.hxx"
+#include "SALOME_ResourcesCatalog_Handler.hxx"
#include <Basics_Utils.hxx>
#include <fstream>
#include <iostream>
#include <list>
#include <sys/types.h>
#include <sys/stat.h>
-#ifdef WNT
+#ifdef WIN32
#else
#include <unistd.h>
#endif
#include <vector>
#include <list>
#include "SALOME_ResourcesCatalog_Parser.hxx"
-#include "SALOME_ResourcesCatalog_Handler.hxx"
#include "SALOME_LoadRateManager.hxx"
#include <sys/types.h>
#include <sys/stat.h>
-#ifdef WNT
+#ifdef WIN32
#else
#include <unistd.h>
#endif
-#ifdef WNT
+#ifdef WIN32
#pragma warning(disable:4251) // Warning DLL Interface ...
#pragma warning(disable:4290) // Warning Exception ...
#endif
#include <map>
#include <iostream>
-#ifdef WNT
+#ifdef WIN32
#pragma warning(disable:4251) // Warning DLL Interface ...
#endif
#include "Utils_SALOME_Exception.hxx"
#include "utilities.h"
#include <SALOMEconfig.h>
-#include "SALOME_ResourcesCatalog_Handler.hxx"
-#include "SALOME_LoadRateManager.hxx"
#include "SALOME_NamingService.hxx"
#include CORBA_CLIENT_HEADER(SALOME_ContainerManager)
#include <string>
# define SALOMERESOURCESMANAGER_EXPORT
#endif
-#ifdef WNT
+#ifdef WIN32
#pragma warning(disable:4275) // Disable warning interface non dll
#endif
${OMNIORB_INCLUDE_DIR}
${HDF5_INCLUDE_DIRS}
${Boost_INCLUDE_DIR}
+ ${SIMANIO_INCLUDE_DIR}
${PROJECT_BINARY_DIR}/salome_adm
${CMAKE_CURRENT_SOURCE_DIR}/../HDFPersist
${CMAKE_CURRENT_SOURCE_DIR}/../Basics
${CMAKE_CURRENT_SOURCE_DIR}/../GenericObj
${CMAKE_CURRENT_SOURCE_DIR}/../SALOMEDSClient
${CMAKE_CURRENT_SOURCE_DIR}/../LifeCycleCORBA
+ ${CMAKE_CURRENT_SOURCE_DIR}/../TOOLSDS
+ ${CMAKE_CURRENT_SOURCE_DIR}/../Container
${PROJECT_BINARY_DIR}/idl
)
SalomeLifeCycleCORBA
SalomeIDLKernel
${HDF5_C_LIBRARIES}
+ ${SIMANIO_LIBRARIES}
)
SET(SalomeDS_SOURCES
SALOMEDS_UseCaseIterator_i.cxx
SALOMEDS_ChildIterator_i.cxx
SALOMEDS_SComponentIterator_i.cxx
+ SALOMEDS_SimanStudy_i.cxx
+ SALOMEDS_SimanStudy.cxx
SALOMEDS_Study_i.cxx
SALOMEDS_StudyBuilder_i.cxx
SALOMEDS_SObject_i.cxx
SALOMEDS_Defines.hxx
SALOMEDS_wrap.hxx
SALOMEDS_Attributes_wrap.hxx
+ SALOMEDS_SimanStudy.hxx
+ SALOMEDS_SimanStudy_i.hxx
)
INSTALL(FILES ${COMMON_HEADERS_HXX} DESTINATION ${SALOME_INSTALL_HEADERS})
--- /dev/null
+// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+// File : SALOMEDS_SimanStudy.cxx
+// Author : Mikhail PONIKAROV
+// Module : SALOME
+//
+#include "utilities.h"
+
+#include "SALOMEDS_SimanStudy.hxx"
+
+#include "SALOMEDS.hxx"
+#include "SALOMEDS_Study.hxx"
+
+#include "SALOMEDSImpl_Study.hxx"
+
+#include "SALOMEDS_SimanStudy_i.hxx"
+
+#include "Basics_Utils.hxx"
+
+#include "Utils_ORB_INIT.hxx"
+#include "Utils_SINGLETON.hxx"
+
+/*
+SALOMEDS_SimanStudy::SALOMEDS_SimanStudy(SALOMEDSImpl_SimanStudy* theStudy)
+{
+ _isLocal = true;
+ _local_impl = theStudy;
+ _corba_impl = SALOMEDS::SimanStudy::_nil();
+ init_orb();
+}*/
+
+SALOMEDS_SimanStudy::SALOMEDS_SimanStudy(SALOMEDS::SimanStudy_ptr theStudy)
+{
+ /*
+#ifdef WIN32
+ long pid = (long)_getpid();
+#else
+ long pid = (long)getpid();
+#endif
+
+ long addr = theStudy->GetLocalImpl(Kernel_Utils::GetHostname().c_str(), pid, _isLocal);
+ if(_isLocal) {
+ _local_impl = reinterpret_cast<SALOMEDSImpl_SimanStudy*>(addr);
+ _corba_impl = SALOMEDS::SimanStudy::_duplicate(theStudy);
+ }
+ else {
+ _local_impl = NULL;
+ _corba_impl = SALOMEDS::SimanStudy::_duplicate(theStudy);
+ }
+ */
+ _corba_impl = SALOMEDS::SimanStudy::_duplicate(theStudy);
+
+ init_orb();
+}
+
+SALOMEDS_SimanStudy::~SALOMEDS_SimanStudy()
+{
+}
+
+void SALOMEDS_SimanStudy::CheckOut(const _PTR(Study) theTarget)
+{
+ if (!theTarget) return;
+ SALOMEDS_Study* aStudy = dynamic_cast<SALOMEDS_Study*>(theTarget.get());
+ /*if (_isLocal) {
+ //SALOMEDS::Locker lock; mpv: this may cause dedlock when importData in module calls another SALOMEDS method with lock
+ _local_impl->CheckOut(aStudy->GetLocalImpl());
+ }
+ else*/ _corba_impl->CheckOut(aStudy->GetStudy());
+}
+
+void SALOMEDS_SimanStudy::CheckIn(const std::string theModuleName)
+{
+ /*if (_isLocal) {
+ //SALOMEDS::Locker lock; mpv: this may cause dedlock when getModifiedData in module calls another SALOMEDS method with lock
+ _local_impl->CheckIn(theModuleName);
+ }
+ else*/ _corba_impl->CheckIn((char*)theModuleName.c_str());
+}
+
+_PTR(Study) SALOMEDS_SimanStudy::getReferencedStudy()
+{
+ SALOMEDSClient_Study* aStudy = NULL;
+ /*if (_isLocal) {
+ SALOMEDS::Locker lock;
+
+ SALOMEDSImpl_Study* aStudy_impl = _local_impl->getReferencedStudy();
+ if (!aStudy_impl) return _PTR(Study)(aStudy);
+ aStudy = new SALOMEDS_Study(aStudy_impl);
+ }
+ else {
+ SALOMEDS::Study_var aStudy_impl = _corba_impl->getReferencedStudy();
+ if (CORBA::is_nil(aStudy_impl)) return _PTR(Study)(aStudy);
+ aStudy = new SALOMEDS_Study(aStudy_impl);
+ }*/
+ SALOMEDS::Study_var aStudy_impl = _corba_impl->getReferencedStudy();
+ if (CORBA::is_nil(aStudy_impl)) return _PTR(Study)(aStudy);
+ aStudy = new SALOMEDS_Study(aStudy_impl);
+ return _PTR(Study)(aStudy);
+}
+
+std::string SALOMEDS_SimanStudy::StudyId()
+{
+ std::string anId;
+ /*if (_isLocal) {
+ SALOMEDS::Locker lock;
+ anId = _local_impl->StudyId();
+ }
+ else*/ anId = (CORBA::String_var)_corba_impl->StudyId();
+ return anId;
+}
+
+void SALOMEDS_SimanStudy::StudyId(const std::string theId)
+{
+ /*if (_isLocal) {
+ SALOMEDS::Locker lock;
+ _local_impl->StudyId(theId);
+ }
+ else*/ _corba_impl->StudyId((char*)theId.c_str());
+}
+
+std::string SALOMEDS_SimanStudy::ScenarioId()
+{
+ std::string anId;
+ /*if (_isLocal) {
+ SALOMEDS::Locker lock;
+ anId = _local_impl->ScenarioId();
+ }
+ else*/ anId = (CORBA::String_var)_corba_impl->ScenarioId();
+ return anId;
+}
+
+void SALOMEDS_SimanStudy::ScenarioId(const std::string theId)
+{
+ /*if (_isLocal) {
+ SALOMEDS::Locker lock;
+ _local_impl->ScenarioId(theId);
+ }
+ else*/ _corba_impl->ScenarioId((char*)theId.c_str());
+}
+
+std::string SALOMEDS_SimanStudy::UserId()
+{
+ std::string anId;
+ /*if (_isLocal) {
+ SALOMEDS::Locker lock;
+ anId = _local_impl->UserId();
+ }
+ else*/ anId = (CORBA::String_var)_corba_impl->UserId();
+ return anId;
+}
+
+void SALOMEDS_SimanStudy::UserId(const std::string theId)
+{
+ /*if (_isLocal) {
+ SALOMEDS::Locker lock;
+ _local_impl->UserId(theId);
+ }
+ else*/ _corba_impl->UserId((char*)theId.c_str());
+}
+
+void SALOMEDS_SimanStudy::init_orb()
+{
+ ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance();
+ ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting());
+ _orb = init(0, 0);
+}
--- /dev/null
+// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+// File : SALOMEDS_SimanStudy.hxx
+// Author : Mikhail PONIKAROV
+// Module : SALOME
+//
+#ifndef __SALOMEDS_SIMANSTUDY_H__
+#define __SALOMEDS_SIMANSTUDY_H__
+
+#include <vector>
+#include <string>
+
+#include <DF_definitions.hxx>
+#include "SALOMEDSClient.hxx"
+//#include "SALOMEDSImpl_SimanStudy.hxx"
+
+// IDL headers
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SALOMEDS)
+
+class Standard_EXPORT SALOMEDS_SimanStudy: public SALOMEDSClient_SimanStudy
+{
+
+private:
+ // bool _isLocal;
+ //SALOMEDSImpl_SimanStudy* _local_impl; // MPV: no local implementation yet: siman operations works only with CORBA interface
+ SALOMEDS::SimanStudy_var _corba_impl;
+ CORBA::ORB_var _orb;
+
+public:
+
+ //SALOMEDS_SimanStudy(SALOMEDSImpl_SimanStudy* theStudy);
+ SALOMEDS_SimanStudy(SALOMEDS::SimanStudy_ptr theStudy);
+ ~SALOMEDS_SimanStudy();
+
+ virtual void CheckOut(const _PTR(Study) theTarget);
+ virtual void CheckIn(const std::string theModuleName);
+ virtual _PTR(Study) getReferencedStudy() ;
+ virtual std::string StudyId();
+ virtual void StudyId(const std::string theId);
+ virtual std::string ScenarioId();
+ virtual void ScenarioId(const std::string theId);
+ virtual std::string UserId();
+ virtual void UserId(const std::string theId);
+
+private:
+ void init_orb();
+
+};
+#endif
--- /dev/null
+// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+// File : SALOMEDS_SimanStudy_i.cxx
+// Author : Mikhail PONIKAROV
+// Module : SALOME
+//
+#include "SALOMEDS_SimanStudy_i.hxx"
+#include "SALOMEDS_Study_i.hxx"
+#include "SALOMEDS_Study.hxx"
+#include "SALOMEDS_Tool.hxx"
+#include "SALOME_DataContainer_i.hxx"
+#include "SALOME_NamingService.hxx"
+#include "SALOME_LifeCycleCORBA.hxx"
+#include "Basics_Utils.hxx"
+#include "Basics_DirUtils.hxx"
+#include "utilities.h"
+
+#ifdef WITH_SIMANIO
+#include <SimanIO_Link.hxx>
+#include <SimanIO_Activity.hxx>
+#endif
+
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SALOME_Component)
+
+//============================================================================
+/*! Function : SALOMEDS_SimanStudy_i
+ * Purpose : standard constructor
+ */
+//============================================================================
+SALOMEDS_SimanStudy_i::SALOMEDS_SimanStudy_i(/*SALOMEDSImpl_SimanStudy* theImpl,*/ CORBA::ORB_ptr orb)
+{
+ _orb = CORBA::ORB::_duplicate(orb);
+ _name_service = new SALOME_NamingService(_orb);
+#ifdef WITH_SIMANIO
+ _checkedOut = new SimanIO_Configuration;
+#endif
+}
+
+//============================================================================
+/*! Function : ~SALOMEDS_SimanStudy_i
+ * Purpose : standard destructor
+ */
+//============================================================================
+SALOMEDS_SimanStudy_i::~SALOMEDS_SimanStudy_i()
+{
+#ifdef WITH_SIMANIO
+ if (_checkedOut) {
+ SimanIO_Configuration::ActivitiesIterator actIter(*_checkedOut);
+ for(; actIter.More(); actIter.Next()) {
+ SimanIO_Activity::DocumentsIterator aDocIter(actIter.Activity());
+ for(; aDocIter.More(); aDocIter.Next()) {
+ SimanIO_Document& aDoc = aDocIter.Document();
+ SimanIO_Document::FilesIterator aFileIter(aDoc);
+ for(; aFileIter.More(); aFileIter.Next()) {
+ std::string aURL = aFileIter.URL();
+ std::string aDir = Kernel_Utils::GetDirName(aURL);
+ aDir += "/";
+ std::string aFileName = aURL.substr(aDir.size());
+ SALOMEDS::ListOfFileNames aTmpFiles;
+ aTmpFiles.length(1);
+ aTmpFiles[0] = aFileName.c_str();
+ // try to remove temporary directory that contains this file if directory becomes empty
+ SALOMEDS_Tool::RemoveTemporaryFiles(aDir, aTmpFiles, true);
+ }
+ }
+ }
+ delete _checkedOut;
+ }
+#endif
+ delete _name_service;
+}
+
+//============================================================================
+/*! Function : CheckOut
+ * Purpose : Get data from SIMAN and put it to the given study
+ */
+//============================================================================
+void SALOMEDS_SimanStudy_i::CheckOut(SALOMEDS::Study_ptr theTarget)
+{
+ // SimanStudy and Study must be located at the same place anyway
+ SALOMEDS_Study aStudy(theTarget);
+ _study = aStudy.GetLocalImpl();
+ if (_study) {
+#ifdef WITH_SIMANIO
+ int aLocked = _study->GetProperties()->IsLocked();
+ if (aLocked) _study->GetProperties()->SetLocked(false);
+
+ SimanIO_Link aLink(_studyId.c_str(), _scenarioId.c_str(), _userId.c_str());
+ if (aLink.IsConnected()) {
+ // Set "C" locale temporarily to avoid possible localization problems
+ Kernel_Utils::Localizer loc;
+ *_checkedOut = aLink.RetrieveConf();
+ SimanIO_Configuration::ActivitiesIterator actIter(*_checkedOut);
+ for(; actIter.More(); actIter.Next()) {
+ Engines::EngineComponent_var aComp =
+ SALOME_LifeCycleCORBA(_name_service).FindOrLoad_Component("FactoryServerPy", actIter.Activity().Module());
+ if (CORBA::is_nil(aComp)) // it is not python container, try to find in C++ container
+ SALOME_LifeCycleCORBA(_name_service).FindOrLoad_Component("FactoryServer", actIter.Activity().Module());
+ if (CORBA::is_nil(aComp)) {
+ MESSAGE("Checkout: component "<<actIter.Activity().Module()<<" is nil");
+ } else {
+ SimanIO_Activity::DocumentsIterator aDocIter(actIter.Activity());
+ for(; aDocIter.More(); aDocIter.Next()) {
+ if (_filesId.find(aDocIter.DocId()) == _filesId.end())
+ _filesId[aDocIter.DocId()] = std::map<std::string, int>();
+ SimanIO_Document& aDoc = aDocIter.Document();
+ SimanIO_Document::FilesIterator aFileIter(aDoc);
+ for(; aFileIter.More(); aFileIter.Next()) {
+ if (aFileIter.GetProcessing() == FILE_IMPORT) {
+ // files provided by SIMAN will be removed later, on study close
+ Engines::DataContainer_var aData = (new Engines_DataContainer_i(
+ aFileIter.URL(), aDoc.Name(), "", false))->_this();
+ Engines::ListOfOptions anEmptyOpts;
+ Engines::ListOfIdentifiers_var anIds = aComp->importData(_study->StudyId(), aData, anEmptyOpts);
+ for(int anIdNum = 0; anIdNum < anIds->length(); anIdNum++) {
+ const char* anId = anIds[anIdNum];
+ _filesId[aDocIter.DocId()][anId] = aFileIter.Id();
+ }
+ } else {
+ MESSAGE("!!! File just downloaded, not imported:"<<aFileIter.Id());
+ }
+ }
+ }
+ }
+ }
+ } else {
+ MESSAGE("There is no connection to SIMAN!");
+ }
+
+ if (aLocked) _study->GetProperties()->SetLocked(true);
+#endif
+ }
+}
+
+//============================================================================
+/*! Function : CheckIn
+ * Purpose : Get data from SIMAN study and stores to SIMAN
+ */
+//============================================================================
+void SALOMEDS_SimanStudy_i::CheckIn(const char* theModuleName)
+{
+ if (_study) {
+#ifdef WITH_SIMANIO
+ std::string aModuleName(theModuleName);
+ SimanIO_Link aLink(_studyId.c_str(), _scenarioId.c_str(), _userId.c_str());
+ if (aLink.IsConnected()) {
+ // Set "C" locale temporarily to avoid possible localization problems
+ Kernel_Utils::Localizer loc;
+ SimanIO_Configuration aToStore; // here create and store data in this configuration to check in to SIMAN
+ std::string aTmpDir = SALOMEDS_Tool::GetTmpDir(); // temporary directory for checked in files
+ int aFileIndex = 0; // for unique file name generation
+ std::list<std::string> aTemporaryFileNames;
+ SimanIO_Configuration::ActivitiesIterator actIter(*_checkedOut);
+ for(; actIter.More(); actIter.Next()) {
+ int aDocId = actIter.Activity().DocumentMaxID();
+ //if (aDocId < 0) continue; // no documents => no check in
+ if (!aModuleName.empty() && aModuleName != actIter.Activity().Module()) {
+ continue;
+ }
+ Engines::EngineComponent_var aComp =
+ SALOME_LifeCycleCORBA(_name_service).FindOrLoad_Component("FactoryServerPy", actIter.Activity().Module());
+ if (CORBA::is_nil(aComp)) // it is not python container, try to find in C++ container
+ SALOME_LifeCycleCORBA(_name_service).FindOrLoad_Component("FactoryServer", actIter.Activity().Module());
+ if (CORBA::is_nil(aComp)) {
+ MESSAGE("Checkin: component "<<actIter.Activity().Module()<<" is nil");
+ } else {
+ SimanIO_Document aDoc;
+ if (aDocId != -1) // get document is at least one exists in this action, "-1" is the Id of the new document otherwise
+ aDoc = actIter.Activity().Document(aDocId);
+ Engines::ListOfData_var aList = aComp->getModifiedData(_study->StudyId());
+ int aNumData = aList->length();
+ for(int aDataIndex = 0; aDataIndex < aNumData; aDataIndex++) {
+ Engines::DataContainer_var aData = aList[aDataIndex];
+ // store this in the configuration
+ SimanIO_Activity& aStoreActivity = aToStore.GetOrCreateActivity(actIter.ActivityId());
+ aStoreActivity.SetName(actIter.Activity().Name());
+ aStoreActivity.SetModule(actIter.Activity().Module());
+ SimanIO_Document& aStoreDoc = aStoreActivity.GetOrCreateDocument(aDocId);
+ aStoreDoc.SetName(aDoc.Name());
+ // prepare a file to store
+ SimanIO_File aStoreFile;
+
+ std::stringstream aNumStore;
+ aNumStore<<"file"<<(++aFileIndex);
+ std::string aFileName(aNumStore.str());
+ std::string anExtension(aData->extension());
+ aFileName += "." + anExtension;
+ std::string aFullPath = aTmpDir + aFileName;
+ Engines::TMPFile* aFileStream = aData->get();
+ const char *aBuffer = (const char*)aFileStream->NP_data();
+#ifdef WIN32
+ std::ofstream aFile(aFullPath.c_str(), std::ios::binary);
+#else
+ std::ofstream aFile(aFullPath.c_str());
+#endif
+ aFile.write(aBuffer, aFileStream->length());
+ aFile.close();
+ aTemporaryFileNames.push_back(aFileName);
+
+ aStoreFile.url = aFullPath;
+ if (_filesId[aDocId].find(aData->identifier()) != _filesId[aDocId].end()) { // file is already exists
+ aStoreFile.id = _filesId[aDocId][aData->identifier()];
+ aStoreFile.result = aDoc.File(aStoreFile.id).result;
+ } else {
+ aStoreFile.id = -1; // to be created as new
+ aStoreFile.result = true; // new is always result
+ }
+
+ aStoreDoc.AddFile(aStoreFile);
+ }
+ }
+ }
+ aLink.StoreConf(aToStore);
+ // after files have been stored, remove them from the temporary directory
+ SALOMEDS::ListOfFileNames aTmpFiles;
+ aTmpFiles.length(aTemporaryFileNames.size());
+ std::list<std::string>::const_iterator aFilesIter = aTemporaryFileNames.begin();
+ for(int a = 0; aFilesIter != aTemporaryFileNames.end(); aFilesIter++, a++) {
+ aTmpFiles[a] = aFilesIter->c_str();
+ }
+ SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir, aTmpFiles, true);
+ } else {
+ MESSAGE("There is no connection to SIMAN!")
+ }
+#endif
+ }
+}
+
+//============================================================================
+/*! Function : getReferencedStudy
+ * Purpose : Returns the %Study with checked out data
+ */
+//============================================================================
+SALOMEDS::Study_ptr SALOMEDS_SimanStudy_i::getReferencedStudy()
+{
+ SALOMEDS::Study_var aStudy = (new SALOMEDS_Study_i(_study, _orb))->_this();
+ return aStudy._retn();
+}
+
+//============================================================================
+/*! Function : StudyId
+ * Purpose : The ID of the study in SIMAN server
+ */
+//============================================================================
+char* SALOMEDS_SimanStudy_i::StudyId()
+{
+ return CORBA::string_dup(_studyId.c_str());
+}
+
+//============================================================================
+/*! Function : StudyId
+ * Purpose : The ID of the study in SIMAN server
+ */
+//============================================================================
+void SALOMEDS_SimanStudy_i::StudyId(const char* theId)
+{
+ _studyId = theId;
+}
+
+//============================================================================
+/*! Function : ScenarioId
+ * Purpose : The ID of the scenario in SIMAN server
+ */
+//============================================================================
+char* SALOMEDS_SimanStudy_i::ScenarioId()
+{
+ return CORBA::string_dup(_scenarioId.c_str());
+}
+
+//============================================================================
+/*! Function : ScenarioId
+ * Purpose : The ID of the scenario in SIMAN server
+ */
+//============================================================================
+void SALOMEDS_SimanStudy_i::ScenarioId(const char* theId)
+{
+ _scenarioId = theId;
+}
+
+//============================================================================
+/*! Function : UserId
+ * Purpose : The ID of the user in SIMAN server
+ */
+//============================================================================
+char* SALOMEDS_SimanStudy_i::UserId()
+{
+ return CORBA::string_dup(_userId.c_str());
+}
+
+//============================================================================
+/*! Function : UserId
+ * Purpose : The ID of the user in SIMAN server
+ */
+//============================================================================
+void SALOMEDS_SimanStudy_i::UserId(const char* theId)
+{
+ _userId = theId;
+}
+
+SALOMEDS_SimanStudy_i* SALOMEDS_SimanStudy_i::GetSimanServant(CORBA::ORB_ptr orb)
+{
+ static SALOMEDS_SimanStudy_i* aServant = 0;
+ if (aServant == 0) {
+ aServant = new SALOMEDS_SimanStudy_i(orb);
+ }
+ return aServant;
+}
+
+/// PRIVATE FUNCTIONS
+/*
+CORBA::LongLong SALOMEDS_SimanStudy_i::GetLocalImpl(const char* theHostname, CORBA::Long thePID, CORBA::Boolean& isLocal)
+{
+#ifdef WIN32
+ long pid = (long)_getpid();
+#else
+ long pid = (long)getpid();
+#endif
+ isLocal = (strcmp(theHostname, Kernel_Utils::GetHostname().c_str()) == 0 && pid == thePID)?1:0;
+ return reinterpret_cast<CORBA::LongLong>(_impl);
+}
+*/
--- /dev/null
+// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+// File : SALOMEDS_SimanStudy_i.hxx
+// Author : Mikhail PONIKAROV
+// Module : SALOME
+//
+#ifndef __SALOMEDS_SIMANSTUDY_I_H__
+#define __SALOMEDS_SIMANSTUDY_I_H__
+
+// IDL headers
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SALOMEDS)
+
+//SALOMEDS headers
+#include "SALOMEDS_Study_i.hxx"
+
+class SimanIO_Configuration;
+class SALOME_NamingService;
+
+class Standard_EXPORT SALOMEDS_SimanStudy_i: public POA_SALOMEDS::SimanStudy
+{
+private:
+ CORBA::ORB_var _orb;
+ SALOME_NamingService* _name_service;
+ //SALOMEDSImpl_SimanStudy* _impl;
+ SALOMEDSImpl_Study* _study;
+
+ std::string _studyId; // SIMAN ID
+ std::string _scenarioId; // SIMAN ID
+ std::string _userId; // SIMAN ID
+
+ SimanIO_Configuration* _checkedOut; // pointer to information about checked out data std::map<int, std::map<std::string, int> > _filesId; // map from document id to component identifiers to SIMAN file ID
+ std::map<int, std::map<std::string, int> > _filesId; // map from document id to component identifiers to SIMAN file ID
+
+public:
+
+ //! constructor create global Siman stduy (is called in StudyManager only)
+ SALOMEDS_SimanStudy_i(/*SALOMEDSImpl_SimanStudy*,*/ CORBA::ORB_ptr);
+
+ //! standard destructor
+ virtual ~SALOMEDS_SimanStudy_i();
+
+ /*! \brief Get data from SIMAN and put it to the given study
+
+ This method is called for just created study to make it referenced
+ by this Siman study. Also it fills this study by the checked out
+ data from SIMAN server.
+ Warning: StudyID, ScenarioID and User Id must be set before calling of this method!
+
+ \param theTarget referenced study for checking out
+ */
+ virtual void CheckOut(SALOMEDS::Study_ptr theTarget);
+
+ /*! \brief Get data from all modules and calls the corresponding SimanIO methods to store it.
+
+ It works only with already checked out study
+ */
+ virtual void CheckIn(const char* themoduleName);
+
+ /*! \brief Returns the %Study with checked out data
+
+ If study is null, there is no such study in this application instance, or Salome was
+ launched without siman option.
+ */
+ virtual SALOMEDS::Study_ptr getReferencedStudy();
+
+ /*! \brief The ID of the study in SIMAN server
+
+ Returns the Id of SIMAN study, used for CheckOut before.
+ */
+ virtual char* StudyId();
+
+ /*! \brief The ID of the study in SIMAN server
+
+ Defines the Id of SIMAN study, used for CheckOut after.
+ */
+ virtual void StudyId(const char* theId);
+
+ /*! \brief The ID of the scenario in SIMAN server
+
+ Returns the Id of SIMAN scenario, used for CheckOut before.
+ */
+ virtual char* ScenarioId();
+
+ /*! \brief The ID of the scenario in SIMAN server
+
+ Defines the Id of SIMAN scenario, used for CheckOut after.
+ */
+ virtual void ScenarioId(const char* theId);
+
+ /*! \brief The ID of the user in SIMAN server
+
+ Returns the Id of SIMAN user, used for CheckOut before.
+ */
+ virtual char* UserId();
+
+ /*! \brief The ID of the user in SIMAN server
+
+ Defines the Id of SIMAN user, used for CheckOut after.
+ */
+ virtual void UserId(const char* theId);
+
+ //virtual CORBA::LongLong GetLocalImpl(const char* theHostname, CORBA::Long thePID, CORBA::Boolean& isLocal);
+
+ static SALOMEDS_SimanStudy_i* GetSimanServant(CORBA::ORB_ptr orb);
+};
+#endif
CORBA::Object_ptr ConvertIORToObject(const std::string& theIOR);
SALOMEDS::Study_ptr GetStudy();
-
+
+ SALOMEDSImpl_Study* GetLocalImpl() { return _local_impl; }
+
private:
void init_orb();
#include "SALOMEDS.hxx"
#include "SALOMEDS_Study.hxx"
#include "SALOMEDS_SObject.hxx"
-
#include "SALOMEDS_Driver_i.hxx"
+#include "SALOMEDS_SimanStudy.hxx"
#include "SALOMEDSImpl_Study.hxx"
return driver;
}
+
+_PTR(SimanStudy) SALOMEDS_StudyManager::GetSimanStudy()
+{
+ SALOMEDSClient_SimanStudy* aSiman = NULL;
+ /*if (_isLocal) {
+ SALOMEDS::Locker lock;
+
+ SALOMEDSImpl_SimanStudy* aSiman_impl = _local_impl->GetSimanStudy();
+ if(!aSiman_impl) return _PTR(SimanStudy)(aSiman);
+ aSiman = new SALOMEDS_SimanStudy(aSiman_impl);
+ }
+ else {
+ SALOMEDS::SimanStudy_var aSiman_impl = _corba_impl->GetSimanStudy();
+ if(CORBA::is_nil(aSiman_impl)) return _PTR(SimanStudy)(aSiman);
+ aSiman = new SALOMEDS_SimanStudy(aSiman_impl);
+ }*/
+ SALOMEDS::SimanStudy_var aSiman_impl = _corba_impl->GetSimanStudy();
+ if(CORBA::is_nil(aSiman_impl)) return _PTR(SimanStudy)(aSiman);
+ aSiman = new SALOMEDS_SimanStudy(aSiman_impl);
+ return _PTR(SimanStudy)(aSiman);
+}
virtual bool Copy(const _PTR(SObject)& theSO);
virtual bool CanPaste(const _PTR(SObject)& theSO);
virtual _PTR(SObject) Paste(const _PTR(SObject)& theSO);
+ virtual _PTR(SimanStudy) GetSimanStudy();
private:
void init_orb();
#include "SALOMEDS_Study_i.hxx"
#include "SALOMEDS_SComponent_i.hxx"
#include "SALOMEDS_Driver_i.hxx"
+#include "SALOMEDS_SimanStudy_i.hxx"
#include "SALOMEDS.hxx"
#include "SALOMEDSImpl_Study.hxx"
delete _name_service;
delete _factory;
delete _impl;
+ delete SALOMEDS_SimanStudy_i::GetSimanServant(_orb);
}
//============================================================================
exit( EXIT_SUCCESS );
}
+//============================================================================
+/*! Function : GetSimanStudy
+ * Purpose : Retruns the created or cashed SimanStudy
+ */
+//============================================================================
+SALOMEDS::SimanStudy_ptr SALOMEDS_StudyManager_i::GetSimanStudy()
+{
+ SALOMEDS::Locker lock;
+
+ SALOMEDS_SimanStudy_i* aSiman_servant = SALOMEDS_SimanStudy_i::GetSimanServant(_orb);
+ return aSiman_servant->_this();
+}
+
//===========================================================================
// PRIVATE FUNCTIONS
//===========================================================================
static PortableServer::POA_ptr GetPOA(const SALOMEDS::Study_ptr theStudy);
void Shutdown() { if(!CORBA::is_nil(_orb)) _orb->shutdown(0); }
+
+ virtual SALOMEDS::SimanStudy_ptr GetSimanStudy();
};
#endif
#include "SALOMEDSClient_GenericAttribute.hxx"
#include "SALOMEDSClient_SComponent.hxx"
#include "SALOMEDSClient_SComponentIterator.hxx"
+#include "SALOMEDSClient_SimanStudy.hxx"
#include "SALOMEDSClient_SObject.hxx"
#include "SALOMEDSClient_Study.hxx"
#include "SALOMEDSClient_StudyBuilder.hxx"
--- /dev/null
+// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+// File : SALOMEDSClient_SimanStudy.hxx
+// Author : Mikhail PONIKAROV
+// Module : SALOME
+//
+#ifndef __SALOMEDSClient_SIMANSTUDY_H__
+#define __SALOMEDSClient_SIMANSTUDY_H__
+
+#include <vector>
+#include <string>
+
+#include "SALOMEDSClient_definitions.hxx"
+#include "SALOMEDSClient_Study.hxx"
+#include <SALOMEconfig.h>
+#include CORBA_CLIENT_HEADER(SALOMEDS)
+
+class SALOMEDSClient_SimanStudy
+{
+
+public:
+ virtual ~SALOMEDSClient_SimanStudy() {}
+
+ virtual void CheckOut(const _PTR(Study) theTarget) = 0;
+ virtual void CheckIn(const std::string theModuleName) = 0;
+ virtual _PTR(Study) getReferencedStudy() = 0;
+ virtual std::string StudyId() = 0;
+ virtual void StudyId(const std::string theId) = 0;
+ virtual std::string ScenarioId() = 0;
+ virtual void ScenarioId(const std::string theId) = 0;
+ virtual std::string UserId() = 0;
+ virtual void UserId(const std::string theId) = 0;
+};
+
+#endif
#include "SALOMEDSClient_definitions.hxx"
#include "SALOMEDSClient_Study.hxx"
+#include "SALOMEDSClient_SimanStudy.hxx"
class SALOMEDSClient_StudyManager
{
virtual bool Copy(const _PTR(SObject)& theSO) = 0;
virtual bool CanPaste(const _PTR(SObject)& theSO) = 0;
virtual _PTR(SObject) Paste(const _PTR(SObject)& theSO) = 0;
-
+ virtual _PTR(SimanStudy) GetSimanStudy() = 0;
};
#endif
SALOMEDSImpl_AttributeTreeNode* aNode = NULL;
if (!(aNode=(SALOMEDSImpl_AttributeTreeNode*)aLabel.FindAttribute(_root->ID()))) return false;
+ std::list<SALOMEDSImpl_SObject> aRefSOs;
std::list<SALOMEDSImpl_SObject> aNodeSOs;
- for (SALOMEDSImpl_AttributeTreeNode* aChildNode=aNode->GetFirst(); aChildNode; aChildNode=aChildNode->GetNext() ) {
- SALOMEDSImpl_SObject aSO = SALOMEDSImpl_Study::SObject(aChildNode->Label());
- if (aSO) {
- aNodeSOs.push_back(aSO);
+ for ( SALOMEDSImpl_AttributeTreeNode* aChildNode=aNode->GetFirst(); aChildNode; aChildNode=aChildNode->GetNext() ) {
+ if ( SALOMEDSImpl_SObject aSO = SALOMEDSImpl_Study::SObject( aChildNode->Label() ) ) {
+ if ( aChildNode->FindAttribute( SALOMEDSImpl_AttributeReference::GetID() ) )
+ aRefSOs.push_back( aSO );
+ else
+ aNodeSOs.push_back( aSO );
}
}
- if (aNodeSOs.empty()) return false;
-
- //sort items by names in ascending/descending order
- theAscendingOrder ? aNodeSOs.sort( AscSortSOs() ) : aNodeSOs.sort( DescSortSOs() );
-
- std::list<SALOMEDSImpl_SObject>::iterator it;
- for (it=aNodeSOs.begin(); it!=aNodeSOs.end(); ++it) {
- AppendTo(aNode->GetSObject(), *it);
+ if ( aRefSOs.empty() && aNodeSOs.empty() ) return false;
+
+ //sort items by names in ascending/descending order
+ std::list<SALOMEDSImpl_SObject>::iterator it;
+ if ( !aRefSOs.empty() ) {
+ theAscendingOrder ? aRefSOs.sort( AscSortSOs() ) : aRefSOs.sort( DescSortSOs() );
+ for ( it = aRefSOs.begin(); it != aRefSOs.end(); ++it ) {
+ AppendTo( theObject, *it );
+ }
+ }
+ if ( !aNodeSOs.empty() ) {
+ theAscendingOrder ? aNodeSOs.sort( AscSortSOs() ) : aNodeSOs.sort( DescSortSOs() );
+ for ( it = aNodeSOs.begin(); it != aNodeSOs.end(); ++it ) {
+ AppendTo( theObject, *it );
+ }
}
return true;
#include <errno.h>
#include <string.h>
-#ifndef WNT
+#ifndef WIN32
#include <unistd.h>
#else
#include <winsock2.h>
#include "SALOME_Utils.hxx"
-#include "omniORB4/CORBA.h"
+#include "omniORB4/CORBA.h"
#include "Utils_CommException.hxx"
-#ifdef WNT
+#ifdef WIN32
#pragma warning(disable:4251) // Warning DLL Interface ...
#pragma warning(disable:4290) // Warning Exception ...
#endif