From: ribes Date: Wed, 22 Oct 2008 13:23:47 +0000 (+0000) Subject: - merge + bugs for gcc-4.3.2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=afffc977abb040a67502db8a445c951acaa86d14;p=modules%2Fkernel.git - merge + bugs for gcc-4.3.2 --- diff --git a/bin/Makefile.am b/bin/Makefile.am index 077743e33..328b52a91 100644 --- a/bin/Makefile.am +++ b/bin/Makefile.am @@ -61,7 +61,7 @@ dist_salomescript_SCRIPTS = \ runSalome.py \ salomeConsole.py \ salome_session.py \ - salome_utilities.py \ + salome_utils.py \ server.py \ setenv.py \ showNS.py \ diff --git a/bin/NSparam.py b/bin/NSparam.py index 2f93c9e54..e209063ff 100755 --- a/bin/NSparam.py +++ b/bin/NSparam.py @@ -31,7 +31,7 @@ def getNSparams(info=""): elif info==port print host else print 2 strings on stdout on one line: host port """ - from salome_utilities import getORBcfgInfo + from salome_utils import getORBcfgInfo my_version, my_host, my_port = getORBcfgInfo() if info=='host': # keep print, stdout used in shell diff --git a/bin/addToKillList.py b/bin/addToKillList.py index 548a8958d..e13aebc5d 100755 --- a/bin/addToKillList.py +++ b/bin/addToKillList.py @@ -29,7 +29,7 @@ def findFileDict(): Detect current SALOME session's port number. Returns port number. """ - from salome_utilities import getPortNumber + from salome_utils import getPortNumber port = getPortNumber() if verbose(): print "myport = ", port return port diff --git a/bin/killSalome.py b/bin/killSalome.py index 1c76890a9..60529d1e7 100755 --- a/bin/killSalome.py +++ b/bin/killSalome.py @@ -29,9 +29,12 @@ def killAllPorts(): """ user = os.getenv('USER') # new-style dot-prefixed pidict file - fpidict = getPiDict('(\d*)',hidden=True) + #fpidict = getPiDict('(\d*)',hidden=True) + #problem with WIN32 path slashes + fpidict = getPiDict('#####',hidden=True) dirpidict = os.path.dirname(fpidict) fpidict = os.path.basename(fpidict) + fpidict = fpidict.replace('#####', '(\d*)') fnamere = re.compile("^%s$" % fpidict) try: for f in os.listdir(dirpidict): @@ -45,9 +48,11 @@ def killAllPorts(): except: pass # provide compatibility with old-style pidict file (not dot-prefixed) - fpidict = getPiDict('(\d*)',hidden=False) + #fpidict = getPiDict('(\d*)',hidden=False) + fpidict = getPiDict('#####',hidden=True) dirpidict = os.path.dirname(fpidict) fpidict = os.path.basename(fpidict) + fpidict = fpidict.replace('#####', '(\d*)') fnamere = re.compile("^%s$" % fpidict) try: for f in os.listdir(dirpidict): diff --git a/bin/killSalomeWithPort.py b/bin/killSalomeWithPort.py index 2308505a0..748d8e9d9 100755 --- a/bin/killSalomeWithPort.py +++ b/bin/killSalomeWithPort.py @@ -39,7 +39,7 @@ def getPiDict(port,appname='salome',full=True,hidden=True): - hidden : if True, file name is prefixed with . (dot) symbol; this internal parameter is used to support compatibility with older versions of SALOME """ - from salome_utilities import generateFileName, getTmpDir + from salome_utils import generateFileName, getTmpDir dir = "" if full: # full path to the pidict file is requested @@ -68,7 +68,7 @@ def appliCleanOmniOrbConfig(port): - ${HOME}/${APPLI}/.omniORB_last.cfg the last is removed only if the link points to the first file. """ - from salome_utilities import generateFileName + from salome_utils import generateFileName home = os.getenv("HOME") appli = os.getenv("APPLI") if appli is None: @@ -115,7 +115,7 @@ def killMyPort(port): try: fpid = open(filedict, 'r') # - from salome_utilities import generateFileName + from salome_utils import generateFileName fpidomniNames = generateFileName(os.path.join('/tmp/logs', os.getenv('USER')), prefix="", suffix="Pid_omniNames", diff --git a/bin/runSalome.py b/bin/runSalome.py index aae7d0dfa..334f5bafb 100755 --- a/bin/runSalome.py +++ b/bin/runSalome.py @@ -204,7 +204,7 @@ class LoggerServer(Server): def __init__(self,args): self.args=args self.initArgs() - from salome_utilities import generateFileName + from salome_utils import generateFileName if sys.platform == "win32": dirpath = os.environ["HOME"] else: dirpath = "/tmp" logfile = generateFileName( dirpath, @@ -749,7 +749,7 @@ def searchFreePort(args, save_config=1): if not portIsUsed(NSPORT, ports): print "%s - OK"%(NSPORT) # - from salome_utilities import generateFileName, getHostName + from salome_utils import generateFileName, getHostName hostname = getHostName() # home = os.getenv("HOME") @@ -831,7 +831,7 @@ def no_main(): def main(): """Salome launch as a main application""" import sys - from salome_utilities import getHostName + from salome_utils import getHostName print "runSalome running on %s" % getHostName() args, modules_list, modules_root_dir = setenv.get_config() kill_salome(args) diff --git a/bin/salome_session.py b/bin/salome_session.py index 64e13c951..cbf5a136f 100644 --- a/bin/salome_session.py +++ b/bin/salome_session.py @@ -39,7 +39,7 @@ def getShortHostName(): socket.gethostname() gives short or complete Hostname, depending on defined aliases. """ - from salome_utilities import getShortHostName + from salome_utils import getShortHostName return getShortHostName() def searchFreePort(): @@ -48,7 +48,7 @@ def searchFreePort(): Returns first found free port number. """ print "Searching a free port for naming service:", - from salome_utilities import generateFileName, getHostName + from salome_utils import generateFileName, getHostName hostname = getHostName() NSPORT = 2810 limit = NSPORT+100 diff --git a/bin/salome_utilities.py b/bin/salome_utilities.py deleted file mode 100644 index b4349cd20..000000000 --- a/bin/salome_utilities.py +++ /dev/null @@ -1,346 +0,0 @@ -# Copyright (C) 2005 OPEN CASCADE, CEA, EDF R&D, LEG -# PRINCIPIA R&D, EADS CCR, Lip6, BV, CEDRAT -# 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 : salome_utilities.py -# Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) -# -# --- - -""" -Set of utility functions used by SALOME python scripts. -""" - -# -# Exported functions -# -__all__ = [ - 'getORBcfgInfo', - 'getHostFromORBcfg', - 'getPortFromORBcfg', - 'getUserName', - 'getHostName', - 'getShortHostName', - 'getAppName', - 'getPortNumber', - 'getTmpDir', - 'generateFileName', - ] - -# --- - -def _try_bool( arg ): - """ - Check if specified parameter represents boolean value and returns its value. - String values like 'True', 'TRUE', 'YES', 'Yes', 'y', 'NO', 'false', 'n', etc - are supported. - If does not represent a boolean, an exception is raised. - """ - import types - if type( arg ) == types.BooleanType : - return arg - elif type( arg ) == types.StringType : - v = str( arg ).lower() - if v in [ "yes", "y", "true" ]: return True - elif v in [ "no", "n", "false" ]: return False - pass - raise Exception("Not boolean value") - -# --- - -def getORBcfgInfo(): - """ - Get omniORB current configuration. - Returns a list of three values: [ orb_version, host_name, port_number ]. - - The information is retrieved from the omniORB configuration file defined - by the OMNIORB_CONFIG environment variable. - If omniORB configuration file can not be accessed, a list of three empty - strings is returned. - """ - import os, re - ret = [ "", "", "" ] - try: - f = open( os.getenv( "OMNIORB_CONFIG" ) ) - lines = f.readlines() - f.close() - regvar = re.compile( "(ORB)?InitRef.*corbaname::(.*):(\d+)\s*$" ) - for l in lines: - try: - m = regvar.match( l ) - if m: - if m.group(1) is None: - ret[0] = "4" - else: - ret[0] = "3" - pass - ret[1] = m.group(2) - ret[2] = m.group(3) - break - pass - except: - pass - pass - pass - except: - pass - return ret - -# --- - -def getHostFromORBcfg(): - """ - Get current omniORB host. - """ - return getORBcfgInfo()[1] -# --- - -def getPortFromORBcfg(): - """ - Get current omniORB port. - """ - return getORBcfgInfo()[2] - -# --- - -def getUserName(): - """ - Get user name: - 1. try USER environment variable - 2. if fails, return 'unknown' as default user name - """ - import os - return os.getenv( "USER", "unknown" ) # 'unknown' is default user name - -# --- - -def getHostName(): - """ - Get host name: - 1. try socket python module gethostname() function - 2. if fails, try HOSTNAME environment variable - 3. if fails, try HOST environment variable - 4. if fails, return 'unknown' as default host name - """ - import os - try: - import socket - host = socket.gethostname() - except: - host = None - pass - if not host: host = os.getenv("HOSTNAME") - if not host: host = os.getenv("HOST") - if not host: host = "unknown" # 'unknown' is default host name - return host - -# --- - -def getShortHostName(): - """ - Get short host name: - 1. try socket python module gethostname() function - 2. if fails, try HOSTNAME environment variable - 3. if fails, try HOST environment variable - 4. if fails, return 'unknown' as default host name - """ - try: - return getHostName().split('.')[0] - except: - pass - return "unknown" # 'unknown' is default host name - -# --- - -def getAppName(): - """ - Get application name: - 1. try APPNAME environment variable - 2. if fails, return 'SALOME' as default application name - """ - import os - return os.getenv( "APPNAME", "SALOME" ) # 'SALOME' is default user name - -# --- - -def getPortNumber(): - """ - Get current naming server port number: - 1. try NSPORT environment variable - 1. if fails, try to parse config file defined by OMNIORB_CONFIG environment variable - 2. if fails, return 2809 as default port number - """ - import os - try: - return int( os.getenv( "NSPORT" ) ) - except: - pass - port = getPortFromORBcfg() - if port is not None: return port - return 2809 # '2809' is default port number - -# --- - -def getTmpDir(): - """ - Get directory to be used for the temporary files. - """ - import os, sys - if sys.platform == "win32": - # for Windows: temporarily using home directory for tmp files; - # to be replaced with TEMP environment variable later... - dir = os.getenv("HOME") - else: - # for Linux: use /tmp/logs/{user} folder - dir = os.path.join( '/tmp', 'logs', getUserName() ) - pass - return dir - -# --- - -def generateFileName( dir, prefix = None, suffix = None, extension = None, - unique = False, separator = "_", hidden = False, **kwargs ): - """ - Generate file name by sepecified parameters. If necessary, file name - can be generated to be unique. - - Parameters: - - dir : directory path - - prefix : file prefix (not added by default) - - suffix : file suffix (not added by default) - - extension : file extension (not added by default) - - unique : if this parameter is True, the unique file name is generated: - in this case, if the file with the generated name already exists - in the directory, an integer suffix is added to the end of the - file name. This parameter is False by default. - - separator : separator of the words ('_' by default) - - hidden : if this parameter is True, the file name is prepended by . (dot) - symbol. This parameter is False by default. - - Other keyword parameters are: - - with_username : 'add user name' flag/option: - * boolean value can be passed to determine user name automatically - * string value to be used as user name - - with_hostname : 'add host name' flag/option: - * boolean value can be passed to determine host name automatically - * string value to be used as host name - - with_port : 'add port number' flag/option: - * boolean value can be passed to determine port number automatically - * string value to be used as port number - - with_app : 'add application name' flag/option: - * boolean value can be passed to determine application name automatically - * string value to be used as application name - All parameters are optional. - """ - supported = [ 'with_username', 'with_hostname', 'with_port', 'with_app' ] - from launchConfigureParser import verbose - filename = [] - # separator - if separator is None: - separator = "" - pass - else: - separator = str( separator ) - pass - # prefix (if specified) - if prefix is not None: - filename.append( str( prefix ) ) - pass - # additional keywords - ### check unsupported parameters - for kw in kwargs: - if kw not in supported and verbose(): - print 'Warning! salome_utilitie.py: generateFileName(): parameter %s is not supported' % kw - pass - pass - ### process supported keywords - for kw in supported: - if kw not in kwargs: continue - ### user name - if kw == 'with_username': - try: - # auto user name ? - if _try_bool( kwargs[kw] ): filename.append( getUserName() ) - pass - except: - # user name given as parameter - filename.append( kwargs[kw] ) - pass - pass - ### host name - elif kw == 'with_hostname': - try: - # auto host name ? - if _try_bool( kwargs[kw] ): filename.append( getShortHostName() ) - pass - except: - # host name given as parameter - filename.append( kwargs[kw] ) - pass - pass - ### port number - elif kw == 'with_port': - try: - # auto port number ? - if _try_bool( kwargs[kw] ): filename.append( str( getPortNumber() ) ) - pass - except: - # port number given as parameter - filename.append( str( kwargs[kw] ) ) - pass - pass - ### application name - elif kw == 'with_app': - try: - # auto application name ? - if _try_bool( kwargs[kw] ): filename.append( getAppName() ) - pass - except: - # application name given as parameter - filename.append( kwargs[kw] ) - pass - pass - pass - # suffix (if specified) - if suffix is not None: - filename.append( str( suffix ) ) - pass - # raise an exception if file name is empty - if not filename: - raise Exception("Empty file name") - # - if extension is not None and extension.startswith("."): extension = extension[1:] - # - import os - name = separator.join( filename ) - if hidden: name = "." + name # add dot for hidden files - if extension: name = name + "." + str( extension ) # add extension if defined - name = os.path.join( dir, name ) - if unique: - # create unique file name - index = 0 - while os.path.exists( name ): - index = index + 1 - name = separator.join( filename ) + separator + str( index ) - if hidden: name = "." + name # add dot for hidden files - if extension: name = name + "." + str( extension ) # add extension if defined - name = os.path.join( dir, name ) - pass - pass - return name diff --git a/bin/salome_utils.py b/bin/salome_utils.py new file mode 100644 index 000000000..7b3aadeac --- /dev/null +++ b/bin/salome_utils.py @@ -0,0 +1,346 @@ +# Copyright (C) 2005 OPEN CASCADE, CEA, EDF R&D, LEG +# PRINCIPIA R&D, EADS CCR, Lip6, BV, CEDRAT +# 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 : salome_utils.py +# Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) +# +# --- + +""" +Set of utility functions used by SALOME python scripts. +""" + +# +# Exported functions +# +__all__ = [ + 'getORBcfgInfo', + 'getHostFromORBcfg', + 'getPortFromORBcfg', + 'getUserName', + 'getHostName', + 'getShortHostName', + 'getAppName', + 'getPortNumber', + 'getTmpDir', + 'generateFileName', + ] + +# --- + +def _try_bool( arg ): + """ + Check if specified parameter represents boolean value and returns its value. + String values like 'True', 'TRUE', 'YES', 'Yes', 'y', 'NO', 'false', 'n', etc + are supported. + If does not represent a boolean, an exception is raised. + """ + import types + if type( arg ) == types.BooleanType : + return arg + elif type( arg ) == types.StringType : + v = str( arg ).lower() + if v in [ "yes", "y", "true" ]: return True + elif v in [ "no", "n", "false" ]: return False + pass + raise Exception("Not boolean value") + +# --- + +def getORBcfgInfo(): + """ + Get omniORB current configuration. + Returns a list of three values: [ orb_version, host_name, port_number ]. + + The information is retrieved from the omniORB configuration file defined + by the OMNIORB_CONFIG environment variable. + If omniORB configuration file can not be accessed, a list of three empty + strings is returned. + """ + import os, re + ret = [ "", "", "" ] + try: + f = open( os.getenv( "OMNIORB_CONFIG" ) ) + lines = f.readlines() + f.close() + regvar = re.compile( "(ORB)?InitRef.*corbaname::(.*):(\d+)\s*$" ) + for l in lines: + try: + m = regvar.match( l ) + if m: + if m.group(1) is None: + ret[0] = "4" + else: + ret[0] = "3" + pass + ret[1] = m.group(2) + ret[2] = m.group(3) + break + pass + except: + pass + pass + pass + except: + pass + return ret + +# --- + +def getHostFromORBcfg(): + """ + Get current omniORB host. + """ + return getORBcfgInfo()[1] +# --- + +def getPortFromORBcfg(): + """ + Get current omniORB port. + """ + return getORBcfgInfo()[2] + +# --- + +def getUserName(): + """ + Get user name: + 1. try USER environment variable + 2. if fails, return 'unknown' as default user name + """ + import os + return os.getenv( "USER", "unknown" ) # 'unknown' is default user name + +# --- + +def getHostName(): + """ + Get host name: + 1. try socket python module gethostname() function + 2. if fails, try HOSTNAME environment variable + 3. if fails, try HOST environment variable + 4. if fails, return 'unknown' as default host name + """ + import os + try: + import socket + host = socket.gethostname() + except: + host = None + pass + if not host: host = os.getenv("HOSTNAME") + if not host: host = os.getenv("HOST") + if not host: host = "unknown" # 'unknown' is default host name + return host + +# --- + +def getShortHostName(): + """ + Get short host name: + 1. try socket python module gethostname() function + 2. if fails, try HOSTNAME environment variable + 3. if fails, try HOST environment variable + 4. if fails, return 'unknown' as default host name + """ + try: + return getHostName().split('.')[0] + except: + pass + return "unknown" # 'unknown' is default host name + +# --- + +def getAppName(): + """ + Get application name: + 1. try APPNAME environment variable + 2. if fails, return 'SALOME' as default application name + """ + import os + return os.getenv( "APPNAME", "SALOME" ) # 'SALOME' is default user name + +# --- + +def getPortNumber(): + """ + Get current naming server port number: + 1. try NSPORT environment variable + 1. if fails, try to parse config file defined by OMNIORB_CONFIG environment variable + 2. if fails, return 2809 as default port number + """ + import os + try: + return int( os.getenv( "NSPORT" ) ) + except: + pass + port = getPortFromORBcfg() + if port is not None: return port + return 2809 # '2809' is default port number + +# --- + +def getTmpDir(): + """ + Get directory to be used for the temporary files. + """ + import os, sys + if sys.platform == "win32": + # for Windows: temporarily using home directory for tmp files; + # to be replaced with TEMP environment variable later... + dir = os.getenv("HOME") + else: + # for Linux: use /tmp/logs/{user} folder + dir = os.path.join( '/tmp', 'logs', getUserName() ) + pass + return dir + +# --- + +def generateFileName( dir, prefix = None, suffix = None, extension = None, + unique = False, separator = "_", hidden = False, **kwargs ): + """ + Generate file name by sepecified parameters. If necessary, file name + can be generated to be unique. + + Parameters: + - dir : directory path + - prefix : file prefix (not added by default) + - suffix : file suffix (not added by default) + - extension : file extension (not added by default) + - unique : if this parameter is True, the unique file name is generated: + in this case, if the file with the generated name already exists + in the directory, an integer suffix is added to the end of the + file name. This parameter is False by default. + - separator : separator of the words ('_' by default) + - hidden : if this parameter is True, the file name is prepended by . (dot) + symbol. This parameter is False by default. + + Other keyword parameters are: + - with_username : 'add user name' flag/option: + * boolean value can be passed to determine user name automatically + * string value to be used as user name + - with_hostname : 'add host name' flag/option: + * boolean value can be passed to determine host name automatically + * string value to be used as host name + - with_port : 'add port number' flag/option: + * boolean value can be passed to determine port number automatically + * string value to be used as port number + - with_app : 'add application name' flag/option: + * boolean value can be passed to determine application name automatically + * string value to be used as application name + All parameters are optional. + """ + supported = [ 'with_username', 'with_hostname', 'with_port', 'with_app' ] + from launchConfigureParser import verbose + filename = [] + # separator + if separator is None: + separator = "" + pass + else: + separator = str( separator ) + pass + # prefix (if specified) + if prefix is not None: + filename.append( str( prefix ) ) + pass + # additional keywords + ### check unsupported parameters + for kw in kwargs: + if kw not in supported and verbose(): + print 'Warning! salome_utilitie.py: generateFileName(): parameter %s is not supported' % kw + pass + pass + ### process supported keywords + for kw in supported: + if kw not in kwargs: continue + ### user name + if kw == 'with_username': + try: + # auto user name ? + if _try_bool( kwargs[kw] ): filename.append( getUserName() ) + pass + except: + # user name given as parameter + filename.append( kwargs[kw] ) + pass + pass + ### host name + elif kw == 'with_hostname': + try: + # auto host name ? + if _try_bool( kwargs[kw] ): filename.append( getShortHostName() ) + pass + except: + # host name given as parameter + filename.append( kwargs[kw] ) + pass + pass + ### port number + elif kw == 'with_port': + try: + # auto port number ? + if _try_bool( kwargs[kw] ): filename.append( str( getPortNumber() ) ) + pass + except: + # port number given as parameter + filename.append( str( kwargs[kw] ) ) + pass + pass + ### application name + elif kw == 'with_app': + try: + # auto application name ? + if _try_bool( kwargs[kw] ): filename.append( getAppName() ) + pass + except: + # application name given as parameter + filename.append( kwargs[kw] ) + pass + pass + pass + # suffix (if specified) + if suffix is not None: + filename.append( str( suffix ) ) + pass + # raise an exception if file name is empty + if not filename: + raise Exception("Empty file name") + # + if extension is not None and extension.startswith("."): extension = extension[1:] + # + import os + name = separator.join( filename ) + if hidden: name = "." + name # add dot for hidden files + if extension: name = name + "." + str( extension ) # add extension if defined + name = os.path.join( dir, name ) + if unique: + # create unique file name + index = 0 + while os.path.exists( name ): + index = index + 1 + name = separator.join( filename ) + separator + str( index ) + if hidden: name = "." + name # add dot for hidden files + if extension: name = name + "." + str( extension ) # add extension if defined + name = os.path.join( dir, name ) + pass + pass + return name diff --git a/bin/virtual_salome.py b/bin/virtual_salome.py index 401b9ccab..37c286929 100644 --- a/bin/virtual_salome.py +++ b/bin/virtual_salome.py @@ -97,11 +97,31 @@ def link_module(options): return home_dir = os.path.expanduser(options.prefix) + #try to find python version of salome application and put it in versio + pys=[os.path.split(s)[1] for s in glob.glob(os.path.join(home_dir,get_lib_dir(),"python*.*"))] + if not pys : + versio=None + else: + versio=pys[0] + + pys=[os.path.split(s)[1] for s in glob.glob(os.path.join(module_dir,get_lib_dir(),"python*.*"))] + #check if the module has a python version compatible with application version + if not pys : + pyversio=versio or py_version + elif versio is None: + pyversio=pys[0] + elif versio in pys: + pyversio=versio + else: + #incompatible python versions + print "incompatible python versions : application has version %s and module %s has not" % (versio,module_dir) + return module_bin_dir=os.path.join(module_dir,'bin','salome') + module_idl_dir=os.path.join(module_dir,'idl','salome') module_lib_dir=os.path.join(module_dir,get_lib_dir(),'salome') - module_lib_py_dir=os.path.join(module_dir,get_lib_dir(),py_version,'site-packages','salome') - module_lib_py_shared_dir=os.path.join(module_dir,get_lib_dir(),py_version, + module_lib_py_dir=os.path.join(module_dir,get_lib_dir(),pyversio,'site-packages','salome') + module_lib_py_shared_dir=os.path.join(module_dir,get_lib_dir(),pyversio, 'site-packages','salome','shared_modules') module_share_dir=os.path.join(module_dir,'share','salome','resources') module_doc_gui_dir=os.path.join(module_dir,'doc','salome','gui') @@ -112,9 +132,10 @@ def link_module(options): module_sharedoc_tui_dir=os.path.join(module_dir,'share','doc','salome','tui') bin_dir=os.path.join(home_dir,'bin','salome') + idl_dir=os.path.join(home_dir,'idl','salome') lib_dir=os.path.join(home_dir,'lib','salome') - lib_py_dir=os.path.join(home_dir,'lib',py_version,'site-packages','salome') - lib_py_shared_dir=os.path.join(home_dir,'lib',py_version, + lib_py_dir=os.path.join(home_dir,'lib',pyversio,'site-packages','salome') + lib_py_shared_dir=os.path.join(home_dir,'lib',pyversio, 'site-packages','salome','shared_modules') share_dir=os.path.join(home_dir,'share','salome','resources') doc_gui_dir=os.path.join(home_dir,'doc','salome','gui') @@ -128,6 +149,7 @@ def link_module(options): if options.clear: rmtree(bin_dir) + rmtree(idl_dir) rmtree(lib_dir) rmtree(lib_py_dir) rmtree(share_dir) @@ -146,6 +168,14 @@ def link_module(options): print module_bin_dir, " doesn't exist" pass + #directory idl/salome : create it and link content + if os.path.exists(module_idl_dir): + mkdir(idl_dir) + for fn in os.listdir(module_idl_dir): + symlink(os.path.join(module_idl_dir, fn), os.path.join(idl_dir, fn)) + else: + print module_idl_dir, " doesn't exist" + #directory lib/salome : create it and link content if os.path.exists(module_lib_dir): mkdir(lib_dir) @@ -157,7 +187,7 @@ def link_module(options): print module_lib_dir, " doesn't exist" pass - #directory lib/py_version/site-packages/salome : create it and link content + #directory lib/pyversio/site-packages/salome : create it and link content if not os.path.exists(module_lib_py_dir): print "Python directory %s does not exist" % module_lib_py_dir else: diff --git a/salome_adm/unix/Makefile.am b/salome_adm/unix/Makefile.am index 0597e7822..0f2178539 100644 --- a/salome_adm/unix/Makefile.am +++ b/salome_adm/unix/Makefile.am @@ -40,17 +40,17 @@ mostlyclean-local: -rm -rf SALOMEconfig.h SALOMEconfig.h.in SALOMEconfig.h.in : SALOMEconfig.ref.in - cp -p $< $@; + cp -pf $< $@; # test if SALOMEconfig.ref has changed (contents), at build time SALOMEconfig.h: $(top_builddir)/salome_adm/unix/SALOMEconfig.ref - @if ! [ -a $@ ]; then \ - echo cp -p $< $@; \ - cp -p $< $@; \ - fi; \ + @if ! [ -a $@ ]; then \ + echo cp -pf $< $@; \ + cp -pf $< $@; \ + fi; \ if ! cmp -s $< $@; then \ - echo cp -p $< $@; \ - cp -p $< $@; \ + echo cp -pf $< $@; \ + cp -pf $< $@; \ fi; # The deprecated files are deprecated for the KERNEL but not for the diff --git a/src/Basics/BasicsGenericDestructor.cxx b/src/Basics/BasicsGenericDestructor.cxx index deca0e9c9..4f6cf3397 100644 --- a/src/Basics/BasicsGenericDestructor.cxx +++ b/src/Basics/BasicsGenericDestructor.cxx @@ -37,7 +37,7 @@ using namespace std; void HouseKeeping(); std::list PROTECTED_DELETE::_objList; -#ifndef WNT +#ifndef WIN32 pthread_mutex_t PROTECTED_DELETE::_listMutex; #else pthread_mutex_t PROTECTED_DELETE::_listMutex = diff --git a/src/Basics/BasicsGenericDestructor.hxx b/src/Basics/BasicsGenericDestructor.hxx index 9ccbb1749..36919df09 100644 --- a/src/Basics/BasicsGenericDestructor.hxx +++ b/src/Basics/BasicsGenericDestructor.hxx @@ -29,23 +29,7 @@ #ifndef _BASICGENERICDESTRUCTOR_HXX_ #define _BASICGENERICDESTRUCTOR_HXX_ -#ifdef WNT - #if defined BASICS_EXPORTS - #if defined WIN32 - #define BASICS_EXPORT __declspec( dllexport ) - #else - #define BASICS_EXPORT - #endif - #else - #if defined WIN32 - #define BASICS_EXPORT __declspec( dllimport ) - #else - #define BASICS_EXPORT - #endif - #endif -#else - #define BASICS_EXPORT -#endif +#include "SALOME_Basics.hxx" #include #include diff --git a/src/Basics/Basics_DirUtils.cxx b/src/Basics/Basics_DirUtils.cxx new file mode 100644 index 000000000..f8591c573 --- /dev/null +++ b/src/Basics/Basics_DirUtils.cxx @@ -0,0 +1,263 @@ +// Copyright (C) 2003 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 : Basics_DirUtils.cxx +// Autor : Alexander A. BORODIN +// Module : SALOME + +#include "Basics_DirUtils.hxx" + +#include +#include + +#ifndef WIN32 +# include +# include +#else +# include +# include +#endif + +using namespace std; + +#ifdef WIN32 +# define _separator_ '\\' +#else +# define _separator_ '/' +#endif + +namespace Kernel_Utils +{ + string GetTmpDirByEnv( const std::string& tmp_path_env ) + { + string dir; + char* val = getenv( tmp_path_env.c_str() ); + val ? dir = string( val ) : ""; + return GetTmpDirByPath( dir ); + } + + string GetTmpDirByPath( const std::string& tmp_path ) + { + string aTmpDir = tmp_path; + if ( aTmpDir == "" ) + { +#ifdef WIN32 + char *Tmp_dir = getenv("TEMP"); + if( Tmp_dir == NULL ) + { + Tmp_dir = getenv("TMP"); + if (Tmp_dir == NULL) + aTmpDir = string("C:\\"); + else + aTmpDir = string(Tmp_dir); + } + else + aTmpDir = string(Tmp_dir); +#else + aTmpDir = string("/tmp/"); +#endif + } + + if(aTmpDir[aTmpDir.size()-1] != _separator_) + aTmpDir+=_separator_; + + srand((unsigned int)time(NULL)); + int aRND = 999 + (int)(100000.0*rand()/(RAND_MAX+1.0)); //Get a random number to present a name of a sub directory + char buffer[127]; + sprintf(buffer, "%d", aRND); + string aSubDir(buffer); + if(aSubDir.size() <= 1) aSubDir = string("123409876"); + + aTmpDir += aSubDir; //Get RND sub directory + + string aDir = aTmpDir; + + if(IsExists(aDir)) { + for(aRND = 0; IsExists(aDir); aRND++) { + sprintf(buffer, "%d", aRND); + aDir = aTmpDir+buffer; //Build a unique directory name + } + } + + if(aDir[aDir.size()-1] != _separator_) aDir += _separator_; + +#ifdef WIN32 + CreateDirectory(aDir.c_str(), NULL); +#else + mkdir(aDir.c_str(), 0x1ff); +#endif + + return aDir; + } + + //============================================================================ + // function : GetTempDir + // purpose : Returns a temp directory to store created files like "/tmp/sub_dir/" + //============================================================================ + string GetTmpDir() + { + return GetTmpDirByPath( "" ); + } + + //============================================================================ + // function : GetTempFileName + // purpose : Returns the unique temporary file name without any extension /tmp/something/file for Unix or c:\something\file for WIN32 + //============================================================================ + string GetTmpFileName() + { + string tmpDir = GetTmpDir(); + string aFilePath = ""; + if(IsExists(tmpDir)) { + srand((unsigned int)time(NULL)); + int aRND = 999 + (int)(100000.0*rand()/(RAND_MAX+1.0)); //Get a random number to present a name of a sub directory + char buffer[127]; + sprintf(buffer, "%d", aRND); + string aSubDir(buffer); + if(aSubDir.size() <= 1) aSubDir = string("123409876"); + + aFilePath = tmpDir; + for(aRND = 0; IsExists(aFilePath); aRND++) { + sprintf(buffer, "%d", aRND); + aFilePath = tmpDir+buffer; //Build a unique file name + } + } + return aFilePath; + } + + //============================================================================ + // function : IsExists + // purpose : Returns True(False) if the path (not)exists + //============================================================================ + bool IsExists(const string& thePath) + { +#ifdef WIN32 + if ( GetFileAttributes ( thePath.c_str() ) == 0xFFFFFFFF ) { + if ( GetLastError () == ERROR_FILE_NOT_FOUND ) { + return false; + } + } +#else + int status = access ( thePath.c_str() , F_OK ); + if (status != 0) return false; +#endif + return true; + } + + //============================================================================ + // function : GetDirByPath + // purpose : Returns directory by path and converts it to native system format + //============================================================================ + string GetDirByPath(const string& thePath) + { + if (thePath.empty()) + return ""; + string path = thePath; + string::size_type length = path.length(); + + //detect all separators in Unix format + for ( int i = 0; i < length; i++ ) + { + if( path[i] == '/' ) + path[i] = '|'; + } + + //detect all separators in Windows format + for ( int i = 0; i < length; i++ ) + { + if( path[i] == '\\' ) + path[i] = '|'; + } + + + string::size_type pos = path.rfind('|'); + if ( pos == string::npos ) + { +#ifdef WIN32 + //check for disk letter ( C: ) + if ( path.length() == 2 && path[1] == ':' ) + path += _separator_; +#else + //not valid path + return ""; +#endif + } + else + { + //remove right subdirectory or filename from path + path = path.substr( 0, pos ); + } + + length = path.length(); + for ( int i = 0; i < length; i++ ) + { + if( path[i] == '|' ) + path[i] = _separator_; + } + return path; + } + + //============================================================================ + // function : IsEmptyDir + // purpose : Returns True(False) if the path (not) empty + // Also returns False if the path is not valid + //============================================================================ + bool IsEmptyDir(const string& thePath) + { + if ( thePath.empty() || !IsExists(thePath)) + return false; + + bool result = false; + +#ifdef WIN32 + WIN32_FIND_DATA aFileData; + HANDLE hFile = FindFirstFile( thePath.c_str(), &aFileData ); + if ( hFile == INVALID_HANDLE_VALUE ) + { + //empty dir + result = true; + } + else + { + //close serching. path is not empty + FindClose( hFile ); + } +#else + DIR *dp; + struct dirent *dirp; + if((dp = opendir(thePath.c_str())) == NULL) + { + //Could not open directory + return false; + } + else + { + result = true; //empty if no file found + while ((dirp = readdir(dp)) != NULL && result ) + { + string file_name(dirp->d_name); + result = file_name.empty() || file_name == "." || file_name == ".."; //if any file - break and return false + } + closedir(dp); + } +#endif + return result; + } +} diff --git a/src/Basics/Basics_DirUtils.hxx b/src/Basics/Basics_DirUtils.hxx new file mode 100644 index 000000000..5a64a84f9 --- /dev/null +++ b/src/Basics/Basics_DirUtils.hxx @@ -0,0 +1,65 @@ +// SALOME Utils : general SALOME's definitions and tools +// +// Copyright (C) 2003 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 : Basics_DirUtils.hxx +// Autor : Alexander A. BORODIN +// Module : SALOME + +#ifndef _Basics_DIRUTILS_HXX_ +#define _Basics_DIRUTILS_HXX_ + +#include "SALOME_Basics.hxx" + +#include + +namespace Kernel_Utils +{ + // Returns the unique temporary directory, that is defined in tmp_path_env if this variable is set + // otherwise return /tmp/something/ for Unix or c:\something\ for WIN32 + BASICS_EXPORT std::string GetTmpDirByEnv( const std::string& tmp_path_env ); + + // Returns the unique temporary directory, that is defined in tmp_path if this variable is set + // otherwise return /tmp/something/ for Unix or c:\something\ for WIN32 + BASICS_EXPORT std::string GetTmpDirByPath( const std::string& tmp_path ); + + // Returns the unique temporary directory in + // /tmp/something/ for Unix or c:\something\ for WIN32 + BASICS_EXPORT std::string GetTmpDir(); + + + // Returns the unique temporary file name without any extension + // /tmp/something/file for Unix or c:\something\file for WIN32 + BASICS_EXPORT std::string GetTmpFileName(); + + // Returns True(False) if the path (not)exists + BASICS_EXPORT bool IsExists( const std::string& path ); + + // Returns directory by path and converts it to native system format + BASICS_EXPORT std::string GetDirByPath( const std::string& path ); + + // Returns True(False) if the path (not) empty + // Also returns False if the path is not valid + BASICS_EXPORT bool IsEmptyDir( const std::string& path ); +} + +#endif diff --git a/src/Basics/Basics_Utils.cxx b/src/Basics/Basics_Utils.cxx new file mode 100644 index 000000000..8a080f7db --- /dev/null +++ b/src/Basics/Basics_Utils.cxx @@ -0,0 +1,85 @@ +// Copyright (C) 2003 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 : Basics_Utils.cxx +// Autor : Alexander A. BORODIN +// Module : SALOME + +#include "Basics_Utils.hxx" +#include + +#ifndef WIN32 +#include +#include +#else +#include +#endif + +using namespace std; + +namespace Kernel_Utils +{ + string GetHostname() + { + int ls = 100, r = 1; + char *s; + + while (ls < 10000 && r) + { + ls *= 2; + s = new char[ls]; + r = gethostname(s, ls-1); + switch (r) + { + case 0: + break; + default: +#ifdef EINVAL + case EINVAL: +#endif +#ifdef ENAMETOOLONG + case ENAMETOOLONG: +#endif +#ifdef WIN32 + case WSAEFAULT: +#endif + delete [] s; + continue; + } + + } + + if (r != 0) + { + s = new char[50]; + strcpy(s, "localhost"); + } + + // remove all after '.' + char *aDot = (strchr(s,'.')); + if (aDot) aDot[0] = '\0'; + + string p = s; + delete [] s; + return p; + } + +} diff --git a/src/Basics/Basics_Utils.hxx b/src/Basics/Basics_Utils.hxx new file mode 100644 index 000000000..9fb86c68b --- /dev/null +++ b/src/Basics/Basics_Utils.hxx @@ -0,0 +1,40 @@ +// SALOME Utils : general SALOME's definitions and tools +// +// Copyright (C) 2003 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 : Basics_DirUtils.hxx +// Autor : Alexander A. BORODIN +// Module : SALOME + +#ifndef _Basics_UTILS_HXX_ +#define _Basics_UTILS_HXX_ + +#include "SALOME_Basics.hxx" + +#include + +namespace Kernel_Utils +{ + BASICS_EXPORT std::string GetHostname(); +} + +#endif //_Basics_UTILS_HXX_ diff --git a/src/Basics/Makefile.am b/src/Basics/Makefile.am index 02dc1f1f4..4e4ba8061 100644 --- a/src/Basics/Makefile.am +++ b/src/Basics/Makefile.am @@ -28,11 +28,20 @@ include $(top_srcdir)/salome_adm/unix/make_common_starter.am -salomeinclude_HEADERS = BasicsGenericDestructor.hxx +salomeinclude_HEADERS = \ + SALOME_Basics.hxx \ + BasicsGenericDestructor.hxx \ + Basics_Utils.hxx \ + Basics_DirUtils.hxx lib_LTLIBRARIES = libSALOMEBasics.la libSALOMEBasics_la_SOURCES = \ BasicsGenericDestructor.cxx \ - BasicsGenericDestructor.hxx + Basics_Utils.cxx \ + Basics_DirUtils.cxx \ + SALOME_Basics.hxx \ + BasicsGenericDestructor.hxx \ + Basics_Utils.hxx \ + Basics_DirUtils.hxx libSALOMEBasics_la_LDFLAGS = -no-undefined -version-info=0:0:0 libSALOMEBasics_la_CPPFLAGS = @CPPFLAGS@ diff --git a/src/Basics/SALOME_Basics.hxx b/src/Basics/SALOME_Basics.hxx new file mode 100644 index 000000000..bbbb47227 --- /dev/null +++ b/src/Basics/SALOME_Basics.hxx @@ -0,0 +1,43 @@ +// SALOME Basics : general SALOME definitions and tools (C++ part - no CORBA) +// +// Copyright (C) 2003 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 : SALOME_Basics.hxx +// Author : Alexander A. BORODIN +// Module : SALOME +// $Header$ + +#ifndef _SALOME_BASICS_HXX_ +#define _SALOME_BASICS_HXX_ + + +#ifdef WIN32 +# ifdef BASICS_EXPORTS +# define BASICS_EXPORT __declspec( dllexport ) +# else +# define BASICS_EXPORT __declspec( dllimport ) +# endif +#else +# define BASICS_EXPORT +#endif + +#endif //_SALOME_BASICS_HXX_ diff --git a/src/Batch/Batch_APIInternalFailureException.hxx b/src/Batch/Batch_APIInternalFailureException.hxx index 4e5d57457..cb8bb1be8 100644 --- a/src/Batch/Batch_APIInternalFailureException.hxx +++ b/src/Batch/Batch_APIInternalFailureException.hxx @@ -30,13 +30,14 @@ #ifndef _APIINTERNALFAILUREEXCEPTION_H_ #define _APIINTERNALFAILUREEXCEPTION_H_ +#include "Batch_Defines.hxx" #include "Batch_GenericException.hxx" #include "Batch_GenericException.hxx" namespace Batch { - class APIInternalFailureException : public GenericException + class BATCH_EXPORT APIInternalFailureException : public GenericException { public: // Constructeur diff --git a/src/Batch/Batch_BatchManager.cxx b/src/Batch/Batch_BatchManager.cxx index 8d3965274..650642008 100644 --- a/src/Batch/Batch_BatchManager.cxx +++ b/src/Batch/Batch_BatchManager.cxx @@ -29,7 +29,12 @@ #include #include #include -#include +#ifdef WIN32 +# include +#else +# include +#endif + //#include "MEDMEM_STRING.hxx" #include "Batch_Job.hxx" #include "Batch_JobId.hxx" diff --git a/src/Batch/Batch_BatchManager.hxx b/src/Batch/Batch_BatchManager.hxx index a1f84bfed..c00f70c0d 100644 --- a/src/Batch/Batch_BatchManager.hxx +++ b/src/Batch/Batch_BatchManager.hxx @@ -29,9 +29,7 @@ #ifndef _BATCHMANAGER_H_ #define _BATCHMANAGER_H_ -#include -#include -#include +#include "Batch_Defines.hxx" #include #include @@ -47,7 +45,7 @@ namespace Batch { class JobInfo; class FactBatchManager; - class BatchManager + class BATCH_EXPORT BatchManager { public: // Constructeur et destructeur diff --git a/src/Batch/Batch_BatchManagerCatalog.hxx b/src/Batch/Batch_BatchManagerCatalog.hxx index 81ab713ec..d19ae24e3 100644 --- a/src/Batch/Batch_BatchManagerCatalog.hxx +++ b/src/Batch/Batch_BatchManagerCatalog.hxx @@ -29,6 +29,8 @@ #ifndef _CATALOG_H_ #define _CATALOG_H_ +#include "Batch_Defines.hxx" + #include #include #include @@ -37,7 +39,7 @@ namespace Batch { class FactBatchManager; - class BatchManagerCatalog + class BATCH_EXPORT BatchManagerCatalog { public: // Constructeur diff --git a/src/Batch/Batch_BatchManager_LSF.cxx b/src/Batch/Batch_BatchManager_LSF.cxx index 301f2eeb0..29f17e21e 100644 --- a/src/Batch/Batch_BatchManager_LSF.cxx +++ b/src/Batch/Batch_BatchManager_LSF.cxx @@ -34,8 +34,11 @@ extern "C" { #include #include #include +#include #include "Batch_BatchManager_LSF.hxx" +using namespace std; + namespace Batch { BatchManager_LSF::BatchManager_LSF(const FactBatchManager * parent, const char * host) throw(InvalidArgumentException,ConnexionFailureException) : BatchManager(parent, host) diff --git a/src/Batch/Batch_BatchManager_LSF.hxx b/src/Batch/Batch_BatchManager_LSF.hxx index 170dbd791..e81f2df9d 100644 --- a/src/Batch/Batch_BatchManager_LSF.hxx +++ b/src/Batch/Batch_BatchManager_LSF.hxx @@ -30,6 +30,7 @@ #ifndef _BATCHMANAGER_LSF_H_ #define _BATCHMANAGER_LSF_H_ +#include "Batch_Defines.hxx" #include "Batch_Job.hxx" #include "Batch_Job.hxx" @@ -50,7 +51,7 @@ namespace Batch { class JobInfo; class FactBatchManager; - class BatchManager_LSF : public BatchManager + class BATCH_EXPORT BatchManager_LSF : public BatchManager { public: // Constructeur et destructeur diff --git a/src/Batch/Batch_BatchManager_Local.cxx b/src/Batch/Batch_BatchManager_Local.cxx index 5359c3d1c..20656bf8a 100644 --- a/src/Batch/Batch_BatchManager_Local.cxx +++ b/src/Batch/Batch_BatchManager_Local.cxx @@ -17,23 +17,29 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // /* - * BatchManager_Local.cxx : - * - * Auteur : Ivan DUTKA-MALEN - EDF R&D - * Mail : mailto:ivan.dutka-malen@der.edf.fr - * Date : Thu Nov 6 10:17:22 2003 - * Projet : Salome 2 - * - */ +* BatchManager_Local.cxx : +* +* Auteur : Ivan DUTKA-MALEN - EDF R&D +* Mail : mailto:ivan.dutka-malen@der.edf.fr +* Date : Thu Nov 6 10:17:22 2003 +* Projet : Salome 2 +* +*/ #include #include #include #include +#include + #include -#include +#ifdef WIN32 +# include +#else +# include +# include +#endif #include -#include #include #include #include @@ -41,11 +47,16 @@ #include "Batch_IOMutex.hxx" #include "Batch_BatchManager_Local.hxx" +using namespace std; + namespace Batch { // Constructeur - BatchManager_Local::BatchManager_Local(const FactBatchManager * parent, const char * host) throw(InvalidArgumentException,ConnexionFailureException) : BatchManager(parent, host), _connect(0), _threads_mutex(), _threads(), _thread_id_id_association_mutex(), _thread_id_id_association_cond(), _thread_id_id_association() + BatchManager_Local::BatchManager_Local(const FactBatchManager * parent, const char * host) throw(InvalidArgumentException,ConnexionFailureException) : BatchManager(parent, host), _connect(0), _threads_mutex(), _threads(), _thread_id_id_association_mutex(), _thread_id_id_association_cond() +#ifndef WIN32 //TODO: porting of following functionality + ,_thread_id_id_association() +#endif { pthread_mutex_init(&_threads_mutex, NULL); pthread_mutex_init(&_thread_id_id_association_mutex, NULL); @@ -95,7 +106,7 @@ namespace Batch { cancel(thread_id); } - + // Methode pour le controle des jobs : suspend un job en file d'attente void BatchManager_Local::holdJob(const JobId & jobid) { @@ -129,8 +140,8 @@ namespace Batch { if (_threads.find(id) != _threads.end()) _threads[id].command_queue.push(RELEASE); pthread_mutex_unlock(&_threads_mutex); - // @@@ --------> SECTION CRITIQUE <-------- @@@ - } + // @@@ --------> SECTION CRITIQUE <-------- @@@ + } // Methode pour le controle des jobs : modifie un job en file d'attente @@ -202,7 +213,12 @@ namespace Batch { pthread_t BatchManager_Local::submit(const Job_Local & job) { // L'id du thread a creer - pthread_t thread_id = 0; + pthread_t thread_id = +#ifdef WIN32 + {0,0}; +#else + 0; +#endif // Les attributs du thread a sa creation pthread_attr_t thread_attr; @@ -213,9 +229,9 @@ namespace Batch { // Creation du thread qui va executer la commande systeme qu'on lui passe int rc = pthread_create(&thread_id, - &thread_attr, - &ThreadAdapter::run, - static_cast(p_ta)); + &thread_attr, + &ThreadAdapter::run, + static_cast(p_ta)); if (rc) { } @@ -253,12 +269,14 @@ namespace Batch { // @@@ --------> SECTION CRITIQUE <-------- @@@ pthread_mutex_lock(&_thread_id_id_association_mutex); +#ifndef WIN32 //TODO: porting of following functionality while (_thread_id_id_association.find(thread_id) == _thread_id_id_association.end()) pthread_cond_wait(&_thread_id_id_association_cond, &_thread_id_id_association_mutex); id = _thread_id_id_association[thread_id]; _thread_id_id_association.erase(thread_id); - +#endif + pthread_mutex_unlock(&_thread_id_id_association_mutex); // @@@ --------> SECTION CRITIQUE <-------- @@@ @@ -274,6 +292,7 @@ namespace Batch { // @@@ --------> SECTION CRITIQUE <-------- @@@ pthread_mutex_lock(&_thread_id_id_association_mutex); +#ifndef WIN32 //TODO: porting of following functionality if (_thread_id_id_association.find(thread_id) == _thread_id_id_association.end()) { id = _thread_id_id_association[thread_id] = nextId(); pthread_cond_signal(&_thread_id_id_association_cond); @@ -281,6 +300,7 @@ namespace Batch { } else { UNDER_LOCK( cerr << "ERROR : Pthread Inconstency. Two threads own the same thread_id." << endl ); } +#endif pthread_mutex_unlock(&_thread_id_id_association_mutex); // @@@ --------> SECTION CRITIQUE <-------- @@@ @@ -291,7 +311,7 @@ namespace Batch { // Constructeur de la classe ThreadAdapter BatchManager_Local::ThreadAdapter::ThreadAdapter(BatchManager_Local & bm, const Job_Local & job) : - _bm(bm), _job(job) + _bm(bm), _job(job) { // Nothing to do } @@ -301,12 +321,12 @@ namespace Batch { // Methode d'execution du thread void * BatchManager_Local::ThreadAdapter::run(void * arg) { +#ifndef WIN32 //TODO: porting of following functionality // On bloque tous les signaux pour ce thread sigset_t setmask; sigfillset(&setmask); pthread_sigmask(SIG_BLOCK, &setmask, NULL); - // On autorise la terminaison differee du thread // (ces valeurs sont les valeurs par defaut mais on les force par precaution) pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL); @@ -338,8 +358,13 @@ namespace Batch { Parametre::const_iterator it; // On initialise la variable workdir a la valeur du Current Working Directory - char * cwd = new char [PATH_MAX]; + char * cwd = +#ifdef WIN32 + _getcwd(NULL, 0); +#else + new char [PATH_MAX]; getcwd(cwd, PATH_MAX); +#endif string workdir = cwd; delete [] cwd; @@ -354,21 +379,21 @@ namespace Batch { Versatile::iterator Vit; for(Vit=V.begin(); Vit!=V.end(); Vit++) { - CoupleType cpt = *static_cast< CoupleType * >(*Vit); - Couple cp = cpt; - string local = cp.getLocal(); - string remote = cp.getRemote(); - - string copy_cmd = p_ta->getBatchManager().copy_command("", local, executionhost, workdir + "/" + remote); - UNDER_LOCK( cout << "Copying : " << copy_cmd << endl ); - - if (system(copy_cmd.c_str()) ) { - // Echec de la copie - rc |= 1; - } else { - // On enregistre le fichier comme etant a detruire - files_to_delete.push_back(workdir + "/" + remote); - } + CoupleType cpt = *static_cast< CoupleType * >(*Vit); + Couple cp = cpt; + string local = cp.getLocal(); + string remote = cp.getRemote(); + + string copy_cmd = p_ta->getBatchManager().copy_command("", local, executionhost, workdir + "/" + remote); + UNDER_LOCK( cout << "Copying : " << copy_cmd << endl ); + + if (system(copy_cmd.c_str()) ) { + // Echec de la copie + rc |= 1; + } else { + // On enregistre le fichier comme etant a detruire + files_to_delete.push_back(workdir + "/" + remote); + } } } @@ -376,7 +401,10 @@ namespace Batch { - +#ifdef WIN32 + //TODO + //Using CreateThread instead fork() POSIX function +#else // On forke/exec un nouveau process pour pouvoir controler le fils // (plus finement qu'avec un appel system) // int rc = system(commande.c_str()); @@ -390,7 +418,7 @@ namespace Batch { } else { // fils p_ta->fils(); } - +#endif @@ -400,21 +428,21 @@ namespace Batch { Versatile::iterator Vit; for(Vit=V.begin(); Vit!=V.end(); Vit++) { - CoupleType cpt = *static_cast< CoupleType * >(*Vit); - Couple cp = cpt; - string local = cp.getLocal(); - string remote = cp.getRemote(); - - string copy_cmd = p_ta->getBatchManager().copy_command(executionhost, workdir + "/" + remote, "", local); - UNDER_LOCK( cout << "Copying : " << copy_cmd << endl ); - - if (system(copy_cmd.c_str()) ) { - // Echec de la copie - rc |= 1; - } else { - // On enregistre le fichier comme etant a detruire - files_to_delete.push_back(workdir + "/" + remote); - } + CoupleType cpt = *static_cast< CoupleType * >(*Vit); + Couple cp = cpt; + string local = cp.getLocal(); + string remote = cp.getRemote(); + + string copy_cmd = p_ta->getBatchManager().copy_command(executionhost, workdir + "/" + remote, "", local); + UNDER_LOCK( cout << "Copying : " << copy_cmd << endl ); + + if (system(copy_cmd.c_str()) ) { + // Echec de la copie + rc |= 1; + } else { + // On enregistre le fichier comme etant a detruire + files_to_delete.push_back(workdir + "/" + remote); + } } } @@ -427,9 +455,9 @@ namespace Batch { if ( (rc == 0) || (child < 0) ) { std::vector::const_iterator it; for(it=files_to_delete.begin(); it!=files_to_delete.end(); it++) { - string remove_cmd = p_ta->getBatchManager().remove_command(executionhost, *it); - UNDER_LOCK( cout << "Removing : " << remove_cmd << endl ); - system(remove_cmd.c_str()); + string remove_cmd = p_ta->getBatchManager().remove_command(executionhost, *it); + UNDER_LOCK( cout << "Removing : " << remove_cmd << endl ); + system(remove_cmd.c_str()); } } @@ -448,7 +476,7 @@ namespace Batch { UNDER_LOCK( cout << "Father is leaving" << endl ); pthread_exit(NULL); - +#endif return NULL; } @@ -457,6 +485,7 @@ namespace Batch { void BatchManager_Local::ThreadAdapter::pere(pid_t child) { +#ifndef WIN32 //TODO: porting of following functionality time_t child_starttime = time(NULL); // On enregistre le fils dans la table des threads @@ -492,44 +521,44 @@ namespace Batch { int child_rc = 0; pid_t child_wait_rc = waitpid(child, &child_rc, WNOHANG /* | WUNTRACED */); if (child_wait_rc > 0) { - if (WIFSTOPPED(child_rc)) { - // NOTA : pour rentrer dans cette section, il faut que le flag WUNTRACED - // soit positionne dans l'appel a waitpid ci-dessus. Ce flag est couramment - // desactive car s'il est possible de detecter l'arret d'un process, il est - // plus difficile de detecter sa reprise. - - // Le fils est simplement stoppe - // @@@ --------> SECTION CRITIQUE <-------- @@@ - pthread_mutex_lock(&_bm._threads_mutex); - _bm._threads[id].status = STOPPED; - _bm._threads[id].param[STATE] = "Stopped"; - pthread_mutex_unlock(&_bm._threads_mutex); - // @@@ --------> SECTION CRITIQUE <-------- @@@ - UNDER_LOCK( cout << "Father sees his child is STOPPED : " << child_wait_rc << endl ); - - } - else { - // Le fils est termine, on sort de la boucle et du if englobant - // @@@ --------> SECTION CRITIQUE <-------- @@@ - pthread_mutex_lock(&_bm._threads_mutex); - _bm._threads[id].status = DONE; - _bm._threads[id].param[STATE] = "Done"; - pthread_mutex_unlock(&_bm._threads_mutex); - // @@@ --------> SECTION CRITIQUE <-------- @@@ - UNDER_LOCK( cout << "Father sees his child is DONE : " << child_wait_rc << " (child_rc=" << (WIFEXITED(child_rc) ? WEXITSTATUS(child_rc) : -1) << ")" << endl ); - break; - } + if (WIFSTOPPED(child_rc)) { + // NOTA : pour rentrer dans cette section, il faut que le flag WUNTRACED + // soit positionne dans l'appel a waitpid ci-dessus. Ce flag est couramment + // desactive car s'il est possible de detecter l'arret d'un process, il est + // plus difficile de detecter sa reprise. + + // Le fils est simplement stoppe + // @@@ --------> SECTION CRITIQUE <-------- @@@ + pthread_mutex_lock(&_bm._threads_mutex); + _bm._threads[id].status = STOPPED; + _bm._threads[id].param[STATE] = "Stopped"; + pthread_mutex_unlock(&_bm._threads_mutex); + // @@@ --------> SECTION CRITIQUE <-------- @@@ + UNDER_LOCK( cout << "Father sees his child is STOPPED : " << child_wait_rc << endl ); + + } + else { + // Le fils est termine, on sort de la boucle et du if englobant + // @@@ --------> SECTION CRITIQUE <-------- @@@ + pthread_mutex_lock(&_bm._threads_mutex); + _bm._threads[id].status = DONE; + _bm._threads[id].param[STATE] = "Done"; + pthread_mutex_unlock(&_bm._threads_mutex); + // @@@ --------> SECTION CRITIQUE <-------- @@@ + UNDER_LOCK( cout << "Father sees his child is DONE : " << child_wait_rc << " (child_rc=" << (WIFEXITED(child_rc) ? WEXITSTATUS(child_rc) : -1) << ")" << endl ); + break; + } } else if (child_wait_rc == -1) { - // Le fils a disparu ... - // @@@ --------> SECTION CRITIQUE <-------- @@@ - pthread_mutex_lock(&_bm._threads_mutex); - _bm._threads[id].status = DEAD; - _bm._threads[id].param[STATE] = "Dead"; - pthread_mutex_unlock(&_bm._threads_mutex); - // @@@ --------> SECTION CRITIQUE <-------- @@@ - UNDER_LOCK( cout << "Father sees his child is DEAD : " << child_wait_rc << " (Reason : " << strerror(errno) << ")" << endl ); - break; + // Le fils a disparu ... + // @@@ --------> SECTION CRITIQUE <-------- @@@ + pthread_mutex_lock(&_bm._threads_mutex); + _bm._threads[id].status = DEAD; + _bm._threads[id].param[STATE] = "Dead"; + pthread_mutex_unlock(&_bm._threads_mutex); + // @@@ --------> SECTION CRITIQUE <-------- @@@ + UNDER_LOCK( cout << "Father sees his child is DEAD : " << child_wait_rc << " (Reason : " << strerror(errno) << ")" << endl ); + break; } @@ -543,33 +572,33 @@ namespace Batch { time_t child_currenttime = time(NULL); time_t child_elapsedtime = child_currenttime - child_starttime; if (param.find(MAXWALLTIME) != param.end()) { - int maxwalltime = param[MAXWALLTIME]; - // cout << "child_starttime = " << child_starttime << endl - // << "child_currenttime = " << child_currenttime << endl - // << "child_elapsedtime = " << child_elapsedtime << endl - // << "maxwalltime = " << maxwalltime << endl - // << "int(maxwalltime * 1.1) = " << int(maxwalltime * 1.1) << endl; - if (child_elapsedtime > int(maxwalltime * 1.1) ) { // On se donne 10% de marge avant le KILL - UNDER_LOCK( cout << "Father is sending KILL command to the thread " << id << endl ); - // On introduit une commande dans la queue du thread - // @@@ --------> SECTION CRITIQUE <-------- @@@ - pthread_mutex_lock(&_bm._threads_mutex); - if (_bm._threads.find(id) != _bm._threads.end()) - _bm._threads[id].command_queue.push(KILL); - pthread_mutex_unlock(&_bm._threads_mutex); - // @@@ --------> SECTION CRITIQUE <-------- @@@ - - - } else if (child_elapsedtime > maxwalltime ) { - UNDER_LOCK( cout << "Father is sending TERM command to the thread " << id << endl ); - // On introduit une commande dans la queue du thread - // @@@ --------> SECTION CRITIQUE <-------- @@@ - pthread_mutex_lock(&_bm._threads_mutex); - if (_bm._threads.find(id) != _bm._threads.end()) - _bm._threads[id].command_queue.push(TERM); - pthread_mutex_unlock(&_bm._threads_mutex); - // @@@ --------> SECTION CRITIQUE <-------- @@@ - } + int maxwalltime = param[MAXWALLTIME]; + // cout << "child_starttime = " << child_starttime << endl + // << "child_currenttime = " << child_currenttime << endl + // << "child_elapsedtime = " << child_elapsedtime << endl + // << "maxwalltime = " << maxwalltime << endl + // << "int(maxwalltime * 1.1) = " << int(maxwalltime * 1.1) << endl; + if (child_elapsedtime > int(maxwalltime * 1.1) ) { // On se donne 10% de marge avant le KILL + UNDER_LOCK( cout << "Father is sending KILL command to the thread " << id << endl ); + // On introduit une commande dans la queue du thread + // @@@ --------> SECTION CRITIQUE <-------- @@@ + pthread_mutex_lock(&_bm._threads_mutex); + if (_bm._threads.find(id) != _bm._threads.end()) + _bm._threads[id].command_queue.push(KILL); + pthread_mutex_unlock(&_bm._threads_mutex); + // @@@ --------> SECTION CRITIQUE <-------- @@@ + + + } else if (child_elapsedtime > maxwalltime ) { + UNDER_LOCK( cout << "Father is sending TERM command to the thread " << id << endl ); + // On introduit une commande dans la queue du thread + // @@@ --------> SECTION CRITIQUE <-------- @@@ + pthread_mutex_lock(&_bm._threads_mutex); + if (_bm._threads.find(id) != _bm._threads.end()) + _bm._threads[id].command_queue.push(TERM); + pthread_mutex_unlock(&_bm._threads_mutex); + // @@@ --------> SECTION CRITIQUE <-------- @@@ + } } @@ -578,51 +607,52 @@ namespace Batch { // @@@ --------> SECTION CRITIQUE <-------- @@@ pthread_mutex_lock(&_bm._threads_mutex); if (_bm._threads.find(id) != _bm._threads.end()) { - while (_bm._threads[id].command_queue.size() > 0) { - Commande cmd = _bm._threads[id].command_queue.front(); - _bm._threads[id].command_queue.pop(); - - switch (cmd) { - case NOP: - UNDER_LOCK( cout << "Father does nothing to his child" << endl ); - break; - - case HOLD: - UNDER_LOCK( cout << "Father is sending SIGSTOP signal to his child" << endl ); - kill(child, SIGSTOP); - break; - - case RELEASE: - UNDER_LOCK( cout << "Father is sending SIGCONT signal to his child" << endl ); - kill(child, SIGCONT); - break; - - case TERM: - UNDER_LOCK( cout << "Father is sending SIGTERM signal to his child" << endl ); - kill(child, SIGTERM); - break; - - case KILL: - UNDER_LOCK( cout << "Father is sending SIGKILL signal to his child" << endl ); - kill(child, SIGKILL); - break; - - case ALTER: - break; - - default: - break; - } - } - + while (_bm._threads[id].command_queue.size() > 0) { + Commande cmd = _bm._threads[id].command_queue.front(); + _bm._threads[id].command_queue.pop(); + + switch (cmd) { + case NOP: + UNDER_LOCK( cout << "Father does nothing to his child" << endl ); + break; + + case HOLD: + UNDER_LOCK( cout << "Father is sending SIGSTOP signal to his child" << endl ); + kill(child, SIGSTOP); + break; + + case RELEASE: + UNDER_LOCK( cout << "Father is sending SIGCONT signal to his child" << endl ); + kill(child, SIGCONT); + break; + + case TERM: + UNDER_LOCK( cout << "Father is sending SIGTERM signal to his child" << endl ); + kill(child, SIGTERM); + break; + + case KILL: + UNDER_LOCK( cout << "Father is sending SIGKILL signal to his child" << endl ); + kill(child, SIGKILL); + break; + + case ALTER: + break; + + default: + break; + } + } + } pthread_mutex_unlock(&_bm._threads_mutex); // @@@ --------> SECTION CRITIQUE <-------- @@@ // On fait une petite pause pour ne pas surcharger inutilement le processeur sleep(1); - + } +#endif } @@ -632,139 +662,140 @@ namespace Batch { void BatchManager_Local::ThreadAdapter::fils() { +#ifndef WIN32 //TODO: porting of following functionality Parametre param = _job.getParametre(); Parametre::iterator it; try { - // On se place dans le repertoire de travail - if ( (it = param.find(WORKDIR)) != param.end() ) { - string workdir = static_cast( (*it).second ); - chdir(workdir.c_str()); - } + // On se place dans le repertoire de travail + if ( (it = param.find(WORKDIR)) != param.end() ) { + string workdir = static_cast( (*it).second ); + chdir(workdir.c_str()); + } - // EXECUTABLE is MANDATORY, if missing, we exit with failure notification - char * execpath = NULL; - if (param.find(EXECUTABLE) != param.end()) { - string executable = _bm.exec_command(param); - execpath = new char [executable.size() + 1]; - strncpy(execpath, executable.c_str(), executable.size() + 1); - } else exit(1); + // EXECUTABLE is MANDATORY, if missing, we exit with failure notification + char * execpath = NULL; + if (param.find(EXECUTABLE) != param.end()) { + string executable = _bm.exec_command(param); + execpath = new char [executable.size() + 1]; + strncpy(execpath, executable.c_str(), executable.size() + 1); + } else exit(1); - string debug_command = execpath; + string debug_command = execpath; - string name = (param.find(NAME) != param.end()) ? param[NAME] : param[EXECUTABLE]; + string name = (param.find(NAME) != param.end()) ? param[NAME] : param[EXECUTABLE]; - char ** argv = NULL; - if (param.find(ARGUMENTS) != param.end()) { - Versatile V = param[ARGUMENTS]; + char ** argv = NULL; + if (param.find(ARGUMENTS) != param.end()) { + Versatile V = param[ARGUMENTS]; - argv = new char * [V.size() + 2]; // 1 pour name et 1 pour le NULL terminal + argv = new char * [V.size() + 2]; // 1 pour name et 1 pour le NULL terminal - argv[0] = new char [name.size() + 1]; - strncpy(argv[0], name.c_str(), name.size() + 1); + argv[0] = new char [name.size() + 1]; + strncpy(argv[0], name.c_str(), name.size() + 1); - debug_command += string(" # ") + argv[0]; + debug_command += string(" # ") + argv[0]; - int i = 1; - for(Versatile::const_iterator it=V.begin(); it!=V.end(); it++, i++) { - StringType argt = * static_cast(*it); - string arg = argt; - argv[i] = new char [arg.size() + 1]; - strncpy(argv[i], arg.c_str(), arg.size() + 1); - debug_command += string(" # ") + argv[i]; + int i = 1; + for(Versatile::const_iterator it=V.begin(); it!=V.end(); it++, i++) { + StringType argt = * static_cast(*it); + string arg = argt; + argv[i] = new char [arg.size() + 1]; + strncpy(argv[i], arg.c_str(), arg.size() + 1); + debug_command += string(" # ") + argv[i]; + } + + // assert (i == V.size() + 1) + argv[i] = NULL; } - // assert (i == V.size() + 1) - argv[i] = NULL; - } + UNDER_LOCK( cout << "*** debug_command = " << debug_command << endl ); - UNDER_LOCK( cout << "*** debug_command = " << debug_command << endl ); + Environnement env = _job.getEnvironnement(); - Environnement env = _job.getEnvironnement(); + char ** envp = NULL; + if(env.size() > 0) { + envp = new char * [env.size() + 1]; // 1 pour le NULL terminal + int i = 0; + for(Environnement::const_iterator it=env.begin(); it!=env.end(); it++, i++) { + const string & key = (*it).first; + const string & value = (*it).second; + ostringstream oss; + oss << key << "=" << value; + envp[i] = new char [oss.str().size() + 1]; + strncpy(envp[i], oss.str().c_str(), oss.str().size() + 1); + } - char ** envp = NULL; - if(env.size() > 0) { - envp = new char * [env.size() + 1]; // 1 pour le NULL terminal - int i = 0; - for(Environnement::const_iterator it=env.begin(); it!=env.end(); it++, i++) { - const string & key = (*it).first; - const string & value = (*it).second; - ostringstream oss; - oss << key << "=" << value; - envp[i] = new char [oss.str().size() + 1]; - strncpy(envp[i], oss.str().c_str(), oss.str().size() + 1); + // assert (i == env.size()) + envp[i] = NULL; } - // assert (i == env.size()) - envp[i] = NULL; - } + // On positionne les limites systeme imposees au fils + if (param.find(MAXCPUTIME) != param.end()) { + int maxcputime = param[MAXCPUTIME]; + struct rlimit limit; + limit.rlim_cur = maxcputime; + limit.rlim_max = int(maxcputime * 1.1); + setrlimit(RLIMIT_CPU, &limit); + } - // On positionne les limites systeme imposees au fils - if (param.find(MAXCPUTIME) != param.end()) { - int maxcputime = param[MAXCPUTIME]; - struct rlimit limit; - limit.rlim_cur = maxcputime; - limit.rlim_max = int(maxcputime * 1.1); - setrlimit(RLIMIT_CPU, &limit); - } + if (param.find(MAXDISKSIZE) != param.end()) { + int maxdisksize = param[MAXDISKSIZE]; + struct rlimit limit; + limit.rlim_cur = maxdisksize * 1024; + limit.rlim_max = int(maxdisksize * 1.1) * 1024; + setrlimit(RLIMIT_FSIZE, &limit); + } - if (param.find(MAXDISKSIZE) != param.end()) { - int maxdisksize = param[MAXDISKSIZE]; - struct rlimit limit; - limit.rlim_cur = maxdisksize * 1024; - limit.rlim_max = int(maxdisksize * 1.1) * 1024; - setrlimit(RLIMIT_FSIZE, &limit); - } + if (param.find(MAXRAMSIZE) != param.end()) { + int maxramsize = param[MAXRAMSIZE]; + struct rlimit limit; + limit.rlim_cur = maxramsize * 1024; + limit.rlim_max = int(maxramsize * 1.1) * 1024; + setrlimit(RLIMIT_AS, &limit); + } - if (param.find(MAXRAMSIZE) != param.end()) { - int maxramsize = param[MAXRAMSIZE]; - struct rlimit limit; - limit.rlim_cur = maxramsize * 1024; - limit.rlim_max = int(maxramsize * 1.1) * 1024; - setrlimit(RLIMIT_AS, &limit); - } + // On cree une session pour le fils de facon a ce qu'il ne soit pas + // detruit lorsque le shell se termine (le shell ouvre une session et + // tue tous les process appartenant a la session en quittant) + setsid(); - // On cree une session pour le fils de facon a ce qu'il ne soit pas - // detruit lorsque le shell se termine (le shell ouvre une session et - // tue tous les process appartenant a la session en quittant) - setsid(); + // On ferme les descripteurs de fichiers standards + //close(STDIN_FILENO); + //close(STDOUT_FILENO); + //close(STDERR_FILENO); - // On ferme les descripteurs de fichiers standards - //close(STDIN_FILENO); - //close(STDOUT_FILENO); - //close(STDERR_FILENO); + // On execute la commande du fils + execve(execpath, argv, envp); - // On execute la commande du fils - execve(execpath, argv, envp); + // No need to deallocate since nothing happens after a successful exec - // No need to deallocate since nothing happens after a successful exec + // Normalement on ne devrait jamais arriver ici + ofstream file_err("error.log"); + UNDER_LOCK( file_err << "Echec de l'appel a execve" << endl ); - // Normalement on ne devrait jamais arriver ici - ofstream file_err("error.log"); - UNDER_LOCK( file_err << "Echec de l'appel a execve" << endl ); - } catch (GenericException & e) { - + std::cerr << "Caught exception : " << e.type << " : " << e.message << std::endl; } exit(99); - +#endif } @@ -772,6 +803,8 @@ namespace Batch { void BatchManager_Local::kill_child_on_exit(void * p_pid) { +#ifndef WIN32 + //TODO: porting of following functionality pid_t child = * static_cast(p_pid); // On tue le fils @@ -780,7 +813,7 @@ namespace Batch { // Nota : on pourrait aussi faire a la suite un kill(child, SIGKILL) // mais cette option n'est pas implementee pour le moment, car il est // preferable de laisser le process fils se terminer normalement et seul. - +#endif } void BatchManager_Local::delete_on_exit(void * arg) diff --git a/src/Batch/Batch_BatchManager_Local.hxx b/src/Batch/Batch_BatchManager_Local.hxx index 53091cab2..d797aaf28 100644 --- a/src/Batch/Batch_BatchManager_Local.hxx +++ b/src/Batch/Batch_BatchManager_Local.hxx @@ -29,11 +29,11 @@ #ifndef _BATCHMANAGER_LOCAL_H_ #define _BATCHMANAGER_LOCAL_H_ +#include "Batch_Defines.hxx" #include #include #include -#include #include #include "Batch_Job.hxx" #include "Batch_JobId.hxx" @@ -50,7 +50,7 @@ namespace Batch { class FactBatchManager; - class BatchManager_Local : public BatchManager + class BATCH_EXPORT BatchManager_Local : public BatchManager { private: friend class ThreadAdapter; @@ -91,7 +91,7 @@ namespace Batch { struct Child { pthread_t thread_id; - queue > command_queue; + std::queue > command_queue; pid_t pid; int exit_code; Status status; @@ -127,16 +127,20 @@ namespace Batch { protected: int _connect; // Local connect id pthread_mutex_t _threads_mutex; - map _threads; + std::map _threads; // Methode abstraite qui renvoie la commande de copie du fichier source en destination - virtual string copy_command(const string & host_source, const string & source, const string & host_destination, const string & destination) const = 0; + virtual std::string copy_command( const std::string & host_source, + const std::string & source, + const std::string & host_destination, + const std::string & destination) const = 0; // Methode abstraite qui renvoie la commande a executer - virtual string exec_command(Parametre & param) const = 0; + virtual std::string exec_command(Parametre & param) const = 0; // Methode abstraite qui renvoie la commande d'effacement du fichier - virtual string remove_command(const string & host_destination, const string & destination) const = 0; + virtual std::string remove_command( const std::string & host_destination, + const std::string & destination) const = 0; private: virtual pthread_t submit(const Job_Local & job); @@ -148,7 +152,10 @@ namespace Batch { Id registerThread_id(pthread_t thread_id); pthread_mutex_t _thread_id_id_association_mutex; pthread_cond_t _thread_id_id_association_cond; - map _thread_id_id_association; +#ifndef WIN32 //TODO: porting of following functionality + //reason: pthread_t on win32 is a struct of pointer and int members + std::map _thread_id_id_association; +#endif #ifdef SWIG public: diff --git a/src/Batch/Batch_BatchManager_Local_RSH.cxx b/src/Batch/Batch_BatchManager_Local_RSH.cxx index e93ede663..a99a9cdcd 100644 --- a/src/Batch/Batch_BatchManager_Local_RSH.cxx +++ b/src/Batch/Batch_BatchManager_Local_RSH.cxx @@ -35,9 +35,11 @@ #include #include #include +#ifndef WIN32 #include -#include #include +#endif +#include #include #include #include @@ -57,6 +59,8 @@ #error "RSH undefined. You must set RSH to a valid path to a rsh-like command." #endif +using namespace std; + namespace Batch { diff --git a/src/Batch/Batch_BatchManager_Local_RSH.hxx b/src/Batch/Batch_BatchManager_Local_RSH.hxx index be7a4a04b..0580a4aad 100644 --- a/src/Batch/Batch_BatchManager_Local_RSH.hxx +++ b/src/Batch/Batch_BatchManager_Local_RSH.hxx @@ -29,6 +29,7 @@ #ifndef _BATCHMANAGER_LOCAL_RSH_H_ #define _BATCHMANAGER_LOCAL_RSH_H_ +#include "Batch_Defines.hxx" #include #include @@ -50,7 +51,7 @@ namespace Batch { class FactBatchManager; - class BatchManager_Local_RSH : public BatchManager_Local + class BATCH_EXPORT BatchManager_Local_RSH : public BatchManager_Local { public: // Constructeur et destructeur @@ -59,13 +60,17 @@ namespace Batch { protected: // Methode abstraite qui renvoie la commande de copie du fichier source en destination - virtual string copy_command(const string & host_source, const string & source, const string & host_destination, const string & destination) const; + virtual std::string copy_command( const std::string & host_source, + const std::string & source, + const std::string & host_destination, + const std::string & destination) const; // Methode abstraite qui renvoie la commande a executer - virtual string exec_command(Parametre & param) const; + virtual std::string exec_command(Parametre & param) const; // Methode qui renvoie la commande d'effacement du fichier - virtual string remove_command(const string & host_destination, const string & destination) const; + virtual std::string remove_command( const std::string & host_destination, + const std::string & destination) const; }; diff --git a/src/Batch/Batch_BatchManager_Local_SH.cxx b/src/Batch/Batch_BatchManager_Local_SH.cxx index be9b990ea..beead5209 100644 --- a/src/Batch/Batch_BatchManager_Local_SH.cxx +++ b/src/Batch/Batch_BatchManager_Local_SH.cxx @@ -35,7 +35,9 @@ #include #include #include +#ifndef WIN32 #include +#endif #include #include #include @@ -57,6 +59,8 @@ #error "SH undefined. You must set SH to a valid path to a sh-like command." #endif +using namespace std; + namespace Batch { diff --git a/src/Batch/Batch_BatchManager_Local_SH.hxx b/src/Batch/Batch_BatchManager_Local_SH.hxx index c3de1af7a..31f79b2aa 100644 --- a/src/Batch/Batch_BatchManager_Local_SH.hxx +++ b/src/Batch/Batch_BatchManager_Local_SH.hxx @@ -29,6 +29,7 @@ #ifndef _BATCHMANAGER_LOCAL_SH_H_ #define _BATCHMANAGER_LOCAL_SH_H_ +#include "Batch_Defines.hxx" #include #include @@ -50,7 +51,7 @@ namespace Batch { class FactBatchManager; - class BatchManager_Local_SH : public BatchManager_Local + class BATCH_EXPORT BatchManager_Local_SH : public BatchManager_Local { public: // Constructeur et destructeur @@ -59,13 +60,17 @@ namespace Batch { protected: // Methode qui renvoie la commande de copie du fichier source en destination - virtual string copy_command(const string & host_source, const string & source, const string & host_destination, const string & destination) const; + virtual std::string copy_command( const std::string & host_source, + const std::string & source, + const std::string & host_destination, + const std::string & destination) const; // Methode qui renvoie la commande a executer - virtual string exec_command(Parametre & param) const; + virtual std::string exec_command(Parametre & param) const; // Methode qui renvoie la commande d'effacement du fichier - virtual string remove_command(const string & host_destination, const string & destination) const; + virtual std::string remove_command( const std::string & host_destination, + const std::string & destination) const; }; diff --git a/src/Batch/Batch_BatchManager_Local_SSH.cxx b/src/Batch/Batch_BatchManager_Local_SSH.cxx index 696d7473e..697c9ea2f 100644 --- a/src/Batch/Batch_BatchManager_Local_SSH.cxx +++ b/src/Batch/Batch_BatchManager_Local_SSH.cxx @@ -35,9 +35,12 @@ #include #include #include +#ifndef WIN32 #include -#include #include +#endif +#include + #include #include #include @@ -57,6 +60,8 @@ #error "SSH undefined. You must set SSH to a valid path to a ssh-like command." #endif +using namespace std; + namespace Batch { diff --git a/src/Batch/Batch_BatchManager_Local_SSH.hxx b/src/Batch/Batch_BatchManager_Local_SSH.hxx index b45314f3c..33ecda42d 100644 --- a/src/Batch/Batch_BatchManager_Local_SSH.hxx +++ b/src/Batch/Batch_BatchManager_Local_SSH.hxx @@ -29,6 +29,7 @@ #ifndef _BATCHMANAGER_LOCAL_SSH_H_ #define _BATCHMANAGER_LOCAL_SSH_H_ +#include "Batch_Defines.hxx" #include #include @@ -50,7 +51,7 @@ namespace Batch { class FactBatchManager; - class BatchManager_Local_SSH : public BatchManager_Local + class BATCH_EXPORT BatchManager_Local_SSH : public BatchManager_Local { public: // Constructeur et destructeur @@ -59,13 +60,17 @@ namespace Batch { protected: // Methode abstraite qui renvoie la commande de copie du fichier source en destination - virtual string copy_command(const string & host_source, const string & source, const string & host_destination, const string & destination) const; + virtual std::string copy_command( const std::string & host_source, + const std::string & source, + const std::string & host_destination, + const std::string & destination) const; // Methode abstraite qui renvoie la commande a executer - virtual string exec_command(Parametre & param) const; + virtual std::string exec_command(Parametre & param) const; // Methode qui renvoie la commande d'effacement du fichier - virtual string remove_command(const string & host_destination, const string & destination) const; + virtual std::string remove_command( const std::string & host_destination, + const std::string & destination) const; }; diff --git a/src/Batch/Batch_BatchManager_PBS.hxx b/src/Batch/Batch_BatchManager_PBS.hxx index 53e8a2798..9e995b540 100644 --- a/src/Batch/Batch_BatchManager_PBS.hxx +++ b/src/Batch/Batch_BatchManager_PBS.hxx @@ -30,6 +30,7 @@ #ifndef _BATCHMANAGER_PBS_H_ #define _BATCHMANAGER_PBS_H_ +#include "Batch_Defines.hxx" #include "Batch_Job.hxx" #include "Batch_Job.hxx" @@ -50,7 +51,7 @@ namespace Batch { class JobInfo; class FactBatchManager; - class BatchManager_PBS : public BatchManager + class BATCH_EXPORT BatchManager_PBS : public BatchManager { public: // Constructeur et destructeur diff --git a/src/Batch/Batch_BatchManager_eClient.cxx b/src/Batch/Batch_BatchManager_eClient.cxx index 41ce47c2e..f8684f26a 100644 --- a/src/Batch/Batch_BatchManager_eClient.cxx +++ b/src/Batch/Batch_BatchManager_eClient.cxx @@ -18,20 +18,27 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // /* - * BatchManager_eLSF.cxx : emulation of LSF client - * - * Auteur : Bernard SECHER - CEA DEN - * Mail : mailto:bernard.secher@cea.fr - * Date : Thu Apr 24 10:17:22 2008 - * Projet : PAL Salome - * - */ +* BatchManager_eLSF.cxx : emulation of LSF client +* +* Auteur : Bernard SECHER - CEA DEN +* Mail : mailto:bernard.secher@cea.fr +* Date : Thu Apr 24 10:17:22 2008 +* Projet : PAL Salome +* +*/ + +#include "Batch_BatchManager_eClient.hxx" +#include "Basics_DirUtils.hxx" #include #include #include #include -#include "Batch_BatchManager_eClient.hxx" +#include +#include + +using namespace std; + namespace Batch { @@ -65,7 +72,7 @@ namespace Batch { copy_command = "scp "; else throw EmulationException("Unknown protocol : only rsh and ssh are known !"); - + // First step : creating batch tmp files directory command = _protocol; command += " "; @@ -108,7 +115,7 @@ namespace Batch { ex_mess += oss.str(); throw EmulationException(ex_mess.c_str()); } - + // Third step : copy filesToExportList into // batch tmp files directory for(Vit=V.begin(); Vit!=V.end(); Vit++) { @@ -118,8 +125,8 @@ namespace Batch { command += inputFile.getLocal(); command += " "; if(_username != ""){ - command += _username; - command += "@"; + command += _username; + command += "@"; } command += _hostname; command += ":"; @@ -127,11 +134,11 @@ namespace Batch { cerr << command.c_str() << endl; status = system(command.c_str()); if(status) { - std::ostringstream oss; - oss << status; - std::string ex_mess("Error of connection on remote host ! status = "); - ex_mess += oss.str(); - throw EmulationException(ex_mess.c_str()); + std::ostringstream oss; + oss << status; + std::string ex_mess("Error of connection on remote host ! status = "); + ex_mess += oss.str(); + throw EmulationException(ex_mess.c_str()); } } @@ -145,20 +152,20 @@ namespace Batch { Parametre params = job.getParametre(); Versatile V = params[OUTFILE]; Versatile::iterator Vit; - + for(Vit=V.begin(); Vit!=V.end(); Vit++) { CoupleType cpt = *static_cast< CoupleType * >(*Vit); Couple outputFile = cpt; if( _protocol == "rsh" ) - command = "rcp "; + command = "rcp "; else if( _protocol == "ssh" ) - command = "scp "; + command = "scp "; else - throw EmulationException("Unknown protocol"); + throw EmulationException("Unknown protocol"); if (_username != ""){ - command += _username; - command += "@"; + command += _username; + command += "@"; } command += _hostname; command += ":"; @@ -169,13 +176,13 @@ namespace Batch { status = system(command.c_str()); if(status) { - // Try to get what we can (logs files) - // throw BatchException("Error of connection on remote host"); - std::string mess("Copy command failed ! status is :"); - ostringstream status_str; - status_str << status; - mess += status_str.str(); - cerr << mess << endl; + // Try to get what we can (logs files) + // throw BatchException("Error of connection on remote host"); + std::string mess("Copy command failed ! status is :"); + ostringstream status_str; + status_str << status; + mess += status_str.str(); + cerr << mess << endl; } } @@ -203,26 +210,22 @@ namespace Batch { string BatchManager_eClient::BuildTemporaryFileName() const { //build more complex file name to support multiple salome session - char *temp = new char[19]; - strcpy(temp, "/tmp/command"); - strcat(temp, "XXXXXX"); -#ifndef WNT - mkstemp(temp); + string aFileName = Kernel_Utils::GetTmpFileName(); +#ifndef WIN32 + aFileName += ".sh"; #else - char aPID[80]; - itoa(getpid(), aPID, 10); - strcat(temp, aPID); + aFileName += ".bat"; #endif - - string command(temp); - delete [] temp; - command += ".sh"; - return command; + return aFileName; } void BatchManager_eClient::RmTmpFile(std::string & TemporaryFileName) { +#ifdef WIN32 + string command = "del /F "; +#else string command = "rm "; +#endif command += TemporaryFileName; char *temp = strdup(command.c_str()); int lgthTemp = strlen(temp); @@ -231,5 +234,4 @@ namespace Batch { system(temp); free(temp); } - } diff --git a/src/Batch/Batch_BatchManager_eClient.hxx b/src/Batch/Batch_BatchManager_eClient.hxx index 717eae6a3..f3d27c406 100644 --- a/src/Batch/Batch_BatchManager_eClient.hxx +++ b/src/Batch/Batch_BatchManager_eClient.hxx @@ -30,15 +30,18 @@ #ifndef _BATCHMANAGER_eClient_H_ #define _BATCHMANAGER_eClient_H_ +#include "Batch_Defines.hxx" #include "MpiImpl.hxx" #include "Batch_BatchManager.hxx" +#include + namespace Batch { class Job; - class EmulationException + class BATCH_EXPORT EmulationException { public: const std::string msg; @@ -46,7 +49,7 @@ namespace Batch { EmulationException(const std::string m) : msg(m) {} }; - class BatchManager_eClient : public BatchManager + class BATCH_EXPORT BatchManager_eClient : public BatchManager { public: // Constructeur et destructeur @@ -61,7 +64,7 @@ namespace Batch { std::string BuildTemporaryFileName() const; void RmTmpFile(std::string & TemporaryFileName); - MpiImpl* FactoryMpiImpl(string mpiImpl) throw(EmulationException); + MpiImpl* FactoryMpiImpl(std::string mpiImpl) throw(EmulationException); void exportInputFiles(const Job & job) throw(EmulationException); private: diff --git a/src/Batch/Batch_BatchManager_eLSF.cxx b/src/Batch/Batch_BatchManager_eLSF.cxx index d1c44e60d..406466192 100644 --- a/src/Batch/Batch_BatchManager_eLSF.cxx +++ b/src/Batch/Batch_BatchManager_eLSF.cxx @@ -31,7 +31,16 @@ #include #include #include +#include +#include + #include "Batch_BatchManager_eLSF.hxx" +#ifdef WIN32 +# include +# include +#endif + +using namespace std; namespace Batch { @@ -228,6 +237,7 @@ namespace Batch { void BatchManager_eLSF::buildBatchScript(const Job & job) throw(EmulationException) { +#ifndef WIN32 //TODO: need for porting on Windows int status; Parametre params = job.getParametre(); const int nbproc = params[NBPROC]; @@ -263,7 +273,12 @@ namespace Batch { tempOutputFile << _mpiImpl->halt(); tempOutputFile.flush(); tempOutputFile.close(); - chmod(TmpFileName.c_str(), 0x1ED); +#ifdef WIN32 + _chmod( +#else + chmod( +#endif + TmpFileName.c_str(), 0x1ED); cerr << TmpFileName.c_str() << endl; string command; @@ -291,6 +306,7 @@ namespace Batch { throw EmulationException("Error of connection on remote host"); RmTmpFile(TmpFileName); +#endif } diff --git a/src/Batch/Batch_BatchManager_eLSF.hxx b/src/Batch/Batch_BatchManager_eLSF.hxx index 00d79a4fa..9673d1a1e 100644 --- a/src/Batch/Batch_BatchManager_eLSF.hxx +++ b/src/Batch/Batch_BatchManager_eLSF.hxx @@ -30,6 +30,7 @@ #ifndef _BATCHMANAGER_eLSF_H_ #define _BATCHMANAGER_eLSF_H_ +#include "Batch_Defines.hxx" #include "Batch_JobId.hxx" #include "Batch_JobInfo.hxx" @@ -48,7 +49,7 @@ namespace Batch { class JobInfo; class FactBatchManager; - class BatchManager_eLSF : public BatchManager_eClient + class BATCH_EXPORT BatchManager_eLSF : public BatchManager_eClient { public: // Constructeur et destructeur diff --git a/src/Batch/Batch_BatchManager_ePBS.cxx b/src/Batch/Batch_BatchManager_ePBS.cxx index 999025cfb..8ac732099 100644 --- a/src/Batch/Batch_BatchManager_ePBS.cxx +++ b/src/Batch/Batch_BatchManager_ePBS.cxx @@ -31,7 +31,16 @@ #include #include #include +#include +#include + #include "Batch_BatchManager_ePBS.hxx" +#ifdef WIN32 +# include +# include +#endif + +using namespace std; namespace Batch { @@ -227,6 +236,7 @@ namespace Batch { void BatchManager_ePBS::buildBatchScript(const Job & job) throw(EmulationException) { +#ifndef WIN32 //TODO: need for porting on Windows int status; Parametre params = job.getParametre(); const long nbproc = params[NBPROC]; @@ -262,7 +272,12 @@ namespace Batch { tempOutputFile << _mpiImpl->halt(); tempOutputFile.flush(); tempOutputFile.close(); - chmod(TmpFileName.c_str(), 0x1ED); +#ifdef WIN32 + _chmod( +#else + chmod( +#endif + TmpFileName.c_str(), 0x1ED); cerr << TmpFileName.c_str() << endl; string command; @@ -290,7 +305,7 @@ namespace Batch { throw EmulationException("Error of connection on remote host"); RmTmpFile(TmpFileName); - +#endif } } diff --git a/src/Batch/Batch_BatchManager_ePBS.hxx b/src/Batch/Batch_BatchManager_ePBS.hxx index 42f4b1b69..2bfa60a1a 100644 --- a/src/Batch/Batch_BatchManager_ePBS.hxx +++ b/src/Batch/Batch_BatchManager_ePBS.hxx @@ -30,6 +30,8 @@ #ifndef _BATCHMANAGER_eLSF_H_ #define _BATCHMANAGER_eLSF_H_ +#include "Batch_Defines.hxx" + #include "Batch_JobId.hxx" #include "Batch_JobInfo.hxx" #include "Batch_JobInfo_ePBS.hxx" @@ -47,7 +49,7 @@ namespace Batch { class JobInfo; class FactBatchManager; - class BatchManager_ePBS : public BatchManager_eClient + class BATCH_EXPORT BatchManager_ePBS : public BatchManager_eClient { public: // Constructeur et destructeur diff --git a/src/Batch/Batch_BoolType.hxx b/src/Batch/Batch_BoolType.hxx index b367b3a02..f25c24c5f 100644 --- a/src/Batch/Batch_BoolType.hxx +++ b/src/Batch/Batch_BoolType.hxx @@ -29,12 +29,14 @@ #ifndef _BOOLTYPE_H_ #define _BOOLTYPE_H_ +#include "Batch_Defines.hxx" + #include #include "Batch_GenericType.hxx" namespace Batch { - class BoolType : public GenericType + class BATCH_EXPORT BoolType : public GenericType { public: // Constructeur diff --git a/src/Batch/Batch_CharType.hxx b/src/Batch/Batch_CharType.hxx index f4894f5d0..abac3be3a 100644 --- a/src/Batch/Batch_CharType.hxx +++ b/src/Batch/Batch_CharType.hxx @@ -29,12 +29,14 @@ #ifndef _CHARTYPE_H_ #define _CHARTYPE_H_ +#include "Batch_Defines.hxx" + #include #include "Batch_GenericType.hxx" namespace Batch { - class CharType : public GenericType + class BATCH_EXPORT CharType : public GenericType { public: // Constructeur diff --git a/src/Batch/Batch_ConnexionFailureException.hxx b/src/Batch/Batch_ConnexionFailureException.hxx index 9ae672885..0d3a47e86 100644 --- a/src/Batch/Batch_ConnexionFailureException.hxx +++ b/src/Batch/Batch_ConnexionFailureException.hxx @@ -30,12 +30,14 @@ #ifndef _CONNEXIONFAILUREEXCEPTION_H_ #define _CONNEXIONFAILUREEXCEPTION_H_ +#include "Batch_Defines.hxx" + #include "Batch_GenericException.hxx" namespace Batch { - class ConnexionFailureException : public GenericException + class BATCH_EXPORT ConnexionFailureException : public GenericException { public: // Constructeur diff --git a/src/Batch/Batch_Couple.hxx b/src/Batch/Batch_Couple.hxx index 717a1c228..9c0deed45 100644 --- a/src/Batch/Batch_Couple.hxx +++ b/src/Batch/Batch_Couple.hxx @@ -30,11 +30,13 @@ #ifndef _COUPLE_H_ #define _COUPLE_H_ +#include "Batch_Defines.hxx" + #include namespace Batch { - class Couple + class BATCH_EXPORT Couple { public: // Constructeur standard diff --git a/src/Batch/Batch_CoupleType.hxx b/src/Batch/Batch_CoupleType.hxx index 6d2500f1c..b7d323331 100644 --- a/src/Batch/Batch_CoupleType.hxx +++ b/src/Batch/Batch_CoupleType.hxx @@ -30,13 +30,15 @@ #ifndef _COUPLETYPE_H_ #define _COUPLETYPE_H_ +#include "Batch_Defines.hxx" + #include #include "Batch_GenericType.hxx" #include "Batch_Couple.hxx" namespace Batch { - class CoupleType : public GenericType + class BATCH_EXPORT CoupleType : public GenericType { public: // Constructeur diff --git a/src/Batch/Batch_Date.hxx b/src/Batch/Batch_Date.hxx index 06ebd5dd1..ff7d37a6f 100644 --- a/src/Batch/Batch_Date.hxx +++ b/src/Batch/Batch_Date.hxx @@ -30,11 +30,13 @@ #ifndef _DATE_H_ #define _DATE_H_ +#include "Batch_Defines.hxx" + #include namespace Batch { - class Date + class BATCH_EXPORT Date { public: Date(const long l=0); diff --git a/src/Batch/Batch_DateType.hxx b/src/Batch/Batch_DateType.hxx index 40a47702e..c7fef39a5 100644 --- a/src/Batch/Batch_DateType.hxx +++ b/src/Batch/Batch_DateType.hxx @@ -30,13 +30,15 @@ #ifndef _DATETYPE_H_ #define _DATETYPE_H_ +#include "Batch_Defines.hxx" + #include #include "Batch_GenericType.hxx" #include "Batch_Date.hxx" namespace Batch { - class DateType : public GenericType + class BATCH_EXPORT DateType : public GenericType { public: // Constructeur diff --git a/src/Batch/Batch_Defines.hxx b/src/Batch/Batch_Defines.hxx new file mode 100755 index 000000000..15c5f7c86 --- /dev/null +++ b/src/Batch/Batch_Defines.hxx @@ -0,0 +1,42 @@ +// Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : Batch_Defines.hxx +// Author : Alexander A. BORODIN +// Module : SALOME + +#ifndef _BATCH_Defines_HXX_ +#define _BATCH_Defines_HXX_ + +#ifdef WIN32 +# ifdef BATCH_EXPORTS +# define BATCH_EXPORT __declspec( dllexport ) +# else +# define BATCH_EXPORT __declspec( dllimport ) +# endif +# define RM "rm" +# define RCP "rpc" +# define RSH "rsh" +#else +# define BATCH_EXPORT +#endif + +#endif diff --git a/src/Batch/Batch_Environnement.hxx b/src/Batch/Batch_Environnement.hxx index 2fb9c73a0..e1e16f654 100644 --- a/src/Batch/Batch_Environnement.hxx +++ b/src/Batch/Batch_Environnement.hxx @@ -30,6 +30,8 @@ #ifndef _ENVIRONNEMENT_H_ #define _ENVIRONNEMENT_H_ +#include "Batch_Defines.hxx" + #include #include diff --git a/src/Batch/Batch_FactBatchManager.cxx b/src/Batch/Batch_FactBatchManager.cxx index 61d18fbd0..27b7f1c1f 100644 --- a/src/Batch/Batch_FactBatchManager.cxx +++ b/src/Batch/Batch_FactBatchManager.cxx @@ -39,9 +39,16 @@ namespace Batch { FactBatchManager::FactBatchManager(const string & _t) : type(_t) { BatchManagerCatalog::addFactBatchManager(type.c_str(), this); + /* + #ifndef WIN32 + Win32 limitation: it's impossible to create new thread of LocalTraceCollector + during initialization of static objects of DLL + Be careful with static objects of types inherited from FactBatchManager class + */ ostringstream msg; msg << "FactBatchManager of type '" << type << "' inserted into catalog"; MESSAGE(msg.str().c_str()); + //#endif } // Destructeur diff --git a/src/Batch/Batch_FactBatchManager.hxx b/src/Batch/Batch_FactBatchManager.hxx index 71d739ef0..3a229be30 100644 --- a/src/Batch/Batch_FactBatchManager.hxx +++ b/src/Batch/Batch_FactBatchManager.hxx @@ -29,6 +29,8 @@ #ifndef _FACTBATCHMANAGER_H_ #define _FACTBATCHMANAGER_H_ +#include "Batch_Defines.hxx" + #include #include @@ -36,7 +38,7 @@ namespace Batch { class BatchManager; - class FactBatchManager + class BATCH_EXPORT FactBatchManager { public: // Constructeur et destructeur diff --git a/src/Batch/Batch_FactBatchManager_LSF.hxx b/src/Batch/Batch_FactBatchManager_LSF.hxx index 718a068fc..239b8edfd 100644 --- a/src/Batch/Batch_FactBatchManager_LSF.hxx +++ b/src/Batch/Batch_FactBatchManager_LSF.hxx @@ -29,9 +29,6 @@ #ifndef _FACTBATCHMANAGER_LSF_H_ #define _FACTBATCHMANAGER_LSF_H_ -using namespace std; -#include -#include #include "Batch_FactBatchManager.hxx" namespace Batch { diff --git a/src/Batch/Batch_FactBatchManager_Local.hxx b/src/Batch/Batch_FactBatchManager_Local.hxx index 77b5d11b3..f9b0d20df 100644 --- a/src/Batch/Batch_FactBatchManager_Local.hxx +++ b/src/Batch/Batch_FactBatchManager_Local.hxx @@ -28,9 +28,6 @@ #ifndef _FACTBATCHMANAGER_LOCAL_H_ #define _FACTBATCHMANAGER_LOCAL_H_ -using namespace std; -#include -#include #include "Batch_FactBatchManager.hxx" namespace Batch { diff --git a/src/Batch/Batch_FactBatchManager_Local_RSH.cxx b/src/Batch/Batch_FactBatchManager_Local_RSH.cxx index 985146e58..456c09e45 100644 --- a/src/Batch/Batch_FactBatchManager_Local_RSH.cxx +++ b/src/Batch/Batch_FactBatchManager_Local_RSH.cxx @@ -31,8 +31,15 @@ //#include "utilities.h" namespace Batch { + + static FactBatchManager_Local_RSH* instanceOfFBM_eLSF() + { + static FactBatchManager_Local_RSH* sFBM_Local_RSH = 0; + if ( !sFBM_Local_RSH ) + sFBM_Local_RSH = new FactBatchManager_Local_RSH(); - static FactBatchManager_Local_RSH sFBM_Local_RSH; + return sFBM_Local_RSH; + } // Constructeur FactBatchManager_Local_RSH::FactBatchManager_Local_RSH() : FactBatchManager("RSH") diff --git a/src/Batch/Batch_FactBatchManager_Local_RSH.hxx b/src/Batch/Batch_FactBatchManager_Local_RSH.hxx index bf10abd14..1f68befd1 100644 --- a/src/Batch/Batch_FactBatchManager_Local_RSH.hxx +++ b/src/Batch/Batch_FactBatchManager_Local_RSH.hxx @@ -28,9 +28,6 @@ #ifndef _FACTBATCHMANAGER_LOCAL_RSH_H_ #define _FACTBATCHMANAGER_LOCAL_RSH_H_ -using namespace std; -#include -#include #include "Batch_FactBatchManager.hxx" namespace Batch { diff --git a/src/Batch/Batch_FactBatchManager_Local_SH.hxx b/src/Batch/Batch_FactBatchManager_Local_SH.hxx index 8ac703a74..29ff50d07 100644 --- a/src/Batch/Batch_FactBatchManager_Local_SH.hxx +++ b/src/Batch/Batch_FactBatchManager_Local_SH.hxx @@ -28,9 +28,6 @@ #ifndef _FACTBATCHMANAGER_LOCAL_SH_H_ #define _FACTBATCHMANAGER_LOCAL_SH_H_ -using namespace std; -#include -#include #include "Batch_FactBatchManager.hxx" namespace Batch { diff --git a/src/Batch/Batch_FactBatchManager_Local_SSH.hxx b/src/Batch/Batch_FactBatchManager_Local_SSH.hxx index 2c3c14e03..4d9764247 100644 --- a/src/Batch/Batch_FactBatchManager_Local_SSH.hxx +++ b/src/Batch/Batch_FactBatchManager_Local_SSH.hxx @@ -28,9 +28,6 @@ #ifndef _FACTBATCHMANAGER_LOCAL_SSH_H_ #define _FACTBATCHMANAGER_LOCAL_SSH_H_ -using namespace std; -#include -#include #include "Batch_FactBatchManager.hxx" namespace Batch { diff --git a/src/Batch/Batch_FactBatchManager_eLSF.cxx b/src/Batch/Batch_FactBatchManager_eLSF.cxx index 227bffa32..d77c4c71b 100644 --- a/src/Batch/Batch_FactBatchManager_eLSF.cxx +++ b/src/Batch/Batch_FactBatchManager_eLSF.cxx @@ -33,7 +33,15 @@ namespace Batch { - static FactBatchManager_eLSF sFBM_eLSF; +static FactBatchManager_eLSF* instanceOfFBM_eLSF() +{ + static FactBatchManager_eLSF* sFBM_eLSF = 0; + if ( !sFBM_eLSF ) + sFBM_eLSF = new FactBatchManager_eLSF(); + + return sFBM_eLSF; +} + // Constructeur FactBatchManager_eLSF::FactBatchManager_eLSF() : FactBatchManager_eClient("eLSF") diff --git a/src/Batch/Batch_FactBatchManager_eLSF.hxx b/src/Batch/Batch_FactBatchManager_eLSF.hxx index e1660aaaa..558ee007e 100644 --- a/src/Batch/Batch_FactBatchManager_eLSF.hxx +++ b/src/Batch/Batch_FactBatchManager_eLSF.hxx @@ -29,7 +29,8 @@ #ifndef _FACTBATCHMANAGER_eLSF_H_ #define _FACTBATCHMANAGER_eLSF_H_ -using namespace std; +#include "Batch_Defines.hxx" + #include #include #include "Batch_BatchManager_eClient.hxx" @@ -39,7 +40,7 @@ namespace Batch { class BatchManager_eLSF; - class FactBatchManager_eLSF : public FactBatchManager_eClient + class BATCH_EXPORT FactBatchManager_eLSF : public FactBatchManager_eClient { public: // Constructeur et destructeur diff --git a/src/Batch/Batch_FactBatchManager_ePBS.cxx b/src/Batch/Batch_FactBatchManager_ePBS.cxx index 3bcbda530..3611a05ea 100644 --- a/src/Batch/Batch_FactBatchManager_ePBS.cxx +++ b/src/Batch/Batch_FactBatchManager_ePBS.cxx @@ -33,7 +33,14 @@ namespace Batch { - static FactBatchManager_ePBS sFBM_ePBS; + static FactBatchManager_ePBS* instanceOfFBM_eLSF() + { + static FactBatchManager_ePBS* sFBM_ePBS = 0; + if ( !sFBM_ePBS ) + sFBM_ePBS = new FactBatchManager_ePBS(); + + return sFBM_ePBS; + } // Constructeur FactBatchManager_ePBS::FactBatchManager_ePBS() : FactBatchManager_eClient("ePBS") diff --git a/src/Batch/Batch_FactBatchManager_ePBS.hxx b/src/Batch/Batch_FactBatchManager_ePBS.hxx index 69fdf322a..b78e76144 100644 --- a/src/Batch/Batch_FactBatchManager_ePBS.hxx +++ b/src/Batch/Batch_FactBatchManager_ePBS.hxx @@ -29,7 +29,8 @@ #ifndef _FACTBATCHMANAGER_ePBS_H_ #define _FACTBATCHMANAGER_ePBS_H_ -using namespace std; +#include "Batch_Defines.hxx" + #include #include #include "Batch_BatchManager_eClient.hxx" @@ -39,7 +40,7 @@ namespace Batch { class BatchManager_ePBS; - class FactBatchManager_ePBS : public FactBatchManager_eClient + class BATCH_EXPORT FactBatchManager_ePBS : public FactBatchManager_eClient { public: // Constructeur et destructeur diff --git a/src/Batch/Batch_GenericException.hxx b/src/Batch/Batch_GenericException.hxx index f62b6a2b9..89f79f49a 100644 --- a/src/Batch/Batch_GenericException.hxx +++ b/src/Batch/Batch_GenericException.hxx @@ -30,12 +30,14 @@ #ifndef _GENERICEXCEPTION_H_ #define _GENERICEXCEPTION_H_ +#include "Batch_Defines.hxx" + #include namespace Batch { - class GenericException + class BATCH_EXPORT GenericException { public: const std::string type; // la nature de l'exception diff --git a/src/Batch/Batch_GenericType.hxx b/src/Batch/Batch_GenericType.hxx index 674b843ad..c5d7faf83 100644 --- a/src/Batch/Batch_GenericType.hxx +++ b/src/Batch/Batch_GenericType.hxx @@ -29,13 +29,15 @@ #ifndef _GENERICTYPE_H_ #define _GENERICTYPE_H_ +#include "Batch_Defines.hxx" + #include #include namespace Batch { - class GenericType + class BATCH_EXPORT GenericType { public: // Constructeur et destructeur diff --git a/src/Batch/Batch_IntType.hxx b/src/Batch/Batch_IntType.hxx index 82ca73a10..3808c9514 100644 --- a/src/Batch/Batch_IntType.hxx +++ b/src/Batch/Batch_IntType.hxx @@ -29,12 +29,14 @@ #ifndef _INTTYPE_H_ #define _INTTYPE_H_ +#include "Batch_Defines.hxx" + #include #include "Batch_GenericType.hxx" namespace Batch { - class IntType : public GenericType + class BATCH_EXPORT IntType : public GenericType { public: // Constructeur diff --git a/src/Batch/Batch_InvalidArgumentException.hxx b/src/Batch/Batch_InvalidArgumentException.hxx index 68b417dda..8ca04c190 100644 --- a/src/Batch/Batch_InvalidArgumentException.hxx +++ b/src/Batch/Batch_InvalidArgumentException.hxx @@ -31,12 +31,14 @@ #define _INVALIDARGUMENTEXCEPTION_H_ +#include "Batch_Defines.hxx" + #include "Batch_GenericException.hxx" #include "Batch_GenericException.hxx" namespace Batch { - class InvalidArgumentException : public GenericException + class BATCH_EXPORT InvalidArgumentException : public GenericException { public: // Constructeur diff --git a/src/Batch/Batch_InvalidKeyException.hxx b/src/Batch/Batch_InvalidKeyException.hxx index e07b876ee..7c9c7022a 100644 --- a/src/Batch/Batch_InvalidKeyException.hxx +++ b/src/Batch/Batch_InvalidKeyException.hxx @@ -30,13 +30,15 @@ #ifndef _INVALIDKEYEXCEPTION_H_ #define _INVALIDKEYEXCEPTION_H_ +#include "Batch_Defines.hxx" + #include "Batch_GenericException.hxx" #include "Batch_GenericException.hxx" namespace Batch { - class InvalidKeyException : public GenericException + class BATCH_EXPORT InvalidKeyException : public GenericException { public: // Constructeur diff --git a/src/Batch/Batch_Job.hxx b/src/Batch/Batch_Job.hxx index d6ad5442b..fabecde27 100644 --- a/src/Batch/Batch_Job.hxx +++ b/src/Batch/Batch_Job.hxx @@ -29,13 +29,15 @@ #ifndef _JOB_H_ #define _JOB_H_ +#include "Batch_Defines.hxx" + #include "Batch_Parametre.hxx" #include "Batch_Environnement.hxx" namespace Batch { - class Job + class BATCH_EXPORT Job { public: // Constructeurs et destructeur diff --git a/src/Batch/Batch_JobId.hxx b/src/Batch/Batch_JobId.hxx index 5046d6a31..9ae57d183 100644 --- a/src/Batch/Batch_JobId.hxx +++ b/src/Batch/Batch_JobId.hxx @@ -30,6 +30,8 @@ #define _JOBID_H_ +#include "Batch_Defines.hxx" + #include "Batch_JobInfo.hxx" #include "Batch_BatchManager.hxx" @@ -37,7 +39,7 @@ namespace Batch { class BatchManager; - class JobId + class BATCH_EXPORT JobId { friend class BatchManager; diff --git a/src/Batch/Batch_JobInfo.cxx b/src/Batch/Batch_JobInfo.cxx index 6e985fdb2..71fe3113b 100644 --- a/src/Batch/Batch_JobInfo.cxx +++ b/src/Batch/Batch_JobInfo.cxx @@ -33,6 +33,8 @@ //#include "MEDMEM_STRING.hxx" #include "Batch_JobInfo.hxx" +using namespace std; + namespace Batch { // Destructeur diff --git a/src/Batch/Batch_JobInfo.hxx b/src/Batch/Batch_JobInfo.hxx index fbb4e35b1..7ec3a5764 100644 --- a/src/Batch/Batch_JobInfo.hxx +++ b/src/Batch/Batch_JobInfo.hxx @@ -30,7 +30,8 @@ #ifndef _JOBINFO_H_ #define _JOBINFO_H_ -using namespace std; +#include "Batch_Defines.hxx" + #include #include #include "Batch_Parametre.hxx" @@ -38,7 +39,7 @@ using namespace std; namespace Batch { - class JobInfo + class BATCH_EXPORT JobInfo { public: // Constructeur standard et destructeur @@ -49,7 +50,7 @@ namespace Batch { JobInfo(const JobInfo & jinfo) : _param(jinfo._param), _env(jinfo._env) {}; // Operateur pour l'affichage sur un stream - friend ostream & operator <<(ostream & os, const JobInfo & ji); + friend std::ostream & operator <<(std::ostream & os, const JobInfo & ji); // Accesseurs // _CS_gbo Ajout explicite du namespace pour les besoins de swig (mauvaise gestion @@ -59,8 +60,8 @@ namespace Batch { // Methodes pour l'interfacage avec Python (SWIG) // TODO : supprimer ces methodes et transferer leur definitions dans SWIG - string __str__() const; // SWIG : affichage en Python - string __repr__() const { return __str__(); }; // SWIG : affichage en Python + std::string __str__() const; // SWIG : affichage en Python + std::string __repr__() const { return __str__(); }; // SWIG : affichage en Python protected: Parametre _param; // parametres du job diff --git a/src/Batch/Batch_JobInfo_LSF.cxx b/src/Batch/Batch_JobInfo_LSF.cxx index 2ae986cd0..79f5d3807 100644 --- a/src/Batch/Batch_JobInfo_LSF.cxx +++ b/src/Batch/Batch_JobInfo_LSF.cxx @@ -29,12 +29,15 @@ #include #include +#include #include "Batch_Parametre.hxx" #include "Batch_Environnement.hxx" #include "Batch_RunTimeException.hxx" #include "Batch_APIInternalFailureException.hxx" #include "Batch_JobInfo_LSF.hxx" +using namespace std; + namespace Batch { diff --git a/src/Batch/Batch_JobInfo_LSF.hxx b/src/Batch/Batch_JobInfo_LSF.hxx index 7ba666211..1edb2e52d 100644 --- a/src/Batch/Batch_JobInfo_LSF.hxx +++ b/src/Batch/Batch_JobInfo_LSF.hxx @@ -57,15 +57,15 @@ namespace Batch { // Methodes pour l'interfacage avec Python (SWIG) // TODO : supprimer ces methodes et transferer leur definitions dans SWIG - string __str__() const; // SWIG : affichage en Python - string __repr__() const { return __str__(); }; // SWIG : affichage en Python + std::string __str__() const; // SWIG : affichage en Python + std::string __repr__() const { return __str__(); }; // SWIG : affichage en Python protected: bool _running; // etat du job en machine private: // Convertit une date HH:MM:SS en secondes - long HMStoLong(const string &); + long HMStoLong(const std::string &); }; diff --git a/src/Batch/Batch_JobInfo_eLSF.cxx b/src/Batch/Batch_JobInfo_eLSF.cxx index 177f2eb06..5edeb0a5b 100644 --- a/src/Batch/Batch_JobInfo_eLSF.cxx +++ b/src/Batch/Batch_JobInfo_eLSF.cxx @@ -37,6 +37,8 @@ #include "Batch_APIInternalFailureException.hxx" #include "Batch_JobInfo_eLSF.hxx" +using namespace std; + namespace Batch { diff --git a/src/Batch/Batch_JobInfo_eLSF.hxx b/src/Batch/Batch_JobInfo_eLSF.hxx index 51d3f6fd3..52b7282cf 100644 --- a/src/Batch/Batch_JobInfo_eLSF.hxx +++ b/src/Batch/Batch_JobInfo_eLSF.hxx @@ -30,10 +30,11 @@ #ifndef _JOBINFO_LSF_H_ #define _JOBINFO_LSF_H_ -#include #include "Batch_RunTimeException.hxx" #include "Batch_JobInfo.hxx" +#include + namespace Batch { class JobInfo_eLSF : public JobInfo @@ -52,15 +53,15 @@ namespace Batch { // Methodes pour l'interfacage avec Python (SWIG) // TODO : supprimer ces methodes et transferer leur definitions dans SWIG - string __str__() const; // SWIG : affichage en Python - string __repr__() const { return __str__(); }; // SWIG : affichage en Python + std::string __str__() const; // SWIG : affichage en Python + std::string __repr__() const { return __str__(); }; // SWIG : affichage en Python protected: bool _running; // etat du job en machine private: // Convertit une date HH:MM:SS en secondes - long HMStoLong(const string &); + long HMStoLong(const std::string &); }; diff --git a/src/Batch/Batch_JobInfo_ePBS.cxx b/src/Batch/Batch_JobInfo_ePBS.cxx index 6d9807a0c..8a1c97506 100644 --- a/src/Batch/Batch_JobInfo_ePBS.cxx +++ b/src/Batch/Batch_JobInfo_ePBS.cxx @@ -37,6 +37,8 @@ #include "Batch_APIInternalFailureException.hxx" #include "Batch_JobInfo_ePBS.hxx" +using namespace std; + namespace Batch { diff --git a/src/Batch/Batch_JobInfo_ePBS.hxx b/src/Batch/Batch_JobInfo_ePBS.hxx index 79fb0b782..03a8601aa 100644 --- a/src/Batch/Batch_JobInfo_ePBS.hxx +++ b/src/Batch/Batch_JobInfo_ePBS.hxx @@ -52,15 +52,15 @@ namespace Batch { // Methodes pour l'interfacage avec Python (SWIG) // TODO : supprimer ces methodes et transferer leur definitions dans SWIG - string __str__() const; // SWIG : affichage en Python - string __repr__() const { return __str__(); }; // SWIG : affichage en Python + std::string __str__() const; // SWIG : affichage en Python + std::string __repr__() const { return __str__(); }; // SWIG : affichage en Python protected: bool _running; // etat du job en machine private: // Convertit une date HH:MM:SS en secondes - long HMStoLong(const string &); + long HMStoLong(const std::string &); }; diff --git a/src/Batch/Batch_Job_LSF.cxx b/src/Batch/Batch_Job_LSF.cxx index 549d4ab36..2d99df052 100644 --- a/src/Batch/Batch_Job_LSF.cxx +++ b/src/Batch/Batch_Job_LSF.cxx @@ -30,10 +30,12 @@ #include #include #include -#include +#include #include #include "Batch_Job_LSF.hxx" +using namespace std; + namespace Batch { diff --git a/src/Batch/Batch_Job_LSF.hxx b/src/Batch/Batch_Job_LSF.hxx index 0de536514..9bc07fa1b 100644 --- a/src/Batch/Batch_Job_LSF.hxx +++ b/src/Batch/Batch_Job_LSF.hxx @@ -35,6 +35,7 @@ extern "C" { #include #include } +#include #include "Batch_Job.hxx" namespace Batch { @@ -54,7 +55,7 @@ namespace Batch { private: struct submit * ParametreToSubmitStruct(const Parametre & P); - char * string2char(const string &); + char * string2char(const std::string &); }; } diff --git a/src/Batch/Batch_Job_Local.cxx b/src/Batch/Batch_Job_Local.cxx index bc276f819..896532c96 100644 --- a/src/Batch/Batch_Job_Local.cxx +++ b/src/Batch/Batch_Job_Local.cxx @@ -28,9 +28,13 @@ #include #include +#ifndef WIN32 #include +#endif #include "Batch_Job_Local.hxx" +using namespace std; + namespace Batch { // Constructeur diff --git a/src/Batch/Batch_ListIsFullException.hxx b/src/Batch/Batch_ListIsFullException.hxx index 241defeb8..0525ba449 100644 --- a/src/Batch/Batch_ListIsFullException.hxx +++ b/src/Batch/Batch_ListIsFullException.hxx @@ -29,11 +29,13 @@ #ifndef _LISTISFULLEXCEPTION_H_ #define _LISTISFULLEXCEPTION_H_ +#include "Batch_Defines.hxx" + #include "Batch_GenericException.hxx" namespace Batch { - class ListIsFullException : public GenericException + class BATCH_EXPORT ListIsFullException : public GenericException { public: // Constructeur diff --git a/src/Batch/Batch_LongType.hxx b/src/Batch/Batch_LongType.hxx index f43e8615e..3970ae0e7 100644 --- a/src/Batch/Batch_LongType.hxx +++ b/src/Batch/Batch_LongType.hxx @@ -29,12 +29,14 @@ #ifndef _LONGTYPE_H_ #define _LONGTYPE_H_ +#include "Batch_Defines.hxx" + #include #include "Batch_GenericType.hxx" namespace Batch { - class LongType : public GenericType + class BATCH_EXPORT LongType : public GenericType { public: // Constructeur diff --git a/src/Batch/Batch_MapKey.hxx b/src/Batch/Batch_MapKey.hxx index 93f219842..43e943f8b 100644 --- a/src/Batch/Batch_MapKey.hxx +++ b/src/Batch/Batch_MapKey.hxx @@ -30,6 +30,8 @@ #ifndef _MAPKEY_H_ #define _MAPKEY_H_ +#include "Batch_Defines.hxx" + #include @@ -37,7 +39,7 @@ namespace Batch { // une classe privee pour les differents types // ces types ne peuvent pas etre redefinis - class MapKey : public std::string + class BATCH_EXPORT MapKey : public std::string { private: friend class Parametre; // seule la classe Parametre peut creer des MapKey diff --git a/src/Batch/Batch_NotYetImplementedException.hxx b/src/Batch/Batch_NotYetImplementedException.hxx index 54f4f6205..509aceaca 100644 --- a/src/Batch/Batch_NotYetImplementedException.hxx +++ b/src/Batch/Batch_NotYetImplementedException.hxx @@ -30,17 +30,18 @@ #ifndef _NOTYETIMPLEMENTEDEXCEPTION_H_ #define _NOTYETIMPLEMENTEDEXCEPTION_H_ - +#include "Batch_Defines.hxx" #include "Batch_GenericException.hxx" -using namespace std; + +#include namespace Batch { - class NotYetImplementedException : public GenericException + class BATCH_EXPORT NotYetImplementedException : public GenericException { public: // Constructeur - NotYetImplementedException(string ch = "undefined") : GenericException("NotYetImplementedException", ch) {} + NotYetImplementedException(std::string ch = "undefined") : GenericException("NotYetImplementedException", ch) {} }; } diff --git a/src/Batch/Batch_Parametre.cxx b/src/Batch/Batch_Parametre.cxx index b218cc443..1facc6287 100644 --- a/src/Batch/Batch_Parametre.cxx +++ b/src/Batch/Batch_Parametre.cxx @@ -26,11 +26,12 @@ * */ -#include #include "Batch_Versatile.hxx" #include "Batch_InvalidKeyException.hxx" #include "Batch_Parametre.hxx" +using namespace std; + // Definition des membres constants statiques // Definition des noms globaux pour les clefs en tant que references // TODO : supprimer les declarations statiques des clefs de la map diff --git a/src/Batch/Batch_Parametre.hxx b/src/Batch/Batch_Parametre.hxx index ce88da4f9..e6feedf9c 100644 --- a/src/Batch/Batch_Parametre.hxx +++ b/src/Batch/Batch_Parametre.hxx @@ -29,25 +29,25 @@ #ifndef _PARAMETRE_H_ #define _PARAMETRE_H_ -using namespace std; +#include "Batch_Defines.hxx" + #include #include #include "Batch_InvalidKeyException.hxx" #include "Batch_Versatile.hxx" - // Ces macros permettent de simplifier l'ajout de nouvelles // clefs dans la map Parametre // TODO : remplacer ce mecanisme statique par la lecture // TODO : d'une descrption dans un fichier exterieur (genre XML) -#define def_extern_MapKey(mk) extern const string & mk; -#define def_static_MapKey(mk) const string Batch::Parametre::mk(#mk); \ - const string & mk = Batch::Parametre::mk; +#define def_extern_MapKey(mk) extern BATCH_EXPORT const std::string & mk; +#define def_static_MapKey(mk) const std::string Batch::Parametre::mk(#mk); \ + const std::string & mk = Batch::Parametre::mk; namespace Batch { - class Parametre : public map< string, Versatile > + class BATCH_EXPORT Parametre : public std::map< std::string, Versatile > { public: // Constructeur standard @@ -57,56 +57,56 @@ namespace Batch { Parametre(const Parametre & PM); // Operateur de recherche dans la map - Versatile & operator [] (const string &); - const Versatile & operator [] (const string &) const; + Versatile & operator [] (const std::string &); + const Versatile & operator [] (const std::string &) const; // Operateur d'affectation Parametre & operator =(const Parametre & PM); // Declarations statique des clefs de la map // TODO : supprimer les declarations statiques des clefs de la map - static const string ACCOUNT; - static const string ARGUMENTS; - static const string CHECKPOINT; - static const string CKPTINTERVAL; - static const string CREATIONTIME; - static const string EGROUP; - static const string ELIGIBLETIME; - static const string ENDTIME; - static const string EUSER; - static const string EXECUTABLE; - static const string EXECUTIONHOST; - static const string EXITCODE; - static const string HOLD; - static const string ID; - static const string INFILE; - static const string MAIL; - static const string MAXCPUTIME; - static const string MAXDISKSIZE; - static const string MAXRAMSIZE; - static const string MAXWALLTIME; - static const string MODIFICATIONTIME; - static const string NAME; - static const string NBPROC; - static const string OUTFILE; - static const string PID; - static const string QUEUE; - static const string QUEUEDTIME; - static const string SERVER; - static const string STARTTIME; - static const string STATE; - static const string TEXT; - static const string TMPDIR; - static const string USEDCPUTIME; - static const string USEDDISKSIZE; - static const string USEDRAMSIZE; - static const string USEDWALLTIME; - static const string USER; - static const string WORKDIR; - static const string HOMEDIR; + static const std::string ACCOUNT; + static const std::string ARGUMENTS; + static const std::string CHECKPOINT; + static const std::string CKPTINTERVAL; + static const std::string CREATIONTIME; + static const std::string EGROUP; + static const std::string ELIGIBLETIME; + static const std::string ENDTIME; + static const std::string EUSER; + static const std::string EXECUTABLE; + static const std::string EXECUTIONHOST; + static const std::string EXITCODE; + static const std::string HOLD; + static const std::string ID; + static const std::string INFILE; + static const std::string MAIL; + static const std::string MAXCPUTIME; + static const std::string MAXDISKSIZE; + static const std::string MAXRAMSIZE; + static const std::string MAXWALLTIME; + static const std::string MODIFICATIONTIME; + static const std::string NAME; + static const std::string NBPROC; + static const std::string OUTFILE; + static const std::string PID; + static const std::string QUEUE; + static const std::string QUEUEDTIME; + static const std::string SERVER; + static const std::string STARTTIME; + static const std::string STATE; + static const std::string TEXT; + static const std::string TMPDIR; + static const std::string USEDCPUTIME; + static const std::string USEDDISKSIZE; + static const std::string USEDRAMSIZE; + static const std::string USEDWALLTIME; + static const std::string USER; + static const std::string WORKDIR; + static const std::string HOMEDIR; protected: - map< string, TypeParam > TypeMap; // map interne servant a controler le type de la valeur associee a chaque clef + std::map< std::string, TypeParam > TypeMap; // map interne servant a controler le type de la valeur associee a chaque clef private: diff --git a/src/Batch/Batch_PyVersatile.cxx b/src/Batch/Batch_PyVersatile.cxx index f38132ca2..10541cb18 100644 --- a/src/Batch/Batch_PyVersatile.cxx +++ b/src/Batch/Batch_PyVersatile.cxx @@ -34,6 +34,8 @@ #include "Batch_PyVersatile.hxx" #include +using namespace std; + namespace Batch { // Constructeur a partir d'un objet Versatile diff --git a/src/Batch/Batch_PyVersatile.hxx b/src/Batch/Batch_PyVersatile.hxx index e111bac43..3bc37f2c5 100644 --- a/src/Batch/Batch_PyVersatile.hxx +++ b/src/Batch/Batch_PyVersatile.hxx @@ -31,16 +31,17 @@ #define _PYVERSATILE_H_ +#include "Batch_Defines.hxx" + #include #include "Batch_Versatile.hxx" #include "Batch_TypeMismatchException.hxx" #include "Batch_ListIsFullException.hxx" #include "Batch_InvalidArgumentException.hxx" -using namespace std; namespace Batch { - class PyVersatile : public Versatile + class BATCH_EXPORT PyVersatile : public Versatile { public: // Constructeur a partir d'un objet Versatile diff --git a/src/Batch/Batch_RunTimeException.hxx b/src/Batch/Batch_RunTimeException.hxx index 3df53a5ca..fe1e168d4 100644 --- a/src/Batch/Batch_RunTimeException.hxx +++ b/src/Batch/Batch_RunTimeException.hxx @@ -30,12 +30,14 @@ #ifndef _RUNTIMEEXCEPTION_H_ #define _RUNTIMEEXCEPTION_H_ +#include "Batch_Defines.hxx" + #include "Batch_GenericException.hxx" namespace Batch { - class RunTimeException : public GenericException + class BATCH_EXPORT RunTimeException : public GenericException { public: // Constructeur diff --git a/src/Batch/Batch_StringType.hxx b/src/Batch/Batch_StringType.hxx index a72173c7e..510924e9b 100644 --- a/src/Batch/Batch_StringType.hxx +++ b/src/Batch/Batch_StringType.hxx @@ -29,12 +29,14 @@ #ifndef _STRINGTYPE_H_ #define _STRINGTYPE_H_ +#include "Batch_Defines.hxx" + #include #include "Batch_GenericType.hxx" namespace Batch { - class StringType : public GenericType + class BATCH_EXPORT StringType : public GenericType { public: // Constructeur diff --git a/src/Batch/Batch_TypeMismatchException.hxx b/src/Batch/Batch_TypeMismatchException.hxx index d235ec20e..b231060dc 100644 --- a/src/Batch/Batch_TypeMismatchException.hxx +++ b/src/Batch/Batch_TypeMismatchException.hxx @@ -29,12 +29,14 @@ #ifndef _TYPEMISMATCHEXCEPTION_H_ #define _TYPEMISMATCHEXCEPTION_H_ +#include "Batch_Defines.hxx" + #include "Batch_GenericException.hxx" namespace Batch { - class TypeMismatchException : public GenericException + class BATCH_EXPORT TypeMismatchException : public GenericException { public: // Constructeur diff --git a/src/Batch/Batch_Versatile.hxx b/src/Batch/Batch_Versatile.hxx index cf97bbb30..c7b6f3bf6 100644 --- a/src/Batch/Batch_Versatile.hxx +++ b/src/Batch/Batch_Versatile.hxx @@ -29,6 +29,8 @@ #ifndef _VERSATILE_H_ #define _VERSATILE_H_ +#include "Batch_Defines.hxx" + #include #include #include @@ -53,7 +55,7 @@ namespace Batch { int maxelem; // le nombre d'elements autorises } TypeParam; - class Versatile : public std::list< GenericType * > + class BATCH_EXPORT Versatile : public std::list< GenericType * > { public: // Constructeur standard et destructeur diff --git a/src/Batch/Makefile.am b/src/Batch/Makefile.am index c6c2cbf86..aaaa33e2b 100644 --- a/src/Batch/Makefile.am +++ b/src/Batch/Makefile.am @@ -68,7 +68,8 @@ LIB_INCLUDES = \ Batch_BatchManager_ePBS.hxx \ Batch_FactBatchManager_ePBS.hxx \ Batch_JobInfo_ePBS.hxx \ - MpiImpl.hxx + MpiImpl.hxx \ + Batch_Defines.hxx LIB_SRC = \ @@ -116,7 +117,7 @@ LIB_CPPFLAGS = \ ${PYTHON_INCLUDES} \ -I$(srcdir)/../Basics \ -I$(srcdir)/../SALOMELocalTrace \ - -I$(top_builddir)/salome_adm/unix + -I$(top_builddir)/salome_adm/unix LIB_LIBADD = \ ../SALOMELocalTrace/libSALOMELocalTrace.la \ diff --git a/src/Batch/MpiImpl.hxx b/src/Batch/MpiImpl.hxx index 07f306bdf..1056c2581 100644 --- a/src/Batch/MpiImpl.hxx +++ b/src/Batch/MpiImpl.hxx @@ -29,9 +29,10 @@ #ifndef _BL_MPIIMPL_H_ #define _BL_MPIIMPL_H_ +#include "Batch_Defines.hxx" #include -class MpiImplException +class BATCH_EXPORT MpiImplException { public: const std::string msg; @@ -39,7 +40,7 @@ public: MpiImplException(const std::string m) : msg(m) {} }; -class MpiImpl +class BATCH_EXPORT MpiImpl { public: // Constructeur et destructeur @@ -58,7 +59,7 @@ private: }; -class MpiImpl_LAM : public MpiImpl +class BATCH_EXPORT MpiImpl_LAM : public MpiImpl { public: // Constructeur et destructeur @@ -77,7 +78,7 @@ private: }; -class MpiImpl_MPICH1 : public MpiImpl +class BATCH_EXPORT MpiImpl_MPICH1 : public MpiImpl { public: // Constructeur et destructeur @@ -96,7 +97,7 @@ private: }; -class MpiImpl_MPICH2 : public MpiImpl +class BATCH_EXPORT MpiImpl_MPICH2 : public MpiImpl { public: // Constructeur et destructeur @@ -115,7 +116,7 @@ private: }; -class MpiImpl_OPENMPI : public MpiImpl +class BATCH_EXPORT MpiImpl_OPENMPI : public MpiImpl { public: // Constructeur et destructeur @@ -134,7 +135,7 @@ private: }; -class MpiImpl_SLURM : public MpiImpl +class BATCH_EXPORT MpiImpl_SLURM : public MpiImpl { public: // Constructeur et destructeur diff --git a/src/Batch_SWIG/libBatch_Swig.i b/src/Batch_SWIG/libBatch_Swig.i index f5b5e791a..4bf0acae6 100644 --- a/src/Batch_SWIG/libBatch_Swig.i +++ b/src/Batch_SWIG/libBatch_Swig.i @@ -41,6 +41,9 @@ /* Le nom du module Python tel qu'il est importe */ %module libBatch_Swig +/* generate docstrings with types */ +%feature("autodoc", "1"); + /* Inclusion des conversions de type */ %include libBatch_Swig_typemap.i @@ -48,6 +51,7 @@ %include libBatch_Swig_exception.i %{ +#include "Batch_Defines.hxx" #include "Batch_Job.hxx" #include "Batch_JobId.hxx" #include "Batch_JobInfo.hxx" @@ -58,6 +62,7 @@ %} /* Les classes exportees en Python */ +%include Batch_Defines.hxx %include Batch_Job.hxx %include Batch_JobId.hxx %include Batch_JobInfo.hxx diff --git a/src/Batch_SWIG/libBatch_Swig_typemap.i b/src/Batch_SWIG/libBatch_Swig_typemap.i index 06bdfce39..9fb772fee 100644 --- a/src/Batch_SWIG/libBatch_Swig_typemap.i +++ b/src/Batch_SWIG/libBatch_Swig_typemap.i @@ -53,6 +53,10 @@ } } +%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER) Batch::Parametre +{ + $1 = PyDict_Check($input)? 1 : 0; +} # // construction d'un dictionnaire Python a partir d'un objet Parametre C++ %typemap(out) Batch::Parametre @@ -136,6 +140,10 @@ } } +%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER) Batch::Environnement +{ + $1 = PyDict_Check($input)? 1 : 0; +} # // construction d'un dictionnaire Python a partir d'un objet Environnement C++ %typemap(out) Batch::Environnement diff --git a/src/Communication/SALOMEMultiComm.cxx b/src/Communication/SALOMEMultiComm.cxx index 823639296..f268af917 100644 --- a/src/Communication/SALOMEMultiComm.cxx +++ b/src/Communication/SALOMEMultiComm.cxx @@ -18,9 +18,6 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #include "SALOMEMultiComm.hxx" -#ifndef WNT -using namespace std; -#endif SALOMEMultiComm::SALOMEMultiComm():_type(SALOME::CORBA_) { diff --git a/src/Communication/SALOME_Comm_i.cxx b/src/Communication/SALOME_Comm_i.cxx index 02f7e68fd..1aeed449c 100644 --- a/src/Communication/SALOME_Comm_i.cxx +++ b/src/Communication/SALOME_Comm_i.cxx @@ -18,7 +18,7 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #include "SALOME_Comm_i.hxx" -#ifndef WNT +#ifndef WIN32 #include #endif #include "omniORB4/poa.h" @@ -30,7 +30,7 @@ #include "SenderFactory.hxx" using namespace std; -#ifndef WNT +#ifndef WIN32 CORBA::ORB_var &getGlobalORB(){ ORB_INIT &init = *SINGLETON_::Instance(); CORBA::ORB_var &orb = init(0,0); diff --git a/src/Communication/SALOME_Comm_i.hxx b/src/Communication/SALOME_Comm_i.hxx index 6664fc4c0..6de8d596c 100644 --- a/src/Communication/SALOME_Comm_i.hxx +++ b/src/Communication/SALOME_Comm_i.hxx @@ -130,7 +130,7 @@ public: ~SALOME_CorbaLongCSender_i(); CORBA::ULong getSize(); SALOME::vectorOfLong* sendPart(CORBA::ULong offset, CORBA::ULong length); -#ifndef WNT +#ifndef WIN32 SALOME::CorbaLongCSender_ptr _this(); #endif }; @@ -161,7 +161,7 @@ private: /*! Type the component of the array*/ SALOME::TypeOfDataTransmitted _type; public: - SALOME_MPISender_i(const void *tabToSend,long lgrTabToSend,int sizeOf,bool ownTabToSend=false); + SALOME_MPISender_i(const void *tabToSend,long lgrTabToSend,int sizeOf,bool owntabToSend=false); ~SALOME_MPISender_i(); SALOME::MPISender::param* getParam(); void send(); @@ -175,7 +175,7 @@ class COMMUNICATION_EXPORT SALOME_MPISenderDouble_i : public POA_SALOME::MPISend public SALOME_MPISender_i { public: - SALOME_MPISenderDouble_i(const double *tabToSend,long lgrTabToSend,bool ownTabToSend=false); + SALOME_MPISenderDouble_i(const double *tabToSend,long lgrTabToSend,bool oWNTabToSend=false); }; class COMMUNICATION_EXPORT SALOME_MPISenderInt_i : public POA_SALOME::MPISenderInt, @@ -183,7 +183,7 @@ class COMMUNICATION_EXPORT SALOME_MPISenderInt_i : public POA_SALOME::MPISenderI public SALOME_MPISender_i { public: - SALOME_MPISenderInt_i(const int *tabToSend,long lgrTabToSend,bool ownTabToSend=false); + SALOME_MPISenderInt_i(const int *tabToSend,long lgrTabToSend,bool owntabToSend=false); }; #endif @@ -206,7 +206,7 @@ private: /*! Type the component of the array*/ SALOME::TypeOfDataTransmitted _type; public: - SALOME_SocketSender_i(const void *tabToSend,long lgrTabToSend,int sizeOf,bool ownTabToSend=false); + SALOME_SocketSender_i(const void *tabToSend,long lgrTabToSend,int sizeOf,bool owntabToSend=false); ~SALOME_SocketSender_i(); SALOME::SocketSender::param* getParam(); void send(); @@ -224,7 +224,7 @@ class COMMUNICATION_EXPORT SALOME_SocketSenderDouble_i : public POA_SALOME::Sock public SALOME_SocketSender_i { public: - SALOME_SocketSenderDouble_i(const double *tabToSend,long lgrTabToSend,bool ownTabToSend=false); + SALOME_SocketSenderDouble_i(const double *tabToSend,long lgrTabToSend,bool owntabToSend=false); }; class COMMUNICATION_EXPORT SALOME_SocketSenderInt_i : public POA_SALOME::SocketSenderInt, @@ -232,7 +232,7 @@ class COMMUNICATION_EXPORT SALOME_SocketSenderInt_i : public POA_SALOME::SocketS public SALOME_SocketSender_i { public: - SALOME_SocketSenderInt_i(const int *tabToSend,long lgrTabToSend,bool ownTabToSend=false); + SALOME_SocketSenderInt_i(const int *tabToSend,long lgrTabToSend,bool owntabToSend=false); }; #endif diff --git a/src/Communication/SALOME_Communication.hxx b/src/Communication/SALOME_Communication.hxx index 93c11cc56..bc92ee00c 100755 --- a/src/Communication/SALOME_Communication.hxx +++ b/src/Communication/SALOME_Communication.hxx @@ -26,22 +26,14 @@ #ifndef _SALOME_COMMIUNICATION_HXX_ #define _SALOME_COMMIUNICATION_HXX_ -#ifdef WNT - #if defined COMMUNICATION_EXPORTS - #if defined WIN32 - #define COMMUNICATION_EXPORT __declspec( dllexport ) - #else - #define COMMUNICATION_EXPORT - #endif - #else - #if defined WIN32 - #define COMMUNICATION_EXPORT __declspec( dllimport ) - #else - #define COMMUNICATION_EXPORT - #endif - #endif +#ifdef WIN32 +# ifdef COMMUNICATION_EXPORTS +# define COMMUNICATION_EXPORT __declspec( dllexport ) +# else +# define COMMUNICATION_EXPORT __declspec( dllimport ) +# endif #else - #define COMMUNICATION_EXPORT +# define COMMUNICATION_EXPORT #endif #endif diff --git a/src/Communication_SWIG/libSALOME_Comm.i b/src/Communication_SWIG/libSALOME_Comm.i index f27bc4f3c..ea53d3017 100644 --- a/src/Communication_SWIG/libSALOME_Comm.i +++ b/src/Communication_SWIG/libSALOME_Comm.i @@ -19,6 +19,8 @@ // %module libSALOME_Comm +%feature("autodoc", "1"); + %{ #include "ReceiverFactory.hxx" #include "MatrixClient.hxx" diff --git a/src/Container/Component_i.cxx b/src/Container/Component_i.cxx index 885750da9..269b0ed87 100644 --- a/src/Container/Component_i.cxx +++ b/src/Container/Component_i.cxx @@ -30,15 +30,15 @@ #include "SALOME_Component_i.hxx" #include "SALOME_Container_i.hxx" #include "RegistryConnexion.hxx" -#include "OpUtil.hxx" +#include "Basics_Utils.hxx" #include -#ifndef WNT +#ifndef WIN32 #include #endif #include #include "utilities.h" -#ifndef WNT +#ifndef WIN32 #include #include #include @@ -125,6 +125,7 @@ Engines_Component_i::Engines_Component_i(CORBA::ORB_ptr orb, * \param instanceName unique instance name for this object (see Container_i) * \param interfaceName component class name * \param notif use of notification + * \param regist (true or false) use of registry (default true) */ //============================================================================= @@ -133,7 +134,8 @@ Engines_Component_i::Engines_Component_i(CORBA::ORB_ptr orb, Engines::Container_ptr container, const char *instanceName, const char *interfaceName, - bool notif) : + bool notif, + bool regist) : _instanceName(instanceName), _interfaceName(interfaceName), _myConnexionToRegistry(0), @@ -160,7 +162,8 @@ Engines_Component_i::Engines_Component_i(CORBA::ORB_ptr orb, _contId = 0; } const CORBA::String_var ior = _orb->object_to_string(_container); - _myConnexionToRegistry = new RegistryConnexion(0, 0, ior,"theSession", _instanceName.c_str()); + if(regist) + _myConnexionToRegistry = new RegistryConnexion(0, 0, ior,"theSession", _instanceName.c_str()); _notifSupplier = new NOTIFICATION_Supplier(instanceName, notif); } @@ -265,7 +268,7 @@ CORBA::Long Engines_Component_i::getStudyId() void Engines_Component_i::ping() { -#ifndef WNT +#ifndef WIN32 MESSAGE("Engines_Component_i::ping() pid "<< getpid() << " threadid " << pthread_self()); #else @@ -290,11 +293,10 @@ void Engines_Component_i::destroy() MESSAGE("Engines_Component_i::destroy()"); //SCRUTE(pd_refCount); - delete _notifSupplier; - _notifSupplier = 0; - - delete _myConnexionToRegistry; + if(_myConnexionToRegistry)delete _myConnexionToRegistry; _myConnexionToRegistry = 0 ; + if(_notifSupplier)delete _notifSupplier; + _notifSupplier = 0; if(_id) delete(_id) ; //SCRUTE(pd_refCount); @@ -385,12 +387,12 @@ bool Engines_Component_i::Kill_impl() // MESSAGE("Engines_Component_i::Kill_i() pthread_t "<< pthread_self() // << " pid " << getpid() << " instanceName " // << _instanceName.c_str() << " interface " << _interfaceName.c_str() -// << " machineName " << GetHostname().c_str()<< " _id " << hex << _id +// << " machineName " << Kernel_Utils::GetHostname().c_str()<< " _id " << hex << _id // << dec << " _ThreadId " << _ThreadId << " this " << hex << this // << dec ) ; bool RetVal = false ; -#ifndef WNT +#ifndef WIN32 if ( _ThreadId > 0 && pthread_self() != _ThreadId ) { RetVal = Killer( _ThreadId , SIGUSR2 ) ; @@ -416,23 +418,23 @@ bool Engines_Component_i::Kill_impl() bool Engines_Component_i::Stop_impl() { -#ifndef WNT +#ifndef WIN32 MESSAGE("Engines_Component_i::Stop_i() pthread_t "<< pthread_self() << " pid " << getpid() << " instanceName " << _instanceName.c_str() << " interface " << _interfaceName.c_str() - << " machineName " << GetHostname().c_str()<< " _id " << hex << _id + << " machineName " << Kernel_Utils::GetHostname().c_str()<< " _id " << hex << _id << dec << " _ThreadId " << _ThreadId ); #else MESSAGE("Engines_Component_i::Stop_i() pthread_t "<< pthread_self().p << " pid " << _getpid() << " instanceName " << _instanceName.c_str() << " interface " << _interfaceName.c_str() - << " machineName " << GetHostname().c_str()<< " _id " << hex << _id + << " machineName " << Kernel_Utils::GetHostname().c_str()<< " _id " << hex << _id << dec << " _ThreadId " << _ThreadId ); #endif bool RetVal = false ; -#ifndef WNT +#ifndef WIN32 if ( _ThreadId > 0 && pthread_self() != _ThreadId ) { RetVal = Killer( _ThreadId , 0 ) ; @@ -456,22 +458,22 @@ bool Engines_Component_i::Stop_impl() bool Engines_Component_i::Suspend_impl() { -#ifndef WNT +#ifndef WIN32 MESSAGE("Engines_Component_i::Suspend_i() pthread_t "<< pthread_self() << " pid " << getpid() << " instanceName " << _instanceName.c_str() << " interface " << _interfaceName.c_str() - << " machineName " << GetHostname().c_str()<< " _id " << hex << _id + << " machineName " << Kernel_Utils::GetHostname().c_str()<< " _id " << hex << _id << dec << " _ThreadId " << _ThreadId ); #else MESSAGE("Engines_Component_i::Suspend_i() pthread_t "<< pthread_self().p << " pid " << _getpid() << " instanceName " << _instanceName.c_str() << " interface " << _interfaceName.c_str() - << " machineName " << GetHostname().c_str()<< " _id " << hex << _id + << " machineName " << Kernel_Utils::GetHostname().c_str()<< " _id " << hex << _id << dec << " _ThreadId " << _ThreadId ); #endif bool RetVal = false ; -#ifndef WNT +#ifndef WIN32 if ( _ThreadId > 0 && pthread_self() != _ThreadId ) #else if ( _ThreadId > 0 && pthread_self().p != _ThreadId->p ) @@ -483,7 +485,7 @@ bool Engines_Component_i::Suspend_impl() } else { -#ifndef WNT +#ifndef WIN32 RetVal = Killer( _ThreadId ,SIGINT ) ; #else RetVal = Killer( *_ThreadId ,SIGINT ) ; @@ -503,21 +505,21 @@ bool Engines_Component_i::Suspend_impl() bool Engines_Component_i::Resume_impl() { -#ifndef WNT +#ifndef WIN32 MESSAGE("Engines_Component_i::Resume_i() pthread_t "<< pthread_self() << " pid " << getpid() << " instanceName " << _instanceName.c_str() << " interface " << _interfaceName.c_str() - << " machineName " << GetHostname().c_str()<< " _id " << hex << _id + << " machineName " << Kernel_Utils::GetHostname().c_str()<< " _id " << hex << _id << dec << " _ThreadId " << _ThreadId ); #else MESSAGE("Engines_Component_i::Resume_i() pthread_t "<< pthread_self().p << " pid " << _getpid() << " instanceName " << _instanceName.c_str() << " interface " << _interfaceName.c_str() - << " machineName " << GetHostname().c_str()<< " _id " << hex << _id + << " machineName " << Kernel_Utils::GetHostname().c_str()<< " _id " << hex << _id << dec << " _ThreadId " << _ThreadId ); #endif bool RetVal = false ; -#ifndef WNT +#ifndef WIN32 if ( _ThreadId > 0 && pthread_self() != _ThreadId ) #else if ( _ThreadId > 0 && pthread_self().p != _ThreadId->p ) @@ -549,7 +551,7 @@ CORBA::Long Engines_Component_i::CpuUsed_impl() { if ( _ThreadId > 0 ) { -#ifndef WNT +#ifndef WIN32 if ( pthread_self() != _ThreadId ) #else if ( pthread_self().p != _ThreadId->p ) @@ -562,7 +564,7 @@ CORBA::Long Engines_Component_i::CpuUsed_impl() { // Get Cpu in the appropriate thread with that object !... theEngines_Component = this ; -#ifndef WNT +#ifndef WIN32 Killer( _ThreadId ,SIGUSR1 ) ; #else Killer( *_ThreadId ,SIGUSR11 ) ; @@ -651,14 +653,14 @@ PortableServer::ObjectId * Engines_Component_i::getId() void Engines_Component_i::beginService(const char *serviceName) { -#ifndef WNT +#ifndef WIN32 MESSAGE(pthread_self() << "Send BeginService notification for " < #include #include -#ifndef WNT +#ifndef WIN32 #include #include #include #else #include #include +#include int SIGUSR1 = 1000; #endif #include "utilities.h" #include -//#ifndef WNT #include CORBA_SERVER_HEADER(SALOME_Component) #include CORBA_SERVER_HEADER(SALOME_Exception) -//#else -//#include -//#endif #include // must be before Python.h ! #include "SALOME_Container_i.hxx" #include "SALOME_Component_i.hxx" @@ -55,7 +52,7 @@ int SIGUSR1 = 1000; #include "SALOME_FileTransfer_i.hxx" #include "Salome_file_i.hxx" #include "SALOME_NamingService.hxx" -#include "OpUtil.hxx" +#include "Basics_Utils.hxx" #include #include "Container_init_python.hxx" @@ -73,10 +70,16 @@ char ** _ArgV ; // Other Containers are started via start_impl of FactoryServer extern "C" {void ActSigIntHandler() ; } -#ifndef WNT - extern "C" {void SigIntHandler(int, siginfo_t *, void *) ; } +#ifndef WIN32 +extern "C" {void SigIntHandler(int, siginfo_t *, void *) ; } #else - extern "C" {void SigIntHandler( int ) ; } +extern "C" {void SigIntHandler( int ) ; } +#endif + +#ifdef WIN32 +# define separator '\\' +#else +# define separator '/' #endif @@ -87,19 +90,19 @@ omni_mutex Engines_Container_i::_numInstanceMutex ; //============================================================================= /*! - * Default constructor, not for use - */ +* Default constructor, not for use +*/ //============================================================================= Engines_Container_i::Engines_Container_i () : - _numInstance(0) +_numInstance(0) { } //============================================================================= /*! - * Construtor to use - */ +* Construtor to use +*/ //============================================================================= Engines_Container_i::Engines_Container_i (CORBA::ORB_ptr orb, @@ -109,7 +112,7 @@ Engines_Container_i::Engines_Container_i (CORBA::ORB_ptr orb, bool activAndRegist, bool isServantAloneInProcess ) : - _numInstance(0),_isServantAloneInProcess(isServantAloneInProcess) +_numInstance(0),_isServantAloneInProcess(isServantAloneInProcess) { _pid = (long)getpid(); @@ -119,107 +122,107 @@ Engines_Container_i::Engines_Container_i (CORBA::ORB_ptr orb, _argc = argc ; _argv = argv ; - string hostname = GetHostname(); -#ifndef WNT + string hostname = Kernel_Utils::GetHostname(); +#ifndef WIN32 MESSAGE(hostname << " " << getpid() << - " Engines_Container_i starting argc " << - _argc << " Thread " << pthread_self() ) ; + " Engines_Container_i starting argc " << + _argc << " Thread " << pthread_self() ) ; #else MESSAGE(hostname << " " << _getpid() << - " Engines_Container_i starting argc " << _argc<< " Thread " << pthread_self().p ) ; + " Engines_Container_i starting argc " << _argc<< " Thread " << pthread_self().p ) ; #endif int i = 0 ; while ( _argv[ i ] ) - { - MESSAGE(" argv" << i << " " << _argv[ i ]) ; - i++ ; - } + { + MESSAGE(" argv" << i << " " << _argv[ i ]) ; + i++ ; + } if ( argc < 2 ) - { - INFOS("SALOME_Container usage : SALOME_Container ServerName"); - ASSERT(0) ; - } + { + INFOS("SALOME_Container usage : SALOME_Container ServerName"); + ASSERT(0) ; + } SCRUTE(argv[1]); _isSupervContainer = false; if (strcmp(argv[1],"SuperVisionContainer") == 0) _isSupervContainer = true; if (_isSupervContainer) - { - _ArgC = argc ; - _ArgV = argv ; - } + { + _ArgC = argc ; + _ArgV = argv ; + } _orb = CORBA::ORB::_duplicate(orb) ; _poa = PortableServer::POA::_duplicate(poa) ; - + // Pour les containers paralleles: il ne faut pas enregistrer et activer // le container generique, mais le container specialise if(activAndRegist) + { + _id = _poa->activate_object(this); + _NS = new SALOME_NamingService(); + _NS->init_orb( _orb ) ; + CORBA::Object_var obj=_poa->id_to_reference(*_id); + Engines::Container_var pCont + = Engines::Container::_narrow(obj); + _remove_ref(); + + _containerName = _NS->BuildContainerNameForNS(containerName, + hostname.c_str()); + SCRUTE(_containerName); + _NS->Register(pCont, _containerName.c_str()); + MESSAGE("Engines_Container_i::Engines_Container_i : Container name " + << _containerName); + + // Python: + // import SALOME_Container + // pycont = SALOME_Container.SALOME_Container_i(containerIORStr) + + CORBA::String_var sior = _orb->object_to_string(pCont); + string myCommand="pyCont = SALOME_Container.SALOME_Container_i('"; + myCommand += _containerName + "','"; + myCommand += sior; + myCommand += "')\n"; + SCRUTE(myCommand); + + if (!_isSupervContainer) { - _id = _poa->activate_object(this); - _NS = new SALOME_NamingService(); - _NS->init_orb( _orb ) ; - CORBA::Object_var obj=_poa->id_to_reference(*_id); - Engines::Container_var pCont - = Engines::Container::_narrow(obj); - _remove_ref(); - - _containerName = _NS->BuildContainerNameForNS(containerName, - hostname.c_str()); - SCRUTE(_containerName); - _NS->Register(pCont, _containerName.c_str()); - MESSAGE("Engines_Container_i::Engines_Container_i : Container name " - << _containerName); - - // Python: - // import SALOME_Container - // pycont = SALOME_Container.SALOME_Container_i(containerIORStr) - - CORBA::String_var sior = _orb->object_to_string(pCont); - string myCommand="pyCont = SALOME_Container.SALOME_Container_i('"; - myCommand += _containerName + "','"; - myCommand += sior; - myCommand += "')\n"; - SCRUTE(myCommand); - - if (!_isSupervContainer) - { -#ifdef WNT +#ifdef WIN32 - PyEval_AcquireLock(); - PyThreadState *myTstate = PyThreadState_New(KERNEL_PYTHON::_interp); - PyThreadState *myoldTstate = PyThreadState_Swap(myTstate); + PyEval_AcquireLock(); + PyThreadState *myTstate = PyThreadState_New(KERNEL_PYTHON::_interp); + PyThreadState *myoldTstate = PyThreadState_Swap(myTstate); #else - Py_ACQUIRE_NEW_THREAD; + Py_ACQUIRE_NEW_THREAD; #endif -#ifdef WNT - // mpv: this is temporary solution: there is a unregular crash if not - //Sleep(2000); - // - // first element is the path to Registry.dll, but it's wrong - PyRun_SimpleString("import sys\n"); - PyRun_SimpleString("sys.path = sys.path[1:]\n"); +#ifdef WIN32 + // mpv: this is temporary solution: there is a unregular crash if not + //Sleep(2000); + // + // first element is the path to Registry.dll, but it's wrong + PyRun_SimpleString("import sys\n"); + PyRun_SimpleString("sys.path = sys.path[1:]\n"); #endif - PyRun_SimpleString("import SALOME_Container\n"); - PyRun_SimpleString((char*)myCommand.c_str()); - Py_RELEASE_NEW_THREAD; - } - - fileTransfer_i* aFileTransfer = new fileTransfer_i(); - CORBA::Object_var obref=aFileTransfer->_this(); - _fileTransfer = Engines::fileTransfer::_narrow(obref); - aFileTransfer->_remove_ref(); + PyRun_SimpleString("import SALOME_Container\n"); + PyRun_SimpleString((char*)myCommand.c_str()); + Py_RELEASE_NEW_THREAD; } + + fileTransfer_i* aFileTransfer = new fileTransfer_i(); + CORBA::Object_var obref=aFileTransfer->_this(); + _fileTransfer = Engines::fileTransfer::_narrow(obref); + aFileTransfer->_remove_ref(); + } } //============================================================================= /*! - * Destructor - */ +* Destructor +*/ //============================================================================= Engines_Container_i::~Engines_Container_i() @@ -232,19 +235,19 @@ Engines_Container_i::~Engines_Container_i() //============================================================================= /*! - * CORBA attribute: Container name (see constructor) - */ +* CORBA attribute: Container name (see constructor) +*/ //============================================================================= char* Engines_Container_i::name() { - return CORBA::string_dup(_containerName.c_str()) ; + return CORBA::string_dup(_containerName.c_str()) ; } //============================================================================= /*! - * CORBA attribute: Container working directory - */ +* CORBA attribute: Container working directory +*/ //============================================================================= char* Engines_Container_i::workingdir() @@ -256,8 +259,8 @@ char* Engines_Container_i::workingdir() //============================================================================= /*! - * CORBA attribute: Container log file name - */ +* CORBA attribute: Container log file name +*/ //============================================================================= char* Engines_Container_i::logfilename() @@ -272,21 +275,21 @@ void Engines_Container_i::logfilename(const char* name) //============================================================================= /*! - * CORBA method: Get the hostName of the Container (without domain extensions) - */ +* CORBA method: Get the hostName of the Container (without domain extensions) +*/ //============================================================================= char* Engines_Container_i::getHostName() { - string s = GetHostname(); + string s = Kernel_Utils::GetHostname(); // MESSAGE("Engines_Container_i::getHostName " << s); return CORBA::string_dup(s.c_str()) ; } //============================================================================= /*! - * CORBA method: Get the PID (process identification) of the Container - */ +* CORBA method: Get the PID (process identification) of the Container +*/ //============================================================================= CORBA::Long Engines_Container_i::getPID() @@ -296,8 +299,8 @@ CORBA::Long Engines_Container_i::getPID() //============================================================================= /*! - * CORBA method: check if servant is still alive - */ +* CORBA method: check if servant is still alive +*/ //============================================================================= void Engines_Container_i::ping() @@ -307,11 +310,11 @@ void Engines_Container_i::ping() //============================================================================= /*! - * CORBA method, oneway: Server shutdown. - * - Container name removed from naming service, - * - servant deactivation, - * - orb shutdown if no other servants in the process - */ +* CORBA method, oneway: Server shutdown. +* - Container name removed from naming service, +* - servant deactivation, +* - orb shutdown if no other servants in the process +*/ //============================================================================= void Engines_Container_i::Shutdown() @@ -319,105 +322,165 @@ void Engines_Container_i::Shutdown() MESSAGE("Engines_Container_i::Shutdown()"); /* For each component contained in this container - * tell it to self-destroy - */ + * tell it to self-destroy + */ std::map::iterator itm; for (itm = _listInstances_map.begin(); itm != _listInstances_map.end(); itm++) - itm->second->destroy(); + { + try + { + itm->second->destroy(); + } + catch(const CORBA::Exception& e) + { + // ignore this entry and continue + } + catch(...) + { + // ignore this entry and continue + } + } _NS->Destroy_FullDirectory(_containerName.c_str()); _NS->Destroy_Name(_containerName.c_str()); //_remove_ref(); //_poa->deactivate_object(*_id); if(_isServantAloneInProcess) - { - MESSAGE("Effective Shutdown of container Begins..."); - if(!CORBA::is_nil(_orb)) - _orb->shutdown(0); - } + { + MESSAGE("Effective Shutdown of container Begins..."); + if(!CORBA::is_nil(_orb)) + _orb->shutdown(0); + } } /* int checkifexecutable(const char *filename) - * - * Return non-zero if the name is an executable file, and - * zero if it is not executable, or if it does not exist. - */ +* +* Return non-zero if the name is an executable file, and +* zero if it is not executable, or if it does not exist. +*/ -int checkifexecutable(const char *filename) +int checkifexecutable(const string& filename) { - int result; - struct stat statinfo; - - result = stat(filename, &statinfo); - if (result < 0) return 0; - if (!S_ISREG(statinfo.st_mode)) return 0; - - if (statinfo.st_uid == geteuid()) return statinfo.st_mode & S_IXUSR; - if (statinfo.st_gid == getegid()) return statinfo.st_mode & S_IXGRP; - return statinfo.st_mode & S_IXOTH; + int result; + struct stat statinfo; + + result = stat(filename.c_str(), &statinfo); + if (result < 0) return 0; + if (!S_ISREG(statinfo.st_mode)) return 0; + +#ifdef WIN32 + return 1; +#else + if (statinfo.st_uid == geteuid()) return statinfo.st_mode & S_IXUSR; + if (statinfo.st_gid == getegid()) return statinfo.st_mode & S_IXGRP; + return statinfo.st_mode & S_IXOTH; +#endif } /* int findpathof(char *pth, const char *exe) - * - * Find executable by searching the PATH environment variable. - * - * const char *exe - executable name to search for. - * char *pth - the path found is stored here, space - * needs to be available. - * - * If a path is found, returns non-zero, and the path is stored - * in pth. If exe is not found returns 0, with pth undefined. - */ - -int findpathof(char *pth, const char *exe) +* +* Find executable by searching the PATH environment variable. +* +* const char *exe - executable name to search for. +* char *pth - the path found is stored here, space +* needs to be available. +* +* If a path is found, returns non-zero, and the path is stored +* in pth. If exe is not found returns 0, with pth undefined. +*/ + +int findpathof(string& pth, const string& exe) { - char *searchpath; - char *beg, *end; - int stop, found; - int len; - - if (strchr(exe, '/') != NULL) { - if (realpath(exe, pth) == NULL) return 0; - return checkifexecutable(pth); - } - - searchpath = getenv("PATH"); - if (searchpath == NULL) return 0; - if (strlen(searchpath) <= 0) return 0; - - beg = searchpath; - stop = 0; found = 0; - do { - end = strchr(beg, ':'); - if (end == NULL) { - stop = 1; - strncpy(pth, beg, PATH_MAX); - len = strlen(pth); - } else { - strncpy(pth, beg, end - beg); - pth[end - beg] = '\0'; - len = end - beg; - } - if (pth[len - 1] != '/') strncat(pth, "/", 1); - strncat(pth, exe, PATH_MAX - len); - found = checkifexecutable(pth); - if (!stop) beg = end + 1; - } while (!stop && !found); - - return found; + string path( getenv("PATH") ); + if ( path.size() == 0 ) + return 0; + + char path_spr = +#ifdef WIN32 + ';'; +#else + ':'; +#endif + + char dir_spr = +#ifdef WIN32 + '\\'; +#else + '/'; +#endif + + int offset = 0; + int stop = 0; + int found = 0; + while(!stop && !found) + { + int pos = path.find( path_spr, offset ); + if (pos == string::npos) + stop = 1; + + pth = path.substr( offset, pos - offset ); + if ( pth.size() > 0 ) + { + if( pth[pth.size()-1] != dir_spr ) + pth += dir_spr; + pth += exe; + found = checkifexecutable(pth.c_str()); + } + offset = pos+1; + } + + +/* char *searchpath; + char *beg, *end; + int stop, found; + int len; + + if (strchr(exe, separator) != NULL) { +#ifndef WIN32 + if (realpath(exe, pth) == NULL) return 0; +#endif + return checkifexecutable(pth); + } + + searchpath = getenv("PATH"); + if (searchpath == NULL) return 0; + if (strlen(searchpath) <= 0) return 0; + + string env_path(searchpath); + + beg = searchpath; + stop = 0; found = 0; + do { + end = strchr(beg, ':'); + if (end == NULL) { + stop = 1; + strncpy(pth, beg, PATH_MAX); + len = strlen(pth); + } else { + strncpy(pth, beg, end - beg); + pth[end - beg] = '\0'; + len = end - beg; + } + if (pth[len - 1] != '/') strncat(pth, "/", 1); + strncat(pth, exe, PATH_MAX - len); + found = checkifexecutable(pth); + if (!stop) beg = end + 1; + } while (!stop && !found); +*/ + return found; } //============================================================================= /*! - * CORBA method: load a new component class (Python or C++ implementation) - * \param componentName like COMPONENT - * try to make a Python import of COMPONENT, - * then a lib open of libCOMPONENTEngine.so - * \return true if dlopen successfull or already done, false otherwise - */ +* CORBA method: load a new component class (Python or C++ implementation) +* \param componentName like COMPONENT +* try to make a Python import of COMPONENT, +* then a lib open of libCOMPONENTEngine.so +* \return true if dlopen successfull or already done, false otherwise +*/ //============================================================================= bool @@ -428,24 +491,24 @@ Engines_Container_i::load_component_Library(const char* componentName) // --- try dlopen C++ component -#ifndef WNT +#ifndef WIN32 string impl_name = string ("lib") + aCompName + string("Engine.so"); #else string impl_name = aCompName + string("Engine.dll"); #endif SCRUTE(impl_name); - + _numInstanceMutex.lock(); // lock to be alone // (see decInstanceCnt, finalize_removal)) if (_toRemove_map.count(impl_name) != 0) _toRemove_map.erase(impl_name); if (_library_map.count(impl_name) != 0) - { - MESSAGE("Library " << impl_name << " already loaded"); - _numInstanceMutex.unlock(); - return true; - } - -#ifndef WNT + { + MESSAGE("Library " << impl_name << " already loaded"); + _numInstanceMutex.unlock(); + return true; + } + +#ifndef WIN32 void* handle; handle = dlopen( impl_name.c_str() , RTLD_LAZY ) ; #else @@ -455,9 +518,9 @@ Engines_Container_i::load_component_Library(const char* componentName) if ( handle ) { - _library_map[impl_name] = handle; - _numInstanceMutex.unlock(); - return true; + _library_map[impl_name] = handle; + _numInstanceMutex.unlock(); + return true; } _numInstanceMutex.unlock(); @@ -465,41 +528,41 @@ Engines_Container_i::load_component_Library(const char* componentName) INFOS("try import Python component "<0) otherwise - * \return a loaded component - */ +* CORBA method: Creates a new servant instance of a component. +* The servant registers itself to naming service and Registry. +* \param genericRegisterName Name of the component instance to register +* in Registry & Name Service (without _inst_n suffix) +* \param studyId 0 for multiStudy instance, +* study Id (>0) otherwise +* \return a loaded component +*/ //============================================================================= Engines::Component_ptr @@ -526,71 +589,71 @@ Engines_Container_i::create_component_instance(const char*genericRegisterName, CORBA::Long studyId) { if (studyId < 0) - { - INFOS("studyId must be > 0 for mono study instance, =0 for multiStudy"); - return Engines::Component::_nil() ; - } + { + INFOS("studyId must be > 0 for mono study instance, =0 for multiStudy"); + return Engines::Component::_nil() ; + } Engines::Component_var iobject = Engines::Component::_nil() ; string aCompName = genericRegisterName; if (_library_map.count(aCompName) != 0) // Python component + { + if (_isSupervContainer) { - if (_isSupervContainer) - { - INFOS("Supervision Container does not support Python Component Engines"); - return Engines::Component::_nil(); - } - _numInstanceMutex.lock() ; // lock on the instance number - _numInstance++ ; - int numInstance = _numInstance ; - _numInstanceMutex.unlock() ; - - char aNumI[12]; - sprintf( aNumI , "%d" , numInstance ) ; - string instanceName = aCompName + "_inst_" + aNumI ; - string component_registerName = - _containerName + "/" + instanceName; - - Py_ACQUIRE_NEW_THREAD; - PyObject *mainmod = PyImport_AddModule("__main__"); - PyObject *globals = PyModule_GetDict(mainmod); - PyObject *pyCont = PyDict_GetItemString(globals, "pyCont"); - PyObject *result = PyObject_CallMethod(pyCont, - (char*)"create_component_instance", - (char*)"ssl", - aCompName.c_str(), - instanceName.c_str(), - studyId); - string iors = PyString_AsString(result); - Py_DECREF(result); - SCRUTE(iors); - Py_RELEASE_NEW_THREAD; - - if( iors!="" ) - { - CORBA::Object_var obj = _orb->string_to_object(iors.c_str()); - iobject = Engines::Component::_narrow( obj ) ; - _listInstances_map[instanceName] = iobject; - } - return iobject._retn(); + INFOS("Supervision Container does not support Python Component Engines"); + return Engines::Component::_nil(); + } + _numInstanceMutex.lock() ; // lock on the instance number + _numInstance++ ; + int numInstance = _numInstance ; + _numInstanceMutex.unlock() ; + + char aNumI[12]; + sprintf( aNumI , "%d" , numInstance ) ; + string instanceName = aCompName + "_inst_" + aNumI ; + string component_registerName = + _containerName + "/" + instanceName; + + Py_ACQUIRE_NEW_THREAD; + PyObject *mainmod = PyImport_AddModule("__main__"); + PyObject *globals = PyModule_GetDict(mainmod); + PyObject *pyCont = PyDict_GetItemString(globals, "pyCont"); + PyObject *result = PyObject_CallMethod(pyCont, + (char*)"create_component_instance", + (char*)"ssl", + aCompName.c_str(), + instanceName.c_str(), + studyId); + string iors = PyString_AsString(result); + Py_DECREF(result); + SCRUTE(iors); + Py_RELEASE_NEW_THREAD; + + if( iors!="" ) + { + CORBA::Object_var obj = _orb->string_to_object(iors.c_str()); + iobject = Engines::Component::_narrow( obj ) ; + _listInstances_map[instanceName] = iobject; } - + return iobject._retn(); + } + //--- try C++ -#ifndef WNT +#ifndef WIN32 string impl_name = string ("lib") + genericRegisterName +string("Engine.so"); #else string impl_name = genericRegisterName +string("Engine.dll"); #endif if (_library_map.count(impl_name) != 0) // C++ component - { - void* handle = _library_map[impl_name]; - iobject = createInstance(genericRegisterName, - handle, - studyId); - return iobject._retn(); - } + { + void* handle = _library_map[impl_name]; + iobject = createInstance(genericRegisterName, + handle, + studyId); + return iobject._retn(); + } // If it's not a Python or a C++ component try to launch a standalone component // in a sub directory @@ -611,11 +674,11 @@ Engines_Container_i::create_component_instance(const char*genericRegisterName, //check if an entry exist in naming service CORBA::Object_var nsobj = _NS->Resolve(component_registerName.c_str()); if ( !CORBA::is_nil(nsobj) ) - { - // unregister the registered component - _NS->Destroy_Name(component_registerName.c_str()); - //kill or shutdown it ??? - } + { + // unregister the registered component + _NS->Destroy_Name(component_registerName.c_str()); + //kill or shutdown it ??? + } // first arg container ior string // second arg container name @@ -644,97 +707,99 @@ Engines_Container_i::create_component_instance(const char*genericRegisterName, int status=system(command.c_str()); if (status == -1) - { - MESSAGE("SALOME_Container::create_component_instance system failed " << "(system command status -1)"); - return Engines::Component::_nil(); - } + { + MESSAGE("SALOME_Container::create_component_instance system failed " << "(system command status -1)"); + return Engines::Component::_nil(); + } +#ifndef WIN32 else if (WEXITSTATUS(status) == 217) - { - MESSAGE("SALOME_Container::create_component_instance system failed " << "(system command status 217)"); - return Engines::Component::_nil(); - } + { + MESSAGE("SALOME_Container::create_component_instance system failed " << "(system command status 217)"); + return Engines::Component::_nil(); + } +#endif else + { + int count=20; + CORBA::Object_var obj = CORBA::Object::_nil() ; + while ( CORBA::is_nil(obj) && count ) { - int count=20; - CORBA::Object_var obj = CORBA::Object::_nil() ; - while ( CORBA::is_nil(obj) && count ) - { -#ifndef WNT - sleep( 1 ) ; +#ifndef WIN32 + sleep( 1 ) ; #else - Sleep(1000); + Sleep(1000); #endif - count-- ; - MESSAGE( count << ". Waiting for component " << genericRegisterName); - obj = _NS->Resolve(component_registerName.c_str()); - } + count-- ; + MESSAGE( count << ". Waiting for component " << genericRegisterName); + obj = _NS->Resolve(component_registerName.c_str()); + } - if(CORBA::is_nil(obj)) - { - MESSAGE("SALOME_Container::create_component_instance failed"); - return Engines::Component::_nil(); - } - else - { - MESSAGE("SALOME_Container::create_component_instance successful"); - iobject=Engines::Component::_narrow(obj); - _listInstances_map[instanceName] = iobject; - return iobject._retn(); - } + if(CORBA::is_nil(obj)) + { + MESSAGE("SALOME_Container::create_component_instance failed"); + return Engines::Component::_nil(); } + else + { + MESSAGE("SALOME_Container::create_component_instance successful"); + iobject=Engines::Component::_narrow(obj); + _listInstances_map[instanceName] = iobject; + return iobject._retn(); + } + } } //============================================================================= /*! - * CORBA method: Finds a servant instance of a component - * \param registeredName Name of the component in Registry or Name Service, - * without instance suffix number - * \param studyId 0 if instance is not associated to a study, - * >0 otherwise (== study id) - * \return the first instance found with same studyId - */ +* CORBA method: Finds a servant instance of a component +* \param registeredName Name of the component in Registry or Name Service, +* without instance suffix number +* \param studyId 0 if instance is not associated to a study, +* >0 otherwise (== study id) +* \return the first instance found with same studyId +*/ //============================================================================= Engines::Component_ptr Engines_Container_i::find_component_instance( const char* registeredName, - CORBA::Long studyId) + CORBA::Long studyId) { Engines::Component_var anEngine = Engines::Component::_nil(); map::iterator itm =_listInstances_map.begin(); while (itm != _listInstances_map.end()) + { + string instance = (*itm).first; + SCRUTE(instance); + if (instance.find(registeredName) == 0) { - string instance = (*itm).first; - SCRUTE(instance); - if (instance.find(registeredName) == 0) - { - anEngine = (*itm).second; - if (studyId == anEngine->getStudyId()) - { - return anEngine._retn(); - } - } - itm++; + anEngine = (*itm).second; + if (studyId == anEngine->getStudyId()) + { + return anEngine._retn(); + } } + itm++; + } return anEngine._retn(); } //============================================================================= /*! - * CORBA method: find or create an instance of the component (servant), - * load a new component class (dynamic library) if required, - * ---- FOR COMPATIBILITY WITH 2.2 ---- - * ---- USE ONLY FOR MULTISTUDY INSTANCES ! -------- - * The servant registers itself to naming service and Registry. - * \param genericRegisterName Name of the component to register - * in Registry & Name Service - * \param componentName Name of the constructed library of the component - * \return a loaded component - */ +* CORBA method: find or create an instance of the component (servant), +* load a new component class (dynamic library) if required, +* ---- FOR COMPATIBILITY WITH 2.2 ---- +* ---- USE ONLY FOR MULTISTUDY INSTANCES ! -------- +* The servant registers itself to naming service and Registry. +* \param genericRegisterName Name of the component to register +* in Registry & Name Service +* \param componentName Name of the constructed library of the component +* \return a loaded component +*/ //============================================================================= Engines::Component_ptr Engines_Container_i::load_impl( const char* genericRegisterName, - const char* componentName ) + const char* componentName ) { string impl_name = string ("lib") + genericRegisterName +string("Engine.so"); Engines::Component_var iobject = Engines::Component::_nil() ; @@ -742,13 +807,13 @@ Engines_Container_i::load_impl( const char* genericRegisterName, iobject = find_or_create_instance(genericRegisterName, impl_name); return iobject._retn(); } - + //============================================================================= /*! - * CORBA method: Stops the component servant, and deletes all related objects - * \param component_i Component to be removed - */ +* CORBA method: Stops the component servant, and deletes all related objects +* \param component_i Component to be removed +*/ //============================================================================= void Engines_Container_i::remove_impl(Engines::Component_ptr component_i) @@ -765,44 +830,44 @@ void Engines_Container_i::remove_impl(Engines::Component_ptr component_i) //============================================================================= /*! - * CORBA method: Discharges unused libraries from the container. - */ +* CORBA method: Discharges unused libraries from the container. +*/ //============================================================================= void Engines_Container_i::finalize_removal() { MESSAGE("finalize unload : dlclose"); _numInstanceMutex.lock(); // lock to be alone - // (see decInstanceCnt, load_component_Library) + // (see decInstanceCnt, load_component_Library) map::iterator ith; for (ith = _toRemove_map.begin(); ith != _toRemove_map.end(); ith++) + { + void *handle = (*ith).second; + string impl_name= (*ith).first; + if (handle) { - void *handle = (*ith).second; - string impl_name= (*ith).first; - if (handle) - { - SCRUTE(handle); - SCRUTE(impl_name); -// dlclose(handle); // SALOME unstable after ... -// _library_map.erase(impl_name); - } + SCRUTE(handle); + SCRUTE(impl_name); + // dlclose(handle); // SALOME unstable after ... + // _library_map.erase(impl_name); } + } _toRemove_map.clear(); _numInstanceMutex.unlock(); } //============================================================================= /*! - * CORBA method: Kill the container process with exit(0). - * To remove : never returns ! - */ +* CORBA method: Kill the container process with exit(0). +* To remove : never returns ! +*/ //============================================================================= bool Engines_Container_i::Kill_impl() { MESSAGE("Engines_Container_i::Kill() pid "<< getpid() << " containerName " - << _containerName.c_str() << " machineName " - << GetHostname().c_str()); + << _containerName.c_str() << " machineName " + << Kernel_Utils::GetHostname().c_str()); INFOS("==============================================================="); INFOS("= REMOVE calls to Kill_impl in C++ container ="); INFOS("==============================================================="); @@ -813,14 +878,14 @@ bool Engines_Container_i::Kill_impl() //============================================================================= /*! - * CORBA method: get or create a fileRef object associated to a local file - * (a file on the computer on which runs the container server), which stores - * a list of (machine, localFileName) corresponding to copies already done. - * - * \param origFileName absolute path for a local file to copy on other - * computers - * \return a fileRef object associated to the file. - */ +* CORBA method: get or create a fileRef object associated to a local file +* (a file on the computer on which runs the container server), which stores +* a list of (machine, localFileName) corresponding to copies already done. +* +* \param origFileName absolute path for a local file to copy on other +* computers +* \return a fileRef object associated to the file. +*/ //============================================================================= Engines::fileRef_ptr @@ -830,22 +895,22 @@ Engines_Container_i::createFileRef(const char* origFileName) Engines::fileRef_var theFileRef = Engines::fileRef::_nil(); if (origName[0] != '/') - { - INFOS("path of file to copy must be an absolute path begining with '/'"); - return Engines::fileRef::_nil(); - } + { + INFOS("path of file to copy must be an absolute path begining with '/'"); + return Engines::fileRef::_nil(); + } if (CORBA::is_nil(_fileRef_map[origName])) - { - CORBA::Object_var obj=_poa->id_to_reference(*_id); - Engines::Container_var pCont = Engines::Container::_narrow(obj); - fileRef_i* aFileRef = new fileRef_i(pCont, origFileName); - theFileRef = Engines::fileRef::_narrow(aFileRef->_this()); - _numInstanceMutex.lock() ; // lock to be alone (stl container write) - _fileRef_map[origName] = theFileRef; - _numInstanceMutex.unlock() ; - } - + { + CORBA::Object_var obj=_poa->id_to_reference(*_id); + Engines::Container_var pCont = Engines::Container::_narrow(obj); + fileRef_i* aFileRef = new fileRef_i(pCont, origFileName); + theFileRef = Engines::fileRef::_narrow(aFileRef->_this()); + _numInstanceMutex.lock() ; // lock to be alone (stl container write) + _fileRef_map[origName] = theFileRef; + _numInstanceMutex.unlock() ; + } + theFileRef = Engines::fileRef::_duplicate(_fileRef_map[origName]); ASSERT(! CORBA::is_nil(theFileRef)); return theFileRef._retn(); @@ -853,9 +918,9 @@ Engines_Container_i::createFileRef(const char* origFileName) //============================================================================= /*! - * CORBA method: - * \return a reference to the fileTransfer object - */ +* CORBA method: +* \return a reference to the fileTransfer object +*/ //============================================================================= Engines::fileTransfer_ptr @@ -872,26 +937,26 @@ Engines_Container_i::createSalome_file(const char* origFileName) { string origName(origFileName); if (CORBA::is_nil(_Salome_file_map[origName])) + { + Salome_file_i* aSalome_file = new Salome_file_i(); + aSalome_file->setContainer(Engines::Container::_duplicate(this->_this())); + try { - Salome_file_i* aSalome_file = new Salome_file_i(); - aSalome_file->setContainer(Engines::Container::_duplicate(this->_this())); - try - { - aSalome_file->setLocalFile(origFileName); - aSalome_file->recvFiles(); - } - catch (const SALOME::SALOME_Exception& e) - { - return Engines::Salome_file::_nil(); - } - - Engines::Salome_file_var theSalome_file = Engines::Salome_file::_nil(); - theSalome_file = Engines::Salome_file::_narrow(aSalome_file->_this()); - _numInstanceMutex.lock() ; // lock to be alone (stl container write) - _Salome_file_map[origName] = theSalome_file; - _numInstanceMutex.unlock() ; + aSalome_file->setLocalFile(origFileName); + aSalome_file->recvFiles(); + } + catch (const SALOME::SALOME_Exception& e) + { + return Engines::Salome_file::_nil(); } - + + Engines::Salome_file_var theSalome_file = Engines::Salome_file::_nil(); + theSalome_file = Engines::Salome_file::_narrow(aSalome_file->_this()); + _numInstanceMutex.lock() ; // lock to be alone (stl container write) + _Salome_file_map[origName] = theSalome_file; + _numInstanceMutex.unlock() ; + } + Engines::Salome_file_ptr theSalome_file = Engines::Salome_file::_duplicate(_Salome_file_map[origName]); ASSERT(!CORBA::is_nil(theSalome_file)); @@ -899,25 +964,25 @@ Engines_Container_i::createSalome_file(const char* origFileName) } //============================================================================= /*! - * C++ method: Finds an already existing servant instance of a component, or - * create an instance. - * ---- USE ONLY FOR MULTISTUDY INSTANCES ! -------- - * \param genericRegisterName Name of the component instance to register - * in Registry & Name Service, - * (without _inst_n suffix, like "COMPONENT") - * \param componentLibraryName like "libCOMPONENTEngine.so" - * \return a loaded component - * - * example with names: - * aGenRegisterName = COMPONENT (= first argument) - * impl_name = libCOMPONENTEngine.so (= second argument) - * _containerName = /Containers/cli76ce/FactoryServer - * factoryName = COMPONENTEngine_factory - * component_registerBase = /Containers/cli76ce/FactoryServer/COMPONENT - * - * instanceName = COMPONENT_inst_1 - * component_registerName = /Containers/cli76ce/FactoryServer/COMPONENT_inst_1 - */ +* C++ method: Finds an already existing servant instance of a component, or +* create an instance. +* ---- USE ONLY FOR MULTISTUDY INSTANCES ! -------- +* \param genericRegisterName Name of the component instance to register +* in Registry & Name Service, +* (without _inst_n suffix, like "COMPONENT") +* \param componentLibraryName like "libCOMPONENTEngine.so" +* \return a loaded component +* +* example with names: +* aGenRegisterName = COMPONENT (= first argument) +* impl_name = libCOMPONENTEngine.so (= second argument) +* _containerName = /Containers/cli76ce/FactoryServer +* factoryName = COMPONENTEngine_factory +* component_registerBase = /Containers/cli76ce/FactoryServer/COMPONENT +* +* instanceName = COMPONENT_inst_1 +* component_registerName = /Containers/cli76ce/FactoryServer/COMPONENT_inst_1 +*/ //============================================================================= Engines::Component_ptr @@ -927,77 +992,77 @@ Engines_Container_i::find_or_create_instance(string genericRegisterName, string aGenRegisterName = genericRegisterName; string impl_name = componentLibraryName; if (_library_map.count(impl_name) == 0) - { - INFOS("shared library " << impl_name <<" must be loaded before creating instance"); - return Engines::Component::_nil() ; - } + { + INFOS("shared library " << impl_name <<" must be loaded before creating instance"); + return Engines::Component::_nil() ; + } else - { - // --- find a registered instance in naming service, or create + { + // --- find a registered instance in naming service, or create - void* handle = _library_map[impl_name]; - string component_registerBase = - _containerName + "/" + aGenRegisterName; - Engines::Component_var iobject = Engines::Component::_nil() ; - try + void* handle = _library_map[impl_name]; + string component_registerBase = + _containerName + "/" + aGenRegisterName; + Engines::Component_var iobject = Engines::Component::_nil() ; + try + { + CORBA::Object_var obj = + _NS->ResolveFirst( component_registerBase.c_str()); + if ( CORBA::is_nil( obj ) ) + { + iobject = createInstance(genericRegisterName, + handle, + 0); // force multiStudy instance here ! + } + else + { + iobject = Engines::Component::_narrow( obj ) ; + Engines_Component_i *servant = + dynamic_cast + (_poa->reference_to_servant(iobject)); + ASSERT(servant) + int studyId = servant->getStudyId(); + ASSERT (studyId >= 0); + if (studyId == 0) // multiStudy instance, OK { - CORBA::Object_var obj = - _NS->ResolveFirst( component_registerBase.c_str()); - if ( CORBA::is_nil( obj ) ) - { - iobject = createInstance(genericRegisterName, - handle, - 0); // force multiStudy instance here ! - } - else - { - iobject = Engines::Component::_narrow( obj ) ; - Engines_Component_i *servant = - dynamic_cast - (_poa->reference_to_servant(iobject)); - ASSERT(servant) - int studyId = servant->getStudyId(); - ASSERT (studyId >= 0); - if (studyId == 0) // multiStudy instance, OK - { - // No ReBind ! - MESSAGE(component_registerBase.c_str()<<" already bound"); - } - else // monoStudy instance: NOK - { - iobject = Engines::Component::_nil(); - INFOS("load_impl & find_component_instance methods " - << "NOT SUITABLE for mono study components"); - } - } + // No ReBind ! + MESSAGE(component_registerBase.c_str()<<" already bound"); } - catch (...) + else // monoStudy instance: NOK { - INFOS( "Container_i::load_impl catched" ) ; + iobject = Engines::Component::_nil(); + INFOS("load_impl & find_component_instance methods " + << "NOT SUITABLE for mono study components"); } - return iobject._retn(); + } + } + catch (...) + { + INFOS( "Container_i::load_impl catched" ) ; } + return iobject._retn(); + } } //============================================================================= /*! - * C++ method: create a servant instance of a component. - * \param genericRegisterName Name of the component instance to register - * in Registry & Name Service, - * (without _inst_n suffix, like "COMPONENT") - * \param handle loaded library handle - * \param studyId 0 for multiStudy instance, - * study Id (>0) otherwise - * \return a loaded component - * - * example with names: - * aGenRegisterName = COMPONENT (= first argument) - * _containerName = /Containers/cli76ce/FactoryServer - * factoryName = COMPONENTEngine_factory - * component_registerBase = /Containers/cli76ce/FactoryServer/COMPONENT - * instanceName = COMPONENT_inst_1 - * component_registerName = /Containers/cli76ce/FactoryServer/COMPONENT_inst_1 - */ +* C++ method: create a servant instance of a component. +* \param genericRegisterName Name of the component instance to register +* in Registry & Name Service, +* (without _inst_n suffix, like "COMPONENT") +* \param handle loaded library handle +* \param studyId 0 for multiStudy instance, +* study Id (>0) otherwise +* \return a loaded component +* +* example with names: +* aGenRegisterName = COMPONENT (= first argument) +* _containerName = /Containers/cli76ce/FactoryServer +* factoryName = COMPONENTEngine_factory +* component_registerBase = /Containers/cli76ce/FactoryServer/COMPONENT +* instanceName = COMPONENT_inst_1 +* component_registerName = /Containers/cli76ce/FactoryServer/COMPONENT_inst_1 +*/ //============================================================================= Engines::Component_ptr @@ -1013,12 +1078,12 @@ Engines_Container_i::createInstance(string genericRegisterName, typedef PortableServer::ObjectId * (*FACTORY_FUNCTION) (CORBA::ORB_ptr, - PortableServer::POA_ptr, - PortableServer::ObjectId *, - const char *, - const char *) ; + PortableServer::POA_ptr, + PortableServer::ObjectId *, + const char *, + const char *) ; -#ifndef WNT +#ifndef WIN32 FACTORY_FUNCTION Component_factory = (FACTORY_FUNCTION)dlsym( handle, factory_name.c_str() ); #else FACTORY_FUNCTION Component_factory = (FACTORY_FUNCTION)GetProcAddress( (HINSTANCE)handle, factory_name.c_str() ); @@ -1026,11 +1091,11 @@ Engines_Container_i::createInstance(string genericRegisterName, if ( !Component_factory ) { - INFOS( "Can't resolve symbol: " + factory_name ); -#ifndef WNT - SCRUTE( dlerror() ); + INFOS( "Can't resolve symbol: " + factory_name ); +#ifndef WIN32 + SCRUTE( dlerror() ); #endif - return Engines::Component::_nil() ; + return Engines::Component::_nil() ; } // --- create instance @@ -1038,68 +1103,68 @@ Engines_Container_i::createInstance(string genericRegisterName, Engines::Component_var iobject = Engines::Component::_nil() ; try - { - _numInstanceMutex.lock() ; // lock on the instance number - _numInstance++ ; - int numInstance = _numInstance ; - _numInstanceMutex.unlock() ; - - char aNumI[12]; - sprintf( aNumI , "%d" , numInstance ) ; - string instanceName = aGenRegisterName + "_inst_" + aNumI ; - string component_registerName = - _containerName + "/" + instanceName; - - // --- Instanciate required CORBA object - - PortableServer::ObjectId *id ; //not owner, do not delete (nore use var) - id = (Component_factory) ( _orb, _poa, _id, instanceName.c_str(), - aGenRegisterName.c_str() ) ; - if (id == NULL) - return iobject._retn(); - - // --- get reference & servant from id - - CORBA::Object_var obj = _poa->id_to_reference(*id); - iobject = Engines::Component::_narrow( obj ) ; + { + _numInstanceMutex.lock() ; // lock on the instance number + _numInstance++ ; + int numInstance = _numInstance ; + _numInstanceMutex.unlock() ; + + char aNumI[12]; + sprintf( aNumI , "%d" , numInstance ) ; + string instanceName = aGenRegisterName + "_inst_" + aNumI ; + string component_registerName = + _containerName + "/" + instanceName; + + // --- Instanciate required CORBA object + + PortableServer::ObjectId *id ; //not owner, do not delete (nore use var) + id = (Component_factory) ( _orb, _poa, _id, instanceName.c_str(), + aGenRegisterName.c_str() ) ; + if (id == NULL) + return iobject._retn(); - Engines_Component_i *servant = - dynamic_cast(_poa->reference_to_servant(iobject)); - ASSERT(servant); - //SCRUTE(servant->pd_refCount); - servant->_remove_ref(); // compensate previous id_to_reference - //SCRUTE(servant->pd_refCount); - _numInstanceMutex.lock() ; // lock to be alone (stl container write) - _listInstances_map[instanceName] = iobject; - _cntInstances_map[aGenRegisterName] += 1; - _numInstanceMutex.unlock() ; - SCRUTE(aGenRegisterName); - SCRUTE(_cntInstances_map[aGenRegisterName]); - //SCRUTE(servant->pd_refCount); + // --- get reference & servant from id + + CORBA::Object_var obj = _poa->id_to_reference(*id); + iobject = Engines::Component::_narrow( obj ) ; + + Engines_Component_i *servant = + dynamic_cast(_poa->reference_to_servant(iobject)); + ASSERT(servant); + //SCRUTE(servant->pd_refCount); + servant->_remove_ref(); // compensate previous id_to_reference + //SCRUTE(servant->pd_refCount); + _numInstanceMutex.lock() ; // lock to be alone (stl container write) + _listInstances_map[instanceName] = iobject; + _cntInstances_map[aGenRegisterName] += 1; + _numInstanceMutex.unlock() ; + SCRUTE(aGenRegisterName); + SCRUTE(_cntInstances_map[aGenRegisterName]); + //SCRUTE(servant->pd_refCount); #if defined(_DEBUG_) || defined(_DEBUG) - bool ret_studyId = servant->setStudyId(studyId); - ASSERT(ret_studyId); + bool ret_studyId = servant->setStudyId(studyId); + ASSERT(ret_studyId); #else - servant->setStudyId(studyId); + servant->setStudyId(studyId); #endif - // --- register the engine under the name - // containerName(.dir)/instanceName(.object) + // --- register the engine under the name + // containerName(.dir)/instanceName(.object) - _NS->Register( iobject , component_registerName.c_str() ) ; - MESSAGE( component_registerName.c_str() << " bound" ) ; - } + _NS->Register( iobject , component_registerName.c_str() ) ; + MESSAGE( component_registerName.c_str() << " bound" ) ; + } catch (...) - { - INFOS( "Container_i::createInstance exception catched" ) ; - } + { + INFOS( "Container_i::createInstance exception catched" ) ; + } return iobject._retn(); } //============================================================================= /*! - * - */ +* +*/ //============================================================================= void Engines_Container_i::decInstanceCnt(string genericRegisterName) @@ -1110,25 +1175,25 @@ void Engines_Container_i::decInstanceCnt(string genericRegisterName) MESSAGE("Engines_Container_i::decInstanceCnt " << aGenRegisterName); ASSERT(_cntInstances_map[aGenRegisterName] > 0); _numInstanceMutex.lock(); // lock to be alone - // (see finalize_removal, load_component_Library) + // (see finalize_removal, load_component_Library) _cntInstances_map[aGenRegisterName] -= 1; SCRUTE(_cntInstances_map[aGenRegisterName]); if (_cntInstances_map[aGenRegisterName] == 0) - { - string impl_name = - Engines_Component_i::GetDynLibraryName(aGenRegisterName.c_str()); - SCRUTE(impl_name); - void* handle = _library_map[impl_name]; - ASSERT(handle); - _toRemove_map[impl_name] = handle; - } + { + string impl_name = + Engines_Component_i::GetDynLibraryName(aGenRegisterName.c_str()); + SCRUTE(impl_name); + void* handle = _library_map[impl_name]; + ASSERT(handle); + _toRemove_map[impl_name] = handle; + } _numInstanceMutex.unlock(); } //============================================================================= /*! - * Retrieves only with container naming convention if it is a python container - */ +* Retrieves only with container naming convention if it is a python container +*/ //============================================================================= bool Engines_Container_i::isPythonContainer(const char* ContainerName) @@ -1143,39 +1208,39 @@ bool Engines_Container_i::isPythonContainer(const char* ContainerName) //============================================================================= /*! - * - */ +* +*/ //============================================================================= void ActSigIntHandler() { -#ifndef WNT +#ifndef WIN32 struct sigaction SigIntAct ; SigIntAct.sa_sigaction = &SigIntHandler ; SigIntAct.sa_flags = SA_SIGINFO ; #endif -// DEBUG 03.02.2005 : the first parameter of sigaction is not a mask of signals -// (SIGINT | SIGUSR1) : -// it must be only one signal ===> one call for SIGINT -// and an other one for SIGUSR1 + // DEBUG 03.02.2005 : the first parameter of sigaction is not a mask of signals + // (SIGINT | SIGUSR1) : + // it must be only one signal ===> one call for SIGINT + // and an other one for SIGUSR1 -#ifndef WNT +#ifndef WIN32 if ( sigaction( SIGINT , &SigIntAct, NULL ) ) - { - perror("SALOME_Container main ") ; - exit(0) ; - } + { + perror("SALOME_Container main ") ; + exit(0) ; + } if ( sigaction( SIGUSR1 , &SigIntAct, NULL ) ) - { - perror("SALOME_Container main ") ; - exit(0) ; - } + { + perror("SALOME_Container main ") ; + exit(0) ; + } if ( sigaction( SIGUSR2 , &SigIntAct, NULL ) ) - { - perror("SALOME_Container main ") ; - exit(0) ; - } + { + perror("SALOME_Container main ") ; + exit(0) ; + } //PAL9042 JR : during the execution of a Signal Handler (and of methods called through Signal Handlers) // use of streams (and so on) should never be used because : @@ -1195,7 +1260,7 @@ void ActSigIntHandler() void SetCpuUsed() ; void CallCancelThread() ; -#ifndef WNT +#ifndef WIN32 void SigIntHandler(int what , siginfo_t * siginfo , void * toto ) @@ -1212,71 +1277,71 @@ void SigIntHandler(int what , // << " si_pid " << siginfo->si_pid) ; if ( _Sleeping ) + { + _Sleeping = false ; + // MESSAGE("SigIntHandler END sleeping.") ; + return ; + } + else + { + ActSigIntHandler() ; + if ( siginfo->si_signo == SIGUSR1 ) { - _Sleeping = false ; - // MESSAGE("SigIntHandler END sleeping.") ; - return ; + SetCpuUsed() ; } - else + else if ( siginfo->si_signo == SIGUSR2 ) { - ActSigIntHandler() ; - if ( siginfo->si_signo == SIGUSR1 ) - { - SetCpuUsed() ; - } - else if ( siginfo->si_signo == SIGUSR2 ) - { - CallCancelThread() ; - } - else - { - _Sleeping = true ; - // MESSAGE("SigIntHandler BEGIN sleeping.") ; - int count = 0 ; - while( _Sleeping ) - { - sleep( 1 ) ; - count += 1 ; - } - // MESSAGE("SigIntHandler LEAVE sleeping after " << count << " s.") ; - } - return ; + CallCancelThread() ; } + else + { + _Sleeping = true ; + // MESSAGE("SigIntHandler BEGIN sleeping.") ; + int count = 0 ; + while( _Sleeping ) + { + sleep( 1 ) ; + count += 1 ; + } + // MESSAGE("SigIntHandler LEAVE sleeping after " << count << " s.") ; + } + return ; + } } -#else // Case WNT +#else // Case WIN32 void SigIntHandler( int what ) { -#ifndef WNT +#ifndef WIN32 MESSAGE( pthread_self() << "SigIntHandler what " << what << endl ); #else MESSAGE( "SigIntHandler what " << what << endl ); #endif if ( _Sleeping ) + { + _Sleeping = false ; + MESSAGE("SigIntHandler END sleeping.") ; + return ; + } + else + { + ActSigIntHandler() ; + if ( what == SIGUSR1 ) { - _Sleeping = false ; - MESSAGE("SigIntHandler END sleeping.") ; - return ; + SetCpuUsed() ; } - else + else { - ActSigIntHandler() ; - if ( what == SIGUSR1 ) - { - SetCpuUsed() ; - } - else - { - _Sleeping = true ; - MESSAGE("SigIntHandler BEGIN sleeping.") ; - int count = 0 ; - while( _Sleeping ) - { - Sleep( 1000 ) ; - count += 1 ; - } - MESSAGE("SigIntHandler LEAVE sleeping after " << count << " s.") ; - } - return ; + _Sleeping = true ; + MESSAGE("SigIntHandler BEGIN sleeping.") ; + int count = 0 ; + while( _Sleeping ) + { + Sleep( 1000 ) ; + count += 1 ; + } + MESSAGE("SigIntHandler LEAVE sleeping after " << count << " s.") ; } + return ; + } } #endif diff --git a/src/Container/Container_init_python.cxx b/src/Container/Container_init_python.cxx index bea28a668..64979635d 100644 --- a/src/Container/Container_init_python.cxx +++ b/src/Container/Container_init_python.cxx @@ -27,7 +27,7 @@ // $Header$ #include -#ifndef WNT +#ifndef WIN32 #include #endif diff --git a/src/Container/Container_init_python.hxx b/src/Container/Container_init_python.hxx index d81ac5760..16bb06213 100644 --- a/src/Container/Container_init_python.hxx +++ b/src/Container/Container_init_python.hxx @@ -59,7 +59,7 @@ struct CONTAINER_EXPORT KERNEL_PYTHON { -#ifdef WNT +#ifdef WIN32 static PyThreadState *get_gtstate() { return KERNEL_PYTHON::_gtstate; } static PyObject *getsalome_shared_modules_module() { return KERNEL_PYTHON::salome_shared_modules_module; } static PyInterpreterState *get_interp() { return KERNEL_PYTHON::_interp; } diff --git a/src/Container/Makefile.am b/src/Container/Makefile.am index 0ad023f7a..16ea20722 100644 --- a/src/Container/Makefile.am +++ b/src/Container/Makefile.am @@ -90,7 +90,7 @@ COMMON_LIBS =\ ../Basics/libSALOMEBasics.la \ ../HDFPersist/libSalomeHDFPersist.la \ ../Batch/libSalomeBatch.la \ - $(top_builddir)/idl/libSalomeIDLKernel.la\ + $(top_builddir)/idl/libSalomeIDLKernel.la \ @MPI_LIBS@ \ @CORBA_LIBS@ \ $(PYTHON_LIBS) @@ -142,6 +142,7 @@ SALOME_Container_CPPFLAGS =\ SALOME_Container_LDADD = \ libSalomeContainer.la \ + ../Basics/libSALOMEBasics.la \ $(HDF5_LIBS) \ $(MPI_LIBS) \ $(CORBA_LIBS) \ @@ -158,6 +159,7 @@ TestSalome_file_CPPFLAGS =\ TestSalome_file_LDADD =\ libSalomeContainer.la \ + ../Basics/libSALOMEBasics.la \ $(HDF5_LIBS) \ $(MPI_LIBS) \ $(CORBA_LIBS) \ diff --git a/src/Container/SALOME_Component_i.hxx b/src/Container/SALOME_Component_i.hxx index 3d49b89c5..3a2f62cc0 100644 --- a/src/Container/SALOME_Component_i.hxx +++ b/src/Container/SALOME_Component_i.hxx @@ -36,7 +36,7 @@ #include #include #include -#ifndef WNT +#ifndef WIN32 #include #endif #include @@ -67,8 +67,9 @@ public: Engines::Container_ptr container, const char *instanceName, const char *interfaceName, - bool notif = false); - // Consructeur pour composant parallele: ne pas faire appel au registry + bool notif = false, + bool regist=true); + // Constructor for parallel component : don't call registry Engines_Component_i(CORBA::ORB_ptr orb, PortableServer::POA_ptr poa, PortableServer::ObjectId * contId, @@ -175,7 +176,7 @@ protected: std::string _nodeName ; private: -#ifndef WNT +#ifndef WIN32 pthread_t _ThreadId ; #else pthread_t* _ThreadId ; diff --git a/src/Container/SALOME_Container.cxx b/src/Container/SALOME_Container.cxx index 61401e7f0..3cdd20a6a 100644 --- a/src/Container/SALOME_Container.cxx +++ b/src/Container/SALOME_Container.cxx @@ -35,13 +35,13 @@ #include #include #include -#ifndef WNT +#ifndef WIN32 # include # include #endif -#ifndef WNT +#ifndef WIN32 #include #else #include @@ -65,8 +65,11 @@ extern "C" void HandleServerSideSignals(CORBA::ORB_ptr theORB); #include #include #include -#include +#ifndef WIN32 +# include +#endif +#ifndef WIN32 typedef void (*sighandler_t)(int); sighandler_t setsig(int sig, sighandler_t handler) { @@ -78,9 +81,11 @@ sighandler_t setsig(int sig, sighandler_t handler) return SIG_ERR; return ocontext.sa_handler; } +#endif //WIN32 void AttachDebugger() { +#ifndef WIN32 if(getenv ("DEBUGGER")) { std::stringstream exec; @@ -89,6 +94,7 @@ void AttachDebugger() system(exec.str().c_str()); while(1); } +#endif } void Handler(int theSigId) @@ -117,12 +123,14 @@ int main(int argc, char* argv[]) MPI_Init(&argc,&argv); #endif +#ifndef WIN32 if(getenv ("DEBUGGER")) { setsig(SIGSEGV,&Handler); set_terminate(&terminateHandler); set_unexpected(&unexpectedHandler); } +#endif // Initialise the ORB. //SRN: BugID: IPAL9541, it's necessary to set a size of one message to be at least 100Mb @@ -167,7 +175,7 @@ int main(int argc, char* argv[]) PortableServer::POAManager_var pman = root_poa->the_POAManager(); // add new container to the kill list -#ifndef WNT +#ifndef WIN32 stringstream aCommand ; aCommand << "addToKillList.py " << getpid() << " SALOME_Container" << ends ; system(aCommand.str().c_str()); diff --git a/src/Container/SALOME_Container.hxx b/src/Container/SALOME_Container.hxx index 4d3ff13a0..29f8a9cb8 100755 --- a/src/Container/SALOME_Container.hxx +++ b/src/Container/SALOME_Container.hxx @@ -26,22 +26,14 @@ #ifndef _SALOME_Container_HXX_ #define _SALOME_Container_HXX_ -#ifdef WNT - #if defined CONTAINER_EXPORTS - #if defined WIN32 - #define CONTAINER_EXPORT __declspec( dllexport ) - #else - #define CONTAINER_EXPORT - #endif - #else - #if defined WIN32 - #define CONTAINER_EXPORT __declspec( dllimport ) - #else - #define CONTAINER_EXPORT - #endif - #endif +#ifdef WIN32 +# ifdef CONTAINER_EXPORTS +# define CONTAINER_EXPORT __declspec( dllexport ) +# else +# define CONTAINER_EXPORT __declspec( dllimport ) +# endif #else - #define CONTAINER_EXPORT +# define CONTAINER_EXPORT #endif #endif diff --git a/src/Container/SALOME_Container.py b/src/Container/SALOME_Container.py index 405d1f963..72d1d25be 100644 --- a/src/Container/SALOME_Container.py +++ b/src/Container/SALOME_Container.py @@ -71,14 +71,15 @@ class SALOME_Container_i: MESSAGE( "SALOME_Container_i::import_component" ) ret=0 try: - print "try import ",componentName + if verbose(): print "try import ",componentName __import__(componentName) - print "import ",componentName," successful" + if verbose(): print "import ",componentName," successful" ret=1 except: - import traceback - traceback.print_exc() - print "import ",componentName," not possible" + if verbose(): + import traceback + traceback.print_exc() + print "import ",componentName," not possible" return ret #------------------------------------------------------------------------- diff --git a/src/Container/SALOME_ContainerManager.cxx b/src/Container/SALOME_ContainerManager.cxx index 8d887aed8..ad3c938df 100644 --- a/src/Container/SALOME_ContainerManager.cxx +++ b/src/Container/SALOME_ContainerManager.cxx @@ -20,10 +20,11 @@ #include "SALOME_ContainerManager.hxx" #include "SALOME_NamingService.hxx" #include "SALOME_ModuleCatalog.hh" -#include "OpUtil.hxx" +#include "Basics_Utils.hxx" +#include "Basics_DirUtils.hxx" #include #include -#ifndef WNT +#ifndef WIN32 #include #endif #include @@ -124,14 +125,21 @@ void SALOME_ContainerManager::ShutdownContainers() if( isOK ){ vector vec = _NS->list_directory_recurs(); list lstCont; - for(vector::iterator iter = vec.begin();iter!=vec.end();iter++){ - SCRUTE((*iter)); - CORBA::Object_var obj=_NS->Resolve((*iter).c_str()); - Engines::Container_var cont=Engines::Container::_narrow(obj); - if(!CORBA::is_nil(cont)){ - lstCont.push_back((*iter)); + for(vector::iterator iter = vec.begin();iter!=vec.end();iter++) + { + SCRUTE((*iter)); + CORBA::Object_var obj=_NS->Resolve((*iter).c_str()); + try + { + Engines::Container_var cont=Engines::Container::_narrow(obj); + if(!CORBA::is_nil(cont)) + lstCont.push_back((*iter)); + } + catch(const CORBA::Exception& e) + { + // ignore this entry and continue + } } - } MESSAGE("Container list: "); for(list::iterator iter=lstCont.begin();iter!=lstCont.end();iter++){ SCRUTE((*iter)); @@ -216,7 +224,7 @@ StartContainer(const Engines::MachineParameters& params, possibleComputers.length()); vector lm; - for(int i=0;iResolve(containerNameInNS.c_str()); if ( !CORBA::is_nil(obj) ) { - // shutdown the registered container if it exists - Engines::Container_var cont=Engines::Container::_narrow(obj); - if(!CORBA::is_nil(cont)) + try { - try - { - cont->Shutdown(); - } - catch(CORBA::Exception&) - { - INFOS("CORBA::Exception ignored."); - } + // shutdown the registered container if it exists + Engines::Container_var cont=Engines::Container::_narrow(obj); + if(!CORBA::is_nil(cont)) + cont->Shutdown(); + } + catch(CORBA::Exception&) + { + INFOS("CORBA::Exception ignored."); } } @@ -301,6 +307,9 @@ StartContainer(const Engines::MachineParameters& params, // launch container with a system call int status=system(command.c_str()); + + RmTmpFile(); // command file can be removed here + if (status == -1){ MESSAGE("SALOME_LifeCycleCORBA::StartOrFindContainer rsh failed " << "(system command status -1)"); @@ -315,7 +324,7 @@ StartContainer(const Engines::MachineParameters& params, int count=TIME_OUT_TO_LAUNCH_CONT; MESSAGE("count = "<logfilename(logFilename.c_str()); } @@ -370,7 +379,7 @@ StartContainer(const Engines::MachineParameters& params, if (CORBA::is_nil (Catalog)) return Engines::Container::_nil(); // Loop through component list - for(int i=0;iGetComponent(compoi); @@ -448,7 +457,7 @@ FindOrStartParallelContainer(const Engines::MachineParameters& params_const, else { INFOS("[FindOrStartParallelContainer] on machine : " << theMachine); string command; - if(theMachine == GetHostname()) { + if(theMachine == Kernel_Utils::GetHostname()) { // Step 3 : starting parallel container proxy params.hostname = CORBA::string_dup(theMachine.c_str()); Engines::MachineParameters params_proxy(params); @@ -474,7 +483,7 @@ FindOrStartParallelContainer(const Engines::MachineParameters& params_const, for (int i = 0; i < params.nb_component_nodes; i++) { char buffer [5]; -#ifndef WNT +#ifndef WIN32 snprintf(buffer,5,"%d",i); #else _snprintf(buffer,5,"%d",i); @@ -487,7 +496,7 @@ FindOrStartParallelContainer(const Engines::MachineParameters& params_const, obj = _NS->Resolve(containerNameInNS.c_str()); while (CORBA::is_nil(obj) && count) { INFOS("[FindOrStartParallelContainer] CONNECTION FAILED !!!!!!!!!!!!!!!!!!!!!!!!"); -#ifndef WNT +#ifndef WIN32 sleep(1) ; #else Sleep(1000); @@ -662,7 +671,7 @@ SALOME_ContainerManager::LaunchParallelContainer(const std::string& command, INFOS("[LaunchParallelContainer] Waiting for Parallel Container proxy on " << theMachine); while (CORBA::is_nil(obj) && count) { -#ifndef WNT +#ifndef WIN32 sleep(1) ; #else Sleep(1000); @@ -687,7 +696,7 @@ SALOME_ContainerManager::LaunchParallelContainer(const std::string& command, // Name of the node char buffer [5]; -#ifndef WNT +#ifndef WIN32 snprintf(buffer,5,"%d",i); #else _snprintf(buffer,5,"%d",i); @@ -700,7 +709,7 @@ SALOME_ContainerManager::LaunchParallelContainer(const std::string& command, containerNameInNS = _NS->BuildContainerNameForNS((char*) name_cont.c_str(),theMachine.c_str()); cerr << "[LaunchContainer] Waiting for Parllel Container node " << containerNameInNS << " on " << theMachine << endl; while (CORBA::is_nil(obj) && count) { -#ifndef WNT +#ifndef WIN32 sleep(1) ; #else Sleep(1000); @@ -903,14 +912,17 @@ string SALOME_ContainerManager::BuildCommandToLaunchLocalContainer (const Engines::MachineParameters& params, const long id,const std::string& container_exe) { - _TmpFileName = ""; + _TmpFileName = BuildTemporaryFileName(); string command; int nbproc = 0; - char idc[3*sizeof(long)]; + //char idc[3*sizeof(long)]; + + ofstream command_file( _TmpFileName.c_str() ); if (params.isMPI) { - command = "mpirun -np "; + //command = "mpirun -np "; + command_file << "mpirun -np "; if ( (params.nb_node <= 0) && (params.nb_proc_per_node <= 0) ) nbproc = 1; @@ -921,24 +933,28 @@ SALOME_ContainerManager::BuildCommandToLaunchLocalContainer else nbproc = params.nb_node * params.nb_proc_per_node; - std::ostringstream o; + //std::ostringstream o; - o << nbproc << " "; + //o << nbproc << " "; + command_file << nbproc << " "; - command += o.str(); + //command += o.str(); #ifdef WITHLAM - command += "-x PATH,LD_LIBRARY_PATH,OMNIORB_CONFIG,SALOME_trace "; + //command += "-x PATH,LD_LIBRARY_PATH,OMNIORB_CONFIG,SALOME_trace "; + command_file << "-x PATH,LD_LIBRARY_PATH,OMNIORB_CONFIG,SALOME_trace "; #endif if (isPythonContainer(params.container_name)) - command += "pyMPI SALOME_ContainerPy.py "; + //command += "pyMPI SALOME_ContainerPy.py "; + command_file << "pyMPI SALOME_ContainerPy.py "; else - command += "SALOME_MPIContainer "; + //command += "SALOME_MPIContainer "; + command_file << "SALOME_MPIContainer "; } else { - command=""; + //command=""; std::string wdir=params.workingdir.in(); if(wdir != "") { @@ -946,33 +962,57 @@ SALOME_ContainerManager::BuildCommandToLaunchLocalContainer if(wdir == "$TEMPDIR") { // a new temporary directory is requested - char dir[]="/tmp/salomeXXXXXX"; - char* mdir=mkdtemp(dir); - if(mdir==NULL) - std::cerr << "Problem in mkdtemp " << dir << " " << mdir << std::endl; - else - command="cd "+std::string(dir)+";"; + string dir = Kernel_Utils::GetTmpDir(); +#ifdef WIN32 + //command += "cd /d "+ dir +";"; + command_file << "cd /d " << dir << endl; +#else + //command = "cd "+ dir +";"; + command_file << "cd " << dir << ";"; +#endif + } else { // a permanent directory is requested use it or create it - command="mkdir -p " + wdir + " && cd " + wdir + ";"; +#ifdef WIN32 + //command="mkdir " + wdir; + command_file << "mkdir " + wdir << endl; + command_file << "cd /D " + wdir << endl; +#else + //command="mkdir -p " + wdir + " && cd " + wdir + ";"; + command_file << "mkdir -p " << wdir << " && cd " << wdir + ";"; +#endif } } if (isPythonContainer(params.container_name)) - command += "SALOME_ContainerPy.py "; + //command += "SALOME_ContainerPy.py "; + command_file << "SALOME_ContainerPy.py "; else - command += container_exe + " "; + //command += container_exe + " "; + command_file << container_exe + " "; + } - command += _NS->ContainerName(params); + + /*command += _NS->ContainerName(params); command += " -id "; sprintf(idc,"%ld",id); command += idc; - command += " -"; - AddOmninamesParams(command); + command += " -"; + AddOmninamesParams(command);*/ + + command_file << _NS->ContainerName(params); + command_file << " -id " << id << " -"; + AddOmninamesParams(command_file); + command_file.close(); + +#ifndef WIN32 + chmod(_TmpFileName.c_str(), 0x1ED); +#endif + command = _TmpFileName; - MESSAGE("Command is ... " << command); + MESSAGE("Command is file ... " << command); return command; } @@ -985,20 +1025,31 @@ SALOME_ContainerManager::BuildCommandToLaunchLocalContainer void SALOME_ContainerManager::RmTmpFile() { - if (_TmpFileName != "") + int lenght = _TmpFileName.size(); + if ( lenght > 0) { -#ifndef WNT - string command = "rm "; -#else +#ifdef WIN32 string command = "del /F "; +#else + string command = "rm "; +#endif + if ( lenght > 4 ) + command += _TmpFileName.substr(0, lenght - 3 ); + else + command += _TmpFileName; + command += '*'; + system(command.c_str()); + //if dir is empty - remove it + string tmp_dir = Kernel_Utils::GetDirByPath( _TmpFileName ); + if ( Kernel_Utils::IsEmptyDir( tmp_dir ) ) + { +#ifdef WIN32 + command = "del /F " + tmp_dir; +#else + command = "rmdir " + tmp_dir; #endif - command += _TmpFileName; - char *temp = strdup(command.c_str()); - int lgthTemp = strlen(temp); - temp[lgthTemp - 3] = '*'; - temp[lgthTemp - 2] = '\0'; - system(temp); - free(temp); + system(command.c_str()); + } } } @@ -1038,23 +1089,13 @@ void SALOME_ContainerManager::AddOmninamesParams(ofstream& fileStream) const string SALOME_ContainerManager::BuildTemporaryFileName() const { //build more complex file name to support multiple salome session - char *temp = new char[19]; - strcpy(temp, "/tmp/command"); - strcat(temp, "XXXXXX"); -#ifndef WNT - - mkstemp(temp); + string aFileName = Kernel_Utils::GetTmpFileName(); +#ifndef WIN32 + aFileName += ".sh"; #else - - char aPID[80]; - itoa(getpid(), aPID, 10); - strcat(temp, aPID); + aFileName += ".bat"; #endif - - string command(temp); - delete [] temp; - command += ".sh"; - return command; + return aFileName; } @@ -1133,7 +1174,9 @@ SALOME_ContainerManager::BuildTempFileToLaunchRemoteContainer tempOutputFile << " &" << endl; tempOutputFile.flush(); tempOutputFile.close(); +#ifndef WIN32 chmod(_TmpFileName.c_str(), 0x1ED); +#endif // --- Build command @@ -1274,7 +1317,7 @@ SALOME_ContainerManager::BuildCommandToLaunchLocalParallelContainer(const std::s command += " > /tmp/"; command += _NS->ContainerName(rtn); command += "_"; - command += GetHostname(); + command += Kernel_Utils::GetHostname(); command += "_"; command += getenv( "USER" ) ; command += ".log 2>&1 &" ; diff --git a/src/Container/SALOME_ContainerPy.py b/src/Container/SALOME_ContainerPy.py index 41cfcaeee..f3ce5f661 100755 --- a/src/Container/SALOME_ContainerPy.py +++ b/src/Container/SALOME_ContainerPy.py @@ -176,9 +176,10 @@ class SALOME_ContainerPy_i (Engines__POA.Container): if verbose(): print "import ",componentName," successful" ret=1 except: - import traceback - traceback.print_exc() - print "import ",componentName," not possible" + if verbose(): + import traceback + traceback.print_exc() + print "import ",componentName," not possible" return ret #------------------------------------------------------------------------- diff --git a/src/Container/SALOME_Container_i.hxx b/src/Container/SALOME_Container_i.hxx index 153b381f8..d9743a75b 100644 --- a/src/Container/SALOME_Container_i.hxx +++ b/src/Container/SALOME_Container_i.hxx @@ -37,7 +37,7 @@ #include #include #include -#ifndef WNT +#ifndef WIN32 #include #endif #include diff --git a/src/Container/SALOME_FileRef_i.cxx b/src/Container/SALOME_FileRef_i.cxx index 3fda8667f..b644795fb 100644 --- a/src/Container/SALOME_FileRef_i.cxx +++ b/src/Container/SALOME_FileRef_i.cxx @@ -25,7 +25,7 @@ #include "SALOME_FileRef_i.hxx" #include "utilities.h" -#include "OpUtil.hxx" +#include "Basics_Utils.hxx" #include using namespace std; @@ -52,7 +52,7 @@ fileRef_i::fileRef_i(Engines::Container_ptr container, MESSAGE("fileRef_i::fileRef_i "<< origFileName); _container = Engines::Container::_duplicate(container); _origFileName = origFileName; - _machine = GetHostname(); + _machine = Kernel_Utils::GetHostname(); #if defined(_DEBUG_) || defined(_DEBUG) int OK = addRef(_machine.c_str(), _origFileName.c_str()); SCRUTE(OK); diff --git a/src/Container/Salome_file_i.cxx b/src/Container/Salome_file_i.cxx index 89aae57db..962a9ad81 100644 --- a/src/Container/Salome_file_i.cxx +++ b/src/Container/Salome_file_i.cxx @@ -26,9 +26,17 @@ #include "Salome_file_i.hxx" #include "utilities.h" #include -#include #include "HDFOI.hxx" -#include +#ifndef WIN32 +# include +# define _getcwd getcwd +# define _open open +#else +# include +# include +# include +#endif + //============================================================================= /*! @@ -39,7 +47,14 @@ Salome_file_i::Salome_file_i() { _fileId = 0; +#ifndef WIN32 _path_max = 1 + pathconf("/", _PC_PATH_MAX); +#else + _path_max = 32768; + //from MSDN: + //Note The C Runtime supports path lengths up to 32768 characters in length, but it is up to the operating system, specifically the file system, to support these longer paths. The sum of the fields should not exceed _MAX_PATH for full backwards compatibility with Windows 98 FAT32 file systems. Windows NT 4.0, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003, and Windows Server 2003 NTFS file system supports paths up to 32768 characters in length, but only when using the Unicode APIs. When using long path names, prefix the path with the characters \\?\ and use the Unicode versions of the C Runtime functions. + //currently #define _MAX_PATH 260 +#endif _state.name = CORBA::string_dup(""); _state.hdf5_file_name = CORBA::string_dup(""); _state.number_of_files = 0; @@ -155,10 +170,8 @@ Salome_file_i::load(const char* hdf5_file) { if (mode == "all") { // Changing path, is now current directory - char CurrentPath[_path_max]; - getcwd(CurrentPath, _path_max); - path = CurrentPath; - + path = getcwd(NULL, _path_max); + std::string group_name("GROUP"); group_name += file_name; hdf_group = new HDFgroup(group_name.c_str(),hdf_file); @@ -491,10 +504,8 @@ Salome_file_i::setLocalFile(const char* comp_file_name) } else { - file_name = comp_file_name; - char CurrentPath[_path_max]; - getcwd(CurrentPath, _path_max); - path = CurrentPath; + file_name = comp_file_name; + path = getcwd(NULL, _path_max);; } // Test if this file is already added @@ -556,9 +567,7 @@ Salome_file_i::setDistributedFile(const char* comp_file_name) else { file_name = comp_file_name; - char CurrentPath[_path_max]; - getcwd(CurrentPath, _path_max); - path = CurrentPath; + path = getcwd(NULL, _path_max);; } // Test if this file is already added diff --git a/src/DF/DF_definitions.hxx b/src/DF/DF_definitions.hxx index 3cfe5585d..a9dd7eaa4 100644 --- a/src/DF/DF_definitions.hxx +++ b/src/DF/DF_definitions.hxx @@ -68,7 +68,7 @@ public: }; -# if defined(WNT) && !defined(HAVE_NO_DLL) +# if defined(WIN32) && !defined(HAVE_NO_DLL) # ifndef Standard_EXPORT # define Standard_EXPORT __declspec( dllexport ) @@ -82,7 +82,7 @@ public: # define Standard_IMPORTC extern "C" __declspec( dllimport ) # endif /* Standard_IMPORT */ -# else /* WNT */ +# else /* WIN32 */ # ifndef Standard_EXPORT # define Standard_EXPORT @@ -96,11 +96,11 @@ public: # define Standard_IMPORTC extern "C" # endif /* Standard_IMPORT */ -# endif /* WNT */ +# endif /* WIN32 */ # ifndef __Standard_API -//# ifdef WNT -# if !defined(WNT) +//# ifdef WIN32 +# if !defined(WIN32) # define __Standard_API Standard_EXPORT # define __Standard_APIEXTERN Standard_EXPORTEXTERN # else @@ -109,7 +109,7 @@ public: # endif // __Standard_DLL //# else //# define __Standard_API -//# endif // WNT +//# endif // WIN32 # endif // __Standard_API #include diff --git a/src/DF/testDF.cxx b/src/DF/testDF.cxx index e5e843253..0924a5d01 100644 --- a/src/DF/testDF.cxx +++ b/src/DF/testDF.cxx @@ -34,7 +34,7 @@ #include "DF_Container.hxx" #include "DF_ChildIterator.hxx" -#ifndef WNT +#ifndef WIN32 #include #include #include @@ -53,7 +53,7 @@ void printStr(const string& theValue) void GetSystemDate(int& year, int& month, int& day, int& hours, int& minutes, int& seconds) { -#ifdef WNT +#ifdef WIN32 SYSTEMTIME st; GetLocalTime ( &st ); @@ -84,7 +84,7 @@ void GetSystemDate(int& year, int& month, int& day, int& hours, int& minutes, in string GetUserName() { -#ifdef WNT +#ifdef WIN32 char* pBuff = new char[UNLEN + 1]; DWORD dwSize = UNLEN + 1; string retVal; @@ -129,7 +129,7 @@ string GetDirFromPath(const string& thePath) { path = thePath+"/"; } -#ifdef WNT //Check if the only disk letter is given as path +#ifdef WIN32 //Check if the only disk letter is given as path if(path.size() == 2 && path[1] == ":") path +='\\'; #endif @@ -141,7 +141,7 @@ string GetDirFromPath(const string& thePath) { bool Exists(const string thePath) { -#ifdef WNT +#ifdef WIN32 if ( GetFileAttributes ( thePath.c_str() ) == 0xFFFFFFFF ) { if ( GetLastError () != ERROR_FILE_NOT_FOUND ) { return false; diff --git a/src/DSC/DSC_Basic/ConnectionManager_i.cxx b/src/DSC/DSC_Basic/ConnectionManager_i.cxx index 2f7f089c9..d023cf6e3 100644 --- a/src/DSC/DSC_Basic/ConnectionManager_i.cxx +++ b/src/DSC/DSC_Basic/ConnectionManager_i.cxx @@ -26,6 +26,10 @@ #include "ConnectionManager_i.hxx" #include "SALOME_NamingService.hxx" +#ifdef WIN32 +# include +#endif + ConnectionManager_i::ConnectionManager_i(CORBA::ORB_ptr orb) { _orb = CORBA::ORB::_duplicate(orb) ; SALOME_NamingService * ns = new SALOME_NamingService(orb); @@ -126,5 +130,10 @@ ConnectionManager_i::ShutdownWithExit() CORBA::Long ConnectionManager_i::getPID() { - return (CORBA::Long)getpid(); + return +#ifndef WIN32 + (CORBA::Long)getpid(); +#else + (CORBA::Long)_getpid(); +#endif } diff --git a/src/DSC/DSC_Basic/DSC_Basic.hxx b/src/DSC/DSC_Basic/DSC_Basic.hxx index 0efc1a2e2..b06f5d075 100755 --- a/src/DSC/DSC_Basic/DSC_Basic.hxx +++ b/src/DSC/DSC_Basic/DSC_Basic.hxx @@ -26,22 +26,14 @@ #ifndef _DSC_Basic_HXX_ #define _DSC_Basic_HXX_ -#ifdef WNT - #if defined DSC_BASIC_EXPORTS - #if defined WIN32 - #define DSC_BASIC_EXPORT __declspec( dllexport ) - #else - #define DSC_BASIC_EXPORT - #endif - #else - #if defined WIN32 - #define DSC_BASIC_EXPORT __declspec( dllimport ) - #else - #define DSC_BASIC_EXPORT - #endif - #endif +#ifdef WIN32 +# ifdef DSC_BASIC_EXPORTS +# define DSC_BASIC_EXPORT __declspec( dllexport ) +# else +# define DSC_BASIC_EXPORT __declspec( dllimport ) +# endif #else - #define DSC_BASIC_EXPORT +# define DSC_BASIC_EXPORT #endif #endif diff --git a/src/DSC/DSC_Basic/DSC_i.cxx b/src/DSC/DSC_Basic/DSC_i.cxx index 2daa87423..7ae1e157b 100644 --- a/src/DSC/DSC_Basic/DSC_i.cxx +++ b/src/DSC/DSC_Basic/DSC_i.cxx @@ -48,7 +48,9 @@ Engines_DSC_i(CORBA::ORB_ptr orb, Engines::Container_ptr container, const char *instanceName, const char *interfaceName, - bool notif) : Engines_Component_i(orb, poa, container, instanceName, interfaceName) + bool notif, + bool regist) : + Engines_Component_i(orb, poa, container, instanceName, interfaceName,notif,regist) { #ifdef _DEBUG_ std::cerr << "--Engines_DSC_i: MARK 1 --" << instanceName << "----" << std::endl; diff --git a/src/DSC/DSC_Basic/DSC_i.hxx b/src/DSC/DSC_Basic/DSC_i.hxx index a66be1d56..98fc8a6ad 100644 --- a/src/DSC/DSC_Basic/DSC_i.hxx +++ b/src/DSC/DSC_Basic/DSC_i.hxx @@ -61,7 +61,8 @@ public: Engines::Container_ptr container, const char *instanceName, const char *interfaceName, - bool notif = false); + bool notif = false, + bool regist = true ); virtual ~Engines_DSC_i(); diff --git a/src/DSC/DSC_User/Basic/basic_port_factory.cxx b/src/DSC/DSC_User/Basic/basic_port_factory.cxx index 4d7d4a75d..e0d8333a2 100644 --- a/src/DSC/DSC_User/Basic/basic_port_factory.cxx +++ b/src/DSC/DSC_User/Basic/basic_port_factory.cxx @@ -25,6 +25,8 @@ #include "basic_port_factory.hxx" +using namespace std; + basic_port_factory::basic_port_factory() {} basic_port_factory::~basic_port_factory() {} diff --git a/src/DSC/DSC_User/Basic/basic_port_factory.hxx b/src/DSC/DSC_User/Basic/basic_port_factory.hxx index 8407c217b..42a698def 100644 --- a/src/DSC/DSC_User/Basic/basic_port_factory.hxx +++ b/src/DSC/DSC_User/Basic/basic_port_factory.hxx @@ -30,8 +30,6 @@ #include "data_short_port_provides.hxx" #include "data_short_port_uses.hxx" -using namespace std; - /*! \class basic_port_factory * \brief This class is an example of factory for DSC_User ports. * @@ -52,7 +50,7 @@ class basic_port_factory : * \param type the basic port's type. * \return a pointer of the provides port. */ - virtual provides_port * create_data_servant(string type); + virtual provides_port * create_data_servant(std::string type); /*! * This method creates a uses port of Basic ports. @@ -60,7 +58,7 @@ class basic_port_factory : * \param type the basic port's type. * \return a pointer of the uses port. */ - virtual uses_port * create_data_proxy(string type); + virtual uses_port * create_data_proxy(std::string type); }; #endif diff --git a/src/DSC/DSC_User/DSC_Exception.hxx b/src/DSC/DSC_User/DSC_Exception.hxx index 46bd5ab03..3e66d8e6f 100644 --- a/src/DSC/DSC_User/DSC_Exception.hxx +++ b/src/DSC/DSC_User/DSC_Exception.hxx @@ -34,12 +34,12 @@ #include "utilities.h" -#ifndef WNT +#ifndef WIN32 extern "C" { #endif #include -#ifndef WNT +#ifndef WIN32 } #endif diff --git a/src/DSC/DSC_User/Datastream/Calcium/Calcium.cxx b/src/DSC/DSC_User/Datastream/Calcium/Calcium.cxx index fde8203a8..4c245e621 100644 --- a/src/DSC/DSC_User/Datastream/Calcium/Calcium.cxx +++ b/src/DSC/DSC_User/Datastream/Calcium/Calcium.cxx @@ -13,7 +13,7 @@ PySupervCompo::PySupervCompo( CORBA::ORB_ptr orb, const char *instanceName, const char *interfaceName, bool notif) : - Superv_Component_i(orb, poa,contain, instanceName, interfaceName) + Superv_Component_i(orb, poa,contain, instanceName, interfaceName,false,false) { } diff --git a/src/DSC/DSC_User/Datastream/Calcium/CalciumCxxInterface.hxx b/src/DSC/DSC_User/Datastream/Calcium/CalciumCxxInterface.hxx index 969b510e8..573f2ea5b 100644 --- a/src/DSC/DSC_User/Datastream/Calcium/CalciumCxxInterface.hxx +++ b/src/DSC/DSC_User/Datastream/Calcium/CalciumCxxInterface.hxx @@ -163,7 +163,7 @@ namespace CalciumInterface { double & ti, double const & tf, long & i, - const string & nomVar, + const std::string & nomVar, size_t bufferLength, size_t & nRead, T1 * &data ) @@ -321,14 +321,14 @@ namespace CalciumInterface { // T1 est le type de données template static void ecp_lecture ( Superv_Component_i & component, - int const & dependencyType, - double & ti, - double const & tf, - long & i, - const string & nomVar, - size_t bufferLength, - size_t & nRead, - T1 * &data ) + int const & dependencyType, + double & ti, + double const & tf, + long & i, + const std::string & nomVar, + size_t bufferLength, + size_t & nRead, + T1 * &data ) { ecp_lecture (component,dependencyType,ti,tf, i,nomVar,bufferLength,nRead,data); @@ -341,12 +341,12 @@ namespace CalciumInterface { // T2 : PortType template static void ecp_ecriture ( Superv_Component_i & component, - int const & dependencyType, - double const & t, - long const & i, - const string & nomVar, - size_t bufferLength, - T1 const & data ) + int const & dependencyType, + double const & t, + long const & i, + const std::string & nomVar, + size_t bufferLength, + T1 const & data ) { assert(&component); @@ -502,7 +502,7 @@ namespace CalciumInterface { #ifdef _DEBUG_ std::cout << "-------- CalciumInterface(ecriture), Valeur de corbaData : " << std::endl; for (int i = 0; i < corbaData->length(); ++i) - cout << "-------- CalciumInterface(ecriture), corbaData[" << i << "] = " << (*corbaData)[i] << endl; + std::cout << "-------- CalciumInterface(ecriture), corbaData[" << i << "] = " << (*corbaData)[i] << std::endl; #endif // if ( !IsSameType::value ) delete corbaData; @@ -521,7 +521,7 @@ namespace CalciumInterface { int const & dependencyType, double const & t, long const & i, - const string & nomVar, + const std::string & nomVar, size_t bufferLength, T1 const & data ) { ecp_ecriture (component,dependencyType,t,i,nomVar,bufferLength,data); diff --git a/src/DSC/DSC_User/Datastream/Calcium/calcium_port_factory.cxx b/src/DSC/DSC_User/Datastream/Calcium/calcium_port_factory.cxx index 504945a57..121ede25d 100644 --- a/src/DSC/DSC_User/Datastream/Calcium/calcium_port_factory.cxx +++ b/src/DSC/DSC_User/Datastream/Calcium/calcium_port_factory.cxx @@ -28,6 +28,8 @@ #include "calcium_port_factory.hxx" +using namespace std; + calcium_port_factory::calcium_port_factory() {} calcium_port_factory::~calcium_port_factory() {} diff --git a/src/DSC/DSC_User/Datastream/Calcium/calcium_port_factory.hxx b/src/DSC/DSC_User/Datastream/Calcium/calcium_port_factory.hxx index 6cb050411..03e317a99 100644 --- a/src/DSC/DSC_User/Datastream/Calcium/calcium_port_factory.hxx +++ b/src/DSC/DSC_User/Datastream/Calcium/calcium_port_factory.hxx @@ -44,8 +44,6 @@ #include "calcium_logical_port_uses.hxx" #include "calcium_complex_port_uses.hxx" -using namespace std; - class calcium_port_factory : public port_factory { @@ -53,8 +51,8 @@ class calcium_port_factory : calcium_port_factory(); virtual ~calcium_port_factory(); - virtual provides_port * create_data_servant(string type); - virtual uses_port * create_data_proxy(string type); + virtual provides_port * create_data_servant(std::string type); + virtual uses_port * create_data_proxy(std::string type); }; #endif diff --git a/src/DSC/DSC_User/Datastream/DataIdFilter.hxx b/src/DSC/DSC_User/Datastream/DataIdFilter.hxx index 91853d713..a59728523 100644 --- a/src/DSC/DSC_User/Datastream/DataIdFilter.hxx +++ b/src/DSC/DSC_User/Datastream/DataIdFilter.hxx @@ -82,8 +82,6 @@ #include // Pour l'utilisation de "vector" de la STL -using namespace std; - // Classe filtre_elementaire // // Implémente une structure de donnée décrivant un filtre élémentaire @@ -177,7 +175,7 @@ private: // Données de configuration de filtrage et conversion: // une table de filtres élémentaires // avec leurs données de conversion associées éventuelles - vector config; + std::vector config; public: // Constructeur: juste une allocation mémoire initiale @@ -187,7 +185,7 @@ public: // réclamer la mémoire utilisée par tous les éléments du vecteur config ~filtre_conversion() { - vector::iterator i; + std::vector::iterator i; for (i = this->config.begin(); i != this->config.end(); i ++) { delete (*i).p_convers; @@ -254,7 +252,7 @@ public: } // applique_filtre_conversion: Opération du filtre et de la conversion - template T applique_filtre_conversion (T valeur_initiale, vector& liste_conversions) const; + template T applique_filtre_conversion (T valeur_initiale, std::vector& liste_conversions) const; }; @@ -278,7 +276,7 @@ public: // si cette longueur est 0, c'est que la valeur initiale ne passe pas le filtre // template -T filtre_conversion::applique_filtre_conversion (T valeur_initiale, vector& liste_conversions) const +T filtre_conversion::applique_filtre_conversion (T valeur_initiale, std::vector& liste_conversions) const { // Part d'une liste vierge liste_conversions.clear(); @@ -289,7 +287,7 @@ T filtre_conversion::applique_filtre_conversion (T valeur_initiale, vector& l // et cherche pour chacun d'eux si la valeur initiale est présente parmi les valeurs filtrées // Pour tous les éléments de configuration du filtrage/conversion - vector::const_iterator i; + std::vector::const_iterator i; for (i = config.begin(); i != config.end(); i ++) { diff --git a/src/DSC/DSC_User/Datastream/Palm/PalmCouplingPolicy.hxx b/src/DSC/DSC_User/Datastream/Palm/PalmCouplingPolicy.hxx index c5f57fff4..ac23a59ce 100644 --- a/src/DSC/DSC_User/Datastream/Palm/PalmCouplingPolicy.hxx +++ b/src/DSC/DSC_User/Datastream/Palm/PalmCouplingPolicy.hxx @@ -87,11 +87,11 @@ public: std::cout << "----Cst ---- InternalDataIdContainer(const DataId & dataId..) " << dataId <::iterator i=_lTime.begin();i!=_lTime.end();++i) + for(std::vector::iterator i=_lTime.begin();i!=_lTime.end();++i) std::cout << "_lTime["<< c++ << "] : " << *i << std::endl; policy.filtre_convert_TAG.applique_filtre_conversion(dataId.second, _lTag); c=0; - for(vector::iterator i=_lTag.begin();i!=_lTag.end();++i) + for(std::vector::iterator i=_lTag.begin();i!=_lTag.end();++i) std::cout << "_lTag["<< c++ << "] : " << *i << std::endl; } diff --git a/src/DSC/DSC_User/Datastream/Palm/palm_port_factory.cxx b/src/DSC/DSC_User/Datastream/Palm/palm_port_factory.cxx index 2c194efb1..43107b133 100644 --- a/src/DSC/DSC_User/Datastream/Palm/palm_port_factory.cxx +++ b/src/DSC/DSC_User/Datastream/Palm/palm_port_factory.cxx @@ -29,6 +29,8 @@ #include "palm_port_factory.hxx" +using namespace std; + palm_port_factory::palm_port_factory() { } diff --git a/src/DSC/DSC_User/Datastream/Palm/palm_port_factory.hxx b/src/DSC/DSC_User/Datastream/Palm/palm_port_factory.hxx index 544a9c1eb..c8007374b 100644 --- a/src/DSC/DSC_User/Datastream/Palm/palm_port_factory.hxx +++ b/src/DSC/DSC_User/Datastream/Palm/palm_port_factory.hxx @@ -38,8 +38,6 @@ #include "palm_data_short_port_provides.hxx" #include "palm_data_seq_short_port_provides.hxx" -using namespace std; - class palm_port_factory : public port_factory { @@ -47,8 +45,8 @@ class palm_port_factory : palm_port_factory(); virtual ~palm_port_factory(); - virtual provides_port * create_data_servant(string type); - virtual uses_port * create_data_proxy(string type); + virtual provides_port * create_data_servant(std::string type); + virtual uses_port * create_data_proxy(std::string type); }; #endif diff --git a/src/DSC/DSC_User/Superv_Component_i.cxx b/src/DSC/DSC_User/Superv_Component_i.cxx index 4a6449990..b4335d38f 100644 --- a/src/DSC/DSC_User/Superv_Component_i.cxx +++ b/src/DSC/DSC_User/Superv_Component_i.cxx @@ -55,7 +55,9 @@ Superv_Component_i::Superv_Component_i(CORBA::ORB_ptr orb, Engines::Container_ptr container, const char *instanceName, const char *interfaceName, - bool notif) : Engines_DSC_i(orb, poa, container, instanceName, interfaceName) + bool notif, + bool regist) : + Engines_DSC_i(orb, poa, container, instanceName, interfaceName,notif,regist) { #ifdef _DEBUG_ std::cerr << "--Superv_Component_i : MARK 1 ---- " << instanceName << "----" << std::endl; diff --git a/src/DSC/DSC_User/Superv_Component_i.hxx b/src/DSC/DSC_User/Superv_Component_i.hxx index 2c8467e05..b0f67130c 100644 --- a/src/DSC/DSC_User/Superv_Component_i.hxx +++ b/src/DSC/DSC_User/Superv_Component_i.hxx @@ -40,8 +40,6 @@ #include "DSC_Exception.hxx" -using namespace std; - /*! \class Superv_Component_i * \brief This class implements DSC_User component. * @@ -70,7 +68,8 @@ public: Engines::Container_ptr container, const char *instanceName, const char *interfaceName, - bool notif = false); + bool notif = false, + bool regist = true ); virtual ~Superv_Component_i(); // Exceptions declarations. diff --git a/src/GenericObj/SALOME_GenericObj_i.cc b/src/GenericObj/SALOME_GenericObj_i.cc index 2760b73db..9158f4ed9 100644 --- a/src/GenericObj/SALOME_GenericObj_i.cc +++ b/src/GenericObj/SALOME_GenericObj_i.cc @@ -41,7 +41,7 @@ GenericObj_i::GenericObj_i(PortableServer::POA_ptr thePOA): myRefCounter(1){ MESSAGE("GenericObj_i::GenericObj_i() - this = "< #include -#ifdef WNT +#ifdef WIN32 #include #include +#include +#define dir_separator '\\' +#else +#define dir_separator '/' #endif using namespace std; @@ -653,11 +657,12 @@ string GetTmpDir() char *Tmp_dir = getenv("SALOME_TMP_DIR"); if(Tmp_dir != NULL) { aTmpDir = string(Tmp_dir); -#ifdef WIN32 + if(aTmpDir[aTmpDir.size()-1] != dir_separator) aTmpDir+=dir_separator; +/*#ifdef WIN32 if(aTmpDir[aTmpDir.size()-1] != '\\') aTmpDir+='\\'; #else if(aTmpDir[aTmpDir.size()-1] != '/') aTmpDir+='/'; -#endif +#endif*/ } else { #ifdef WIN32 @@ -676,11 +681,14 @@ string GetTmpDir() aTmpDir += aSubDir; //Get RND sub directory + if(aTmpDir[aTmpDir.size()-1] != dir_separator) aTmpDir+=dir_separator; +/* #ifdef WIN32 if(aTmpDir[aTmpDir.size()-1] != '\\') aTmpDir+='\\'; #else if(aTmpDir[aTmpDir.size()-1] != '/') aTmpDir+='/'; #endif + */ string aDir = aTmpDir; @@ -689,13 +697,15 @@ string GetTmpDir() aDir = aTmpDir+buffer; //Build a unique directory name } -#ifdef WNT +#ifdef WIN32 + //fuction CreateDirectory create only final directory, but not intermediate + CreateDirectory(aTmpDir.c_str(), NULL); CreateDirectory(aDir.c_str(), NULL); #else mkdir(aDir.c_str(), 0x1ff); #endif - return aDir; + return aDir + dir_separator; } char* makeName(char* name) @@ -753,7 +763,7 @@ void read_float64(FILE* fp, hdf_float64* value) bool Exists(const string thePath) { -#ifdef WNT +#ifdef WIN32 if ( GetFileAttributes ( thePath.c_str() ) == 0xFFFFFFFF ) { if ( GetLastError () != ERROR_FILE_NOT_FOUND ) { return false; @@ -768,7 +778,7 @@ bool Exists(const string thePath) void Move(const string& fName, const string& fNameDst) { -#ifdef WNT +#ifdef WIN32 MoveFileEx (fName.c_str(), fNameDst.c_str(),MOVEFILE_REPLACE_EXISTING | MOVEFILE_COPY_ALLOWED); #else rename(fName.c_str(), fNameDst.c_str()); diff --git a/src/HDFPersist/HDFascii.hxx b/src/HDFPersist/HDFascii.hxx index 999b17352..254fc9de5 100644 --- a/src/HDFPersist/HDFascii.hxx +++ b/src/HDFPersist/HDFascii.hxx @@ -31,7 +31,7 @@ #include "HDFexport.hxx" -class HDF_EXPORT HDFascii +class HDFPERSIST_EXPORT HDFascii { public: diff --git a/src/HDFPersist/HDFattrWrite.c b/src/HDFPersist/HDFattrWrite.c index faac557fc..844d21190 100644 --- a/src/HDFPersist/HDFattrWrite.c +++ b/src/HDFPersist/HDFattrWrite.c @@ -48,7 +48,7 @@ hdf_err HDFattrWrite(hdf_idt id, void *val) #ifdef PCLINUX if((H5Tget_class(type_id) == H5T_INTEGER) && (H5Tget_size(type_id) == 4)) { isI32BE = 1; /* See HDFattrCreate */ - if (H5Tconvert(H5T_NATIVE_INT,H5T_STD_I32BE,1,(void *)val,NULL,NULL) < 0) + if (H5Tconvert(H5T_NATIVE_INT,H5T_STD_I32BE,1,(void *)val,NULL,(hid_t)NULL) < 0) return -1; } #endif @@ -57,7 +57,7 @@ hdf_err HDFattrWrite(hdf_idt id, void *val) #ifdef PCLINUX - if (isI32BE && (H5Tconvert(H5T_STD_I32BE,H5T_NATIVE_INT,1,(void *)val,NULL,NULL) < 0)) + if (isI32BE && (H5Tconvert(H5T_STD_I32BE,H5T_NATIVE_INT,1,(void *)val,NULL,(hid_t)NULL) < 0)) return -1; #endif diff --git a/src/HDFPersist/HDFattribute.hxx b/src/HDFPersist/HDFattribute.hxx index 9ec84e75b..9ede64cec 100644 --- a/src/HDFPersist/HDFattribute.hxx +++ b/src/HDFPersist/HDFattribute.hxx @@ -34,7 +34,7 @@ extern "C" #include "HDFinternalObject.hxx" #include "HDFcontainerObject.hxx" -class HDFattribute : public HDFobject +class HDFPERSIST_EXPORT HDFattribute : public HDFobject { private : HDFinternalObject *_father; diff --git a/src/HDFPersist/HDFcontainerObject.hxx b/src/HDFPersist/HDFcontainerObject.hxx index dfc237b26..117145c94 100644 --- a/src/HDFPersist/HDFcontainerObject.hxx +++ b/src/HDFPersist/HDFcontainerObject.hxx @@ -35,7 +35,7 @@ extern "C" #include "HDFinternalObject.hxx" #include "HDFexport.hxx" -class HDF_EXPORT HDFcontainerObject : public HDFinternalObject +class HDFPERSIST_EXPORT HDFcontainerObject : public HDFinternalObject { private : HDFinternalObject *_firstson; diff --git a/src/HDFPersist/HDFconvert.cc b/src/HDFPersist/HDFconvert.cc index eaf7b21a5..6bac949e0 100644 --- a/src/HDFPersist/HDFconvert.cc +++ b/src/HDFPersist/HDFconvert.cc @@ -27,7 +27,7 @@ #include "HDFconvert.hxx" using namespace std; -#ifdef WNT +#ifdef WIN32 #include #include #endif @@ -64,7 +64,7 @@ int HDFConvert::FromAscii(const string& file, const HDFcontainerObject & hdf_con perror("HDFConvert::FromAscii"); return -1; }; -#elif defined WNT +#elif defined WIN32 #define SHMEMSIZE 4096 diff --git a/src/HDFPersist/HDFconvert.hxx b/src/HDFPersist/HDFconvert.hxx index 20b65affd..876340d44 100644 --- a/src/HDFPersist/HDFconvert.hxx +++ b/src/HDFPersist/HDFconvert.hxx @@ -30,7 +30,7 @@ extern "C" { #include "HDFtypes.h" -#ifndef WNT +#ifndef WIN32 #include #include #else @@ -41,13 +41,14 @@ extern "C" #include #include } +#include "HDFexport.hxx" #include "HDFcontainerObject.hxx" #include "HDFdataset.hxx" #include "HDFfile.hxx" #include -class HDFConvert +class HDFPERSIST_EXPORT HDFConvert { private: diff --git a/src/HDFPersist/HDFdataset.hxx b/src/HDFPersist/HDFdataset.hxx index 1e2a62401..b27f8bade 100644 --- a/src/HDFPersist/HDFdataset.hxx +++ b/src/HDFPersist/HDFdataset.hxx @@ -35,7 +35,7 @@ extern "C" #include "HDFcontainerObject.hxx" #include "HDFexport.hxx" -class HDF_EXPORT HDFdataset : public HDFinternalObject +class HDFPERSIST_EXPORT HDFdataset : public HDFinternalObject { private : HDFcontainerObject *_father; diff --git a/src/HDFPersist/HDFexception.hxx b/src/HDFPersist/HDFexception.hxx index 2ec2ce4a5..7cc9c4986 100644 --- a/src/HDFPersist/HDFexception.hxx +++ b/src/HDFPersist/HDFexception.hxx @@ -27,11 +27,13 @@ #ifndef __HDFexception_H__ #define __HDFexception_H__ +#include "HDFexport.hxx" + /* Exception */ #include -class HDFexception +class HDFPERSIST_EXPORT HDFexception { public : HDFexception(const char *message) { diff --git a/src/HDFPersist/HDFexplorer.hxx b/src/HDFPersist/HDFexplorer.hxx index e66fbe390..c2d5f3682 100644 --- a/src/HDFPersist/HDFexplorer.hxx +++ b/src/HDFPersist/HDFexplorer.hxx @@ -30,7 +30,7 @@ #include "HDFinternalObject.hxx" #include "HDFcontainerObject.hxx" -class HDFexplorer { +class HDFPERSIST_EXPORT HDFexplorer { private : int _size; HDFcontainerObject *_container; diff --git a/src/HDFPersist/HDFexport.hxx b/src/HDFPersist/HDFexport.hxx index 21b64d34e..060b1e592 100644 --- a/src/HDFPersist/HDFexport.hxx +++ b/src/HDFPersist/HDFexport.hxx @@ -26,14 +26,14 @@ #ifndef _HDF_export_HXX_ #define _HDF_export_HXX_ -#ifdef WNT - #if defined WIN32 - #define HDF_EXPORT __declspec( dllimport ) - #else - #define HDF_EXPORT - #endif +#ifdef WIN32 +# ifdef HDFPERSIST_EXPORTS +# define HDFPERSIST_EXPORT __declspec( dllexport ) +# else +# define HDFPERSIST_EXPORT __declspec( dllimport ) +# endif #else - #define HDF_EXPORT +# define HDFPERSIST_EXPORT #endif #endif diff --git a/src/HDFPersist/HDFfile.cc b/src/HDFPersist/HDFfile.cc index 96c763598..aea67a55a 100644 --- a/src/HDFPersist/HDFfile.cc +++ b/src/HDFPersist/HDFfile.cc @@ -27,7 +27,7 @@ extern "C" { #include "hdfi.h" -#ifndef WNT +#ifndef WIN32 #include #else #include diff --git a/src/HDFPersist/HDFfile.hxx b/src/HDFPersist/HDFfile.hxx index b1d32881f..2f908cf9f 100644 --- a/src/HDFPersist/HDFfile.hxx +++ b/src/HDFPersist/HDFfile.hxx @@ -34,7 +34,7 @@ extern "C" #include "HDFcontainerObject.hxx" #include "HDFexport.hxx" -class HDF_EXPORT HDFfile : public HDFcontainerObject +class HDFPERSIST_EXPORT HDFfile : public HDFcontainerObject { private : hdf_access_mode _access_mode; diff --git a/src/HDFPersist/HDFgroup.hxx b/src/HDFPersist/HDFgroup.hxx index 07e79e36e..0a1bbc407 100644 --- a/src/HDFPersist/HDFgroup.hxx +++ b/src/HDFPersist/HDFgroup.hxx @@ -34,7 +34,7 @@ extern "C" #include "HDFcontainerObject.hxx" #include "HDFexport.hxx" -class HDF_EXPORT HDFgroup : public HDFcontainerObject +class HDFPERSIST_EXPORT HDFgroup : public HDFcontainerObject { private : HDFcontainerObject *_father; diff --git a/src/HDFPersist/HDFinternalObject.cc b/src/HDFPersist/HDFinternalObject.cc index 716e6da49..7a5fb6f0e 100644 --- a/src/HDFPersist/HDFinternalObject.cc +++ b/src/HDFPersist/HDFinternalObject.cc @@ -29,9 +29,6 @@ extern "C" #include "hdfi.h" } #include "HDFinternalObject.hxx" -#ifndef WNT -using namespace std; -#endif HDFinternalObject::HDFinternalObject(const char *name) : HDFobject(name) diff --git a/src/HDFPersist/HDFinternalObject.hxx b/src/HDFPersist/HDFinternalObject.hxx index ee4c32e51..232305016 100644 --- a/src/HDFPersist/HDFinternalObject.hxx +++ b/src/HDFPersist/HDFinternalObject.hxx @@ -34,7 +34,7 @@ extern "C" #include "HDFobject.hxx" #include "HDFexport.hxx" -class HDF_EXPORT HDFinternalObject : public HDFobject +class HDFPERSIST_EXPORT HDFinternalObject : public HDFobject { private : HDFinternalObject *_previousbrother; diff --git a/src/HDFPersist/HDFobject.cc b/src/HDFPersist/HDFobject.cc index 5adb8aafe..e4f751a9b 100644 --- a/src/HDFPersist/HDFobject.cc +++ b/src/HDFPersist/HDFobject.cc @@ -28,8 +28,9 @@ extern "C" { #include "hdfi.h" -#include } + +#include //#include "utilities.h" using namespace std; diff --git a/src/HDFPersist/HDFobject.hxx b/src/HDFPersist/HDFobject.hxx index 3c829822a..9862e8428 100644 --- a/src/HDFPersist/HDFobject.hxx +++ b/src/HDFPersist/HDFobject.hxx @@ -31,9 +31,9 @@ extern "C" { #include "HDFtypes.h" } -#include +#include "HDFexport.hxx" -class HDF_EXPORT HDFobject { +class HDFPERSIST_EXPORT HDFobject { protected : char *_name; hdf_idt _id; diff --git a/src/KERNEL_PY/batchmode_salome.py b/src/KERNEL_PY/batchmode_salome.py index c25b1dd80..f3aff3542 100755 --- a/src/KERNEL_PY/batchmode_salome.py +++ b/src/KERNEL_PY/batchmode_salome.py @@ -284,5 +284,5 @@ else: myStudyName = myStudy._get_Name() myStudyId = myStudy._get_StudyId() -print myStudyId +#print myStudyId diff --git a/src/Launcher/BatchTest.cxx b/src/Launcher/BatchTest.cxx index bb44166f4..c51301490 100644 --- a/src/Launcher/BatchTest.cxx +++ b/src/Launcher/BatchTest.cxx @@ -1,5 +1,15 @@ #include "BatchTest.hxx" +#include "Batch_Date.hxx" +#include "MpiImpl.hxx" +#include "utilities.h" + +#include +#include +#include +#ifdef WIN32 +# include +#endif BatchTest::BatchTest(const Engines::MachineParameters& batch_descr) { _batch_descr = batch_descr; @@ -17,7 +27,7 @@ BatchTest::BatchTest(const Engines::MachineParameters& batch_descr) } i++ ; } - + // Creating test temporary file _test_filename = "/tmp/"; _test_filename += _date + "_test_cluster_file_"; @@ -66,11 +76,11 @@ BatchTest::test() << "--- Application : " << result_appli << std::endl ); - if (result_connection == "OK" and - result_filecopy == "OK" and - result_getresult == "OK" and - result_jobsubmit_simple == "OK" and - result_jobsubmit_mpi == "OK" and + if (result_connection == "OK" && + result_filecopy == "OK" && + result_getresult == "OK" && + result_jobsubmit_simple == "OK" && + result_jobsubmit_mpi == "OK" && result_appli == "OK") rtn = true; @@ -99,7 +109,7 @@ BatchTest::test_connection() result += "username is empty !"; return result; } - if( protocol != "rsh" and protocol != "ssh") + if( protocol != "rsh" && protocol != "ssh") { result += "protocol unknown ! (" + protocol + ")"; return result; @@ -341,7 +351,11 @@ BatchTest::test_jobsubmit_simple() if(status == 153 || status == 256*153 ) stop = true; +#ifdef WIN32 + Sleep(1); +#else sleep(1); +#endif } // Build command for getting results @@ -446,7 +460,12 @@ BatchTest::test_jobsubmit_mpi() << "echo HELLO MPI\n"; file_script.flush(); file_script.close(); - chmod(_test_file_script.c_str(), 0x1ED); +#ifdef WIN32 + _chmod +#else + chmod +#endif + (_test_file_script.c_str(), 0x1ED); std::string _test_file_mpi = _test_filename + "_mpi"; std::ofstream file_mpi; @@ -529,7 +548,11 @@ BatchTest::test_jobsubmit_mpi() if(status == 153 || status == 256*153 ) stop = true; +#ifdef WIN32 + Sleep(1); +#else sleep(1); +#endif } // Build command for getting results @@ -569,7 +592,7 @@ BatchTest::test_jobsubmit_mpi() return result; } result = "OK"; - return result; + return result; } std::string diff --git a/src/Launcher/BatchTest.hxx b/src/Launcher/BatchTest.hxx index 600b71bee..da32b1db3 100644 --- a/src/Launcher/BatchTest.hxx +++ b/src/Launcher/BatchTest.hxx @@ -21,18 +21,14 @@ #ifndef __BatchTest_HXX__ #define __BatchTest_HXX__ -#include -#include -#include +#include "SALOME_Launcher_defs.hxx" #include -#include "utilities.h" #include CORBA_CLIENT_HEADER(SALOME_ContainerManager) -#include "Batch_Date.hxx" -#include "MpiImpl.hxx" +#include -class BatchTest +class SALOMELAUNCHER_EXPORT BatchTest { public: BatchTest(const Engines::MachineParameters& batch_descr); diff --git a/src/Launcher/Launcher.cxx b/src/Launcher/Launcher.cxx index 7f2d491c5..ed4641f00 100644 --- a/src/Launcher/Launcher.cxx +++ b/src/Launcher/Launcher.cxx @@ -17,15 +17,22 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // + +#include "Launcher.hxx" + #include "Batch_Date.hxx" #include "Batch_FactBatchManager_eLSF.hxx" #include "Batch_FactBatchManager_ePBS.hxx" -#include "Launcher.hxx" -#include "utilities.h" +#include "Batch_BatchManager_eClient.hxx" + #include #include #include +#ifdef WIN32 +# include +#endif + using namespace std; //============================================================================= @@ -39,7 +46,9 @@ using namespace std; Launcher_cpp::Launcher_cpp() { - MESSAGE ( "Launcher_cpp constructor" ); +#if defined(_DEBUG_) || defined(_DEBUG) + cerr << "Launcher_cpp constructor" << endl; +#endif } //============================================================================= @@ -50,7 +59,9 @@ Launcher_cpp::Launcher_cpp() Launcher_cpp::~Launcher_cpp() { - MESSAGE ( "Launcher_cpp destructor" ); +#if defined(_DEBUG_) || defined(_DEBUG) + cerr << "Launcher_cpp destructor" << endl; +#endif std::map < string, Batch::BatchManager_eClient * >::const_iterator it1; for(it1=_batchmap.begin();it1!=_batchmap.end();it1++) delete it1->second; @@ -74,7 +85,9 @@ long Launcher_cpp::submitSalomeJob( const string fileToExecute , const batchParams& batch_params, const machineParams& params) throw(LauncherException) { - MESSAGE ( "BEGIN OF Launcher_cpp::submitSalomeJob" ); +#if defined(_DEBUG_) || defined(_DEBUG) + cerr << "BEGIN OF Launcher_cpp::submitSalomeJob" << endl; +#endif long jobId; vector aMachineList; @@ -95,7 +108,9 @@ long Launcher_cpp::submitSalomeJob( const string fileToExecute , ParserResourcesType p = _ResManager->GetResourcesList(aMachineList[0]); string clustername(p.Alias); - MESSAGE ( "Choose cluster: " << clustername ); +#if defined(_DEBUG_) || defined(_DEBUG) + cerr << "Choose cluster: " << clustername << endl; +#endif // search batch manager for that cluster in map or instanciate one map < string, Batch::BatchManager_eClient * >::const_iterator it = _batchmap.find(clustername); @@ -149,7 +164,7 @@ long Launcher_cpp::submitSalomeJob( const string fileToExecute , istringstream iss(jid.getReference()); iss >> jobId; - _jobmap[ pair(clustername,jobId) ] = job; + _jobmap[ pair(clustername,jobId) ] = job; } catch(const Batch::EmulationException &ex){ throw LauncherException(ex.msg.c_str()); @@ -286,18 +301,26 @@ Batch::BatchManager_eClient *Launcher_cpp::FactoryBatchManager( const ParserReso mpi = "indif"; break; } - MESSAGE ( "Instanciation of batch manager" ); +#if defined(_DEBUG_) || defined(_DEBUG) + cerr << "Instanciation of batch manager" << endl; +#endif switch( params.Batch ){ case pbs: - MESSAGE ( "Instantiation of PBS batch manager" ); +#if defined(_DEBUG_) || defined(_DEBUG) + cerr << "Instantiation of PBS batch manager" << endl; +#endif fact = new Batch::FactBatchManager_ePBS; break; case lsf: - MESSAGE ( "Instantiation of LSF batch manager" ); +#if defined(_DEBUG_) || defined(_DEBUG) + cerr << "Instantiation of LSF batch manager" << endl; +#endif fact = new Batch::FactBatchManager_eLSF; break; default: - MESSAGE ( "BATCH = " << params.Batch ); +#if defined(_DEBUG_) || defined(_DEBUG) + cerr << "BATCH = " << params.Batch << endl; +#endif throw LauncherException("no batchmanager for that cluster"); } return (*fact)(hostname.c_str(),protocol.c_str(),mpi.c_str()); @@ -305,6 +328,7 @@ Batch::BatchManager_eClient *Launcher_cpp::FactoryBatchManager( const ParserReso string Launcher_cpp::buildSalomeCouplingScript(const string fileToExecute, const string dirForTmpFiles, const ParserResourcesType& params) { +#ifndef WIN32 //TODO: need for porting on Windows int idx = dirForTmpFiles.find("Batch/"); std::string filelogtemp = dirForTmpFiles.substr(idx+6, dirForTmpFiles.length()); @@ -407,11 +431,16 @@ string Launcher_cpp::buildSalomeCouplingScript(const string fileToExecute, const tempOutputFile.flush(); tempOutputFile.close(); chmod(TmpFileName.c_str(), 0x1ED); - MESSAGE ( TmpFileName.c_str() ); +#if defined(_DEBUG_) || defined(_DEBUG) + cerr << TmpFileName.c_str() << endl; +#endif delete mpiImpl; return TmpFileName; +#else + return ""; +#endif } @@ -471,8 +500,10 @@ string Launcher_cpp::getRemoteFile( std::string remoteDir, std::string localFile bool Launcher_cpp::check(const batchParams& batch_params) { bool rtn = true; - MESSAGE ( "Job parameters are :" ); - MESSAGE ( "Directory : $HOME/Batch/$date" ); +#if defined(_DEBUG_) || defined(_DEBUG) + cerr << "Job parameters are :" << endl; + cerr << "Directory : $HOME/Batch/$date" << endl; +#endif // check expected_during_time (check the format) std::string edt_info = batch_params.expected_during_time; @@ -509,7 +540,9 @@ bool Launcher_cpp::check(const batchParams& batch_params) else { edt_info = "No value given"; } - MESSAGE ( "Expected during time : " << edt_info ); +#if defined(_DEBUG_) || defined(_DEBUG) + cerr << "Expected during time : " << edt_info << endl;; +#endif // check memory (check the format) std::string mem_info; @@ -527,7 +560,7 @@ bool Launcher_cpp::check(const batchParams& batch_params) rtn = false; } std::string end_mem_value = mem_value.substr(mem_value.length()-2); - if (end_mem_value != "gb" and end_mem_value != "mb") { + if (end_mem_value != "gb" && end_mem_value != "mb") { mem_info = "Error on definition, type is bad ! " + mem_value; rtn = false; } @@ -535,7 +568,9 @@ bool Launcher_cpp::check(const batchParams& batch_params) else { mem_info = "No value given"; } - MESSAGE ( "Memory : " << mem_info ); +#if defined(_DEBUG_) || defined(_DEBUG) + cerr << "Memory : " << mem_info << endl; +#endif // check nb_proc std::string nb_proc_info; @@ -549,7 +584,9 @@ bool Launcher_cpp::check(const batchParams& batch_params) else { nb_proc_info = nb_proc_value.str(); } - MESSAGE ( "Nb of processors : " << nb_proc_info ); +#if defined(_DEBUG_) || defined(_DEBUG) + cerr << "Nb of processors : " << nb_proc_info << endl; +#endif return rtn; } @@ -617,7 +654,9 @@ Launcher_cpp::getHomeDir(const ParserResourcesType& p, const std::string& tmpdir command += p.Alias; command += " 'echo $HOME' > "; command += filelogtemp; - MESSAGE ( command.c_str() ); +#if defined(_DEBUG_) || defined(_DEBUG) + std::cerr << command.c_str() << std::endl; +#endif int status = system(command.c_str()); if(status) throw LauncherException("Error of launching home command on remote host"); diff --git a/src/Launcher/Launcher.hxx b/src/Launcher/Launcher.hxx index 84dd59dd5..fdf3eba54 100644 --- a/src/Launcher/Launcher.hxx +++ b/src/Launcher/Launcher.hxx @@ -20,10 +20,28 @@ #ifndef __LAUNCHER_HXX__ #define __LAUNCHER_HXX__ -#include "Batch_BatchManager_eClient.hxx" +#ifdef WIN32 +# ifdef LAUNCHER_EXPORTS +# define LAUNCHER_EXPORT __declspec(dllexport) +# else +# define LAUNCHER_EXPORT __declspec(dllimport) +# endif +#else +# define LAUNCHER_EXPORT +#endif + +#include #include "ResourcesManager.hxx" #include +#include + +class MpiImpl; + +namespace Batch{ + class BatchManager_eClient; + class Job; +} struct batchParams{ std::string batch_directory; @@ -32,7 +50,7 @@ struct batchParams{ unsigned long nb_proc; }; -class LauncherException +class LAUNCHER_EXPORT LauncherException { public: const std::string msg; @@ -40,7 +58,7 @@ public: LauncherException(const std::string m) : msg(m) {} }; -class Launcher_cpp +class LAUNCHER_EXPORT Launcher_cpp { public: @@ -61,7 +79,7 @@ public: protected: - std::string buildSalomeCouplingScript(const string fileToExecute, const string dirForTmpFiles, const ParserResourcesType& params); + std::string buildSalomeCouplingScript(const std::string fileToExecute, const std::string dirForTmpFiles, const ParserResourcesType& params); MpiImpl *FactoryMpiImpl(MpiImplType mpiImpl) throw(LauncherException); Batch::BatchManager_eClient *FactoryBatchManager( const ParserResourcesType& params ) throw(LauncherException); std::string getTmpDirForBatchFiles(); diff --git a/src/Launcher/Makefile.am b/src/Launcher/Makefile.am index 848a21f1d..9211ed82d 100644 --- a/src/Launcher/Makefile.am +++ b/src/Launcher/Makefile.am @@ -38,6 +38,7 @@ include $(top_srcdir)/salome_adm/unix/make_common_starter.am salomeinclude_HEADERS = \ BatchTest.hxx \ SALOME_Launcher.hxx \ + SALOME_Launcher_defs.hxx \ Launcher.hxx # Scripts to be installed @@ -139,6 +140,7 @@ SALOME_LauncherServer_CPPFLAGS=\ SALOME_LauncherServer_LDADD =\ libSalomeLauncher.la \ + ../Basics/libSALOMEBasics.la \ $(MPI_LIBS) \ $(CORBA_LIBS) \ $(LIBXML_LIBS) \ diff --git a/src/Launcher/SALOME_Launcher.cxx b/src/Launcher/SALOME_Launcher.cxx index 726091089..a053c8cc5 100644 --- a/src/Launcher/SALOME_Launcher.cxx +++ b/src/Launcher/SALOME_Launcher.cxx @@ -18,13 +18,18 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #include "SALOME_Launcher.hxx" +#include "BatchTest.hxx" #include "OpUtil.hxx" -#include -#ifndef WNT -#include +#include "SALOME_ContainerManager.hxx" +#include "Utils_CorbaException.hxx" + +#ifdef WIN32 +# include +#else +# include #endif +#include #include -#include "Utils_CorbaException.hxx" using namespace std; @@ -97,7 +102,13 @@ void SALOME_Launcher::Shutdown() //============================================================================= CORBA::Long SALOME_Launcher::getPID() { - return (CORBA::Long)getpid(); + return +#ifndef WIN32 + (CORBA::Long)getpid(); +#else + (CORBA::Long)_getpid(); +#endif + } //============================================================================= @@ -172,6 +183,7 @@ SALOME_Launcher::testBatch(const Engines::MachineParameters& params) const Engines::MachineParameters* p = _ResManager->GetMachineParameters((*aMachineList)[0]); string clustername(p->alias); INFOS("Choose cluster" << clustername); + BatchTest t(*p); if (t.test()) { @@ -205,7 +217,7 @@ char* SALOME_Launcher::querySalomeJob( const CORBA::Long jobId, p.mem_mb = params.mem_mb; try{ - status = _l.querySalomeJob(jobId,p); + status = _l.querySalomeJob(jobId,p); } catch(const LauncherException &ex){ INFOS("Caught exception."); diff --git a/src/Launcher/SALOME_Launcher.hxx b/src/Launcher/SALOME_Launcher.hxx index 8ba73cdac..8d59dd53f 100644 --- a/src/Launcher/SALOME_Launcher.hxx +++ b/src/Launcher/SALOME_Launcher.hxx @@ -20,31 +20,19 @@ #ifndef __SALOME_LAUNCHER_HXX__ #define __SALOME_LAUNCHER_HXX__ +#include "SALOME_Launcher_defs.hxx" + #include #include CORBA_CLIENT_HEADER(SALOME_ContainerManager) -#include "SALOME_ContainerManager.hxx" -#include "BatchTest.hxx" #include "Launcher.hxx" #include class SALOME_NamingService; +class SALOME_ContainerManager; +class SALOME_ResourcesManager; -#if defined LAUNCHER_EXPORTS -#if defined WIN32 -#define LAUNCHER_EXPORT __declspec( dllexport ) -#else -#define LAUNCHER_EXPORT -#endif -#else -#if defined WNT -#define LAUNCHER_EXPORT __declspec( dllimport ) -#else -#define LAUNCHER_EXPORT -#endif -#endif - -class LAUNCHER_EXPORT SALOME_Launcher: +class SALOMELAUNCHER_EXPORT SALOME_Launcher: public POA_Engines::SalomeLauncher, public PortableServer::RefCountServantBase { @@ -59,9 +47,9 @@ public: const Engines::BatchParameters& batch_params, const Engines::MachineParameters& params); - char* querySalomeJob( const CORBA::Long jobId, const Engines::MachineParameters& params); - void deleteSalomeJob( const CORBA::Long jobId, const Engines::MachineParameters& params); - void getResultSalomeJob( const char * directory, const CORBA::Long jobId, const Engines::MachineParameters& params ); + char* querySalomeJob( CORBA::Long jobId, const Engines::MachineParameters& params); + void deleteSalomeJob( CORBA::Long jobId, const Engines::MachineParameters& params); + void getResultSalomeJob( const char * directory, CORBA::Long jobId, const Engines::MachineParameters& params ); CORBA::Boolean testBatch(const Engines::MachineParameters& params); diff --git a/src/Launcher/SALOME_LauncherServer.cxx b/src/Launcher/SALOME_LauncherServer.cxx index 5913d0ffb..f0f25f91a 100644 --- a/src/Launcher/SALOME_LauncherServer.cxx +++ b/src/Launcher/SALOME_LauncherServer.cxx @@ -28,25 +28,27 @@ using namespace std; void AttachDebugger() { +#ifndef WIN32 if(getenv ("DEBUGGER")) { std::stringstream exec; exec << "$DEBUGGER SALOME_LauncherServer " << getpid() << "&"; - std::cerr << exec.str() << std::endl; + MESSAGE ( exec.str() ); system(exec.str().c_str()); while(1); } +#endif } void terminateHandler(void) { - std::cerr << "Terminate: not managed exception !" << std::endl; + MESSAGE ( "Terminate: not managed exception !" ); AttachDebugger(); } void unexpectedHandler(void) { - std::cerr << "Unexpected: unexpected exception !" << std::endl; + MESSAGE ( "Unexpected: unexpected exception !" ); AttachDebugger(); } diff --git a/src/Launcher/SALOME_Launcher_defs.hxx b/src/Launcher/SALOME_Launcher_defs.hxx new file mode 100755 index 000000000..cc7f196de --- /dev/null +++ b/src/Launcher/SALOME_Launcher_defs.hxx @@ -0,0 +1,33 @@ +// Copyright (C) 2005 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 __SALOME_LAUNCHER_DEFS_HXX__ +#define __SALOME_LAUNCHER_DEFS_HXX__ + +#ifdef WIN32 +# ifdef SALOMELAUNCHER_EXPORTS +# define SALOMELAUNCHER_EXPORT __declspec(dllexport) +# else +# define SALOMELAUNCHER_EXPORT __declspec(dllimport) +# endif +#else +# define SALOMELAUNCHER_EXPORT +#endif + +#endif //__SALOME_LAUNCHER_DEFS_HXX__ diff --git a/src/LifeCycleCORBA/SALOME_FileTransferCORBA.cxx b/src/LifeCycleCORBA/SALOME_FileTransferCORBA.cxx index 4ce5d8b97..f2edfe0fb 100644 --- a/src/LifeCycleCORBA/SALOME_FileTransferCORBA.cxx +++ b/src/LifeCycleCORBA/SALOME_FileTransferCORBA.cxx @@ -26,7 +26,7 @@ #include "SALOME_FileTransferCORBA.hxx" #include "SALOME_LifeCycleCORBA.hxx" #include "utilities.h" -#include "OpUtil.hxx" +#include "Basics_Utils.hxx" using namespace std; @@ -146,7 +146,7 @@ string SALOME_FileTransferCORBA::getLocalFile(string localFile) container = _theFileRef->getContainer(); ASSERT(! CORBA::is_nil(container)); - string myMachine = GetHostname(); + string myMachine = Kernel_Utils::GetHostname(); string localCopy = _theFileRef->getRef(myMachine.c_str()); if (localCopy.empty()) // no existing copy available diff --git a/src/LifeCycleCORBA/SALOME_FileTransferCORBA.hxx b/src/LifeCycleCORBA/SALOME_FileTransferCORBA.hxx index c0927d92c..4ac4576c8 100644 --- a/src/LifeCycleCORBA/SALOME_FileTransferCORBA.hxx +++ b/src/LifeCycleCORBA/SALOME_FileTransferCORBA.hxx @@ -34,7 +34,7 @@ #include -#ifdef WNT +#ifdef WIN32 # if defined LIFECYCLECORBA_EXPORTS # define LIFECYCLECORBA_EXPORT __declspec( dllexport ) # else diff --git a/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx b/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx index 9b399893d..ef14d7cc9 100644 --- a/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx +++ b/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx @@ -32,29 +32,22 @@ #include #include -#ifndef WNT +#ifndef WIN32 #include #endif -#include "OpUtil.hxx" +#include "Basics_Utils.hxx" #include "utilities.h" #include #include "SALOME_LifeCycleCORBA.hxx" -#ifndef WNT #include CORBA_CLIENT_HEADER(SALOME_ModuleCatalog) #include CORBA_CLIENT_HEADER(SALOME_Session) #include CORBA_CLIENT_HEADER(DSC_Engines) #include CORBA_CLIENT_HEADER(SALOME_Registry) #include CORBA_CLIENT_HEADER(SALOMEDS) -#else -#include "SALOME_ModuleCatalog.hh" -#include "SALOME_Session.hh" -#include "DSC_Engines.hh" -#include "SALOME_Registry.hh" -#include "SALOMEDS.hh" -#endif + #include "SALOME_ContainerManager.hxx" #include "SALOME_Component_i.hxx" #include "SALOME_NamingService.hxx" @@ -276,7 +269,7 @@ SALOME_LifeCycleCORBA::FindOrLoad_Component(const char *containerName, { // containerName doesn't contain "/" => Local container params->container_name=CORBA::string_dup(stContainer); - params->hostname=CORBA::string_dup(GetHostname().c_str()); + params->hostname=CORBA::string_dup(Kernel_Utils::GetHostname().c_str()); } else { @@ -453,7 +446,7 @@ void SALOME_LifeCycleCORBA::shutdownServers() } } - string hostname = GetHostname(); + string hostname = Kernel_Utils::GetHostname(); // 1) SalomeLauncher CORBA::Object_var objSL = _NS->Resolve("/SalomeLauncher"); diff --git a/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.hxx b/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.hxx index 42e67688d..65ec4e026 100644 --- a/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.hxx +++ b/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.hxx @@ -30,7 +30,7 @@ #define _SALOME_LIFECYCLECORBA_HXX_ #include -#ifndef WNT +#ifndef WIN32 #include #endif #include @@ -40,8 +40,8 @@ #include CORBA_CLIENT_HEADER(SALOME_ContainerManager) #include CORBA_CLIENT_HEADER(SALOME_Component) #include -using namespace std; -#ifdef WNT + +#ifdef WIN32 # if defined LIFECYCLECORBA_EXPORTS # define LIFECYCLECORBA_EXPORT __declspec( dllexport ) # else diff --git a/src/LifeCycleCORBA/Test/LifeCycleCORBATest.cxx b/src/LifeCycleCORBA/Test/LifeCycleCORBATest.cxx index 7a047fd38..1fc751484 100644 --- a/src/LifeCycleCORBA/Test/LifeCycleCORBATest.cxx +++ b/src/LifeCycleCORBA/Test/LifeCycleCORBATest.cxx @@ -23,7 +23,7 @@ #include "SALOME_FileTransferCORBA.hxx" #include "Utils_ORB_INIT.hxx" #include "Utils_SINGLETON.hxx" -#include "OpUtil.hxx" +#include "Basics_Utils.hxx" #include #include @@ -294,7 +294,7 @@ LifeCycleCORBATest::testFindOrLoad_Component_LaunchContainerHostname() // --- get a local container (with a name based on local hostname), // load an engine, check that the CORBA object is not null - string containerName = GetHostname(); + string containerName = Kernel_Utils::GetHostname(); containerName += "/theContainer"; DEVTRACE("containerName = " << containerName); Engines::Component_var mycompo = @@ -329,7 +329,7 @@ LifeCycleCORBATest::testFindOrLoad_Component_SameContainer() _LCC.FindOrLoad_Component(containerName.c_str(),"SalomeTestComponent"); CPPUNIT_ASSERT(!CORBA::is_nil(mycompo1)); - containerName = GetHostname(); + containerName = Kernel_Utils::GetHostname(); containerName += "/aContainer"; DEVTRACE("containerName = " << containerName); Engines::Component_var mycompo2 = @@ -441,7 +441,7 @@ LifeCycleCORBATest::testFindOrLoad_Component_ParamsLocalContainer() Engines::MachineParameters params; _LCC.preSet(params); - string hostname=GetHostname(); + string hostname=Kernel_Utils::GetHostname(); params.hostname=hostname.c_str(); Engines::Component_var mycompo = _LCC.FindOrLoad_Component(params,"SalomeTestComponent"); @@ -458,7 +458,7 @@ LifeCycleCORBATest::testFindOrLoad_Component_ParamsLocalContainer() Engines::Container_var c1 = m1->GetContainerRef(); CPPUNIT_ASSERT(!CORBA::is_nil(c1)); string hostname1 = c1->getHostName(); - CPPUNIT_ASSERT_EQUAL(hostname1, GetHostname()); + CPPUNIT_ASSERT_EQUAL(hostname1, Kernel_Utils::GetHostname()); } @@ -492,7 +492,7 @@ LifeCycleCORBATest::testFindOrLoad_Component_ParamsContainerName() Engines::Container_var c1 = m1->GetContainerRef(); CPPUNIT_ASSERT(!CORBA::is_nil(c1)); string hostname1 = c1->getHostName(); - CPPUNIT_ASSERT_EQUAL(hostname1, GetHostname()); + CPPUNIT_ASSERT_EQUAL(hostname1, Kernel_Utils::GetHostname()); string cname1 = c1->name(); CPPUNIT_ASSERT(cname1.find(containerName) != string::npos); } @@ -621,7 +621,7 @@ void LifeCycleCORBATest::testgetLocalFile_localComputer() SALOME_LifeCycleCORBA _LCC(&_NS); string origFileName = getenv("KERNEL_ROOT_DIR"); origFileName += "/lib/salome/libSalomeLifeCycleCORBA.so.0.0.0"; - SALOME_FileTransferCORBA transfer( GetHostname(), + SALOME_FileTransferCORBA transfer( Kernel_Utils::GetHostname(), origFileName); string local = transfer.getLocalFile(); CPPUNIT_ASSERT(!local.empty()); @@ -688,7 +688,7 @@ string LifeCycleCORBATest::GetRemoteHost() resourcesManager->GetFittingResources(params,clist); CPPUNIT_ASSERT(hostList->length() > 1); - string localHost = GetHostname(); + string localHost = Kernel_Utils::GetHostname(); string remoteHost; for (unsigned int i=0; i < hostList->length(); i++) { diff --git a/src/LifeCycleCORBA/Test_LifeCycleCORBA.cxx b/src/LifeCycleCORBA/Test_LifeCycleCORBA.cxx index 2cd147634..eaf0ba7d8 100644 --- a/src/LifeCycleCORBA/Test_LifeCycleCORBA.cxx +++ b/src/LifeCycleCORBA/Test_LifeCycleCORBA.cxx @@ -27,22 +27,17 @@ // $Header$ #include -#ifndef WNT +#ifndef WIN32 #include #endif #include -#ifndef WNT #include CORBA_CLIENT_HEADER(SALOME_Component) #include CORBA_CLIENT_HEADER(SALOME_TestComponent) -#else -#include -#include -#endif #include "SALOME_NamingService.hxx" #include "SALOME_LifeCycleCORBA.hxx" #include "SALOME_FileTransferCORBA.hxx" #include "utilities.h" -#include +#include using namespace std; @@ -108,7 +103,7 @@ int main (int argc, char * argv[]) // --- yet another container, with hostname, // load an engine, and invoque methods on that engine - string containerName4 = GetHostname(); + string containerName4 = Kernel_Utils::GetHostname(); containerName4 += "/titiPy"; Engines::Component_var mycompo4 = _LCC.FindOrLoad_Component(containerName4.c_str(),"SALOME_TestComponentPy"); @@ -120,7 +115,7 @@ int main (int argc, char * argv[]) // --- try a local file transfer string origFileName = "/home/prascle/petitfichier"; - SALOME_FileTransferCORBA transfer( GetHostname(), + SALOME_FileTransferCORBA transfer( Kernel_Utils::GetHostname(), origFileName); string local = transfer.getLocalFile(); SCRUTE(local); diff --git a/src/LifeCycleCORBA_SWIG/libSALOME_LifeCycleCORBA.i b/src/LifeCycleCORBA_SWIG/libSALOME_LifeCycleCORBA.i index feaca2631..b6b03ca38 100644 --- a/src/LifeCycleCORBA_SWIG/libSALOME_LifeCycleCORBA.i +++ b/src/LifeCycleCORBA_SWIG/libSALOME_LifeCycleCORBA.i @@ -23,6 +23,8 @@ %module libSALOME_LifeCycleCORBA +%feature("autodoc", "1"); + %include @@ -116,10 +118,13 @@ struct omniORBpyAPI { $result = PyString_FromString($1.c_str()); } -%typemap(typecheck) const Engines::MachineParameters &, - Engines::MachineParameters const & +%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER) Engines::MachineParameters const & +{ + $1 = PyDict_Check($input)? 1 : 0; +} +%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER) const Engines::MachineParameters & { - $1 = PyDict_Check($input); + $1 = PyDict_Check($input)? 1 : 0; } %typemap(typecheck) std::string, diff --git a/src/Logger/SALOME_Logger_Server.cxx b/src/Logger/SALOME_Logger_Server.cxx index 88d33c576..af0bd305d 100644 --- a/src/Logger/SALOME_Logger_Server.cxx +++ b/src/Logger/SALOME_Logger_Server.cxx @@ -16,7 +16,7 @@ # include #endif -#ifdef WNT +#ifdef WIN32 #include #endif diff --git a/src/Logger/SALOME_Logger_Server.hxx b/src/Logger/SALOME_Logger_Server.hxx index cd0a304c8..8beadd7b7 100644 --- a/src/Logger/SALOME_Logger_Server.hxx +++ b/src/Logger/SALOME_Logger_Server.hxx @@ -12,15 +12,15 @@ #define SALOME_Logger_Server_include #include - #include + #ifdef WNT #include #endif #include #include "Logger.hh" -#ifdef WNT +#ifdef WIN32 # if defined LOGGER_EXPORTS # define LOGGER_EXPORT __declspec( dllexport ) # else diff --git a/src/Logger/SALOME_Logger_Server_main.cxx b/src/Logger/SALOME_Logger_Server_main.cxx index 1be06053f..4ac7ae1c8 100644 --- a/src/Logger/SALOME_Logger_Server_main.cxx +++ b/src/Logger/SALOME_Logger_Server_main.cxx @@ -47,7 +47,7 @@ int main(int argc, char **argv) for (i = 1; i <= NumberOfTries; i++) { -#ifndef WNT +#ifndef WIN32 if (i != 1) nanosleep(&ts_req, &ts_rem); #else if (i != 1) Sleep(TIMESleep / 1000000); diff --git a/src/Logger/SALOME_Trace.cxx b/src/Logger/SALOME_Trace.cxx index e9b9e4f6e..7e7e254bb 100644 --- a/src/Logger/SALOME_Trace.cxx +++ b/src/Logger/SALOME_Trace.cxx @@ -16,7 +16,7 @@ #include using namespace std; -#ifdef WNT +#ifdef WIN32 #include #endif @@ -57,7 +57,7 @@ int SALOME_Trace::Initialize(CORBA::ORB_ptr theOrb) { // searchin for naming service for 0.25*40=10 seconds for (i = 1; i <= NumberOfTries; i++) { -#ifndef WNT +#ifndef WIN32 if (i != 1) nanosleep(&ts_req,&ts_rem); #else if (i != 1) Sleep(TIMESleep / 1000000); @@ -92,7 +92,7 @@ int SALOME_Trace::Initialize(CORBA::ORB_ptr theOrb) { name[0].id=CORBA::string_dup("Logger"); for(i = 1; i <= NumberOfTries; i++){ -#ifndef WNT +#ifndef WIN32 if (i != 1) nanosleep(&ts_req, &ts_rem); #else if (i != 1) Sleep(TIMESleep / 1000000); diff --git a/src/Logger/SALOME_Trace.hxx b/src/Logger/SALOME_Trace.hxx index 24ef7ba8e..f5f9ea6be 100644 --- a/src/Logger/SALOME_Trace.hxx +++ b/src/Logger/SALOME_Trace.hxx @@ -16,7 +16,7 @@ #include "Logger.hh" //these declarations for files don't using OCC includes (for example HDF) -# ifdef WNT +# ifdef WIN32 # ifndef Standard_EXPORT # define Standard_EXPORT __declspec( dllexport ) @@ -30,7 +30,7 @@ # define Standard_IMPORTC extern "C" __declspec( dllimport ) # endif /* Standard_IMPORT */ -# else /* WNT */ +# else /* WIN32 */ # ifndef Standard_EXPORT # define Standard_EXPORT @@ -44,7 +44,7 @@ # define Standard_IMPORTC extern "C" # endif /* Standard_IMPORT */ -# endif /* WNT */ +# endif /* WIN32 */ class SALOME_Trace : public std::ostrstream { diff --git a/src/MPIContainer/MPIContainer_i.cxx b/src/MPIContainer/MPIContainer_i.cxx index 926a16763..287edee53 100644 --- a/src/MPIContainer/MPIContainer_i.cxx +++ b/src/MPIContainer/MPIContainer_i.cxx @@ -76,7 +76,7 @@ Engines_MPIContainer_i::Engines_MPIContainer_i(int nbproc, int numproc, CORBA::Object_var obj=_poa->id_to_reference(*_id); Engines::Container_var pCont = Engines::Container::_narrow(obj); - string hostname = GetHostname(); + string hostname = Kernel_Utils::GetHostname(); _containerName = _NS->BuildContainerNameForNS(containerName,hostname.c_str()); SCRUTE(_containerName); _NS->Register(pCont, _containerName.c_str()); diff --git a/src/Makefile.am b/src/Makefile.am index 82efa8787..368f6c0ee 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -110,9 +110,9 @@ if CORBA_GEN SUBDIRS += $(SUBDIR_CORBA) endif -#if MPI_IS_OK -# SUBDIRS += $(SUBDIR_MPI) -#endif +if MPI_IS_OK + SUBDIRS += $(SUBDIR_MPI) +endif if CPPUNIT_IS_OK if CORBA_GEN @@ -129,3 +129,5 @@ endif if WITH_PACO_PARALLEL SUBDIRS += $(SUBDIR_PARALLEL) endif + +EXTRA_DIST = win32pm diff --git a/src/ModuleCatalog/SALOME_ModuleCatalog.hxx b/src/ModuleCatalog/SALOME_ModuleCatalog.hxx index 75d05ccb8..7f2fcf44c 100755 --- a/src/ModuleCatalog/SALOME_ModuleCatalog.hxx +++ b/src/ModuleCatalog/SALOME_ModuleCatalog.hxx @@ -26,20 +26,12 @@ #ifndef _SALOME_ModuleCatalog_HXX_ #define _SALOME_ModuleCatalog_HXX_ -#ifdef WNT - #if defined MODULECATALOG_EXPORTS - #if defined WIN32 - #define MODULECATALOG_EXPORT __declspec( dllexport ) - #else - #define MODULECATALOG_EXPORT - #endif - #else - #if defined WIN32 - #define MODULECATALOG_EXPORT __declspec( dllimport ) - #else - #define MODULECATALOG_EXPORT - #endif - #endif +#ifdef WIN32 +# ifdef MODULECATALOG_EXPORTS +# define MODULECATALOG_EXPORT __declspec( dllexport ) +# else +# define MODULECATALOG_EXPORT __declspec( dllimport ) +# endif #else #define MODULECATALOG_EXPORT #endif diff --git a/src/ModuleCatalog/SALOME_ModuleCatalog_Acomponent_impl.cxx b/src/ModuleCatalog/SALOME_ModuleCatalog_Acomponent_impl.cxx index 3208d6e89..1bc6a2075 100644 --- a/src/ModuleCatalog/SALOME_ModuleCatalog_Acomponent_impl.cxx +++ b/src/ModuleCatalog/SALOME_ModuleCatalog_Acomponent_impl.cxx @@ -503,11 +503,7 @@ void SALOME_ModuleCatalog_AcomponentImpl::duplicate _length = S_in.ServiceoutParameter.length(); S_out.ServiceoutParameter.length(_length); -#ifndef WNT for (unsigned int ind2 = 0; ind2 < _length ; ind2 ++) -#else - for (ind2 = 0; ind2 < _length ; ind2 ++) -#endif duplicate(S_out.ServiceoutParameter[ind2], S_in.ServiceoutParameter[ind2]); @@ -515,11 +511,7 @@ void SALOME_ModuleCatalog_AcomponentImpl::duplicate _length = S_in.ServiceinDataStreamParameter.length(); S_out.ServiceinDataStreamParameter.length(_length); -#ifndef WNT for (unsigned int ind2 = 0; ind2 < _length ; ind2 ++) -#else - for (ind2 = 0; ind2 < _length ; ind2 ++) -#endif duplicate(S_out.ServiceinDataStreamParameter[ind2], S_in.ServiceinDataStreamParameter[ind2]); @@ -528,11 +520,7 @@ void SALOME_ModuleCatalog_AcomponentImpl::duplicate if(MYDEBUG) SCRUTE(_length); S_out.ServiceoutDataStreamParameter.length(_length); -#ifndef WNT for (unsigned int ind2 = 0; ind2 < _length ; ind2 ++) -#else - for (ind2 = 0; ind2 < _length ; ind2 ++) -#endif duplicate(S_out.ServiceoutDataStreamParameter[ind2], S_in.ServiceoutDataStreamParameter[ind2]); } diff --git a/src/ModuleCatalog/SALOME_ModuleCatalog_Client.cxx b/src/ModuleCatalog/SALOME_ModuleCatalog_Client.cxx index 02384368c..108eca1af 100644 --- a/src/ModuleCatalog/SALOME_ModuleCatalog_Client.cxx +++ b/src/ModuleCatalog/SALOME_ModuleCatalog_Client.cxx @@ -78,21 +78,13 @@ int main(int argc,char **argv) MESSAGE("Get Typed Component list (SUPERV Type)"); list_typed_composants = Catalogue->GetTypedComponentList(SALOME_ModuleCatalog::SUPERV); -#ifndef WNT for (unsigned int ind = 0; ind < list_typed_composants->length();ind++) -#else - for (ind = 0; ind < list_typed_composants->length();ind++) -#endif MESSAGE("Component SUPERV list : " << list_typed_composants[ind]); // Get list of couple (component name, component icone) SALOME_ModuleCatalog::ListOfIAPP_Affich_var list_composants_icone = Catalogue->GetComponentIconeList(); -#ifndef WNT for (unsigned int ind = 0; ind < list_composants_icone->length();ind++) -#else - for (ind = 0; ind < list_composants_icone->length();ind++) -#endif { MESSAGE("Component name: " << list_composants_icone[ind].modulename); MESSAGE("Component icone: " << list_composants_icone[ind].moduleicone); diff --git a/src/ModuleCatalog/SALOME_ModuleCatalog_Server.cxx b/src/ModuleCatalog/SALOME_ModuleCatalog_Server.cxx index 892b2fbb8..2271273bd 100644 --- a/src/ModuleCatalog/SALOME_ModuleCatalog_Server.cxx +++ b/src/ModuleCatalog/SALOME_ModuleCatalog_Server.cxx @@ -73,7 +73,7 @@ int main(int argc,char **argv) for (int i = 1; i<=NumberOfTries; i++) { if (i!=1) -#ifndef WNT +#ifndef WIN32 a=nanosleep(&ts_req,&ts_rem); #else Sleep(TIMESleep/1000000); @@ -106,7 +106,7 @@ int main(int argc,char **argv) for(int j=1; j<=NumberOfTries; j++) { if (j!=1) -#ifndef WNT +#ifndef WIN32 a=nanosleep(&ts_req, &ts_rem); #else Sleep(TIMESleep/1000000); diff --git a/src/ModuleCatalog/SALOME_ModuleCatalog_impl.cxx b/src/ModuleCatalog/SALOME_ModuleCatalog_impl.cxx index 435951b23..8c81c0290 100644 --- a/src/ModuleCatalog/SALOME_ModuleCatalog_impl.cxx +++ b/src/ModuleCatalog/SALOME_ModuleCatalog_impl.cxx @@ -30,10 +30,13 @@ #include "SALOME_ModuleCatalog_Acomponent_impl.hxx" #include #include +#include "utilities.h" -using namespace std; +#ifdef WIN32 +# include +#endif -#include "utilities.h" +using namespace std; #ifdef _DEBUG_ static int MYDEBUG = 0; @@ -127,7 +130,7 @@ SALOME_ModuleCatalogImpl::SALOME_ModuleCatalogImpl(int argc, char** argv, CORBA: list dirList; -#ifdef WNT +#ifdef WIN32 dirList = splitStringToList(_general_path, SEPARATOR); #else //check for new format @@ -356,7 +359,7 @@ SALOME_ModuleCatalogImpl::GetComponentList() // The components in the general catalog are taken only if they're // not defined in the personal catalog -#ifndef WNT +#ifndef WIN32 for(unsigned int ind=0; ind < _general_module_list.size();ind++){ #else for(ind=0; ind < _general_module_list.size();ind++){ @@ -421,7 +424,7 @@ SALOME_ModuleCatalogImpl::GetComponentIconeList() // The components in the general catalog are taken only if they're // not defined in the personal catalog -#ifndef WNT +#ifndef WIN32 for(unsigned int ind=0; ind < _general_module_list.size();ind++){ #else for(ind=0; ind < _general_module_list.size();ind++){ @@ -516,7 +519,7 @@ SALOME_ModuleCatalogImpl::GetTypedComponentList(SALOME_ModuleCatalog::ComponentT // The components in the general catalog are taken only if they're // not defined in the personal catalog -#ifndef WNT +#ifndef WIN32 for (unsigned int ind=0; ind < _general_module_list.size();ind++) #else for (ind=0; ind < _general_module_list.size();ind++) @@ -619,7 +622,12 @@ SALOME_ModuleCatalogImpl::GetComponentInfo(const char *name) CORBA::Long SALOME_ModuleCatalogImpl::getPID() { - return (CORBA::Long)getpid(); + return +#ifndef WIN32 + (CORBA::Long)getpid(); +#else + (CORBA::Long)_getpid(); +#endif } void SALOME_ModuleCatalogImpl::ShutdownWithExit() @@ -816,7 +824,7 @@ void SALOME_ModuleCatalogImpl::duplicate _length = S_parser.outParameters.size(); S_corba.ServiceoutParameter.length(_length); -#ifndef WNT +#ifndef WIN32 for (unsigned int ind2 = 0; ind2 < _length ; ind2 ++) #else for (ind2 = 0; ind2 < _length ; ind2 ++) @@ -828,7 +836,7 @@ void SALOME_ModuleCatalogImpl::duplicate _length = S_parser.inDataStreamParameters.size(); S_corba.ServiceinDataStreamParameter.length(_length); -#ifndef WNT +#ifndef WIN32 for (unsigned int ind2 = 0; ind2 < _length ; ind2 ++) #else for (ind2 = 0; ind2 < _length ; ind2 ++) @@ -841,7 +849,7 @@ void SALOME_ModuleCatalogImpl::duplicate // if(MYDEBUG) SCRUTE(_length); S_corba.ServiceoutDataStreamParameter.length(_length); -#ifndef WNT +#ifndef WIN32 for (unsigned int ind2 = 0; ind2 < _length ; ind2 ++) #else for (ind2 = 0; ind2 < _length ; ind2 ++) @@ -939,11 +947,7 @@ SALOME_ModuleCatalogImpl::_verify_path_prefix(ParserPathPrefixes & pathList) } // Parse if a computer name is twice in the list of computers -#ifndef WNT for (unsigned int ind = 0; ind < _machine_list.size(); ind++) -#else - for (ind = 0; ind < _machine_list.size(); ind++) -#endif { for (unsigned int ind1 = ind+1 ; ind1 < _machine_list.size(); ind1++) { diff --git a/src/ModuleGenerator/IDLparser.py b/src/ModuleGenerator/IDLparser.py index 0b74eb3af..7ffd96c34 100644 --- a/src/ModuleGenerator/IDLparser.py +++ b/src/ModuleGenerator/IDLparser.py @@ -80,6 +80,7 @@ class Tree: self.parent = None self.childs = [] self.comments = [] + self.attrs={} def addChild(self, tree): if tree is not None: @@ -114,7 +115,10 @@ class Tree: d = depth if self.name != '': s = string.ljust('', 4*depth) - s += '<' + self.name + '>' + s += '<' + self.name + for k,v in self.attrs.items(): + s += ' ' + k + '="' + v + '"' + s += '>' if self.content != '': s += self.content else: @@ -213,6 +217,9 @@ class Tree: L_merge.addChild(i_ext) self.replaceChild(L_merge) + + def setAttrib(self, name,value): + self.attrs[name]=value @@ -476,6 +483,7 @@ class Catalog(ContentHandler, Tree): parser.parse(filename) else: t = self.addNamedChild('begin-catalog') + t.addNamedChild('type-list') t.addNamedChild('component-list') n = self.getChild('begin-catalog') @@ -484,6 +492,9 @@ class Catalog(ContentHandler, Tree): return if n.getChild('path-prefix-list') is None: n.insertFirstNamedChild('path-prefix-list') + if n.getChild('type-list') is None: + p=n.childs.index(n.getChild('path-prefix-list')) + n.childs.insert(p+1,Tree('type-list')) if n.getChild('component-list') is None: n.addNamedChild('component-list') @@ -516,6 +527,16 @@ class Catalog(ContentHandler, Tree): e = p.addChild(parameter(mode='in')) elif name == 'outParameter': e = p.addChild(parameter(mode='out')) + elif name == 'sequence': + e = p.addChild(SeqType(attrs["name"],attrs["content"])) + elif name == 'objref': + e = p.addChild(ObjType(attrs["name"])) + elif name == 'struct': + e = p.addChild(StructType(attrs["name"])) + elif name == 'type': + e = p.addChild(Type(attrs["name"],attrs["kind"])) + elif name == 'member': + e = p.addChild(Member(attrs["name"],attrs["type"])) else: e = p.addNamedChild(name) self.list.append(e) @@ -555,8 +576,66 @@ class Catalog(ContentHandler, Tree): print ' replace component', i_ext.getChild('component-name').content i_int.merge(i_ext) - - + def mergeType(self, type): + L_int = self.getNode('type-list') + if L_int is None: + error("Catalog.mergeType : 'type-list' is not found") + return + for t in L_int.childs: + if t.attrs["name"] == type.attrs["name"]: + t.merge(type) + return + + L_int.addChild(type) + +class Member(Tree): + def __init__(self, name,type): + Tree.__init__(self, 'member') + self.setAttrib("name",name) + self.setAttrib("type",type) + +class Type(Tree): + def __init__(self, name,kind): + Tree.__init__(self, 'type') + self.setAttrib("name",name) + self.setAttrib("kind",kind) + + def merge(self,t): + self.setAttrib("kind",t.attrs["kind"]) + +class SeqType(Tree): + def __init__(self, name,content): + Tree.__init__(self, 'sequence') + self.setAttrib("name",name) + self.setAttrib("content",content) + + def merge(self,t): + self.setAttrib("content",t.attrs["content"]) + +class StructType(Tree): + def __init__(self, name): + Tree.__init__(self, 'struct') + self.setAttrib("name",name) + + def merge(self,t): + #remove childs and replace by t childs + self.childs=[] + for c in t.childs: + self.childs.append(c) + +class ObjType(Tree): + def __init__(self, name): + Tree.__init__(self, 'objref') + self.setAttrib("name",name) + + def merge(self,t): + RepoId=t.attrs.get("id") + if RepoId: + self.setAttrib("id",RepoId) + #remove childs and replace by t childs + self.childs=[] + for c in t.childs: + self.childs.append(c) # IDL file reader @@ -589,47 +668,61 @@ class ModuleCatalogVisitor (idlvisitor.AstVisitor): def __init__(self, catalog): self.catalog = catalog self.EngineType = 0 + self.currentScope=None def visitAST(self, node): for n in node.declarations(): - n.accept(self) + if n.mainFile(): + n.accept(self) def visitModule(self, node): + self.currentScope=node for n in node.definitions(): n.accept(self) def visitInterface(self, node): - if node.mainFile(): self.EngineType = 0 for i in node.inherits(): s = i.scopedName(); - if ((s[0] == "Engines") & (s[1] == "Component")): + if s[0] == "Engines": + if s[1] == "Component": self.EngineType = 1; break + if s[1] == "Superv_Component": + self.EngineType = 2; break - Comp = Component(node.identifier()) + if self.EngineType: + #This interface is a SALOME component + Comp = Component(node.identifier()) - self.currentInterface = Comp.createInterface(node.identifier()) + self.currentInterface = Comp.createInterface(node.identifier()) - for c in node.callables(): + for c in node.callables(): if isinstance(c, idlast.Operation): c.accept(self) - for c in node.declarations(): + for c in node.declarations(): if isinstance(c, idlast.Struct): c.accept(self) - for i in node.comments(): + for i in node.comments(): self.currentInterface.comments.append(str(i)) - self.currentInterface.processDataStreams() + if self.EngineType == 2: + self.currentInterface.processDataStreams() - if (self.EngineType): - global nb_components - nb_components = nb_components + 1 - self.catalog.mergeComponent(Comp) + global nb_components + nb_components = nb_components + 1 + self.catalog.mergeComponent(Comp) + + else: + #This interface is not a component : use it as a DataType + t=ObjType("/".join(node.scopedName())) + for i in node.inherits(): + t.addNamedChild("base","/".join(i.scopedName())) + self.catalog.mergeType(t) self.EngineType = 0 @@ -652,7 +745,9 @@ class ModuleCatalogVisitor (idlvisitor.AstVisitor): def visitDeclaredType(self, type): - self.currentType = type.name() + name=type.name() + scoped_name="/".join(type.scopedName()) + self.currentType = scoped_name def visitBaseType(self, type): self.currentType = ttsMap[type.kind()] @@ -669,6 +764,58 @@ class ModuleCatalogVisitor (idlvisitor.AstVisitor): self.currentService.createOutParameter \ (node.identifier(), self.currentType) + def visitSequenceType(self,type): + type.seqType().accept(self) + if type.bound() == 0: + self.contentType=self.currentType + self.currentType = "sequence" + else: + self.currentType = None + + def visitTypedef(self, node): + if node.constrType(): + node.aliasType().decl().accept(self) + + node.aliasType().accept(self) + type = self.currentType + if not type: + return + decll = [] + for d in node.declarators(): + d.accept(self) + if self.__result_declarator: + decll.append(self.__result_declarator) + if type == "sequence": + #it's a sequence type + for name in decll: + scoped_name="/".join(self.currentScope.scopedName()+[name]) + self.catalog.mergeType(SeqType(scoped_name,self.contentType)) + #else: + #it's an alias + # for name in decll: + # scoped_name="/".join(self.currentScope.scopedName()+[name]) + # self.catalog.mergeType(Type(scoped_name,type)) + + def visitStruct(self, node): + t=StructType("/".join(node.scopedName())) + for m in node.members(): + if m.constrType(): + m.memberType().decl().accept(self) + + m.memberType().accept(self) + type = self.currentType + for d in m.declarators(): + d.accept(self) + t.addChild(Member(self.__result_declarator,type)) + + self.catalog.mergeType(t) + + def visitDeclarator(self, node): + if node.sizes(): + self.__result_declarator =None + else: + self.__result_declarator =node.identifier() + #-------------------------------------------------- # parse idl and store xml file #-------------------------------------------------- diff --git a/src/ModuleGenerator/testIDLparser.in b/src/ModuleGenerator/testIDLparser.in index 64709e7ac..fbb90b735 100755 --- a/src/ModuleGenerator/testIDLparser.in +++ b/src/ModuleGenerator/testIDLparser.in @@ -4,7 +4,7 @@ ROOT_SRCDIR=@ROOT_SRCDIR@ export ROOT_SRCDIR ROOT_BUILDDIR=@ROOT_BUILDDIR@ export ROOT_BUILDDIR -SRCDIR=${ROOT_SRCDIR}/SALOME/src/ModuleGenerator +SRCDIR=${ROOT_SRCDIR}/src/ModuleGenerator export SRCDIR ${SRCDIR}/tests/test$1.sh diff --git a/src/ModuleGenerator/tests/AddComponent.idl b/src/ModuleGenerator/tests/AddComponent.idl new file mode 100644 index 000000000..6a13292bf --- /dev/null +++ b/src/ModuleGenerator/tests/AddComponent.idl @@ -0,0 +1,67 @@ +// Copyright (C) 2005 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// 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 : AddComponent.idl +// Author : Jean Rahuel + +#ifndef _ADDCOMPONENT_IDL +#define _ADDCOMPONENT_IDL + +#include "SALOME_Component.idl" + +module SuperVisionTest { + + interface Adder ; + + interface AddComponent : Engines::Component { + double Add( in double x , in double y , out double z ) ; + double AddWithoutSleep( in double x , in double y , out double z ) ; + void Setx( in double x ) ; + void Sety( in double y ) ; + double Addxy() ; + double AddyTox( in double y ) ; + long Sigma( in long n ) ; + double LastResult() ; + + Adder Addition() ; + boolean AdditionObjRef1( out Adder anAdder ) ; + void AdditionObjRef2( out boolean FuncValue , out Adder anAdder ) ; + boolean AdditionObjRefs( in AddComponent AddComponent1 , + in AddComponent Adder2 , + in AddComponent Adder3 , + out AddComponent RetAddComponent1 , + out AddComponent RetAdder2 , + out AddComponent RetAdder3 ) ; + }; + + interface Adder : Engines::Component { + double Add( in double x , in double y , out double z ) ; + double AddWithoutSleep( in double x , in double y , out double z ) ; + double AddAndCompare( in double x , in double y , in Adder anOtherAdder, + out double z ) ; + void SetLastResult( in double z ) ; + void LastResult( out double z ) ; + Engines::Component LccAddComponent( in string aContainer , + in string aComponentName ) ; + }; + +} ; + +#endif diff --git a/src/ModuleGenerator/tests/SubComponent.idl b/src/ModuleGenerator/tests/SubComponent.idl new file mode 100644 index 000000000..d651d236e --- /dev/null +++ b/src/ModuleGenerator/tests/SubComponent.idl @@ -0,0 +1,37 @@ +// Copyright (C) 2005 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// 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 : SubComponent.idl +// Author : Jean Rahuel + +#ifndef _SUBCOMPONENT_IDL +#define _SUBCOMPONENT_IDL + +#include "SALOME_Component.idl" + +module SuperVisionTest { + + interface SubComponent : Engines::Component { + void Sub( in double x , in double y , out double z ) ; + } ; +}; + + +#endif diff --git a/src/ModuleGenerator/tests/test1.sh b/src/ModuleGenerator/tests/test1.sh index 34dd9cddd..6133420cd 100755 --- a/src/ModuleGenerator/tests/test1.sh +++ b/src/ModuleGenerator/tests/test1.sh @@ -32,7 +32,8 @@ echo "test1: \rm -f my_catalog.xml* -${ROOT_BUILDDIR}/bin/runIDLparser \ +sh ${ROOT_BUILDDIR}/bin/runIDLparser -p ${SRCDIR} \ + -I${ROOT_SRCDIR}/idl \ -Wbcatalog=my_catalog.xml \ - ${ROOT_SRCDIR}/idl/AddComponent.idl + ${SRCDIR}/tests/AddComponent.idl diff --git a/src/ModuleGenerator/tests/test1b.sh b/src/ModuleGenerator/tests/test1b.sh index 8af58c555..4d323a402 100755 --- a/src/ModuleGenerator/tests/test1b.sh +++ b/src/ModuleGenerator/tests/test1b.sh @@ -24,7 +24,7 @@ # File : test1b.sh # Module : SALOME -echo "test6: +echo "test1b: test derivation Engine::Component " @@ -36,7 +36,8 @@ echo " --> creation d'un nouveau catalogue avec un composant " -${ROOT_BUILDDIR}/bin/runIDLparser \ - -Wbcatalog=my_catalog.xml \ +sh ${ROOT_BUILDDIR}/bin/runIDLparser -p ${SRCDIR} \ + -I${ROOT_SRCDIR}/idl \ + -Wbcatalog=my_catalog.xml \ ${SRCDIR}/tests/TrucComponent.idl diff --git a/src/ModuleGenerator/tests/test2.sh b/src/ModuleGenerator/tests/test2.sh index dc2ba48d8..7ce6b0c5f 100755 --- a/src/ModuleGenerator/tests/test2.sh +++ b/src/ModuleGenerator/tests/test2.sh @@ -37,25 +37,28 @@ echo " --> creation d'un nouveau catalogue avec un composant " -${ROOT_BUILDDIR}/bin/runIDLparser \ +sh ${ROOT_BUILDDIR}/bin/runIDLparser -p ${SRCDIR} \ + -I${ROOT_SRCDIR}/idl \ -Wbcatalog=my_catalog.xml \ - ${ROOT_SRCDIR}/idl/AddComponent.idl + ${SRCDIR}/tests/AddComponent.idl echo " --> ajout d'un nouveau composant dans le catalogue " -${ROOT_BUILDDIR}/bin/runIDLparser \ +sh ${ROOT_BUILDDIR}/bin/runIDLparser -p ${SRCDIR} \ + -I${ROOT_SRCDIR}/idl \ -Wbcatalog=my_catalog.xml \ - ${ROOT_SRCDIR}/idl/SubComponent.idl + ${SRCDIR}/tests/SubComponent.idl echo " --> remplacement du premier composant dans le catalogue " -${ROOT_BUILDDIR}/bin/runIDLparser \ +sh ${ROOT_BUILDDIR}/bin/runIDLparser -p ${SRCDIR} \ + -I${ROOT_SRCDIR}/idl \ -Wbcatalog=my_catalog.xml \ - ${ROOT_SRCDIR}/idl/AddComponent.idl + ${SRCDIR}/tests/AddComponent.idl diff --git a/src/ModuleGenerator/tests/test3.sh b/src/ModuleGenerator/tests/test3.sh index 8bead0b7e..236550d83 100755 --- a/src/ModuleGenerator/tests/test3.sh +++ b/src/ModuleGenerator/tests/test3.sh @@ -37,14 +37,17 @@ echo " --> creation d'un nouveau catalogue avec un composant " -${ROOT_BUILDDIR}/bin/runIDLparser \ - -Wbcatalog=my_catalog.xml \ - ${ROOT_SRCDIR}/idl/AddComponent.idl +sh ${ROOT_BUILDDIR}/bin/runIDLparser -p ${SRCDIR} \ + -I${ROOT_SRCDIR}/idl \ + -Wbcatalog=my_catalog.xml \ + ${SRCDIR}/tests/AddComponent.idl + echo " --> remplacement du composant dans le catalogue (meme idl) " -${ROOT_BUILDDIR}/bin/runIDLparser \ - -Wbcatalog=my_catalog.xml \ - ${ROOT_SRCDIR}/idl/AddComponent.idl +sh ${ROOT_BUILDDIR}/bin/runIDLparser -p ${SRCDIR} \ + -I${ROOT_SRCDIR}/idl \ + -Wbcatalog=my_catalog.xml \ + ${SRCDIR}/tests/AddComponent.idl diff --git a/src/ModuleGenerator/tests/test4.sh b/src/ModuleGenerator/tests/test4.sh index 7c6b77c76..b14f3b0bd 100755 --- a/src/ModuleGenerator/tests/test4.sh +++ b/src/ModuleGenerator/tests/test4.sh @@ -36,9 +36,10 @@ echo " --> creation d'un nouveau catalogue avec un composant " -${ROOT_BUILDDIR}/bin/runIDLparser \ - -Wbcatalog=my_catalog.xml \ - ${ROOT_SRCDIR}/idl/AddComponent.idl +sh ${ROOT_BUILDDIR}/bin/runIDLparser -p ${SRCDIR} \ + -I${ROOT_SRCDIR}/idl \ + -Wbcatalog=my_catalog.xml \ + ${SRCDIR}/tests/AddComponent.idl mv my_catalog.xml C1 @@ -53,7 +54,8 @@ mv C1 my_catalog.xml --> remplacement du composant dans le catalogue (autre idl) " -${ROOT_BUILDDIR}/bin/runIDLparser \ - -Wbcatalog=my_catalog.xml \ - ${SRCDIR}/tests/Truc2Component.idl +sh ${ROOT_BUILDDIR}/bin/runIDLparser -p ${SRCDIR} \ + -I${ROOT_SRCDIR}/idl \ + -Wbcatalog=my_catalog.xml \ + ${SRCDIR}/tests/Truc2Component.idl diff --git a/src/ModuleGenerator/tests/test5.sh b/src/ModuleGenerator/tests/test5.sh index 8f03323b2..02783763f 100755 --- a/src/ModuleGenerator/tests/test5.sh +++ b/src/ModuleGenerator/tests/test5.sh @@ -24,7 +24,7 @@ # File : test5.sh # Module : SALOME -echo "test4: +echo "test5: creation d'un catalogue avec tous les idl de Salome (au 29/3/2002) @@ -37,6 +37,7 @@ do echo echo " processing " `basename $i` echo - ${ROOT_BUILDDIR}/bin/runIDLparser \ - -Wbcatalog=my_catalog.xml $i + sh ${ROOT_BUILDDIR}/bin/runIDLparser -p ${SRCDIR} \ + -I${ROOT_SRCDIR}/idl \ + -Wbcatalog=my_catalog.xml $i done diff --git a/src/NOTIFICATION_SWIG/NOTIFICATION.i b/src/NOTIFICATION_SWIG/NOTIFICATION.i index ccd684c2f..01ad8b667 100644 --- a/src/NOTIFICATION_SWIG/NOTIFICATION.i +++ b/src/NOTIFICATION_SWIG/NOTIFICATION.i @@ -27,6 +27,7 @@ %module libNOTIFICATION +%feature("autodoc", "1"); %{ //#define __declspec(a) diff --git a/src/NOTIFICATION_SWIG/SALOME_NOTIFICATION_SWIG.hxx b/src/NOTIFICATION_SWIG/SALOME_NOTIFICATION_SWIG.hxx index 33d751c91..23f3c05bc 100755 --- a/src/NOTIFICATION_SWIG/SALOME_NOTIFICATION_SWIG.hxx +++ b/src/NOTIFICATION_SWIG/SALOME_NOTIFICATION_SWIG.hxx @@ -26,22 +26,14 @@ #ifndef _SALOME_NOTIFICATION_SWIG_HXX_ #define _SALOME_NOTIFICATION_SWIG_HXX_ -#ifdef WNT - #if defined NOTIFICATION_SWIG_EXPORTS - #if defined WIN32 - #define NOTIFICATION_SWIG_EXPORT __declspec( dllexport ) - #else - #define NOTIFICATION_SWIG_EXPORT - #endif - #else - #if defined WIN32 - #define NOTIFICATION_SWIG_EXPORT __declspec( dllimport ) - #else - #define NOTIFICATION_SWIG_EXPORT - #endif - #endif +#ifdef WIN32 +# ifdef NOTIFICATION_SWIG_EXPORTS +# define NOTIFICATION_SWIG_EXPORT __declspec( dllexport ) +# else +# define NOTIFICATION_SWIG_EXPORT __declspec( dllimport ) +# endif #else - #define NOTIFICATION_SWIG_EXPORT +# define NOTIFICATION_SWIG_EXPORT #endif #endif diff --git a/src/NamingService/Makefile.am b/src/NamingService/Makefile.am index a371d7e1c..3717f4377 100644 --- a/src/NamingService/Makefile.am +++ b/src/NamingService/Makefile.am @@ -32,7 +32,8 @@ include $(top_srcdir)/salome_adm/unix/make_common_starter.am salomeinclude_HEADERS =\ SALOME_NamingService.hxx \ ServiceUnreachable.hxx \ - NamingService_WaitForServerReadiness.hxx + NamingService_WaitForServerReadiness.hxx \ + SALOME_NamingService_defs.hxx # Scripts to be exported dist_salomescript_DATA =\ diff --git a/src/NamingService/NamingService_WaitForServerReadiness.cxx b/src/NamingService/NamingService_WaitForServerReadiness.cxx index d4eb2aa7e..0cdc78ad5 100644 --- a/src/NamingService/NamingService_WaitForServerReadiness.cxx +++ b/src/NamingService/NamingService_WaitForServerReadiness.cxx @@ -79,7 +79,7 @@ void NamingService_WaitForServerReadiness(SALOME_NamingService* NS, break; // server found, no more try to do } MESSAGE("Server "<< serverName <<" not yet ready, waiting..."); -#ifndef WNT +#ifndef WIN32 nanosleep(&ts_req,&ts_rem); // wait before retry #else Sleep(TIMESleep/1000000); @@ -89,7 +89,7 @@ void NamingService_WaitForServerReadiness(SALOME_NamingService* NS, catch( ServiceUnreachable& ) { MESSAGE("CORBA::COMM_FAILURE: Naming Service not yet ready, waiting..."); -#ifndef WNT +#ifndef WIN32 nanosleep(&ts_req,&ts_rem); // wait before retry #else Sleep(TIMESleep/1000000); diff --git a/src/NamingService/SALOME_NamingService.hxx b/src/NamingService/SALOME_NamingService.hxx index 57e53ab75..ce23e360e 100644 --- a/src/NamingService/SALOME_NamingService.hxx +++ b/src/NamingService/SALOME_NamingService.hxx @@ -39,19 +39,7 @@ #include "Utils_Mutex.hxx" #include "ServiceUnreachable.hxx" -#if defined NAMINGSERVICE_EXPORTS -#if defined WIN32 -#define NAMINGSERVICE_EXPORT __declspec( dllexport ) -#else -#define NAMINGSERVICE_EXPORT -#endif -#else -#if defined WNT -#define NAMINGSERVICE_EXPORT __declspec( dllimport ) -#else -#define NAMINGSERVICE_EXPORT -#endif -#endif +#include "SALOME_NamingService_defs.hxx" class NAMINGSERVICE_EXPORT SALOME_NamingService { diff --git a/src/NamingService/SALOME_NamingService_defs.hxx b/src/NamingService/SALOME_NamingService_defs.hxx new file mode 100644 index 000000000..32feab74e --- /dev/null +++ b/src/NamingService/SALOME_NamingService_defs.hxx @@ -0,0 +1,42 @@ +// SALOME NamingService : wrapping NamingService services +// +// Copyright (C) 2003 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 : SALOME_NamingService_defs.hxx +// Author : Alexander A. BORODIN +// Module : SALOME +// $Header$ + +#ifndef SALOME_NAMINGSERVICE_DEFS_HXX +#define SALOME_NAMINGSERVICE_DEFS_HXX + +#ifdef WIN32 +# ifdef NAMINGSERVICE_EXPORTS +# define NAMINGSERVICE_EXPORT __declspec( dllexport ) +# else +# define NAMINGSERVICE_EXPORT __declspec( dllimport ) +# endif +#else +# define NAMINGSERVICE_EXPORT +#endif + +#endif //SALOME_NAMINGSERVICE_DEFS_HXX diff --git a/src/NamingService/ServiceUnreachable.hxx b/src/NamingService/ServiceUnreachable.hxx index 496f376fe..14ffae697 100644 --- a/src/NamingService/ServiceUnreachable.hxx +++ b/src/NamingService/ServiceUnreachable.hxx @@ -29,20 +29,7 @@ #if !defined ( SERVICEUNREACHABLE_H ) #define SERVICEUNREACHABLE_H -#if defined NAMINGSERVICE_EXPORTS -#if defined WNT -#define NAMINGSERVICE_EXPORT __declspec( dllexport ) -#else -#define NAMINGSERVICE_EXPORT -#endif -#else -#if defined WNT -#define NAMINGSERVICE_EXPORT __declspec( dllimport ) -#else -#define NAMINGSERVICE_EXPORT -#endif -#endif - +#include "SALOME_NamingService_defs.hxx" #include "Utils_SALOME_Exception.hxx" //! exception class for NamingService : ServiceUnreachable diff --git a/src/Notification/SALOME_NOTIFICATION.hxx b/src/Notification/SALOME_NOTIFICATION.hxx index c187b4119..bc58c084e 100755 --- a/src/Notification/SALOME_NOTIFICATION.hxx +++ b/src/Notification/SALOME_NOTIFICATION.hxx @@ -26,22 +26,14 @@ #ifndef _SALOME_NOTIFICATION_HXX_ #define _SALOME_NOTIFICATION_HXX_ -#ifdef WNT - #if defined NOTIFICATION_EXPORTS - #if defined WIN32 - #define NOTIFICATION_EXPORT __declspec( dllexport ) - #else - #define NOTIFICATION_EXPORT - #endif - #else - #if defined WIN32 - #define NOTIFICATION_EXPORT __declspec( dllimport ) - #else - #define NOTIFICATION_EXPORT - #endif - #endif +#ifdef WIN32 +# ifdef NOTIFICATION_EXPORTS +# define NOTIFICATION_EXPORT __declspec( dllexport ) +# else +# define NOTIFICATION_EXPORT __declspec( dllimport ) +# endif #else - #define NOTIFICATION_EXPORT +# define NOTIFICATION_EXPORT #endif #endif diff --git a/src/ParallelContainer/SALOME_ParallelComponent_i.cxx b/src/ParallelContainer/SALOME_ParallelComponent_i.cxx index fab45e703..59749089b 100644 --- a/src/ParallelContainer/SALOME_ParallelComponent_i.cxx +++ b/src/ParallelContainer/SALOME_ParallelComponent_i.cxx @@ -28,13 +28,13 @@ #include "OpUtil.hxx" #include -#ifndef WNT +#ifndef WIN32 #include #endif #include #include "utilities.h" -#ifndef WNT +#ifndef WIN32 #include #include #include @@ -304,7 +304,7 @@ bool Engines_Parallel_Component_i::Kill_impl() // << dec ) ; bool RetVal = false ; -#ifndef WNT +#ifndef WIN32 if ( _ThreadId > 0 && pthread_self() != _ThreadId ) { RetVal = Killer( _ThreadId , 0 ) ; @@ -333,12 +333,12 @@ bool Engines_Parallel_Component_i::Stop_impl() MESSAGE("Engines_Parallel_Component_i::Stop_i() pthread_t "<< pthread_self() << " pid " << getpid() << " instanceName " << _instanceName.c_str() << " interface " << _interfaceName.c_str() - << " machineName " << GetHostname().c_str()<< " _id " << hex << _id + << " machineName " << Kernel_Utils::GetHostname().c_str()<< " _id " << hex << _id << dec << " _ThreadId " << _ThreadId ); bool RetVal = false ; -#ifndef WNT +#ifndef WIN32 if ( _ThreadId > 0 && pthread_self() != _ThreadId ) { RetVal = Killer( _ThreadId , 0 ) ; @@ -365,11 +365,11 @@ bool Engines_Parallel_Component_i::Suspend_impl() MESSAGE("Engines_Parallel_Component_i::Suspend_i() pthread_t "<< pthread_self() << " pid " << getpid() << " instanceName " << _instanceName.c_str() << " interface " << _interfaceName.c_str() - << " machineName " << GetHostname().c_str()<< " _id " << hex << _id + << " machineName " << Kernel_Utils::GetHostname().c_str()<< " _id " << hex << _id << dec << " _ThreadId " << _ThreadId ); bool RetVal = false ; -#ifndef WNT +#ifndef WIN32 if ( _ThreadId > 0 && pthread_self() != _ThreadId ) #else if ( _ThreadId > 0 && pthread_self().p != _ThreadId->p ) @@ -381,7 +381,7 @@ bool Engines_Parallel_Component_i::Suspend_impl() } else { -#ifndef WNT +#ifndef WIN32 RetVal = Killer( _ThreadId ,SIGINT ) ; #else RetVal = Killer( *_ThreadId ,SIGINT ) ; @@ -404,10 +404,10 @@ bool Engines_Parallel_Component_i::Resume_impl() MESSAGE("Engines_Parallel_Component_i::Resume_i() pthread_t "<< pthread_self() << " pid " << getpid() << " instanceName " << _instanceName.c_str() << " interface " << _interfaceName.c_str() - << " machineName " << GetHostname().c_str()<< " _id " << hex << _id + << " machineName " << Kernel_Utils::GetHostname().c_str()<< " _id " << hex << _id << dec << " _ThreadId " << _ThreadId ); bool RetVal = false ; -#ifndef WNT +#ifndef WIN32 if ( _ThreadId > 0 && pthread_self() != _ThreadId ) #else if ( _ThreadId > 0 && pthread_self().p != _ThreadId->p ) @@ -439,7 +439,7 @@ CORBA::Long Engines_Parallel_Component_i::CpuUsed_impl() { if ( _ThreadId > 0 ) { -#ifndef WNT +#ifndef WIN32 if ( pthread_self() != _ThreadId ) #else if ( pthread_self().p != _ThreadId->p ) @@ -452,7 +452,7 @@ CORBA::Long Engines_Parallel_Component_i::CpuUsed_impl() { // Get Cpu in the appropriate thread with that object !... theEngines_Component = this ; -#ifndef WNT +#ifndef WIN32 Killer( _ThreadId ,SIGUSR1 ) ; #else Killer( *_ThreadId ,SIGUSR11 ) ; @@ -543,7 +543,7 @@ void Engines_Parallel_Component_i::beginService(const char *serviceName) { MESSAGE(pthread_self() << "Send BeginService notification for " < #include #include -#ifndef WNT +#ifndef WIN32 #include #endif #include @@ -45,18 +45,14 @@ class Engines_Parallel_Container_i; -#if defined CONTAINER_EXPORTS -#if defined WIN32 -#define CONTAINER_EXPORT __declspec( dllexport ) +#ifdef WIN32 +# ifdef CONTAINER_EXPORTS +# define CONTAINER_EXPORT __declspec( dllexport ) +# else +# define CONTAINER_EXPORT __declspec( dllimport ) +# endif #else -#define CONTAINER_EXPORT -#endif -#else -#if defined WNT -#define CONTAINER_EXPORT __declspec( dllimport ) -#else -#define CONTAINER_EXPORT -#endif +# define CONTAINER_EXPORT #endif class CONTAINER_EXPORT Engines_Parallel_Component_i: @@ -191,7 +187,7 @@ protected: char * _proxy; private: -#ifndef WNT +#ifndef WIN32 pthread_t _ThreadId ; #else pthread_t* _ThreadId ; diff --git a/src/ParallelContainer/SALOME_ParallelContainerNodeDummy.cxx b/src/ParallelContainer/SALOME_ParallelContainerNodeDummy.cxx index d3470b9de..bde83c19d 100644 --- a/src/ParallelContainer/SALOME_ParallelContainerNodeDummy.cxx +++ b/src/ParallelContainer/SALOME_ParallelContainerNodeDummy.cxx @@ -29,7 +29,7 @@ #include #include -#ifndef WNT +#ifndef WIN32 #include #else #include @@ -135,7 +135,7 @@ int main(int argc, char* argv[]) PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj); PortableServer::POAManager_var pman = root_poa->the_POAManager(); -#ifndef WNT +#ifndef WIN32 // add this container to the kill list char aCommand[100]; sprintf(aCommand, "addToKillList.py %d SALOME_ParallelContainerNode", getpid()); @@ -170,7 +170,7 @@ int main(int argc, char* argv[]) obj = root_poa->id_to_reference(*_id); // In the NamingService - string hostname = GetHostname(); + string hostname = Kernel_Utils::GetHostname(); int myid = 0; char buffer [5]; snprintf(buffer, 5, "%d", myid); diff --git a/src/ParallelContainer/SALOME_ParallelContainerNodeMpi.cxx b/src/ParallelContainer/SALOME_ParallelContainerNodeMpi.cxx index baea9d421..0b29d128e 100644 --- a/src/ParallelContainer/SALOME_ParallelContainerNodeMpi.cxx +++ b/src/ParallelContainer/SALOME_ParallelContainerNodeMpi.cxx @@ -29,7 +29,7 @@ #include #include -#ifndef WNT +#ifndef WIN32 #include #else #include @@ -170,7 +170,7 @@ int main(int argc, char* argv[]) PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj); PortableServer::POAManager_var pman = root_poa->the_POAManager(); -#ifndef WNT +#ifndef WIN32 // add this container to the kill list char aCommand[100]; sprintf(aCommand, "addToKillList.py %d SALOME_ParallelContainerNodeMpi", getpid()); @@ -207,7 +207,7 @@ int main(int argc, char* argv[]) obj = root_poa->id_to_reference(*_id); // In the NamingService - string hostname = GetHostname(); + string hostname = Kernel_Utils::GetHostname(); int myid; MPI_Comm_rank(MPI_COMM_WORLD, &myid); diff --git a/src/ParallelContainer/SALOME_ParallelContainerProxyDummy.cxx b/src/ParallelContainer/SALOME_ParallelContainerProxyDummy.cxx index e8df8733b..4ce592d5d 100644 --- a/src/ParallelContainer/SALOME_ParallelContainerProxyDummy.cxx +++ b/src/ParallelContainer/SALOME_ParallelContainerProxyDummy.cxx @@ -29,7 +29,7 @@ #include #include -#ifndef WNT +#ifndef WIN32 #include #else #include @@ -84,7 +84,7 @@ int main(int argc, char* argv[]) PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj); PortableServer::POAManager_var pman = root_poa->the_POAManager(); -#ifndef WNT +#ifndef WIN32 // add this container to the kill list char aCommand[100]; sprintf(aCommand, "addToKillList.py %d SALOME_ParallelContainerProxyDummy", getpid()); @@ -114,7 +114,7 @@ int main(int argc, char* argv[]) obj = root_poa->id_to_reference(_id); // In the NamingService - string hostname = GetHostname(); + string hostname = Kernel_Utils::GetHostname(); Engines::Container_var pCont = Engines::Container::_narrow(obj); string _containerName = ns->BuildContainerNameForNS(containerName.c_str(), hostname.c_str()); diff --git a/src/ParallelContainer/SALOME_ParallelContainerProxyMpi.cxx b/src/ParallelContainer/SALOME_ParallelContainerProxyMpi.cxx index f14b09e18..da7248b33 100644 --- a/src/ParallelContainer/SALOME_ParallelContainerProxyMpi.cxx +++ b/src/ParallelContainer/SALOME_ParallelContainerProxyMpi.cxx @@ -29,7 +29,7 @@ #include #include -#ifndef WNT +#ifndef WIN32 #include #else #include @@ -88,7 +88,7 @@ int main(int argc, char* argv[]) PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj); PortableServer::POAManager_var pman = root_poa->the_POAManager(); -#ifndef WNT +#ifndef WIN32 // add this container to the kill list char aCommand[100]; sprintf(aCommand, "addToKillList.py %d SALOME_ParallelContainerProxyMpi", getpid()); @@ -119,7 +119,7 @@ int main(int argc, char* argv[]) obj = root_poa->id_to_reference(_id); // in the NamingService - string hostname = GetHostname(); + string hostname = Kernel_Utils::GetHostname(); Engines::Container_var pCont = Engines::Container::_narrow(obj); string _containerName = ns->BuildContainerNameForNS(containerName.c_str(), hostname.c_str()); diff --git a/src/ParallelContainer/SALOME_ParallelContainer_i.cxx b/src/ParallelContainer/SALOME_ParallelContainer_i.cxx index 97f655b39..77da1ab10 100644 --- a/src/ParallelContainer/SALOME_ParallelContainer_i.cxx +++ b/src/ParallelContainer/SALOME_ParallelContainer_i.cxx @@ -24,7 +24,7 @@ // Author : Paul RASCLE, EDF - MARC TAJCHMAN, CEA #include -#ifndef WNT +#ifndef WIN32 #else #include #endif @@ -40,11 +40,11 @@ #include "OpUtil.hxx" #include #include -#ifndef WNT +#ifndef WIN32 #include #include #else -#include "../../adm/win32/SALOME_WNT.hxx" +#include "../../adm/win32/SALOME_WIN32.hxx" #include #include int SIGUSR1 = 1000; @@ -60,7 +60,7 @@ bool _Sleeping = false ; // Other Containers are started via start_impl of FactoryServer extern "C" {void ActSigIntHandler() ; } -#ifndef WNT +#ifndef WIN32 extern "C" {void SigIntHandler(int, siginfo_t *, void *) ; } #else extern "C" {void SigIntHandler( int ) ; } @@ -114,7 +114,7 @@ Engines_Parallel_Container_i::Engines_Parallel_Container_i (CORBA::ORB_ptr orb, _argc = argc ; _argv = argv ; - string hostname = GetHostname(); + string hostname = Kernel_Utils::GetHostname(); _orb = CORBA::ORB::_duplicate(orb) ; _poa = PortableServer::POA::_duplicate(poa) ; @@ -157,7 +157,7 @@ char* Engines_Parallel_Container_i::name() char* Engines_Parallel_Container_i::getHostName() { - string s = GetHostname(); + string s = Kernel_Utils::GetHostname(); MESSAGE("Engines_Parallel_Container_i::getHostName " << s); return CORBA::string_dup(s.c_str()) ; } @@ -226,7 +226,7 @@ Engines_Parallel_Container_i::load_component_Library(const char* componentName) string aCompName = componentName; // --- try dlopen C++ component -#ifndef WNT +#ifndef WIN32 string impl_name = string ("lib") + aCompName + string("Engine.so"); #else string impl_name = aCompName + string("Engine.dll"); @@ -244,7 +244,7 @@ Engines_Parallel_Container_i::load_component_Library(const char* componentName) } void* handle; -#ifndef WNT +#ifndef WIN32 handle = dlopen( impl_name.c_str() , RTLD_LAZY ) ; #else handle = dlopen( impl_name.c_str() , 0 ) ; @@ -305,7 +305,7 @@ Engines_Parallel_Container_i::create_component_instance(const char*genericRegist } //--- try C++ -#ifndef WNT +#ifndef WIN32 string impl_name = string ("lib") + aCompName +string("Engine.so"); #else string impl_name = aCompName +string("Engine.dll"); @@ -452,7 +452,7 @@ bool Engines_Parallel_Container_i::Kill_impl() { MESSAGE("Engines_Parallel_Container_i::Kill() pid "<< getpid() << " containerName " << _containerName.c_str() << " machineName " - << GetHostname().c_str()); + << Kernel_Utils::GetHostname().c_str()); INFOS("==============================================================="); INFOS("= REMOVE calls to Kill_impl in C++ container ="); INFOS("==============================================================="); @@ -730,7 +730,7 @@ Engines_Parallel_Container_i::createParallelInstance(string genericRegisterName, string instanceName = aGenRegisterName + "_inst_" + aNumI ; string component_registerName = _containerName + "/" + instanceName; - string hostname = GetHostname(); + string hostname = Kernel_Utils::GetHostname(); CORBA::Object_var temp = _NS->Resolve(component_registerName.c_str()); Engines::Component_var obj_proxy = Engines::Component::_narrow(temp); @@ -850,7 +850,7 @@ bool Engines_Parallel_Container_i::isPythonContainer(const char* ContainerName) void ActSigIntHandler() { -#ifndef WNT +#ifndef WIN32 struct sigaction SigIntAct ; SigIntAct.sa_sigaction = &SigIntHandler ; SigIntAct.sa_flags = SA_SIGINFO ; @@ -860,7 +860,7 @@ void ActSigIntHandler() // (SIGINT | SIGUSR1) : // it must be only one signal ===> one call for SIGINT // and an other one for SIGUSR1 -#ifndef WNT +#ifndef WIN32 if ( sigaction( SIGINT , &SigIntAct, NULL ) ) { perror("SALOME_Container main ") ; exit(0) ; @@ -885,7 +885,7 @@ void ActSigIntHandler() void SetCpuUsed() ; -#ifndef WNT +#ifndef WIN32 void SigIntHandler(int what , siginfo_t * siginfo , void * toto ) { //PAL9042 JR : during the execution of a Signal Handler (and of methods called through Signal Handlers) @@ -921,7 +921,7 @@ void SigIntHandler(int what , siginfo_t * siginfo , return ; } } -#else // Case WNT +#else // Case WIN32 void SigIntHandler( int what ) { MESSAGE( pthread_self() << "SigIntHandler what " << what << endl ); if ( _Sleeping ) { diff --git a/src/ParallelContainer/SALOME_ParallelContainer_i.hxx b/src/ParallelContainer/SALOME_ParallelContainer_i.hxx index 34d980fdb..1c2efb303 100644 --- a/src/ParallelContainer/SALOME_ParallelContainer_i.hxx +++ b/src/ParallelContainer/SALOME_ParallelContainer_i.hxx @@ -33,7 +33,7 @@ #include #include #include -#ifndef WNT +#ifndef WIN32 #include #endif #include @@ -43,19 +43,14 @@ class SALOME_NamingService; - -#if defined CONTAINER_EXPORTS -#if defined WIN32 -#define CONTAINER_EXPORT __declspec( dllexport ) -#else -#define CONTAINER_EXPORT -#endif +#ifdef WIN32 +# ifdef CONTAINER_EXPORTS +# define CONTAINER_EXPORT __declspec( dllexport ) +# else +# define CONTAINER_EXPORT __declspec( dllimport ) +# endif #else -#if defined WNT -#define CONTAINER_EXPORT __declspec( dllimport ) -#else -#define CONTAINER_EXPORT -#endif +# define CONTAINER_EXPORT #endif class CONTAINER_EXPORT Engines_Parallel_Container_i: diff --git a/src/Registry/RegistryConnexion.cxx b/src/Registry/RegistryConnexion.cxx index 62f017e15..657bbc159 100644 --- a/src/Registry/RegistryConnexion.cxx +++ b/src/Registry/RegistryConnexion.cxx @@ -98,7 +98,7 @@ RegistryConnexion::~RegistryConnexion() _VarComponents->remove( _Id ) ; } _Id = 0 ; -#ifndef WNT +#ifndef WIN32 delete [] _Ior; #else delete [] (char*) _Ior; diff --git a/src/Registry/RegistryService.cxx b/src/Registry/RegistryService.cxx index 939c1adc6..5b4e333a1 100644 --- a/src/Registry/RegistryService.cxx +++ b/src/Registry/RegistryService.cxx @@ -35,7 +35,7 @@ extern "C" # include } -#ifndef WNT +#ifndef WIN32 #include #else #include @@ -78,7 +78,7 @@ RegistryService::~RegistryService() _Compteur = -1 ; if ( _SessionName ) { -#ifndef WNT +#ifndef WIN32 delete [] _SessionName ; #else delete [] (char*)_SessionName ; @@ -116,7 +116,7 @@ CORBA::ULong RegistryService::add( const Registry::Infos & infos ) return (CORBA::ULong)_Compteur ; } -#ifndef WNT +#ifndef WIN32 void RegistryService::remove( const CORBA::ULong id) #else void RegistryService::remove( CORBA::ULong id) @@ -144,7 +144,7 @@ void RegistryService::remove( CORBA::ULong id) } -#ifndef WNT +#ifndef WIN32 void RegistryService::hello( const CORBA::ULong id ) #else void RegistryService::hello( CORBA::ULong id ) @@ -263,7 +263,7 @@ void RegistryService::SessionName( const char *sessionName ) } void RegistryService::ping() { -#ifndef WNT +#ifndef WIN32 MESSAGE(" RegistryService::ping() pid "<< getpid()); #else MESSAGE(" RegistryService::ping() pid "<< _getpid()); diff --git a/src/Registry/RegistryService.hxx b/src/Registry/RegistryService.hxx index bc6097fcd..b274a5deb 100644 --- a/src/Registry/RegistryService.hxx +++ b/src/Registry/RegistryService.hxx @@ -75,7 +75,7 @@ public : CORBA::Long getPID(); virtual CORBA::ULong add (const Registry::Infos & infos); virtual CORBA::ULong size ( void ); -#ifndef WNT +#ifndef WIN32 virtual void remove( const CORBA::ULong id ); virtual void hello( const CORBA::ULong id ); #else diff --git a/src/Registry/SALOME_Registry.hxx b/src/Registry/SALOME_Registry.hxx index 4ca01a2c7..d798156c1 100755 --- a/src/Registry/SALOME_Registry.hxx +++ b/src/Registry/SALOME_Registry.hxx @@ -26,22 +26,14 @@ #ifndef _SALOME_Registry_HXX_ #define _SALOME_Registry_HXX_ -#ifdef WNT - #if defined REGISTRY_EXPORTS - #if defined WIN32 - #define REGISTRY_EXPORT __declspec( dllexport ) - #else - #define REGISTRY_EXPORT - #endif - #else - #if defined WIN32 - #define REGISTRY_EXPORT __declspec( dllimport ) - #else - #define REGISTRY_EXPORT - #endif - #endif +#ifdef WIN32 +# ifdef REGISTRY_EXPORTS +# define REGISTRY_EXPORT __declspec( dllexport ) +# else +# define REGISTRY_EXPORT __declspec( dllimport ) +# endif #else - #define REGISTRY_EXPORT +# define REGISTRY_EXPORT #endif #endif diff --git a/src/Registry/SALOME_Registry_Server.cxx b/src/Registry/SALOME_Registry_Server.cxx index 8183340c2..718552c8d 100644 --- a/src/Registry/SALOME_Registry_Server.cxx +++ b/src/Registry/SALOME_Registry_Server.cxx @@ -104,7 +104,7 @@ int main( int argc , char **argv ) for (int i = 1; i<=NumberOfTries; i++) { if (i!=1) -#ifndef WNT +#ifndef WIN32 a=nanosleep(&ts_req,&ts_rem); #else Sleep(TIMESleep/1000000); @@ -133,7 +133,7 @@ int main( int argc , char **argv ) for(int j=1; j<=NumberOfTries; j++) { if (j!=1) -#ifndef WNT +#ifndef WIN32 a=nanosleep(&ts_req, &ts_rem); #else Sleep(TIMESleep/1000000); diff --git a/src/ResourcesManager/Makefile.am b/src/ResourcesManager/Makefile.am index b12707efa..7eef30ae1 100755 --- a/src/ResourcesManager/Makefile.am +++ b/src/ResourcesManager/Makefile.am @@ -39,7 +39,8 @@ salomeinclude_HEADERS = \ SALOME_ResourcesManager.hxx \ SALOME_ResourcesCatalog_Handler.hxx \ SALOME_LoadRateManager.hxx \ - ResourcesManager.hxx + ResourcesManager.hxx \ + ResourcesManager_Defs.hxx # # =============================================================== @@ -63,6 +64,7 @@ COMMON_CPPFLAGS=\ COMMON_LIBS =\ ../NamingService/libSalomeNS.la \ ../Utils/libOpUtil.la \ + ../Basics/libSALOMEBasics.la \ $(top_builddir)/idl/libSalomeIDLKernel.la \ @LIBXML_LIBS@ @@ -91,8 +93,10 @@ libResourcesManager_la_SOURCES =\ libResourcesManager_la_CPPFLAGS =\ -I$(srcdir)/../Basics \ -I$(srcdir)/../SALOMELocalTrace \ + -I$(srcdir)/../Utils \ @LIBXML_INCLUDES@ libResourcesManager_la_LDFLAGS = -no-undefined -version-info=0:0:0 libResourcesManager_la_LIBADD =\ + ../Utils/libOpUtil.la \ @LIBXML_LIBS@ diff --git a/src/ResourcesManager/ResourcesManager.cxx b/src/ResourcesManager/ResourcesManager.cxx index 06dc126ed..94de9d4e0 100644 --- a/src/ResourcesManager/ResourcesManager.cxx +++ b/src/ResourcesManager/ResourcesManager.cxx @@ -18,6 +18,7 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #include "ResourcesManager.hxx" +#include #include #include #include @@ -27,10 +28,9 @@ #include #include -#include #include -#include "utilities.h" +#include #define MAX_SIZE_FOR_HOSTNAME 256; @@ -46,7 +46,9 @@ ResourcesManager_cpp:: ResourcesManager_cpp(const char *xmlFilePath) : _path_resources(xmlFilePath) { - MESSAGE ( "ResourcesManager_cpp constructor" ); +#if defined(_DEBUG_) || defined(_DEBUG) + cerr << "ResourcesManager_cpp constructor" << endl; +#endif } //============================================================================= @@ -62,7 +64,9 @@ ResourcesManager_cpp(const char *xmlFilePath) : ResourcesManager_cpp::ResourcesManager_cpp() { - MESSAGE ( "ResourcesManager_cpp constructor" ); +#if defined(_DEBUG_) || defined(_DEBUG) + cerr << "ResourcesManager_cpp constructor" << endl; +#endif _isAppliSalomeDefined = (getenv("APPLI") != 0); if (_isAppliSalomeDefined) @@ -80,7 +84,9 @@ ResourcesManager_cpp::ResourcesManager_cpp() } ParseXmlFile(); - MESSAGE ( "ResourcesManager_cpp constructor end" ); +#if defined(_DEBUG_) || defined(_DEBUG) + cerr << "ResourcesManager_cpp constructor end"; +#endif } //============================================================================= @@ -91,7 +97,9 @@ ResourcesManager_cpp::ResourcesManager_cpp() ResourcesManager_cpp::~ResourcesManager_cpp() { - MESSAGE ( "ResourcesManager_cpp destructor" ); +#if defined(_DEBUG_) || defined(_DEBUG) + cerr << "ResourcesManager_cpp destructor" << endl; +#endif } //============================================================================= @@ -112,23 +120,33 @@ std::vector ResourcesManager_cpp::GetFittingResources(const machineParams& params, const std::vector& componentList) throw(ResourcesException) { +//#if defined(_DEBUG_) || defined(_DEBUG) // cerr << "ResourcesManager_cpp::GetFittingResources" << endl; +//#endif vector vec; ParseXmlFile(); const char *hostname = params.hostname.c_str(); - MESSAGE ( "GetFittingResources " << hostname << " " << GetHostname().c_str() ); +#if defined(_DEBUG_) || defined(_DEBUG) + cerr << "GetFittingResources " << hostname << " " << Kernel_Utils::GetHostname().c_str() << endl; +#endif if (hostname[0] != '\0'){ - // cerr << "ResourcesManager_cpp::GetFittingResources : hostname specified" << endl; +//#if defined(_DEBUG_) || defined(_DEBUG) +// cerr << "ResourcesManager_cpp::GetFittingResources : hostname specified" << endl; +//#endif if ( strcmp(hostname, "localhost") == 0 || - strcmp(hostname, GetHostname().c_str()) == 0 ) + strcmp(hostname, Kernel_Utils::GetHostname().c_str()) == 0 ) { - // cerr << "ResourcesManager_cpp::GetFittingResources : localhost" << endl; - vec.push_back(GetHostname().c_str()); - // cerr << "ResourcesManager_cpp::GetFittingResources : " << vec.size() << endl; +//#if defined(_DEBUG_) || defined(_DEBUG) +// cerr << "ResourcesManager_cpp::GetFittingResources : localhost" << endl; +//#endif + vec.push_back(Kernel_Utils::GetHostname().c_str()); +//#if defined(_DEBUG_) || defined(_DEBUG) +// cerr << "ResourcesManager_cpp::GetFittingResources : " << vec.size() << endl; +//#endif } else if (_resourcesList.find(hostname) != _resourcesList.end()) @@ -149,15 +167,19 @@ ResourcesManager_cpp::GetFittingResources(const machineParams& params, if( (*iter).second.DataForSort._nbOfNodes > 1 ){ if( strncmp(hostname,(*iter).first.c_str(),strlen(hostname)) == 0 ){ vec.push_back((*iter).first.c_str()); - //cerr << "SALOME_ResourcesManager_cpp::GetFittingResources vector[" - // << cpt << "] = " << (*iter).first.c_str() << endl ; +//#if defined(_DEBUG_) || defined(_DEBUG) +// cerr << "SALOME_ResourcesManager_cpp::GetFittingResources vector[" +// << cpt << "] = " << (*iter).first.c_str() << endl ; +//#endif cpt++; } } } if(cpt==0){ // --- user specified an unknown hostame so notify him. - MESSAGE ( "ResourcesManager_cpp::GetFittingResources : SALOME_Exception" ); +#if defined(_DEBUG_) || defined(_DEBUG) + cerr << "ResourcesManager_cpp::GetFittingResources : SALOME_Exception" << endl; +#endif throw ResourcesException("unknown host"); } } @@ -273,7 +295,9 @@ void ResourcesManager_cpp::WriteInXmlFile() if (aFile == NULL) { - INFOS ( "Error opening file !" ); +#if defined(_DEBUG_) || defined(_DEBUG) + cerr << "Error opening file !" << endl; +#endif return; } @@ -285,17 +309,21 @@ void ResourcesManager_cpp::WriteInXmlFile() handler->PrepareDocToXmlFile(aDoc); delete handler; +#if defined(_DEBUG_) || defined(_DEBUG) int isOk = xmlSaveFile(aFilePath, aDoc); - - if (!isOk) - INFOS ( "Error while XML file saving." ); + if (!isOk) cerr << "Error while XML file saving." << endl; +#else + xmlSaveFile(aFilePath, aDoc); +#endif // Free the document xmlFreeDoc(aDoc); fclose(aFile); - INFOS ( "WRITING DONE!" ); +#if defined(_DEBUG_) || defined(_DEBUG) + cerr << "WRITING DONE!" << endl; +#endif } //============================================================================= @@ -318,16 +346,20 @@ const MapOfParserResourcesType& ResourcesManager_cpp::ParseXmlFile() if (aDoc != NULL) handler->ProcessXmlDocument(aDoc); +#if defined(_DEBUG_) || defined(_DEBUG) else - INFOS ( "ResourcesManager_cpp: could not parse file "<< aFilePath ); + cerr << "ResourcesManager_cpp: could not parse file "<< aFilePath << endl; +#endif // Free the document xmlFreeDoc(aDoc); fclose(aFile); } +#if defined(_DEBUG_) || defined(_DEBUG) else - INFOS ( "ResourcesManager_cpp: file "< 0 ){ - for(int i=0;i::const_iterator itt = find(mapOfModulesOfCurrentHost.begin(), mapOfModulesOfCurrentHost.end(), @@ -446,43 +478,3 @@ ParserResourcesType ResourcesManager_cpp::GetResourcesList(const std::string& ma else return _resourcesBatchList[machine]; } - -std::string ResourcesManager_cpp::GetHostname() -{ - int ls = 100, r = 1; - char *s; - - while (ls < 10000 && r) { - ls *= 2; - s = new char[ls]; - r = gethostname(s, ls-1); - switch (r) - { - case 0: - break; - default: -#ifdef EINVAL - case EINVAL: -#endif -#ifdef ENAMETOOLONG - case ENAMETOOLONG: -#endif - delete [] s; - continue; - } - } - - if (r != 0) { - s = new char[50]; - strcpy(s, "localhost"); - } - - // remove all after '.' - char *aDot = (strchr(s,'.')); - if (aDot) aDot[0] = '\0'; - - string p = s; - delete [] s; - return p; -} - diff --git a/src/ResourcesManager/ResourcesManager.hxx b/src/ResourcesManager/ResourcesManager.hxx index 951aba5da..bd509b77f 100644 --- a/src/ResourcesManager/ResourcesManager.hxx +++ b/src/ResourcesManager/ResourcesManager.hxx @@ -20,6 +20,8 @@ #ifndef __RESOURCESMANAGER_HXX__ #define __RESOURCESMANAGER_HXX__ +#include "ResourcesManager_Defs.hxx" + #include #include #include @@ -42,7 +44,7 @@ struct machineParams{ unsigned int mem_mb; }; -class ResourcesException +class RESOURCESMANAGER_EXPORT ResourcesException { public: const std::string msg; @@ -50,7 +52,7 @@ public: ResourcesException(const std::string m) : msg(m) {} }; -class ResourcesManager_cpp +class RESOURCESMANAGER_EXPORT ResourcesManager_cpp { public: @@ -108,9 +110,7 @@ class ResourcesManager_cpp SALOME_LoadRateManager _dynamicResourcesSelecter; //! different behaviour if $APPLI exists (SALOME Application) - bool _isAppliSalomeDefined; - - std::string GetHostname(); + bool _isAppliSalomeDefined; }; #endif // __RESOURCESMANAGER_HXX__ diff --git a/src/ResourcesManager/ResourcesManager_Defs.hxx b/src/ResourcesManager/ResourcesManager_Defs.hxx new file mode 100755 index 000000000..c1169b653 --- /dev/null +++ b/src/ResourcesManager/ResourcesManager_Defs.hxx @@ -0,0 +1,33 @@ +// Copyright (C) 2005 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 __RESOURCESMANAGER_DEFS_HXX__ +#define __RESOURCESMANAGER_DEFS_HXX__ + +#ifdef WIN32 +# ifdef RESOURCESMANAGER_EXPORTS +# define RESOURCESMANAGER_EXPORT __declspec( dllexport ) +# else +# define RESOURCESMANAGER_EXPORT __declspec( dllimport ) +# endif +#else +# define RESOURCESMANAGER_EXPORT +#endif + +#endif // __RESOURCESMANAGER_DEFS_HXX__ diff --git a/src/ResourcesManager/SALOME_LoadRateManager.hxx b/src/ResourcesManager/SALOME_LoadRateManager.hxx index 7c4c3f03d..66a5d827c 100644 --- a/src/ResourcesManager/SALOME_LoadRateManager.hxx +++ b/src/ResourcesManager/SALOME_LoadRateManager.hxx @@ -20,23 +20,10 @@ #ifndef __SALOME_LOADRATEMANAGER_HXX__ #define __SALOME_LOADRATEMANAGER_HXX__ +#include "ResourcesManager_Defs.hxx" #include #include "SALOME_ResourcesCatalog_Parser.hxx" -#if defined RESOURCESMANAGER_EXPORTS -#if defined WIN32 -#define RESOURCESMANAGER_EXPORT __declspec( dllexport ) -#else -#define RESOURCESMANAGER_EXPORT -#endif -#else -#if defined WNT -#define RESOURCESMANAGER_EXPORT __declspec( dllimport ) -#else -#define RESOURCESMANAGER_EXPORT -#endif -#endif - class RESOURCESMANAGER_EXPORT SALOME_LoadRateManager { diff --git a/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.cxx b/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.cxx index b3d54fe40..955068744 100755 --- a/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.cxx +++ b/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.cxx @@ -27,6 +27,7 @@ //$Header$ #include "SALOME_ResourcesCatalog_Handler.hxx" +#include "Basics_Utils.hxx" #include #include @@ -288,13 +289,17 @@ void SALOME_ResourcesCatalog_Handler::ProcessXmlDocument(xmlDocPtr theDoc) _resource.HostName = nodeName ; _resources_list[nodeName] = _resource; } - } - else - _resources_list[_resource.HostName] = _resource; - } - else - _resources_batch_list[_resource.HostName] = _resource; - } + } + else + { + _resources_list[_resource.HostName] = _resource; + if(_resource.HostName == "localhost") + _resources_list[Kernel_Utils::GetHostname()] = _resource; + } + } + else + _resources_batch_list[_resource.HostName] = _resource; + } aCurNode = aCurNode->next; } diff --git a/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.hxx b/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.hxx index 9422c7bd1..152b5c58e 100755 --- a/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.hxx +++ b/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.hxx @@ -29,6 +29,9 @@ #ifndef SALOME_RESOURCES_CATALOG_HANDLER #define SALOME_RESOURCES_CATALOG_HANDLER + +#include "ResourcesManager_Defs.hxx" + #include "SALOME_ResourcesCatalog_Parser.hxx" #include @@ -36,7 +39,7 @@ #include -class SALOME_ResourcesCatalog_Handler +class RESOURCESMANAGER_EXPORT SALOME_ResourcesCatalog_Handler { public : diff --git a/src/ResourcesManager/SALOME_ResourcesCatalog_Parser.hxx b/src/ResourcesManager/SALOME_ResourcesCatalog_Parser.hxx index 901def13c..b668279e3 100755 --- a/src/ResourcesManager/SALOME_ResourcesCatalog_Parser.hxx +++ b/src/ResourcesManager/SALOME_ResourcesCatalog_Parser.hxx @@ -29,6 +29,8 @@ #ifndef SALOME_RESOURCES_CATALOG_PARSER #define SALOME_RESOURCES_CATALOG_PARSER +#include "ResourcesManager_Defs.hxx" + #include #include #include @@ -42,7 +44,7 @@ enum BatchType {none, pbs, lsf}; enum MpiImplType {indif, lam, mpich1, mpich2, openmpi, slurm}; -class ResourceDataToSort +class RESOURCESMANAGER_EXPORT ResourceDataToSort { public: @@ -70,7 +72,7 @@ class ResourceDataToSort unsigned int GetNumberOfPoints() const; }; -struct ParserResourcesType +struct RESOURCESMANAGER_EXPORT ParserResourcesType { ResourceDataToSort DataForSort; std::string HostName; diff --git a/src/ResourcesManager/SALOME_ResourcesManager.cxx b/src/ResourcesManager/SALOME_ResourcesManager.cxx index 90f273d69..345131640 100644 --- a/src/ResourcesManager/SALOME_ResourcesManager.cxx +++ b/src/ResourcesManager/SALOME_ResourcesManager.cxx @@ -23,7 +23,7 @@ #include "OpUtil.hxx" #include -#ifndef WNT +#ifndef WIN32 #include #else #include @@ -153,14 +153,14 @@ SALOME_ResourcesManager::GetFittingResources(const Engines::MachineParameters& p p.mem_mb = params.mem_mb; vector cl; - for(int i=0;i vec = _rm.GetFittingResources(p,cl); ret->length(vec.size()); - for(int i=0;i ml; - for(int i=0;iusername = CORBA::string_dup(resource.UserName.c_str()); p_ptr->applipath = CORBA::string_dup(resource.AppliPath.c_str()); p_ptr->modList.length(resource.ModulesList.size()); - for(int i=0;imodList[i] = CORBA::string_dup(resource.ModulesList[i].c_str()); p_ptr->OS = CORBA::string_dup(resource.OS.c_str()); p_ptr->mem_mb = resource.DataForSort._memInMB; p_ptr->cpu_clock = resource.DataForSort._CPUFreqMHz; p_ptr->nb_proc_per_node = resource.DataForSort._nbOfProcPerNode; p_ptr->nb_node = resource.DataForSort._nbOfNodes; + if( resource.mpi == indif ) p_ptr->mpiImpl = "indif"; else if( resource.mpi == lam ) @@ -220,11 +221,18 @@ Engines::MachineParameters* SALOME_ResourcesManager::GetMachineParameters(const p_ptr->mpiImpl = "openmpi"; else if( resource.mpi == slurm ) p_ptr->mpiImpl = "slurm"; + + p_ptr->isMPI=false; + if(resource.mpi != indif ) + p_ptr->isMPI=true; + if( resource.Batch == pbs ) p_ptr->batch = "pbs"; else if( resource.Batch == lsf ) p_ptr->batch = "lsf"; + p_ptr->nb_component_nodes=1; + return p_ptr; } diff --git a/src/ResourcesManager/SALOME_ResourcesManager.hxx b/src/ResourcesManager/SALOME_ResourcesManager.hxx index f2fdc259b..bec75471c 100644 --- a/src/ResourcesManager/SALOME_ResourcesManager.hxx +++ b/src/ResourcesManager/SALOME_ResourcesManager.hxx @@ -32,18 +32,15 @@ #include #include "ResourcesManager.hxx" -#if defined RESOURCESMANAGER_EXPORTS -#if defined WIN32 -#define RESOURCESMANAGER_EXPORT __declspec( dllexport ) -#else -#define RESOURCESMANAGER_EXPORT -#endif -#else -#if defined WNT -#define RESOURCESMANAGER_EXPORT __declspec( dllimport ) + +#ifdef WIN32 +# ifdef SALOMERESOURCESMANAGER_EXPORTS +# define SALOMERESOURCESMANAGER_EXPORT __declspec( dllexport ) +# else +# define SALOMERESOURCESMANAGER_EXPORT __declspec( dllimport ) +# endif #else -#define RESOURCESMANAGER_EXPORT -#endif +# define SALOMERESOURCESMANAGER_EXPORT #endif // --- WARNING --- @@ -52,7 +49,7 @@ // Only one thread should use the SALOME_ResourcesManager class in a SALOME // session. -class RESOURCESMANAGER_EXPORT SALOME_ResourcesManager: +class SALOMERESOURCESMANAGER_EXPORT SALOME_ResourcesManager: public POA_Engines::ResourcesManager, public PortableServer::RefCountServantBase { diff --git a/src/SALOMEDS/Makefile.am b/src/SALOMEDS/Makefile.am index 37686d204..2de4da2fc 100644 --- a/src/SALOMEDS/Makefile.am +++ b/src/SALOMEDS/Makefile.am @@ -285,9 +285,13 @@ bin_PROGRAMS = SALOMEDS_Server SALOMEDS_Client SALOMEDS_Server_SOURCES = SALOMEDS_Server.cxx SALOMEDS_Server_CPPFLAGS = $(COMMON_CPPFLAGS) SALOMEDS_Server_LDADD = libSalomeDS.la \ - $(HDF5_LIBS) $(CORBA_LIBS) + ../Basics/libSALOMEBasics.la \ + $(HDF5_LIBS) \ + $(CORBA_LIBS) SALOMEDS_Client_SOURCES = SALOMEDS_Client.cxx SALOMEDS_Client_CPPFLAGS = $(COMMON_CPPFLAGS) SALOMEDS_Client_LDADD = libSalomeDS.la \ - $(HDF5_LIBS) $(CORBA_LIBS) + ../Basics/libSALOMEBasics.la \ + $(HDF5_LIBS) \ + $(CORBA_LIBS) diff --git a/src/SALOMEDS/SALOMEDS.cxx b/src/SALOMEDS/SALOMEDS.cxx index 8ee2138d2..87085d3c0 100644 --- a/src/SALOMEDS/SALOMEDS.cxx +++ b/src/SALOMEDS/SALOMEDS.cxx @@ -26,18 +26,6 @@ // Module : SALOME // $Header$ -#ifdef WNT -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#else #include "SALOMEDS.hxx" #include "SALOMEDS_StudyManager.hxx" #include "SALOMEDS_Study.hxx" @@ -48,7 +36,6 @@ #include "SALOMEDSClient_IParameters.hxx" #include "SALOMEDS_IParameters.hxx" #include "SALOMEDS_StudyManager_i.hxx" -#endif #include "SALOMEDS_Defines.hxx" diff --git a/src/SALOMEDS/SALOMEDS_AttributeStudyProperties.cxx b/src/SALOMEDS/SALOMEDS_AttributeStudyProperties.cxx index d3ca2e668..4cd5f3faa 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeStudyProperties.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeStudyProperties.cxx @@ -59,7 +59,7 @@ std::string SALOMEDS_AttributeStudyProperties::GetUserName() SALOMEDS::Locker lock; aName = dynamic_cast(_local_impl)->GetCreatorName(); } -#ifndef WNT +#ifndef WIN32 else aName = SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->GetUserName(); #else else aName = SALOMEDS::AttributeStudyProperties::_narrow(_corba_impl)->GetUserNameA(); diff --git a/src/SALOMEDS/SALOMEDS_AttributeTreeNode_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeTreeNode_i.cxx index 41e69b8a7..c8b9aa565 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeTreeNode_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeTreeNode_i.cxx @@ -64,7 +64,7 @@ SALOMEDS::AttributeTreeNode_ptr SALOMEDS_AttributeTreeNode_i::GetFather() SALOMEDS::Locker lock; SALOMEDS_AttributeTreeNode_i* aFather; aFather = new SALOMEDS_AttributeTreeNode_i(dynamic_cast(_impl)->GetFather(), _orb); -#ifndef WNT +#ifndef WIN32 return aFather->POA_SALOMEDS::AttributeTreeNode::_this(); #else return aFather->AttributeTreeNode::_this(); @@ -90,7 +90,7 @@ SALOMEDS::AttributeTreeNode_ptr SALOMEDS_AttributeTreeNode_i::GetPrevious() SALOMEDS::Locker lock; SALOMEDS_AttributeTreeNode_i* aPrevious; aPrevious=new SALOMEDS_AttributeTreeNode_i(dynamic_cast(_impl)->GetPrevious(), _orb); -#ifndef WNT +#ifndef WIN32 return aPrevious->POA_SALOMEDS::AttributeTreeNode::_this(); #else return aPrevious->AttributeTreeNode::_this(); @@ -116,7 +116,7 @@ SALOMEDS::AttributeTreeNode_ptr SALOMEDS_AttributeTreeNode_i::GetNext() SALOMEDS::Locker lock; SALOMEDS_AttributeTreeNode_i* aNext; aNext = new SALOMEDS_AttributeTreeNode_i(dynamic_cast(_impl)->GetNext(), _orb); -#ifndef WNT +#ifndef WIN32 return aNext->POA_SALOMEDS::AttributeTreeNode::_this(); #else return aNext->AttributeTreeNode::_this(); @@ -142,7 +142,7 @@ SALOMEDS::AttributeTreeNode_ptr SALOMEDS_AttributeTreeNode_i::GetFirst() SALOMEDS::Locker lock; SALOMEDS_AttributeTreeNode_i* aFirst; aFirst = new SALOMEDS_AttributeTreeNode_i(dynamic_cast(_impl)->GetFirst(), _orb); -#ifndef WNT +#ifndef WIN32 return aFirst->POA_SALOMEDS::AttributeTreeNode::_this(); #else return aFirst->AttributeTreeNode::_this(); diff --git a/src/SALOMEDS/SALOMEDS_Defines.hxx b/src/SALOMEDS/SALOMEDS_Defines.hxx index 33c4bde26..c18d742ab 100755 --- a/src/SALOMEDS/SALOMEDS_Defines.hxx +++ b/src/SALOMEDS/SALOMEDS_Defines.hxx @@ -26,22 +26,14 @@ #ifndef _SALOMEDS_Defines_HXX_ #define _SALOMEDS_Defines_HXX_ -#ifdef WNT - #if defined SALOMEDS_EXPORTS - #if defined WIN32 - #define SALOMEDS_EXPORT __declspec( dllexport ) - #else - #define SALOMEDS_EXPORT - #endif - #else - #if defined WIN32 - #define SALOMEDS_EXPORT __declspec( dllimport ) - #else - #define SALOMEDS_EXPORT - #endif - #endif +#ifdef WIN32 +# ifdef SALOMEDS_EXPORTS +# define SALOMEDS_EXPORT __declspec( dllexport ) +# else +# define SALOMEDS_EXPORT __declspec( dllimport ) +# endif #else - #define SALOMEDS_EXPORT +# define SALOMEDS_EXPORT #endif #endif diff --git a/src/SALOMEDS/SALOMEDS_GenericAttribute.cxx b/src/SALOMEDS/SALOMEDS_GenericAttribute.cxx index 56657e5b3..5fd785cf9 100644 --- a/src/SALOMEDS/SALOMEDS_GenericAttribute.cxx +++ b/src/SALOMEDS/SALOMEDS_GenericAttribute.cxx @@ -31,6 +31,8 @@ #include "SALOMEDS_ClientAttributes.hxx" #include "SALOMEDS.hxx" +#include "Basics_Utils.hxx" + #ifdef WIN32 #include #else @@ -38,8 +40,6 @@ #include #endif -#include "OpUtil.hxx" - using namespace std; SALOMEDS_GenericAttribute::SALOMEDS_GenericAttribute(SALOMEDSImpl_GenericAttribute* theGA) @@ -57,7 +57,7 @@ SALOMEDS_GenericAttribute::SALOMEDS_GenericAttribute(SALOMEDS::GenericAttribute_ long pid = (long)getpid(); #endif - CORBA::LongLong addr = theGA->GetLocalImpl(GetHostname().c_str(), pid, _isLocal); + CORBA::LongLong addr = theGA->GetLocalImpl(Kernel_Utils::GetHostname().c_str(), pid, _isLocal); if(_isLocal) { _local_impl = reinterpret_cast(addr); _corba_impl = SALOMEDS::GenericAttribute::_nil(); diff --git a/src/SALOMEDS/SALOMEDS_GenericAttribute_i.cxx b/src/SALOMEDS/SALOMEDS_GenericAttribute_i.cxx index 78a3006e5..9390c7f67 100644 --- a/src/SALOMEDS/SALOMEDS_GenericAttribute_i.cxx +++ b/src/SALOMEDS/SALOMEDS_GenericAttribute_i.cxx @@ -29,6 +29,7 @@ #include "SALOMEDSImpl_SObject.hxx" #include "SALOMEDSImpl_Study.hxx" #include "Utils_ExceptHandlers.hxx" +#include "Basics_Utils.hxx" #include #ifdef WIN32 @@ -38,8 +39,6 @@ #include #endif -#include "OpUtil.hxx" - using namespace std; UNEXPECT_CATCH(GALockProtection, SALOMEDS::GenericAttribute::LockProtection); @@ -79,7 +78,8 @@ char* SALOMEDS_GenericAttribute_i::Type() { SALOMEDS::Locker lock; if (_impl) { - return CORBA::string_dup(SALOMEDSImpl_GenericAttribute::Impl_GetType(_impl)); + string type = SALOMEDSImpl_GenericAttribute::Impl_GetType(_impl); + return CORBA::string_dup(type.c_str()); } return (char*)""; @@ -89,7 +89,8 @@ char* SALOMEDS_GenericAttribute_i::GetClassType() { SALOMEDS::Locker lock; if (_impl) { - return CORBA::string_dup(SALOMEDSImpl_GenericAttribute::Impl_GetClassType(_impl)); + string class_type = SALOMEDSImpl_GenericAttribute::Impl_GetClassType(_impl); + return CORBA::string_dup(class_type.c_str()); } return (char*)""; @@ -121,6 +122,6 @@ CORBA::LongLong SALOMEDS_GenericAttribute_i::GetLocalImpl(const char* theHostnam #else long pid = (long)getpid(); #endif - isLocal = (strcmp(theHostname, GetHostname().c_str()) == 0 && pid == thePID)?1:0; + isLocal = (strcmp(theHostname, Kernel_Utils::GetHostname().c_str()) == 0 && pid == thePID)?1:0; return reinterpret_cast(_impl); } diff --git a/src/SALOMEDS/SALOMEDS_SObject.cxx b/src/SALOMEDS/SALOMEDS_SObject.cxx index 2110c24dc..2aeb5400e 100644 --- a/src/SALOMEDS/SALOMEDS_SObject.cxx +++ b/src/SALOMEDS/SALOMEDS_SObject.cxx @@ -38,6 +38,10 @@ #include "Utils_ORB_INIT.hxx" #include "Utils_SINGLETON.hxx" +#include "Basics_Utils.hxx" + +#include "utilities.h" + #ifdef WIN32 #include #include @@ -46,8 +50,7 @@ #include #endif -#include "OpUtil.hxx" -#include "utilities.h" + using namespace std; @@ -60,7 +63,7 @@ SALOMEDS_SObject::SALOMEDS_SObject(SALOMEDS::SObject_ptr theSObject) #endif CORBA::LongLong addr = // mpv: fix for IPAL13534: for 64-bit platforms use 8-bytes long for pointer storage - theSObject->GetLocalImpl(GetHostname().c_str(), pid, _isLocal); + theSObject->GetLocalImpl(Kernel_Utils::GetHostname().c_str(), pid, _isLocal); if(_isLocal) { _local_impl = reinterpret_cast(addr); diff --git a/src/SALOMEDS/SALOMEDS_SObject_i.cxx b/src/SALOMEDS/SALOMEDS_SObject_i.cxx index 08eddaa70..cb70d26c6 100644 --- a/src/SALOMEDS/SALOMEDS_SObject_i.cxx +++ b/src/SALOMEDS/SALOMEDS_SObject_i.cxx @@ -33,6 +33,7 @@ #include "SALOMEDSImpl_SComponent.hxx" #include "SALOMEDSImpl_Study.hxx" #include "SALOMEDSImpl_AttributeIOR.hxx" +#include "Basics_Utils.hxx" #include @@ -43,8 +44,6 @@ #include #endif -#include "OpUtil.hxx" - using namespace std; SALOMEDS::SObject_ptr SALOMEDS_SObject_i::New(const SALOMEDSImpl_SObject& theImpl, CORBA::ORB_ptr theORB) @@ -331,6 +330,6 @@ CORBA::LongLong SALOMEDS_SObject_i::GetLocalImpl(const char* theHostname, CORBA: #else long pid = (long)getpid(); #endif - isLocal = (strcmp(theHostname, GetHostname().c_str()) == 0 && pid == thePID)?1:0; + isLocal = (strcmp(theHostname, Kernel_Utils::GetHostname().c_str()) == 0 && pid == thePID)?1:0; return reinterpret_cast(_impl); } diff --git a/src/SALOMEDS/SALOMEDS_Server.cxx b/src/SALOMEDS/SALOMEDS_Server.cxx index 8ecce2d4b..c62134252 100644 --- a/src/SALOMEDS/SALOMEDS_Server.cxx +++ b/src/SALOMEDS/SALOMEDS_Server.cxx @@ -87,7 +87,7 @@ int main(int argc, char** argv) for (int i = 1; i<=NumberOfTries; i++) { if (i!=1) -#ifndef WNT +#ifndef WIN32 a=nanosleep(&ts_req,&ts_rem); #else Sleep(TIMESleep/1000000); @@ -114,7 +114,7 @@ int main(int argc, char** argv) for(int j=1; j<=NumberOfTries; j++) { if (j!=1) -#ifndef WNT +#ifndef WIN32 a=nanosleep(&ts_req, &ts_rem); #else Sleep(TIMESleep/1000000); diff --git a/src/SALOMEDS/SALOMEDS_Study.cxx b/src/SALOMEDS/SALOMEDS_Study.cxx index 3bfebc5b0..e3d3218c6 100644 --- a/src/SALOMEDS/SALOMEDS_Study.cxx +++ b/src/SALOMEDS/SALOMEDS_Study.cxx @@ -52,6 +52,8 @@ #include "Utils_ORB_INIT.hxx" #include "Utils_SINGLETON.hxx" +#include "Basics_Utils.hxx" + #ifdef WIN32 #include #else @@ -59,8 +61,6 @@ #include #endif -#include "OpUtil.hxx" - using namespace std; SALOMEDS_Study::SALOMEDS_Study(SALOMEDSImpl_Study* theStudy) @@ -79,7 +79,7 @@ SALOMEDS_Study::SALOMEDS_Study(SALOMEDS::Study_ptr theStudy) long pid = (long)getpid(); #endif - long addr = theStudy->GetLocalImpl(GetHostname().c_str(), pid, _isLocal); + long addr = theStudy->GetLocalImpl(Kernel_Utils::GetHostname().c_str(), pid, _isLocal); if(_isLocal) { _local_impl = reinterpret_cast(addr); _corba_impl = SALOMEDS::Study::_duplicate(theStudy); diff --git a/src/SALOMEDS/SALOMEDS_StudyManager.cxx b/src/SALOMEDS/SALOMEDS_StudyManager.cxx index edff1f88f..5740720c9 100644 --- a/src/SALOMEDS/SALOMEDS_StudyManager.cxx +++ b/src/SALOMEDS/SALOMEDS_StudyManager.cxx @@ -35,6 +35,8 @@ #include "Utils_ORB_INIT.hxx" #include "Utils_SINGLETON.hxx" +#include "Basics_Utils.hxx" + #ifdef WIN32 #include #else @@ -42,8 +44,6 @@ #include #endif -#include "OpUtil.hxx" - using namespace std; SALOMEDS_Driver_i* GetDriver(const SALOMEDSImpl_SObject& theObject, CORBA::ORB_ptr orb); @@ -57,7 +57,7 @@ SALOMEDS_StudyManager::SALOMEDS_StudyManager(SALOMEDS::StudyManager_ptr theManag long pid = (long)getpid(); #endif - CORBA::LongLong addr = theManager->GetLocalImpl(GetHostname().c_str(), pid, _isLocal); + CORBA::LongLong addr = theManager->GetLocalImpl(Kernel_Utils::GetHostname().c_str(), pid, _isLocal); if(_isLocal) { _local_impl = reinterpret_cast(addr); _corba_impl = SALOMEDS::StudyManager::_duplicate(theManager); @@ -85,7 +85,7 @@ SALOMEDS_StudyManager::SALOMEDS_StudyManager() long pid = (long)getpid(); #endif - CORBA::LongLong addr = theManager->GetLocalImpl(GetHostname().c_str(), pid, _isLocal); + CORBA::LongLong addr = theManager->GetLocalImpl(Kernel_Utils::GetHostname().c_str(), pid, _isLocal); if(_isLocal) { _local_impl = reinterpret_cast(addr); _corba_impl = SALOMEDS::StudyManager::_duplicate(theManager); diff --git a/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx b/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx index d40b1d772..f2e291cec 100644 --- a/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx +++ b/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx @@ -35,11 +35,13 @@ #include "SALOMEDSImpl_AttributeIOR.hxx" #include "Utils_CorbaException.hxx" +#include "Utils_ExceptHandlers.hxx" +#include "Basics_Utils.hxx" +#include "SALOME_GenericObj_i.hh" #include #include #include -using namespace std; #ifdef WIN32 #include @@ -48,11 +50,7 @@ using namespace std; #include #endif -#include "OpUtil.hxx" - -#include "SALOME_GenericObj_i.hh" - -#include "Utils_ExceptHandlers.hxx" +using namespace std; UNEXPECT_CATCH(SalomeException,SALOME::SALOME_Exception); UNEXPECT_CATCH(LockProtection, SALOMEDS::StudyBuilder::LockProtection); @@ -157,6 +155,9 @@ SALOMEDS::Study_ptr SALOMEDS_StudyManager_i::Open(const char* aUrl) SALOMEDSImpl_Study* aStudyImpl = _impl->Open(string(aUrl)); + if ( !aStudyImpl ) + THROW_SALOME_CORBA_EXCEPTION("Impossible to Open study from file", SALOME::BAD_PARAM) + MESSAGE("Open : Creating the CORBA servant holding it... "); // Temporary aStudyUrl in place of study name @@ -475,7 +476,7 @@ CORBA::LongLong SALOMEDS_StudyManager_i::GetLocalImpl(const char* theHostname, C #else long pid = (long)getpid(); #endif - isLocal = (strcmp(theHostname, GetHostname().c_str()) == 0 && pid == thePID)?1:0; + isLocal = (strcmp(theHostname, Kernel_Utils::GetHostname().c_str()) == 0 && pid == thePID)?1:0; return reinterpret_cast(_impl); } diff --git a/src/SALOMEDS/SALOMEDS_StudyManager_i.hxx b/src/SALOMEDS/SALOMEDS_StudyManager_i.hxx index d837acba1..d155f3101 100644 --- a/src/SALOMEDS/SALOMEDS_StudyManager_i.hxx +++ b/src/SALOMEDS/SALOMEDS_StudyManager_i.hxx @@ -27,7 +27,7 @@ // std C++ headers #include -#ifndef WNT +#ifndef WIN32 #include #endif diff --git a/src/SALOMEDS/SALOMEDS_Study_i.cxx b/src/SALOMEDS/SALOMEDS_Study_i.cxx index 1f5f2a127..c3a86cf7a 100644 --- a/src/SALOMEDS/SALOMEDS_Study_i.cxx +++ b/src/SALOMEDS/SALOMEDS_Study_i.cxx @@ -43,6 +43,8 @@ #include "DF_Label.hxx" #include "DF_Attribute.hxx" +#include "Basics_Utils.hxx" + #ifdef WIN32 #include #else @@ -50,8 +52,6 @@ #include #endif -#include "OpUtil.hxx" - using namespace std; //============================================================================ @@ -704,7 +704,7 @@ void SALOMEDS_Study_i::AddCreatedPostponed(const char* theIOR) * Purpose : */ //============================================================================ -#ifndef WNT +#ifndef WIN32 void SALOMEDS_Study_i::RemovePostponed(const CORBA::Long /*theUndoLimit*/) #else void SALOMEDS_Study_i::RemovePostponed(CORBA::Long /*theUndoLimit*/) @@ -731,7 +731,7 @@ void SALOMEDS_Study_i::RemovePostponed(CORBA::Long /*theUndoLimit*/) * Purpose : */ //============================================================================ -#ifndef WNT +#ifndef WIN32 void SALOMEDS_Study_i::UndoPostponed(const CORBA::Long theWay) #else void SALOMEDS_Study_i::UndoPostponed(CORBA::Long theWay) @@ -888,6 +888,6 @@ CORBA::LongLong SALOMEDS_Study_i::GetLocalImpl(const char* theHostname, CORBA::L #else long pid = (long)getpid(); #endif - isLocal = (strcmp(theHostname, GetHostname().c_str()) == 0 && pid == thePID)?1:0; + isLocal = (strcmp(theHostname, Kernel_Utils::GetHostname().c_str()) == 0 && pid == thePID)?1:0; return reinterpret_cast(_impl); } diff --git a/src/SALOMEDS/SALOMEDS_Study_i.hxx b/src/SALOMEDS/SALOMEDS_Study_i.hxx index efb31e66e..c0965f183 100644 --- a/src/SALOMEDS/SALOMEDS_Study_i.hxx +++ b/src/SALOMEDS/SALOMEDS_Study_i.hxx @@ -269,7 +269,7 @@ public: virtual void AddCreatedPostponed(const char* theIOR); -#ifndef WNT +#ifndef WIN32 virtual void RemovePostponed(const CORBA::Long theUndoLimit); // removes postponed IORs of old transaction // if theUndoLimit==0, removes all virtual void UndoPostponed(const CORBA::Long theWay); // theWay = 1: resurrect objects, diff --git a/src/SALOMEDS/Test/Makefile.am b/src/SALOMEDS/Test/Makefile.am index 7c765fa9f..bd6bda7d6 100644 --- a/src/SALOMEDS/Test/Makefile.am +++ b/src/SALOMEDS/Test/Makefile.am @@ -145,4 +145,5 @@ bin_PROGRAMS = TestSALOMEDS dist_TestSALOMEDS_SOURCES = TestSALOMEDS.cxx TestSALOMEDS_CPPFLAGS = $(COMMON_CPPFLAGS) TestSALOMEDS_LDADD = libSALOMEDSTest.la \ + $(RPATH)/Basics/libSALOMEBasics.la \ $(CORBA_LIBS) diff --git a/src/SALOMEDS/Test/TestSALOMEDS.cxx b/src/SALOMEDS/Test/TestSALOMEDS.cxx index 2d02b2829..0f6a00e1e 100644 --- a/src/SALOMEDS/Test/TestSALOMEDS.cxx +++ b/src/SALOMEDS/Test/TestSALOMEDS.cxx @@ -46,11 +46,13 @@ CPPUNIT_TEST_SUITE_REGISTRATION( SALOMEDSTest_Embedded ); #include "utilities.h" #include "Utils_SINGLETON.hxx" #include "Utils_ORB_INIT.hxx" -#include "OpUtil.hxx" +#include "Basics_Utils.hxx" #include "SALOME_NamingService.hxx" #include "NamingService_WaitForServerReadiness.hxx" #include "SALOMEDS_StudyManager_i.hxx" +using namespace std; + // ============================================================================ /*! * Main program source for Unit Tests with cppunit package does not depend @@ -84,9 +86,9 @@ int main(int argc, char* argv[]) sleep(15); - string host; // = GetHostname(); + string host; // = Kernel_Utils::GetHostname(); char* wait_Superv = getenv("SALOMEDS_UNITTESTS_WAIT_SUPERVISOR"); - if(wait_Superv) host = GetHostname(); + if(wait_Superv) host = Kernel_Utils::GetHostname(); SALOME_NamingService NS(orb); if(host.empty()) diff --git a/src/SALOMEDSImpl/Makefile.am b/src/SALOMEDSImpl/Makefile.am index 4ca4e58ab..de0b5f12e 100644 --- a/src/SALOMEDSImpl/Makefile.am +++ b/src/SALOMEDSImpl/Makefile.am @@ -74,6 +74,7 @@ salomeinclude_HEADERS= \ SALOMEDSImpl_Study.hxx \ SALOMEDSImpl_StudyManager.hxx \ SALOMEDSImpl_ChildNodeIterator.hxx \ + SALOMEDSImpl_Defines.hxx \ SALOMEDSImpl_IParameters.hxx \ SALOMEDSImpl_TMPFile.hxx @@ -189,6 +190,7 @@ libSalomeDSImpl_la_SOURCES =\ SALOMEDSImpl_Callback.hxx \ SALOMEDSImpl_ChildIterator.hxx \ SALOMEDSImpl_ChildNodeIterator.hxx \ + SALOMEDSImpl_Defines.hxx \ SALOMEDSImpl_Driver.hxx \ SALOMEDSImpl_GenericAttribute.hxx \ SALOMEDSImpl_SComponent.hxx \ diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeComment.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeComment.cxx index e76570dd1..45be60a9d 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeComment.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeComment.cxx @@ -23,22 +23,20 @@ #include "SALOMEDSImpl_AttributeComment.hxx" -#ifndef WNT using namespace std; -#endif //======================================================================= //function : GetID //purpose : //======================================================================= -const std::string& SALOMEDSImpl_AttributeComment::GetID () +const string& SALOMEDSImpl_AttributeComment::GetID () { - static std::string CommentID ("7AF2F7CC-1CA2-4476-BE95-8ACC996BC7B9"); + static string CommentID ("7AF2F7CC-1CA2-4476-BE95-8ACC996BC7B9"); return CommentID; } SALOMEDSImpl_AttributeComment* SALOMEDSImpl_AttributeComment::Set (const DF_Label& L, - const std::string& Val) + const string& Val) { SALOMEDSImpl_AttributeComment* A = NULL; if (!(A=(SALOMEDSImpl_AttributeComment*)L.FindAttribute(SALOMEDSImpl_AttributeComment::GetID()))) { @@ -73,7 +71,7 @@ void SALOMEDSImpl_AttributeComment::SetValue (const string& S) //function : ID //purpose : //======================================================================= -const std::string& SALOMEDSImpl_AttributeComment::ID () const { return GetID(); } +const string& SALOMEDSImpl_AttributeComment::ID () const { return GetID(); } //======================================================================= //function : NewEmpty diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeComment.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeComment.hxx index 8f6e361b5..71f7e25e5 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeComment.hxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeComment.hxx @@ -24,37 +24,39 @@ #ifndef _SALOMEDSImpl_AttributeComment_HeaderFile #define _SALOMEDSImpl_AttributeComment_HeaderFile +#include "SALOMEDSImpl_Defines.hxx" +#include "SALOMEDSImpl_GenericAttribute.hxx" #include "DF_Attribute.hxx" #include "DF_Label.hxx" -#include "SALOMEDSImpl_GenericAttribute.hxx" #include -class SALOMEDSImpl_AttributeComment : public SALOMEDSImpl_GenericAttribute +class SALOMEDSIMPL_EXPORT SALOMEDSImpl_AttributeComment : + public SALOMEDSImpl_GenericAttribute { private: - std::string myString; + std::string myString; public: -Standard_EXPORT static const std::string& GetID() ; + static const std::string& GetID() ; -Standard_EXPORT SALOMEDSImpl_AttributeComment() :SALOMEDSImpl_GenericAttribute("AttributeComment") {} + SALOMEDSImpl_AttributeComment() :SALOMEDSImpl_GenericAttribute("AttributeComment") {} -Standard_EXPORT static SALOMEDSImpl_AttributeComment* Set(const DF_Label& L, const std::string& Val); -Standard_EXPORT void SetValue (const std::string& S); -Standard_EXPORT std::string Value() const { return myString; } + static SALOMEDSImpl_AttributeComment* Set(const DF_Label& L, const std::string& Val); + void SetValue (const std::string& S); + std::string Value() const { return myString; } -Standard_EXPORT virtual std::string Save() { return myString; } -Standard_EXPORT virtual void Load(const std::string& theValue) { myString = theValue; } + virtual std::string Save() { return myString; } + virtual void Load(const std::string& theValue) { myString = theValue; } -Standard_EXPORT const std::string& ID() const; -Standard_EXPORT void Restore(DF_Attribute* with) ; -Standard_EXPORT DF_Attribute* NewEmpty() const; -Standard_EXPORT void Paste(DF_Attribute* into); + const std::string& ID() const; + void Restore(DF_Attribute* with) ; + DF_Attribute* NewEmpty() const; + void Paste(DF_Attribute* into); -Standard_EXPORT ~SALOMEDSImpl_AttributeComment() {} + ~SALOMEDSImpl_AttributeComment() {} }; diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeDrawable.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeDrawable.cxx index 70a954f43..25f8f3c9d 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeDrawable.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeDrawable.cxx @@ -23,9 +23,7 @@ #include "SALOMEDSImpl_AttributeDrawable.hxx" -#ifndef WNT using namespace std; -#endif //======================================================================= //function : GetID diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeDrawable.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeDrawable.hxx index 9fa1122e7..d1b464bfd 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeDrawable.hxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeDrawable.hxx @@ -24,31 +24,33 @@ #ifndef _SALOMEDSImpl_AttributeDrawable_HeaderFile #define _SALOMEDSImpl_AttributeDrawable_HeaderFile +#include "SALOMEDSImpl_GenericAttribute.hxx" +#include "SALOMEDSImpl_Defines.hxx" #include "DF_Attribute.hxx" -#include #include "DF_Label.hxx" -#include "SALOMEDSImpl_GenericAttribute.hxx" - -class SALOMEDSImpl_AttributeDrawable : public SALOMEDSImpl_GenericAttribute +#include + +class SALOMEDSIMPL_EXPORT SALOMEDSImpl_AttributeDrawable : + public SALOMEDSImpl_GenericAttribute { private: -int myValue; + int myValue; public: -Standard_EXPORT virtual std::string Save() { return (myValue == 0)?(char*)"0":(char*)"1"; } -Standard_EXPORT virtual void Load(const std::string& theValue) { (theValue == "0")?myValue=0:myValue=1; } - -Standard_EXPORT static const std::string& GetID() ; -Standard_EXPORT static SALOMEDSImpl_AttributeDrawable* Set(const DF_Label& label,const int value) ; - -Standard_EXPORT void SetDrawable(const int theValue); -Standard_EXPORT int IsDrawable() const { return myValue; } -Standard_EXPORT SALOMEDSImpl_AttributeDrawable(); -Standard_EXPORT const std::string& ID() const; -Standard_EXPORT void Restore(DF_Attribute* with) ; -Standard_EXPORT DF_Attribute* NewEmpty() const; -Standard_EXPORT void Paste(DF_Attribute* into); -Standard_EXPORT ~SALOMEDSImpl_AttributeDrawable() {} + virtual std::string Save() { return (myValue == 0)?(char*)"0":(char*)"1"; } + virtual void Load(const std::string& theValue) { (theValue == "0")?myValue=0:myValue=1; } + + static const std::string& GetID() ; + static SALOMEDSImpl_AttributeDrawable* Set(const DF_Label& label,const int value) ; + + void SetDrawable(const int theValue); + int IsDrawable() const { return myValue; } + SALOMEDSImpl_AttributeDrawable(); + const std::string& ID() const; + void Restore(DF_Attribute* with) ; + DF_Attribute* NewEmpty() const; + void Paste(DF_Attribute* into); + ~SALOMEDSImpl_AttributeDrawable() {} }; diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeExpandable.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeExpandable.cxx index a77d1e8c4..774abcfd2 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeExpandable.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeExpandable.cxx @@ -23,9 +23,7 @@ #include "SALOMEDSImpl_AttributeExpandable.hxx" -#ifndef WNT using namespace std; -#endif //======================================================================= //function : GetID diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeExpandable.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeExpandable.hxx index 8b80e3b39..c22b57ab6 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeExpandable.hxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeExpandable.hxx @@ -24,32 +24,34 @@ #ifndef _SALOMEDSImpl_AttributeExpandable_HeaderFile #define _SALOMEDSImpl_AttributeExpandable_HeaderFile +#include "SALOMEDSImpl_Defines.hxx" +#include "SALOMEDSImpl_GenericAttribute.hxx" #include "DF_Attribute.hxx" #include "DF_Label.hxx" -#include -#include "SALOMEDSImpl_GenericAttribute.hxx" +#include -class SALOMEDSImpl_AttributeExpandable : public SALOMEDSImpl_GenericAttribute +class SALOMEDSIMPL_EXPORT SALOMEDSImpl_AttributeExpandable : + public SALOMEDSImpl_GenericAttribute { private: -int myValue; + int myValue; public: -Standard_EXPORT virtual std::string Save() { return (myValue == 0)?(char*)"0":(char*)"1"; } -Standard_EXPORT virtual void Load(const std::string& theValue) { (theValue == "0")?myValue=0:myValue=1; } - -Standard_EXPORT static const std::string& GetID() ; -Standard_EXPORT static SALOMEDSImpl_AttributeExpandable* Set(const DF_Label& label,const int value) ; -Standard_EXPORT SALOMEDSImpl_AttributeExpandable(); -Standard_EXPORT void SetExpandable(const int value); -Standard_EXPORT int IsExpandable() const { return myValue; } -Standard_EXPORT const std::string& ID() const; -Standard_EXPORT void Restore(DF_Attribute* with) ; -Standard_EXPORT DF_Attribute* NewEmpty() const; -Standard_EXPORT void Paste(DF_Attribute* into); -Standard_EXPORT ~SALOMEDSImpl_AttributeExpandable() {} + virtual std::string Save() { return (myValue == 0)?(char*)"0":(char*)"1"; } + virtual void Load(const std::string& theValue) { (theValue == "0")?myValue=0:myValue=1; } + + static const std::string& GetID() ; + static SALOMEDSImpl_AttributeExpandable* Set(const DF_Label& label,const int value) ; + SALOMEDSImpl_AttributeExpandable(); + void SetExpandable(const int value); + int IsExpandable() const { return myValue; } + const std::string& ID() const; + void Restore(DF_Attribute* with) ; + DF_Attribute* NewEmpty() const; + void Paste(DF_Attribute* into); + ~SALOMEDSImpl_AttributeExpandable() {} }; diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeExternalFileDef.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeExternalFileDef.hxx index 2222717bd..ee5649952 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeExternalFileDef.hxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeExternalFileDef.hxx @@ -21,32 +21,35 @@ #ifndef _SALOMEDSImpl_AttributeExternalFileDef_HeaderFile #define _SALOMEDSImpl_AttributeExternalFileDef_HeaderFile +#include "SALOMEDSImpl_Defines.hxx" +#include "SALOMEDSImpl_GenericAttribute.hxx" #include "DF_Attribute.hxx" #include "DF_Label.hxx" #include -#include "SALOMEDSImpl_GenericAttribute.hxx" -class SALOMEDSImpl_AttributeExternalFileDef : public SALOMEDSImpl_GenericAttribute + +class SALOMEDSIMPL_EXPORT SALOMEDSImpl_AttributeExternalFileDef : + public SALOMEDSImpl_GenericAttribute { private: - std::string myString; + std::string myString; public: -Standard_EXPORT static const std::string& GetID() ; -Standard_EXPORT static SALOMEDSImpl_AttributeExternalFileDef* Set(const DF_Label& label, - const std::string& Name); -Standard_EXPORT SALOMEDSImpl_AttributeExternalFileDef(); -Standard_EXPORT void SetValue(const std::string& value); -Standard_EXPORT std::string Value() const { return myString; } -Standard_EXPORT const std::string& ID() const; -Standard_EXPORT void Restore(DF_Attribute* with) ; -Standard_EXPORT DF_Attribute* NewEmpty() const; -Standard_EXPORT void Paste(DF_Attribute* into); -Standard_EXPORT ~SALOMEDSImpl_AttributeExternalFileDef() {} - -Standard_EXPORT virtual std::string Save() { return myString; } -Standard_EXPORT virtual void Load(const std::string& theValue) { myString = theValue; } + static const std::string& GetID() ; + static SALOMEDSImpl_AttributeExternalFileDef* Set(const DF_Label& label, + const std::string& Name); + SALOMEDSImpl_AttributeExternalFileDef(); + void SetValue(const std::string& value); + std::string Value() const { return myString; } + const std::string& ID() const; + void Restore(DF_Attribute* with) ; + DF_Attribute* NewEmpty() const; + void Paste(DF_Attribute* into); + ~SALOMEDSImpl_AttributeExternalFileDef() {} + + virtual std::string Save() { return myString; } + virtual void Load(const std::string& theValue) { myString = theValue; } }; diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeFileType.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeFileType.hxx index a4d61fe96..d5396bd02 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeFileType.hxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeFileType.hxx @@ -21,32 +21,35 @@ #ifndef _SALOMEDSImpl_AttributeFileType_HeaderFile #define _SALOMEDSImpl_AttributeFileType_HeaderFile +#include "SALOMEDSImpl_Defines.hxx" +#include "SALOMEDSImpl_GenericAttribute.hxx" #include "DF_Attribute.hxx" #include "DF_Label.hxx" #include -#include "SALOMEDSImpl_GenericAttribute.hxx" -class SALOMEDSImpl_AttributeFileType : public SALOMEDSImpl_GenericAttribute + +class SALOMEDSIMPL_EXPORT SALOMEDSImpl_AttributeFileType : + public SALOMEDSImpl_GenericAttribute { private: - std::string myString; + std::string myString; public: -Standard_EXPORT static const std::string& GetID() ; -Standard_EXPORT static SALOMEDSImpl_AttributeFileType* Set(const DF_Label& label, - const std::string& Name) ; -Standard_EXPORT SALOMEDSImpl_AttributeFileType(); -Standard_EXPORT void SetValue(const std::string& value); -Standard_EXPORT std::string Value() const { return myString; } -Standard_EXPORT const std::string& ID() const; -Standard_EXPORT void Restore(DF_Attribute* with) ; -Standard_EXPORT DF_Attribute* NewEmpty() const; -Standard_EXPORT void Paste(DF_Attribute* into); -Standard_EXPORT ~SALOMEDSImpl_AttributeFileType() {} - -Standard_EXPORT virtual std::string Save() { return myString; } -Standard_EXPORT virtual void Load(const std::string& theValue) { myString = theValue; } + static const std::string& GetID() ; + static SALOMEDSImpl_AttributeFileType* Set(const DF_Label& label, + const std::string& Name) ; + SALOMEDSImpl_AttributeFileType(); + void SetValue(const std::string& value); + std::string Value() const { return myString; } + const std::string& ID() const; + void Restore(DF_Attribute* with) ; + DF_Attribute* NewEmpty() const; + void Paste(DF_Attribute* into); + ~SALOMEDSImpl_AttributeFileType() {} + + virtual std::string Save() { return myString; } + virtual void Load(const std::string& theValue) { myString = theValue; } }; diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeFlags.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeFlags.hxx index 773df8891..353c1ed21 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeFlags.hxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeFlags.hxx @@ -24,38 +24,37 @@ #ifndef SALOMEDSImpl_AttributeFlags_HeaderFile #define SALOMEDSImpl_AttributeFlags_HeaderFile +#include "SALOMEDSImpl_Defines.hxx" +#include "SALOMEDSImpl_GenericAttribute.hxx" #include "DF_Attribute.hxx" #include "DF_Label.hxx" -#include "SALOMEDSImpl_GenericAttribute.hxx" + /* - Class : SALOMEDSImpl_AttributeFlags - Description : This class is intended for storing different object attributes that - have only two states (0 and 1). +Class : SALOMEDSImpl_AttributeFlags +Description : This class is intended for storing different object attributes that +have only two states (0 and 1). */ -#ifndef WNT -class Standard_EXPORT SALOMEDSImpl_AttributeFlags : public SALOMEDSImpl_GenericAttribute -#else -class SALOMEDSImpl_AttributeFlags : public SALOMEDSImpl_GenericAttribute -#endif +class SALOMEDSIMPL_EXPORT SALOMEDSImpl_AttributeFlags : + public SALOMEDSImpl_GenericAttribute { private: -int myValue; + int myValue; public: -Standard_EXPORT static const std::string& GetID() ; -Standard_EXPORT static SALOMEDSImpl_AttributeFlags* Set(const DF_Label&, const int theValue ); - - SALOMEDSImpl_AttributeFlags(); -Standard_EXPORT virtual ~SALOMEDSImpl_AttributeFlags(); - -Standard_EXPORT const std::string& ID() const; -Standard_EXPORT void Restore( DF_Attribute* with ); -Standard_EXPORT DF_Attribute* NewEmpty() const; -Standard_EXPORT void Paste( DF_Attribute* into); -Standard_EXPORT void Set( const int ); -Standard_EXPORT int Get() const; + static const std::string& GetID() ; + static SALOMEDSImpl_AttributeFlags* Set(const DF_Label&, const int theValue ); + + SALOMEDSImpl_AttributeFlags(); + virtual ~SALOMEDSImpl_AttributeFlags(); + + const std::string& ID() const; + void Restore( DF_Attribute* with ); + DF_Attribute* NewEmpty() const; + void Paste( DF_Attribute* into); + void Set( const int ); + int Get() const; }; diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeGraphic.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeGraphic.hxx index 69801875a..5358b81ec 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeGraphic.hxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeGraphic.hxx @@ -24,42 +24,39 @@ #ifndef SALOMEDSImpl_AttributeGraphic_HeaderFile #define SALOMEDSImpl_AttributeGraphic_HeaderFile +#include "SALOMEDSImpl_Defines.hxx" +#include "SALOMEDSImpl_GenericAttribute.hxx" #include "DF_Attribute.hxx" #include "DF_Label.hxx" -#include "SALOMEDSImpl_GenericAttribute.hxx" - #include /* - Class : SALOMEDSImpl_AttributeGraphic - Description : This class is intended for storing information about - graphic representation of objects in dirrent views +Class : SALOMEDSImpl_AttributeGraphic +Description : This class is intended for storing information about +graphic representation of objects in dirrent views */ -#ifndef WNT -class Standard_EXPORT SALOMEDSImpl_AttributeGraphic : public SALOMEDSImpl_GenericAttribute -#else -class SALOMEDSImpl_AttributeGraphic : public SALOMEDSImpl_GenericAttribute -#endif +class SALOMEDSIMPL_EXPORT SALOMEDSImpl_AttributeGraphic : + public SALOMEDSImpl_GenericAttribute { public: -Standard_EXPORT SALOMEDSImpl_AttributeGraphic(); -Standard_EXPORT ~SALOMEDSImpl_AttributeGraphic(); - -Standard_EXPORT static const std::string& GetID() ; + SALOMEDSImpl_AttributeGraphic(); + ~SALOMEDSImpl_AttributeGraphic(); + + static const std::string& GetID() ; + + void SetVisibility( const int, const bool ); + bool GetVisibility( const int ); + const std::string& ID() const; + void Restore( DF_Attribute* theWith ); + DF_Attribute* NewEmpty() const; + void Paste( DF_Attribute* theInto); -Standard_EXPORT void SetVisibility( const int, const bool ); -Standard_EXPORT bool GetVisibility( const int ); -Standard_EXPORT const std::string& ID() const; -Standard_EXPORT void Restore( DF_Attribute* theWith ); -Standard_EXPORT DF_Attribute* NewEmpty() const; -Standard_EXPORT void Paste( DF_Attribute* theInto); + void SetVisibility( const std::map& ); -Standard_EXPORT void SetVisibility( const std::map& ); + const std::map& GetVisibility(); -Standard_EXPORT const std::map& GetVisibility(); - private: std::map myVisibility; diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.cxx index 866265851..ea88de4fc 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.cxx @@ -24,9 +24,7 @@ #include "SALOMEDSImpl_AttributeIOR.hxx" #include "SALOMEDSImpl_Study.hxx" -#ifndef WNT using namespace std; -#endif //======================================================================= //function : GetID diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.hxx index eb0be83c5..8f061a033 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.hxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.hxx @@ -24,30 +24,32 @@ #ifndef _SALOMEDSImpl_AttributeIOR_HeaderFile #define _SALOMEDSImpl_AttributeIOR_HeaderFile +#include "SALOMEDSImpl_Defines.hxx" #include "DF_Attribute.hxx" #include #include "DF_Label.hxx" #include "SALOMEDSImpl_GenericAttribute.hxx" -class SALOMEDSImpl_AttributeIOR : public SALOMEDSImpl_GenericAttribute +class SALOMEDSIMPL_EXPORT SALOMEDSImpl_AttributeIOR : + public SALOMEDSImpl_GenericAttribute { private: - std::string myString; + std::string myString; public: -Standard_EXPORT static const std::string& GetID() ; -Standard_EXPORT static SALOMEDSImpl_AttributeIOR* Set(const DF_Label& label, - const std::string& IOR); -Standard_EXPORT SALOMEDSImpl_AttributeIOR(); -Standard_EXPORT const std::string& ID() const; -Standard_EXPORT void SetValue(const std::string& theValue); -Standard_EXPORT std::string Value() const ; -Standard_EXPORT void Restore(DF_Attribute* with); -Standard_EXPORT DF_Attribute* NewEmpty() const; -Standard_EXPORT void Paste(DF_Attribute* into); -Standard_EXPORT ~SALOMEDSImpl_AttributeIOR() {} + static const std::string& GetID() ; + static SALOMEDSImpl_AttributeIOR* Set(const DF_Label& label, + const std::string& IOR); + SALOMEDSImpl_AttributeIOR(); + const std::string& ID() const; + void SetValue(const std::string& theValue); + std::string Value() const ; + void Restore(DF_Attribute* with); + DF_Attribute* NewEmpty() const; + void Paste(DF_Attribute* into); + ~SALOMEDSImpl_AttributeIOR() {} }; diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeInteger.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeInteger.cxx index ea1058ff9..e6a0fcfbb 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeInteger.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeInteger.cxx @@ -23,11 +23,8 @@ #include "SALOMEDSImpl_AttributeInteger.hxx" -#ifndef WNT -using namespace std; -#endif - #include +using namespace std; //======================================================================= //function : GetID diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeInteger.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeInteger.hxx index 94751adfa..a2a2e5753 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeInteger.hxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeInteger.hxx @@ -24,31 +24,32 @@ #ifndef _SALOMEDSImpl_AttributeInteger_HeaderFile #define _SALOMEDSImpl_AttributeInteger_HeaderFile +#include "SALOMEDSImpl_Defines.hxx" #include "DF_Attribute.hxx" #include #include "DF_Label.hxx" #include "SALOMEDSImpl_GenericAttribute.hxx" -class SALOMEDSImpl_AttributeInteger : public SALOMEDSImpl_GenericAttribute +class SALOMEDSIMPL_EXPORT SALOMEDSImpl_AttributeInteger : public SALOMEDSImpl_GenericAttribute { private: -int myValue; + int myValue; public: -Standard_EXPORT static const std::string& GetID() ; - -Standard_EXPORT SALOMEDSImpl_AttributeInteger():SALOMEDSImpl_GenericAttribute("AttributeInteger") {} -Standard_EXPORT static SALOMEDSImpl_AttributeInteger* Set (const DF_Label& L, int Val); -Standard_EXPORT void SetValue(const int theVal); -Standard_EXPORT int Value() const; -Standard_EXPORT virtual std::string Save(); -Standard_EXPORT virtual void Load(const std::string& theValue); - -Standard_EXPORT const std::string& ID() const; -Standard_EXPORT void Restore(DF_Attribute* with) ; -Standard_EXPORT DF_Attribute* NewEmpty() const; -Standard_EXPORT void Paste(DF_Attribute* into); -Standard_EXPORT ~SALOMEDSImpl_AttributeInteger() {} + static const std::string& GetID() ; + + SALOMEDSImpl_AttributeInteger():SALOMEDSImpl_GenericAttribute("AttributeInteger") {} + static SALOMEDSImpl_AttributeInteger* Set (const DF_Label& L, int Val); + void SetValue(const int theVal); + int Value() const; + virtual std::string Save(); + virtual void Load(const std::string& theValue); + + const std::string& ID() const; + void Restore(DF_Attribute* with) ; + DF_Attribute* NewEmpty() const; + void Paste(DF_Attribute* into); + ~SALOMEDSImpl_AttributeInteger() {} }; diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeLocalID.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeLocalID.hxx index 2654146b4..d44c06009 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeLocalID.hxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeLocalID.hxx @@ -24,31 +24,33 @@ #ifndef _SALOMEDSImpl_AttributeLocalID_HeaderFile #define _SALOMEDSImpl_AttributeLocalID_HeaderFile +#include "SALOMEDSImpl_Defines.hxx" #include "DF_Attribute.hxx" #include #include "DF_Label.hxx" #include "SALOMEDSImpl_GenericAttribute.hxx" -class SALOMEDSImpl_AttributeLocalID : public SALOMEDSImpl_GenericAttribute +class SALOMEDSIMPL_EXPORT SALOMEDSImpl_AttributeLocalID : + public SALOMEDSImpl_GenericAttribute { private: -int myValue; + int myValue; public: -Standard_EXPORT virtual std::string Save(); -Standard_EXPORT virtual void Load(const std::string& theValue); - -Standard_EXPORT static const std::string& GetID() ; -Standard_EXPORT static SALOMEDSImpl_AttributeLocalID* Set(const DF_Label& label,const int value) ; -Standard_EXPORT void SetValue(const int value); -Standard_EXPORT int Value() const { return myValue; } -Standard_EXPORT SALOMEDSImpl_AttributeLocalID(); -Standard_EXPORT const std::string& ID() const; -Standard_EXPORT void Restore(DF_Attribute* with) ; -Standard_EXPORT DF_Attribute* NewEmpty() const; -Standard_EXPORT void Paste(DF_Attribute*); -Standard_EXPORT ~SALOMEDSImpl_AttributeLocalID() {} + virtual std::string Save(); + virtual void Load(const std::string& theValue); + + static const std::string& GetID() ; + static SALOMEDSImpl_AttributeLocalID* Set(const DF_Label& label,const int value) ; + void SetValue(const int value); + int Value() const { return myValue; } + SALOMEDSImpl_AttributeLocalID(); + const std::string& ID() const; + void Restore(DF_Attribute* with) ; + DF_Attribute* NewEmpty() const; + void Paste(DF_Attribute*); + ~SALOMEDSImpl_AttributeLocalID() {} }; diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeName.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeName.hxx index 2bb858a68..2e5d0e961 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeName.hxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeName.hxx @@ -24,35 +24,37 @@ #ifndef _SALOMEDSImpl_AttributeName_HeaderFile #define _SALOMEDSImpl_AttributeName_HeaderFile +#include "SALOMEDSImpl_Defines.hxx" #include "DF_Attribute.hxx" #include #include "DF_Label.hxx" #include "SALOMEDSImpl_GenericAttribute.hxx" -class SALOMEDSImpl_AttributeName : public SALOMEDSImpl_GenericAttribute +class SALOMEDSIMPL_EXPORT SALOMEDSImpl_AttributeName : + public SALOMEDSImpl_GenericAttribute { private: - std::string myString; + std::string myString; public: -Standard_EXPORT static const std::string& GetID() ; + static const std::string& GetID() ; -Standard_EXPORT SALOMEDSImpl_AttributeName():SALOMEDSImpl_GenericAttribute("AttributeName") {} -Standard_EXPORT static SALOMEDSImpl_AttributeName* Set (const DF_Label& L, const std::string& Val); -Standard_EXPORT void SetValue(const std::string& theVal); -Standard_EXPORT std::string Value() const { return myString; } + SALOMEDSImpl_AttributeName():SALOMEDSImpl_GenericAttribute("AttributeName") {} + static SALOMEDSImpl_AttributeName* Set (const DF_Label& L, const std::string& Val); + void SetValue(const std::string& theVal); + std::string Value() const { return myString; } -Standard_EXPORT virtual std::string Save() { return myString; } -Standard_EXPORT virtual void Load(const std::string& theValue) { myString = theValue; } + virtual std::string Save() { return myString; } + virtual void Load(const std::string& theValue) { myString = theValue; } -Standard_EXPORT const std::string& ID() const; -Standard_EXPORT void Restore(DF_Attribute* with) ; -Standard_EXPORT DF_Attribute* NewEmpty() const; -Standard_EXPORT void Paste(DF_Attribute* into); + const std::string& ID() const; + void Restore(DF_Attribute* with) ; + DF_Attribute* NewEmpty() const; + void Paste(DF_Attribute* into); -Standard_EXPORT ~SALOMEDSImpl_AttributeName() {} + ~SALOMEDSImpl_AttributeName() {} }; diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeOpened.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeOpened.hxx index 8efd33901..b86d496ec 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeOpened.hxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeOpened.hxx @@ -24,31 +24,33 @@ #ifndef _SALOMEDSImpl_AttributeOpened_HeaderFile #define _SALOMEDSImpl_AttributeOpened_HeaderFile +#include "SALOMEDSImpl_Defines.hxx" #include "DF_Attribute.hxx" #include #include "DF_Label.hxx" #include "SALOMEDSImpl_GenericAttribute.hxx" -class SALOMEDSImpl_AttributeOpened : public SALOMEDSImpl_GenericAttribute +class SALOMEDSIMPL_EXPORT SALOMEDSImpl_AttributeOpened : + public SALOMEDSImpl_GenericAttribute { private: -int myValue; + int myValue; public: -Standard_EXPORT virtual std::string Save() { return (myValue == 0)?(char*)"0":(char*)"1"; } -Standard_EXPORT virtual void Load(const std::string& theValue) { (theValue == "0")?myValue=0:myValue=1; } - -Standard_EXPORT static const std::string& GetID() ; -Standard_EXPORT static SALOMEDSImpl_AttributeOpened* Set(const DF_Label& label,const int value) ; -Standard_EXPORT SALOMEDSImpl_AttributeOpened(); -Standard_EXPORT void SetOpened(const int value); -Standard_EXPORT int IsOpened() const { return myValue; } -Standard_EXPORT const std::string& ID() const; -Standard_EXPORT void Restore(DF_Attribute* with) ; -Standard_EXPORT DF_Attribute* NewEmpty() const; -Standard_EXPORT void Paste(DF_Attribute* into); -Standard_EXPORT ~SALOMEDSImpl_AttributeOpened() {} + virtual std::string Save() { return (myValue == 0)?(char*)"0":(char*)"1"; } + virtual void Load(const std::string& theValue) { (theValue == "0")?myValue=0:myValue=1; } + + static const std::string& GetID() ; + static SALOMEDSImpl_AttributeOpened* Set(const DF_Label& label,const int value) ; + SALOMEDSImpl_AttributeOpened(); + void SetOpened(const int value); + int IsOpened() const { return myValue; } + const std::string& ID() const; + void Restore(DF_Attribute* with) ; + DF_Attribute* NewEmpty() const; + void Paste(DF_Attribute* into); + ~SALOMEDSImpl_AttributeOpened() {} }; diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeParameter.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeParameter.hxx index ecbc14ec2..f40e9bf87 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeParameter.hxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeParameter.hxx @@ -24,6 +24,7 @@ #ifndef _SALOMEDSImpl_AttributeParameter_HeaderFile #define _SALOMEDSImpl_AttributeParameter_HeaderFile +#include "SALOMEDSImpl_Defines.hxx" #include "DF_Attribute.hxx" #include "DF_Label.hxx" #include "SALOMEDSImpl_GenericAttribute.hxx" @@ -35,15 +36,16 @@ enum Parameter_Types {PT_INTEGER, PT_REAL, PT_BOOLEAN, PT_STRING, PT_REALARRAY, PT_INTARRAY, PT_STRARRAY}; /*! - Class: SALOMEDSImpl_AttributeParameter - Description : AttributeParameter is a universal container of basic types +Class: SALOMEDSImpl_AttributeParameter +Description : AttributeParameter is a universal container of basic types */ -class SALOMEDSImpl_AttributeParameter : public SALOMEDSImpl_GenericAttribute +class SALOMEDSIMPL_EXPORT SALOMEDSImpl_AttributeParameter : + public SALOMEDSImpl_GenericAttribute { private: - + std::map _ints; std::map _reals; std::map _strings; @@ -53,55 +55,54 @@ private: std::map< std::string, std::vector > _strarrays; public: - Standard_EXPORT static const std::string& GetID() ; - - Standard_EXPORT SALOMEDSImpl_AttributeParameter():SALOMEDSImpl_GenericAttribute("AttributeParameter") {} - Standard_EXPORT static SALOMEDSImpl_AttributeParameter* Set (const DF_Label& L); - - - Standard_EXPORT void SetInt(const std::string& theID, const int& theValue); - Standard_EXPORT int GetInt(const std::string& theID); - - Standard_EXPORT void SetReal(const std::string& theID, const double& theValue); - Standard_EXPORT double GetReal(const std::string& theID); - - Standard_EXPORT void SetString(const std::string& theID, const std::string& theValue); - Standard_EXPORT std::string GetString(const std::string& theID); - - Standard_EXPORT void SetBool(const std::string& theID, const bool& theValue); - Standard_EXPORT bool GetBool(const std::string& theID); - - Standard_EXPORT void SetRealArray(const std::string& theID, const std::vector& theArray); - Standard_EXPORT std::vector GetRealArray(const std::string& theID); - - Standard_EXPORT void SetIntArray(const std::string& theID, const std::vector& theArray); - Standard_EXPORT std::vector GetIntArray(const std::string& theID); - - Standard_EXPORT void SetStrArray(const std::string& theID, const std::vector& theArray); - Standard_EXPORT std::vector GetStrArray(const std::string& theID); - Standard_EXPORT bool IsSet(const std::string& theID, const Parameter_Types theType); + static const std::string& GetID() ; - Standard_EXPORT bool RemoveID(const std::string& theID, const Parameter_Types theType); - - Standard_EXPORT SALOMEDSImpl_AttributeParameter* GetFather(); - Standard_EXPORT bool HasFather(); - Standard_EXPORT bool IsRoot(); - - Standard_EXPORT std::vector GetIDs(const Parameter_Types theType); - - Standard_EXPORT void Clear(); - - Standard_EXPORT virtual std::string Save(); - Standard_EXPORT virtual void Load(const std::string& theValue); - - Standard_EXPORT const std::string& ID() const; - Standard_EXPORT void Restore(DF_Attribute* with) ; - Standard_EXPORT DF_Attribute* NewEmpty() const; - Standard_EXPORT void Paste(DF_Attribute* into); - - Standard_EXPORT ~SALOMEDSImpl_AttributeParameter() {} - + SALOMEDSImpl_AttributeParameter():SALOMEDSImpl_GenericAttribute("AttributeParameter") {} + static SALOMEDSImpl_AttributeParameter* Set (const DF_Label& L); + + void SetInt(const std::string& theID, const int& theValue); + int GetInt(const std::string& theID); + + void SetReal(const std::string& theID, const double& theValue); + double GetReal(const std::string& theID); + + void SetString(const std::string& theID, const std::string& theValue); + std::string GetString(const std::string& theID); + + void SetBool(const std::string& theID, const bool& theValue); + bool GetBool(const std::string& theID); + + void SetRealArray(const std::string& theID, const std::vector& theArray); + std::vector GetRealArray(const std::string& theID); + + void SetIntArray(const std::string& theID, const std::vector& theArray); + std::vector GetIntArray(const std::string& theID); + + void SetStrArray(const std::string& theID, const std::vector& theArray); + std::vector GetStrArray(const std::string& theID); + + bool IsSet(const std::string& theID, const Parameter_Types theType); + + bool RemoveID(const std::string& theID, const Parameter_Types theType); + + SALOMEDSImpl_AttributeParameter* GetFather(); + bool HasFather(); + bool IsRoot(); + + std::vector GetIDs(const Parameter_Types theType); + + void Clear(); + + virtual std::string Save(); + virtual void Load(const std::string& theValue); + + const std::string& ID() const; + void Restore(DF_Attribute* with) ; + DF_Attribute* NewEmpty() const; + void Paste(DF_Attribute* into); + + ~SALOMEDSImpl_AttributeParameter() {} }; #endif diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributePersistentRef.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributePersistentRef.hxx index fa95a619f..256da73eb 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_AttributePersistentRef.hxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributePersistentRef.hxx @@ -24,33 +24,35 @@ #ifndef _SALOMEDSImpl_AttributePersistentRef_HeaderFile #define _SALOMEDSImpl_AttributePersistentRef_HeaderFile +#include "SALOMEDSImpl_Defines.hxx" #include "DF_Attribute.hxx" #include #include "DF_Label.hxx" #include "SALOMEDSImpl_GenericAttribute.hxx" -class SALOMEDSImpl_AttributePersistentRef : public SALOMEDSImpl_GenericAttribute +class SALOMEDSIMPL_EXPORT SALOMEDSImpl_AttributePersistentRef : + public SALOMEDSImpl_GenericAttribute { private: - std::string myString; + std::string myString; public: -Standard_EXPORT virtual std::string Save() { return myString; } -Standard_EXPORT virtual void Load(const std::string& theValue) { myString = theValue; } - -Standard_EXPORT static const std::string& GetID() ; -Standard_EXPORT static SALOMEDSImpl_AttributePersistentRef* Set(const DF_Label& label, - const std::string& value) ; -Standard_EXPORT SALOMEDSImpl_AttributePersistentRef(); -Standard_EXPORT const std::string& ID() const; -Standard_EXPORT void SetValue(const std::string& value); -Standard_EXPORT std::string Value() const { return myString; } -Standard_EXPORT void Restore(DF_Attribute* with) ; -Standard_EXPORT DF_Attribute* NewEmpty() const; -Standard_EXPORT void Paste(DF_Attribute* into); -Standard_EXPORT ~SALOMEDSImpl_AttributePersistentRef() {} + virtual std::string Save() { return myString; } + virtual void Load(const std::string& theValue) { myString = theValue; } + + static const std::string& GetID() ; + static SALOMEDSImpl_AttributePersistentRef* Set(const DF_Label& label, + const std::string& value) ; + SALOMEDSImpl_AttributePersistentRef(); + const std::string& ID() const; + void SetValue(const std::string& value); + std::string Value() const { return myString; } + void Restore(DF_Attribute* with) ; + DF_Attribute* NewEmpty() const; + void Paste(DF_Attribute* into); + ~SALOMEDSImpl_AttributePersistentRef() {} }; diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributePixMap.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributePixMap.hxx index ac0fcbd33..feb9e67d9 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_AttributePixMap.hxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributePixMap.hxx @@ -24,33 +24,35 @@ #ifndef _SALOMEDSImpl_AttributePixMap_HeaderFile #define _SALOMEDSImpl_AttributePixMap_HeaderFile +#include "SALOMEDSImpl_Defines.hxx" #include "DF_Attribute.hxx" #include #include "DF_Label.hxx" #include "SALOMEDSImpl_GenericAttribute.hxx" -class SALOMEDSImpl_AttributePixMap : public SALOMEDSImpl_GenericAttribute +class SALOMEDSIMPL_EXPORT SALOMEDSImpl_AttributePixMap : + public SALOMEDSImpl_GenericAttribute { private: - std::string myString; + std::string myString; public: -Standard_EXPORT virtual std::string Save() { return myString; } -Standard_EXPORT virtual void Load(const std::string& theValue) { myString = theValue; } - -Standard_EXPORT static const std::string& GetID() ; -Standard_EXPORT static SALOMEDSImpl_AttributePixMap* Set(const DF_Label& label, - const std::string& string) ; -Standard_EXPORT SALOMEDSImpl_AttributePixMap(); -Standard_EXPORT const std::string& ID() const; -Standard_EXPORT void SetPixMap(const std::string& value); -Standard_EXPORT std::string GetPixMap() const { return myString; } -Standard_EXPORT bool HasPixMap() const { return (myString != "None"); } -Standard_EXPORT void Restore(DF_Attribute* with) ; -Standard_EXPORT DF_Attribute* NewEmpty() const; -Standard_EXPORT void Paste(DF_Attribute* into); -Standard_EXPORT ~SALOMEDSImpl_AttributePixMap() {} + virtual std::string Save() { return myString; } + virtual void Load(const std::string& theValue) { myString = theValue; } + + static const std::string& GetID() ; + static SALOMEDSImpl_AttributePixMap* Set(const DF_Label& label, + const std::string& string) ; + SALOMEDSImpl_AttributePixMap(); + const std::string& ID() const; + void SetPixMap(const std::string& value); + std::string GetPixMap() const { return myString; } + bool HasPixMap() const { return (myString != "None"); } + void Restore(DF_Attribute* with) ; + DF_Attribute* NewEmpty() const; + void Paste(DF_Attribute* into); + ~SALOMEDSImpl_AttributePixMap() {} }; diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributePythonObject.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributePythonObject.hxx index bda55e4fa..b9c105e50 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_AttributePythonObject.hxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributePythonObject.hxx @@ -24,6 +24,7 @@ #ifndef _SALOMEDSImpl_AttributePythonObject_HeaderFile #define _SALOMEDSImpl_AttributePythonObject_HeaderFile +#include "SALOMEDSImpl_Defines.hxx" #include "DF_Attribute.hxx" #include "DF_Label.hxx" #include @@ -33,30 +34,31 @@ #undef GetObject #endif -class SALOMEDSImpl_AttributePythonObject : public SALOMEDSImpl_GenericAttribute +class SALOMEDSIMPL_EXPORT SALOMEDSImpl_AttributePythonObject : + public SALOMEDSImpl_GenericAttribute { public: -Standard_EXPORT virtual std::string Save(); -Standard_EXPORT virtual void Load(const std::string&); - -Standard_EXPORT static const std::string& GetID() ; -Standard_EXPORT static SALOMEDSImpl_AttributePythonObject* Set(const DF_Label& label) ; -Standard_EXPORT SALOMEDSImpl_AttributePythonObject(); -Standard_EXPORT void SetObject(const std::string& theSequence, const bool theScript) ; -Standard_EXPORT std::string GetObject() const; -Standard_EXPORT bool IsScript() const; -Standard_EXPORT int GetLength() const; -Standard_EXPORT const std::string& ID() const; -Standard_EXPORT void Restore(DF_Attribute* with) ; -Standard_EXPORT DF_Attribute* NewEmpty() const; -Standard_EXPORT void Paste(DF_Attribute* into); -Standard_EXPORT ~SALOMEDSImpl_AttributePythonObject() {} + virtual std::string Save(); + virtual void Load(const std::string&); + + static const std::string& GetID() ; + static SALOMEDSImpl_AttributePythonObject* Set(const DF_Label& label) ; + SALOMEDSImpl_AttributePythonObject(); + void SetObject(const std::string& theSequence, const bool theScript) ; + std::string GetObject() const; + bool IsScript() const; + int GetLength() const; + const std::string& ID() const; + void Restore(DF_Attribute* with) ; + DF_Attribute* NewEmpty() const; + void Paste(DF_Attribute* into); + ~SALOMEDSImpl_AttributePythonObject() {} private: -std::string mySequence; -bool myIsScript; + std::string mySequence; + bool myIsScript; }; diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeReal.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeReal.hxx index 488f3bfe8..93bdba112 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeReal.hxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeReal.hxx @@ -24,31 +24,33 @@ #ifndef _SALOMEDSImpl_AttributeReal_HeaderFile #define _SALOMEDSImpl_AttributeReal_HeaderFile +#include "SALOMEDSImpl_Defines.hxx" #include "DF_Attribute.hxx" #include #include "DF_Label.hxx" #include "SALOMEDSImpl_GenericAttribute.hxx" -class SALOMEDSImpl_AttributeReal : public SALOMEDSImpl_GenericAttribute +class SALOMEDSIMPL_EXPORT SALOMEDSImpl_AttributeReal : + public SALOMEDSImpl_GenericAttribute { private: double myValue; public: -Standard_EXPORT static const std::string& GetID() ; + static const std::string& GetID() ; -Standard_EXPORT SALOMEDSImpl_AttributeReal():SALOMEDSImpl_GenericAttribute("AttributeReal") {} -Standard_EXPORT static SALOMEDSImpl_AttributeReal* Set (const DF_Label& L, const double& Val); -Standard_EXPORT void SetValue(const double& theVal); -Standard_EXPORT double Value() const { return myValue; } -Standard_EXPORT virtual std::string Save(); -Standard_EXPORT virtual void Load(const std::string& theValue); + SALOMEDSImpl_AttributeReal():SALOMEDSImpl_GenericAttribute("AttributeReal") {} + static SALOMEDSImpl_AttributeReal* Set (const DF_Label& L, const double& Val); + void SetValue(const double& theVal); + double Value() const { return myValue; } + virtual std::string Save(); + virtual void Load(const std::string& theValue); -Standard_EXPORT const std::string& ID() const; -Standard_EXPORT void Restore(DF_Attribute* with) ; -Standard_EXPORT DF_Attribute* NewEmpty() const; -Standard_EXPORT void Paste(DF_Attribute* into); -Standard_EXPORT ~SALOMEDSImpl_AttributeReal() {} + const std::string& ID() const; + void Restore(DF_Attribute* with) ; + DF_Attribute* NewEmpty() const; + void Paste(DF_Attribute* into); + ~SALOMEDSImpl_AttributeReal() {} }; diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeReference.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeReference.hxx index 4c69dee7b..f1e78ad64 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeReference.hxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeReference.hxx @@ -24,33 +24,35 @@ #ifndef _SALOMEDSImpl_AttributeReference_HeaderFile #define _SALOMEDSImpl_AttributeReference_HeaderFile +#include "SALOMEDSImpl_Defines.hxx" #include "DF_Attribute.hxx" #include "DF_Label.hxx" #include #include "SALOMEDSImpl_GenericAttribute.hxx" -class SALOMEDSImpl_AttributeReference : public SALOMEDSImpl_GenericAttribute +class SALOMEDSIMPL_EXPORT SALOMEDSImpl_AttributeReference : + public SALOMEDSImpl_GenericAttribute { private: - DF_Label myLabel; + DF_Label myLabel; public: -Standard_EXPORT static const std::string& GetID() ; + static const std::string& GetID() ; -Standard_EXPORT SALOMEDSImpl_AttributeReference():SALOMEDSImpl_GenericAttribute("AttributeReference") {} -Standard_EXPORT static SALOMEDSImpl_AttributeReference* Set(const DF_Label& theLabel, const DF_Label& theRefLabel); -Standard_EXPORT void Set(const DF_Label& theLabel); -Standard_EXPORT DF_Label Get() const { return myLabel; } -Standard_EXPORT virtual std::string Save(); -Standard_EXPORT virtual void Load(const std::string& theValue); + SALOMEDSImpl_AttributeReference():SALOMEDSImpl_GenericAttribute("AttributeReference") {} + static SALOMEDSImpl_AttributeReference* Set(const DF_Label& theLabel, const DF_Label& theRefLabel); + void Set(const DF_Label& theLabel); + DF_Label Get() const { return myLabel; } + virtual std::string Save(); + virtual void Load(const std::string& theValue); -Standard_EXPORT const std::string& ID() const; -Standard_EXPORT void Restore(DF_Attribute* with) ; -Standard_EXPORT DF_Attribute* NewEmpty() const; -Standard_EXPORT void Paste(DF_Attribute* into); + const std::string& ID() const; + void Restore(DF_Attribute* with) ; + DF_Attribute* NewEmpty() const; + void Paste(DF_Attribute* into); -Standard_EXPORT ~SALOMEDSImpl_AttributeReference() {} + ~SALOMEDSImpl_AttributeReference() {} }; #endif diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeSelectable.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeSelectable.hxx index dfdc71871..56d5fa750 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeSelectable.hxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeSelectable.hxx @@ -24,31 +24,33 @@ #ifndef _SALOMEDSImpl_AttributeSelectable_HeaderFile #define _SALOMEDSImpl_AttributeSelectable_HeaderFile +#include "SALOMEDSImpl_Defines.hxx" #include "DF_Attribute.hxx" #include "DF_Label.hxx" #include #include "SALOMEDSImpl_GenericAttribute.hxx" -class SALOMEDSImpl_AttributeSelectable : public SALOMEDSImpl_GenericAttribute +class SALOMEDSIMPL_EXPORT SALOMEDSImpl_AttributeSelectable : + public SALOMEDSImpl_GenericAttribute { private: -int myValue; + int myValue; public: -Standard_EXPORT virtual std::string Save() { return (myValue == 0)?(char*)"0":(char*)"1"; } -Standard_EXPORT virtual void Load(const std::string& theValue) { (theValue == "0")?myValue=0:myValue=1; } - -Standard_EXPORT static const std::string& GetID() ; -Standard_EXPORT static SALOMEDSImpl_AttributeSelectable* Set(const DF_Label& label,const int value) ; -Standard_EXPORT SALOMEDSImpl_AttributeSelectable(); -Standard_EXPORT void SetSelectable(const int value); -Standard_EXPORT int IsSelectable() const { return myValue; } -Standard_EXPORT const std::string& ID() const; -Standard_EXPORT void Restore(DF_Attribute* with) ; -Standard_EXPORT DF_Attribute* NewEmpty() const; -Standard_EXPORT void Paste(DF_Attribute* into); -Standard_EXPORT ~SALOMEDSImpl_AttributeSelectable() {} + virtual std::string Save() { return (myValue == 0)?(char*)"0":(char*)"1"; } + virtual void Load(const std::string& theValue) { (theValue == "0")?myValue=0:myValue=1; } + + static const std::string& GetID() ; + static SALOMEDSImpl_AttributeSelectable* Set(const DF_Label& label,const int value) ; + SALOMEDSImpl_AttributeSelectable(); + void SetSelectable(const int value); + int IsSelectable() const { return myValue; } + const std::string& ID() const; + void Restore(DF_Attribute* with) ; + DF_Attribute* NewEmpty() const; + void Paste(DF_Attribute* into); + ~SALOMEDSImpl_AttributeSelectable() {} }; diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeSequenceOfInteger.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeSequenceOfInteger.hxx index f1f935b4d..7c0f5cb83 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeSequenceOfInteger.hxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeSequenceOfInteger.hxx @@ -24,38 +24,40 @@ #ifndef _SALOMEDSImpl_AttributeSequenceOfInteger_HeaderFile #define _SALOMEDSImpl_AttributeSequenceOfInteger_HeaderFile +#include "SALOMEDSImpl_Defines.hxx" #include "DF_Attribute.hxx" #include "DF_Label.hxx" #include #include #include "SALOMEDSImpl_GenericAttribute.hxx" -class SALOMEDSImpl_AttributeSequenceOfInteger : public SALOMEDSImpl_GenericAttribute +class SALOMEDSIMPL_EXPORT SALOMEDSImpl_AttributeSequenceOfInteger : + public SALOMEDSImpl_GenericAttribute { public: -Standard_EXPORT virtual std::string Save(); -Standard_EXPORT virtual void Load(const std::string&); - -Standard_EXPORT static const std::string& GetID() ; -Standard_EXPORT static SALOMEDSImpl_AttributeSequenceOfInteger* Set(const DF_Label& label) ; -Standard_EXPORT SALOMEDSImpl_AttributeSequenceOfInteger(); -Standard_EXPORT void Assign(const std::vector& other) ; -Standard_EXPORT void ChangeValue(const int Index,const int Value) ; -Standard_EXPORT void Add(const int value) ; -Standard_EXPORT int Value(const int Index) ; -Standard_EXPORT void Remove(const int Index) ; -Standard_EXPORT int Length() ; -Standard_EXPORT const std::string& ID() const; -Standard_EXPORT void Restore(DF_Attribute* with) ; -Standard_EXPORT DF_Attribute* NewEmpty() const; -Standard_EXPORT void Paste(DF_Attribute* into); -Standard_EXPORT ~SALOMEDSImpl_AttributeSequenceOfInteger() {} -Standard_EXPORT const std::vector& Array() { return myValue; } + virtual std::string Save(); + virtual void Load(const std::string&); + + static const std::string& GetID() ; + static SALOMEDSImpl_AttributeSequenceOfInteger* Set(const DF_Label& label) ; + SALOMEDSImpl_AttributeSequenceOfInteger(); + void Assign(const std::vector& other) ; + void ChangeValue(const int Index,const int Value) ; + void Add(const int value) ; + int Value(const int Index) ; + void Remove(const int Index) ; + int Length() ; + const std::string& ID() const; + void Restore(DF_Attribute* with) ; + DF_Attribute* NewEmpty() const; + void Paste(DF_Attribute* into); + ~SALOMEDSImpl_AttributeSequenceOfInteger() {} + const std::vector& Array() { return myValue; } private: -std::vector myValue; + std::vector myValue; }; #endif diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeSequenceOfReal.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeSequenceOfReal.hxx index 10ebdf846..91f0a7c68 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeSequenceOfReal.hxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeSequenceOfReal.hxx @@ -24,6 +24,7 @@ #ifndef _SALOMEDSImpl_AttributeSequenceOfReal_HeaderFile #define _SALOMEDSImpl_AttributeSequenceOfReal_HeaderFile +#include "SALOMEDSImpl_Defines.hxx" #include "DF_Attribute.hxx" #include "DF_Label.hxx" #include @@ -31,32 +32,33 @@ #include "SALOMEDSImpl_GenericAttribute.hxx" -class SALOMEDSImpl_AttributeSequenceOfReal : public SALOMEDSImpl_GenericAttribute +class SALOMEDSIMPL_EXPORT SALOMEDSImpl_AttributeSequenceOfReal : + public SALOMEDSImpl_GenericAttribute { public: -Standard_EXPORT virtual std::string Save(); -Standard_EXPORT virtual void Load(const std::string&); - -Standard_EXPORT static const std::string& GetID() ; -Standard_EXPORT static SALOMEDSImpl_AttributeSequenceOfReal* Set(const DF_Label& label) ; -Standard_EXPORT SALOMEDSImpl_AttributeSequenceOfReal(); -Standard_EXPORT void Assign(const std::vector& other) ; -Standard_EXPORT void ChangeValue(const int Index,const double& Value) ; -Standard_EXPORT void Add(const double& Value) ; -Standard_EXPORT double Value(const int Index) ; -Standard_EXPORT void Remove(const int Index) ; -Standard_EXPORT int Length() ; -Standard_EXPORT const std::string& ID() const; -Standard_EXPORT void Restore(DF_Attribute* with) ; -Standard_EXPORT DF_Attribute* NewEmpty() const; -Standard_EXPORT void Paste(DF_Attribute* into); -Standard_EXPORT ~SALOMEDSImpl_AttributeSequenceOfReal() {} -Standard_EXPORT const std::vector& Array() { return myValue; } + virtual std::string Save(); + virtual void Load(const std::string&); + + static const std::string& GetID() ; + static SALOMEDSImpl_AttributeSequenceOfReal* Set(const DF_Label& label) ; + SALOMEDSImpl_AttributeSequenceOfReal(); + void Assign(const std::vector& other) ; + void ChangeValue(const int Index,const double& Value) ; + void Add(const double& Value) ; + double Value(const int Index) ; + void Remove(const int Index) ; + int Length() ; + const std::string& ID() const; + void Restore(DF_Attribute* with) ; + DF_Attribute* NewEmpty() const; + void Paste(DF_Attribute* into); + ~SALOMEDSImpl_AttributeSequenceOfReal() {} + const std::vector& Array() { return myValue; } private: -std::vector myValue; + std::vector myValue; }; diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeString.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeString.cxx index 9bdc26b23..2ac9acf90 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeString.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeString.cxx @@ -23,9 +23,7 @@ #include "SALOMEDSImpl_AttributeString.hxx" -#ifndef WNT using namespace std; -#endif //======================================================================= //function : GetID diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeStudyProperties.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeStudyProperties.hxx index c520bce61..3cf59dfb3 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeStudyProperties.hxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeStudyProperties.hxx @@ -24,77 +24,78 @@ #ifndef _SALOMEDSImpl_AttributeStudyProperties_HeaderFile #define _SALOMEDSImpl_AttributeStudyProperties_HeaderFile +#include "SALOMEDSImpl_Defines.hxx" #include "DF_Attribute.hxx" #include "DF_Label.hxx" #include #include #include "SALOMEDSImpl_GenericAttribute.hxx" -class SALOMEDSImpl_AttributeStudyProperties : public SALOMEDSImpl_GenericAttribute +class SALOMEDSIMPL_EXPORT SALOMEDSImpl_AttributeStudyProperties : public SALOMEDSImpl_GenericAttribute { public: -Standard_EXPORT SALOMEDSImpl_AttributeStudyProperties(); -Standard_EXPORT ~SALOMEDSImpl_AttributeStudyProperties() {} + SALOMEDSImpl_AttributeStudyProperties(); + ~SALOMEDSImpl_AttributeStudyProperties() {} -Standard_EXPORT static const std::string& GetID(); -Standard_EXPORT const std::string& ID() const; + static const std::string& GetID(); + const std::string& ID() const; -Standard_EXPORT static SALOMEDSImpl_AttributeStudyProperties* Set(const DF_Label& label); + static SALOMEDSImpl_AttributeStudyProperties* Set(const DF_Label& label); -Standard_EXPORT void Init(); + void Init(); -Standard_EXPORT virtual std::string Save(); -Standard_EXPORT virtual void Load(const std::string&); + virtual std::string Save(); + virtual void Load(const std::string&); -Standard_EXPORT void SetModification(const std::string& theUserName, - const int theMinute, - const int theHour, - const int theDay, - const int theMonth, - const int theYear); -Standard_EXPORT void GetModifications(std::vector& theUserNames, - std::vector& theMinutes, - std::vector& theHours, - std::vector& theDays, - std::vector& theMonths, - std::vector& theYears) const; + void SetModification(const std::string& theUserName, + const int theMinute, + const int theHour, + const int theDay, + const int theMonth, + const int theYear); + void GetModifications(std::vector& theUserNames, + std::vector& theMinutes, + std::vector& theHours, + std::vector& theDays, + std::vector& theMonths, + std::vector& theYears) const; -Standard_EXPORT std::string GetCreatorName() const; -Standard_EXPORT bool GetCreationDate(int& theMinute, - int& theHour, - int& theDay, - int& theMonth, - int& theYear) const; + std::string GetCreatorName() const; + bool GetCreationDate(int& theMinute, + int& theHour, + int& theDay, + int& theMonth, + int& theYear) const; -Standard_EXPORT void ChangeCreatorName(const std::string& theUserName); + void ChangeCreatorName(const std::string& theUserName); -Standard_EXPORT void SetCreationMode(const int theMode); -Standard_EXPORT int GetCreationMode() const; + void SetCreationMode(const int theMode); + int GetCreationMode() const; -Standard_EXPORT void SetModified(const int theModified); -Standard_EXPORT bool IsModified() const; -Standard_EXPORT int GetModified() const; + void SetModified(const int theModified); + bool IsModified() const; + int GetModified() const; -Standard_EXPORT void SetLocked(const bool theLocked); -Standard_EXPORT bool IsLocked() const; -Standard_EXPORT bool IsLockChanged(const bool theErase); + void SetLocked(const bool theLocked); + bool IsLocked() const; + bool IsLockChanged(const bool theErase); -Standard_EXPORT void Restore(DF_Attribute* with); -Standard_EXPORT DF_Attribute* NewEmpty() const; -Standard_EXPORT void Paste(DF_Attribute* into); + void Restore(DF_Attribute* with); + DF_Attribute* NewEmpty() const; + void Paste(DF_Attribute* into); private: -std::vector myUserName; -std::vector myMinute; -std::vector myHour; -std::vector myDay; -std::vector myMonth; -std::vector myYear; -int myMode; -int myModified; -bool myLocked; -bool myLockChanged; + std::vector myUserName; + std::vector myMinute; + std::vector myHour; + std::vector myDay; + std::vector myMonth; + std::vector myYear; + int myMode; + int myModified; + bool myLocked; + bool myLockChanged; }; diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfInteger.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfInteger.hxx index 84434df7b..b89383513 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfInteger.hxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfInteger.hxx @@ -11,6 +11,7 @@ #ifndef _SALOMEDSImpl_AttributeTableOfInteger_HeaderFile #define _SALOMEDSImpl_AttributeTableOfInteger_HeaderFile +#include "SALOMEDSImpl_Defines.hxx" #include "DF_Attribute.hxx" #include "DF_Label.hxx" #include "SALOMEDSImpl_GenericAttribute.hxx" @@ -20,58 +21,59 @@ #include -class SALOMEDSImpl_AttributeTableOfInteger : public SALOMEDSImpl_GenericAttribute +class SALOMEDSIMPL_EXPORT SALOMEDSImpl_AttributeTableOfInteger : + public SALOMEDSImpl_GenericAttribute { public: -Standard_EXPORT virtual std::string Save(); -Standard_EXPORT virtual void Load(const std::string&); -Standard_EXPORT static const std::string& GetID() ; -Standard_EXPORT static SALOMEDSImpl_AttributeTableOfInteger* Set(const DF_Label& label) ; -Standard_EXPORT SALOMEDSImpl_AttributeTableOfInteger(); -Standard_EXPORT void SetNbColumns(const int theNbColumns); -Standard_EXPORT void SetTitle(const std::string& theTitle) ; -Standard_EXPORT std::string GetTitle() const; -Standard_EXPORT void SetRowData(const int theRow,const std::vector& theData) ; -Standard_EXPORT std::vector GetRowData(const int theRow) ; -Standard_EXPORT void SetRowTitle(const int theRow,const std::string& theTitle) ; -Standard_EXPORT void SetRowUnit(const int theRow,const std::string& theUnit) ; -Standard_EXPORT std::string GetRowUnit(const int theRow) const; -Standard_EXPORT void SetRowUnits(const std::vector& theUnits) ; -Standard_EXPORT std::vector GetRowUnits(); -Standard_EXPORT void SetRowTitles(const std::vector& theTitles) ; -Standard_EXPORT std::vector GetRowTitles(); -Standard_EXPORT std::string GetRowTitle(const int theRow) const; -Standard_EXPORT void SetColumnData(const int theColumn,const std::vector& theData) ; -Standard_EXPORT std::vector GetColumnData(const int theColumn) ; -Standard_EXPORT void SetColumnTitle(const int theColumn,const std::string& theTitle) ; -Standard_EXPORT std::string GetColumnTitle(const int theColumn) const; -Standard_EXPORT void SetColumnTitles(const std::vector& theTitles); -Standard_EXPORT std::vector GetColumnTitles(); -Standard_EXPORT int GetNbRows() const; -Standard_EXPORT int GetNbColumns() const; + virtual std::string Save(); + virtual void Load(const std::string&); + static const std::string& GetID() ; + static SALOMEDSImpl_AttributeTableOfInteger* Set(const DF_Label& label) ; + SALOMEDSImpl_AttributeTableOfInteger(); + void SetNbColumns(const int theNbColumns); + void SetTitle(const std::string& theTitle) ; + std::string GetTitle() const; + void SetRowData(const int theRow,const std::vector& theData) ; + std::vector GetRowData(const int theRow) ; + void SetRowTitle(const int theRow,const std::string& theTitle) ; + void SetRowUnit(const int theRow,const std::string& theUnit) ; + std::string GetRowUnit(const int theRow) const; + void SetRowUnits(const std::vector& theUnits) ; + std::vector GetRowUnits(); + void SetRowTitles(const std::vector& theTitles) ; + std::vector GetRowTitles(); + std::string GetRowTitle(const int theRow) const; + void SetColumnData(const int theColumn,const std::vector& theData) ; + std::vector GetColumnData(const int theColumn) ; + void SetColumnTitle(const int theColumn,const std::string& theTitle) ; + std::string GetColumnTitle(const int theColumn) const; + void SetColumnTitles(const std::vector& theTitles); + std::vector GetColumnTitles(); + int GetNbRows() const; + int GetNbColumns() const; -Standard_EXPORT void PutValue(const int theValue,const int theRow,const int theColumn) ; -Standard_EXPORT bool HasValue(const int theRow,const int theColumn) ; -Standard_EXPORT int GetValue(const int theRow,const int theColumn) ; -Standard_EXPORT const std::string& ID() const; -Standard_EXPORT void Restore(DF_Attribute* with) ; -Standard_EXPORT DF_Attribute* NewEmpty() const; -Standard_EXPORT void Paste(DF_Attribute* into); + void PutValue(const int theValue,const int theRow,const int theColumn) ; + bool HasValue(const int theRow,const int theColumn) ; + int GetValue(const int theRow,const int theColumn) ; + const std::string& ID() const; + void Restore(DF_Attribute* with) ; + DF_Attribute* NewEmpty() const; + void Paste(DF_Attribute* into); -Standard_EXPORT std::vector GetSetRowIndices(const int theRow); -Standard_EXPORT std::vector GetSetColumnIndices(const int theColumn); + std::vector GetSetRowIndices(const int theRow); + std::vector GetSetColumnIndices(const int theColumn); -Standard_EXPORT ~SALOMEDSImpl_AttributeTableOfInteger() {} + ~SALOMEDSImpl_AttributeTableOfInteger() {} private: -std::map myTable; -std::string myTitle; -std::vector myRows; -std::vector myCols; -int myNbRows; -int myNbColumns; + std::map myTable; + std::string myTitle; + std::vector myRows; + std::vector myCols; + int myNbRows; + int myNbColumns; }; diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfReal.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfReal.hxx index 3dea7567d..672a26e5b 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfReal.hxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfReal.hxx @@ -11,6 +11,7 @@ #ifndef _SALOMEDSImpl_AttributeTableOfReal_HeaderFile #define _SALOMEDSImpl_AttributeTableOfReal_HeaderFile +#include "SALOMEDSImpl_Defines.hxx" #include "DF_Attribute.hxx" #include "DF_Label.hxx" #include "SALOMEDSImpl_GenericAttribute.hxx" @@ -19,57 +20,58 @@ #include #include -class SALOMEDSImpl_AttributeTableOfReal : public SALOMEDSImpl_GenericAttribute +class SALOMEDSIMPL_EXPORT SALOMEDSImpl_AttributeTableOfReal : + public SALOMEDSImpl_GenericAttribute { public: -Standard_EXPORT virtual std::string Save(); -Standard_EXPORT virtual void Load(const std::string&); -Standard_EXPORT static const std::string& GetID() ; -Standard_EXPORT static SALOMEDSImpl_AttributeTableOfReal* Set(const DF_Label& label) ; -Standard_EXPORT SALOMEDSImpl_AttributeTableOfReal(); -Standard_EXPORT void SetNbColumns(const int theNbColumns); -Standard_EXPORT void SetTitle(const std::string& theTitle) ; -Standard_EXPORT std::string GetTitle() const; -Standard_EXPORT void SetRowData(const int theRow,const std::vector& theData) ; -Standard_EXPORT std::vector GetRowData(const int theRow) ; -Standard_EXPORT void SetRowTitle(const int theRow,const std::string& theTitle) ; -Standard_EXPORT void SetRowUnit(const int theRow,const std::string& theUnit) ; -Standard_EXPORT std::string GetRowUnit(const int theRow) const; -Standard_EXPORT void SetRowUnits(const std::vector& theUnits) ; -Standard_EXPORT std::vector GetRowUnits(); -Standard_EXPORT void SetRowTitles(const std::vector& theTitles) ; -Standard_EXPORT std::vector GetRowTitles(); -Standard_EXPORT std::string GetRowTitle(const int theRow) const; -Standard_EXPORT void SetColumnData(const int theColumn,const std::vector& theData) ; -Standard_EXPORT std::vector GetColumnData(const int theColumn) ; -Standard_EXPORT void SetColumnTitle(const int theColumn,const std::string& theTitle) ; -Standard_EXPORT void SetColumnTitles(const std::vector& theTitles); -Standard_EXPORT std::vector GetColumnTitles(); -Standard_EXPORT std::string GetColumnTitle(const int theColumn) const; -Standard_EXPORT int GetNbRows() const; -Standard_EXPORT int GetNbColumns() const; + virtual std::string Save(); + virtual void Load(const std::string&); + static const std::string& GetID() ; + static SALOMEDSImpl_AttributeTableOfReal* Set(const DF_Label& label) ; + SALOMEDSImpl_AttributeTableOfReal(); + void SetNbColumns(const int theNbColumns); + void SetTitle(const std::string& theTitle) ; + std::string GetTitle() const; + void SetRowData(const int theRow,const std::vector& theData) ; + std::vector GetRowData(const int theRow) ; + void SetRowTitle(const int theRow,const std::string& theTitle) ; + void SetRowUnit(const int theRow,const std::string& theUnit) ; + std::string GetRowUnit(const int theRow) const; + void SetRowUnits(const std::vector& theUnits) ; + std::vector GetRowUnits(); + void SetRowTitles(const std::vector& theTitles) ; + std::vector GetRowTitles(); + std::string GetRowTitle(const int theRow) const; + void SetColumnData(const int theColumn,const std::vector& theData) ; + std::vector GetColumnData(const int theColumn) ; + void SetColumnTitle(const int theColumn,const std::string& theTitle) ; + void SetColumnTitles(const std::vector& theTitles); + std::vector GetColumnTitles(); + std::string GetColumnTitle(const int theColumn) const; + int GetNbRows() const; + int GetNbColumns() const; -Standard_EXPORT void PutValue(const double& theValue,const int theRow,const int theColumn) ; -Standard_EXPORT bool HasValue(const int theRow,const int theColumn) ; -Standard_EXPORT double GetValue(const int theRow,const int theColumn) ; -Standard_EXPORT const std::string& ID() const; -Standard_EXPORT void Restore(DF_Attribute* with) ; -Standard_EXPORT DF_Attribute* NewEmpty() const; -Standard_EXPORT void Paste(DF_Attribute* into); + void PutValue(const double& theValue,const int theRow,const int theColumn) ; + bool HasValue(const int theRow,const int theColumn) ; + double GetValue(const int theRow,const int theColumn) ; + const std::string& ID() const; + void Restore(DF_Attribute* with) ; + DF_Attribute* NewEmpty() const; + void Paste(DF_Attribute* into); -Standard_EXPORT std::vector GetSetRowIndices(const int theRow); -Standard_EXPORT std::vector GetSetColumnIndices(const int theColumn); + std::vector GetSetRowIndices(const int theRow); + std::vector GetSetColumnIndices(const int theColumn); -Standard_EXPORT ~SALOMEDSImpl_AttributeTableOfReal() {} + ~SALOMEDSImpl_AttributeTableOfReal() {} private: -std::map myTable; -std::string myTitle; -std::vector myRows; -std::vector myCols; -int myNbRows; -int myNbColumns; + std::map myTable; + std::string myTitle; + std::vector myRows; + std::vector myCols; + int myNbRows; + int myNbColumns; }; diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfString.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfString.hxx index 0a4da3185..f30caa8a3 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfString.hxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfString.hxx @@ -11,6 +11,7 @@ #ifndef _SALOMEDSImpl_AttributeTableOfString_HeaderFile #define _SALOMEDSImpl_AttributeTableOfString_HeaderFile +#include "SALOMEDSImpl_Defines.hxx" #include "DF_Label.hxx" #include "DF_Attribute.hxx" #include "SALOMEDSImpl_GenericAttribute.hxx" @@ -19,58 +20,59 @@ #include #include -class SALOMEDSImpl_AttributeTableOfString : public SALOMEDSImpl_GenericAttribute +class SALOMEDSIMPL_EXPORT SALOMEDSImpl_AttributeTableOfString : + public SALOMEDSImpl_GenericAttribute { public: -Standard_EXPORT virtual std::string Save(); -Standard_EXPORT virtual void Load(const std::string&); -Standard_EXPORT static const std::string& GetID() ; -Standard_EXPORT static SALOMEDSImpl_AttributeTableOfString* Set(const DF_Label& label) ; -Standard_EXPORT SALOMEDSImpl_AttributeTableOfString(); -Standard_EXPORT void SetNbColumns(const int theNbColumns); -Standard_EXPORT void SetTitle(const std::string& theTitle) ; -Standard_EXPORT std::string GetTitle() const; -Standard_EXPORT void SetRowData(const int theRow,const std::vector& theData) ; -Standard_EXPORT std::vector GetRowData(const int theRow) ; -Standard_EXPORT void SetRowTitle(const int theRow,const std::string& theTitle) ; -Standard_EXPORT void SetRowUnit(const int theRow,const std::string& theUnit) ; -Standard_EXPORT std::string GetRowUnit(const int theRow) const; -Standard_EXPORT void SetRowUnits(const std::vector& theUnits) ; -Standard_EXPORT std::vector GetRowUnits(); -Standard_EXPORT void SetRowTitles(const std::vector& theTitles) ; -Standard_EXPORT std::vector GetRowTitles(); -Standard_EXPORT std::string GetRowTitle(const int theRow) const; -Standard_EXPORT void SetColumnData(const int theColumn,const std::vector& theData) ; -Standard_EXPORT std::vector GetColumnData(const int theColumn) ; -Standard_EXPORT void SetColumnTitle(const int theColumn,const std::string& theTitle) ; -Standard_EXPORT std::string GetColumnTitle(const int theColumn) const; -Standard_EXPORT void SetColumnTitles(const std::vector& theTitles); -Standard_EXPORT std::vector GetColumnTitles(); -Standard_EXPORT int GetNbRows() const; -Standard_EXPORT int GetNbColumns() const; + virtual std::string Save(); + virtual void Load(const std::string&); + static const std::string& GetID() ; + static SALOMEDSImpl_AttributeTableOfString* Set(const DF_Label& label) ; + SALOMEDSImpl_AttributeTableOfString(); + void SetNbColumns(const int theNbColumns); + void SetTitle(const std::string& theTitle) ; + std::string GetTitle() const; + void SetRowData(const int theRow,const std::vector& theData) ; + std::vector GetRowData(const int theRow) ; + void SetRowTitle(const int theRow,const std::string& theTitle) ; + void SetRowUnit(const int theRow,const std::string& theUnit) ; + std::string GetRowUnit(const int theRow) const; + void SetRowUnits(const std::vector& theUnits) ; + std::vector GetRowUnits(); + void SetRowTitles(const std::vector& theTitles) ; + std::vector GetRowTitles(); + std::string GetRowTitle(const int theRow) const; + void SetColumnData(const int theColumn,const std::vector& theData) ; + std::vector GetColumnData(const int theColumn) ; + void SetColumnTitle(const int theColumn,const std::string& theTitle) ; + std::string GetColumnTitle(const int theColumn) const; + void SetColumnTitles(const std::vector& theTitles); + std::vector GetColumnTitles(); + int GetNbRows() const; + int GetNbColumns() const; -Standard_EXPORT void PutValue(const std::string& theValue,const int theRow,const int theColumn) ; -Standard_EXPORT bool HasValue(const int theRow,const int theColumn) ; -Standard_EXPORT std::string GetValue(const int theRow,const int theColumn) ; -Standard_EXPORT const std::string& ID() const; -Standard_EXPORT void Restore(DF_Attribute* with) ; -Standard_EXPORT DF_Attribute* NewEmpty() const; -Standard_EXPORT void Paste(DF_Attribute* into); + void PutValue(const std::string& theValue,const int theRow,const int theColumn) ; + bool HasValue(const int theRow,const int theColumn) ; + std::string GetValue(const int theRow,const int theColumn) ; + const std::string& ID() const; + void Restore(DF_Attribute* with) ; + DF_Attribute* NewEmpty() const; + void Paste(DF_Attribute* into); -Standard_EXPORT std::vector GetSetRowIndices(const int theRow); -Standard_EXPORT std::vector GetSetColumnIndices(const int theColumn); + std::vector GetSetRowIndices(const int theRow); + std::vector GetSetColumnIndices(const int theColumn); -Standard_EXPORT ~SALOMEDSImpl_AttributeTableOfString() {} + ~SALOMEDSImpl_AttributeTableOfString() {} private: -std::map myTable; -std::string myTitle; -std::vector myRows; -std::vector myCols; -int myNbRows; -int myNbColumns; + std::map myTable; + std::string myTitle; + std::vector myRows; + std::vector myCols; + int myNbRows; + int myNbColumns; }; diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTarget.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTarget.hxx index 5c4bb4f71..ea3663759 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTarget.hxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTarget.hxx @@ -24,33 +24,35 @@ #ifndef _SALOMEDSImpl_AttributeTarget_HeaderFile #define _SALOMEDSImpl_AttributeTarget_HeaderFile +#include "SALOMEDSImpl_Defines.hxx" #include "DF_Attribute.hxx" #include "DF_Label.hxx" #include #include "SALOMEDSImpl_GenericAttribute.hxx" #include "SALOMEDSImpl_SObject.hxx" -class SALOMEDSImpl_AttributeTarget : public SALOMEDSImpl_GenericAttribute +class SALOMEDSIMPL_EXPORT SALOMEDSImpl_AttributeTarget : + public SALOMEDSImpl_GenericAttribute { private: -std::string myRelation; -std::vector myVariables; + std::string myRelation; + std::vector myVariables; public: -Standard_EXPORT static const std::string& GetID() ; -Standard_EXPORT static SALOMEDSImpl_AttributeTarget* Set(const DF_Label& label) ; -Standard_EXPORT SALOMEDSImpl_AttributeTarget(); -Standard_EXPORT void Add(const SALOMEDSImpl_SObject& theSO); -Standard_EXPORT std::vector Get(); -Standard_EXPORT void Remove(const SALOMEDSImpl_SObject& theSO); -Standard_EXPORT std::string GetRelation() { return myRelation; } -Standard_EXPORT void SetRelation(const std::string& theRelation); -Standard_EXPORT std::vector& GetVariables() { return myVariables; } -Standard_EXPORT const std::string& ID() const; -Standard_EXPORT void Restore(DF_Attribute* with) ; -Standard_EXPORT DF_Attribute* NewEmpty() const; -Standard_EXPORT void Paste(DF_Attribute* into); -Standard_EXPORT ~SALOMEDSImpl_AttributeTarget() {} + static const std::string& GetID() ; + static SALOMEDSImpl_AttributeTarget* Set(const DF_Label& label) ; + SALOMEDSImpl_AttributeTarget(); + void Add(const SALOMEDSImpl_SObject& theSO); + std::vector Get(); + void Remove(const SALOMEDSImpl_SObject& theSO); + std::string GetRelation() { return myRelation; } + void SetRelation(const std::string& theRelation); + std::vector& GetVariables() { return myVariables; } + const std::string& ID() const; + void Restore(DF_Attribute* with) ; + DF_Attribute* NewEmpty() const; + void Paste(DF_Attribute* into); + ~SALOMEDSImpl_AttributeTarget() {} }; diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTextColor.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTextColor.hxx index a0e9f50d7..477cda6c1 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTextColor.hxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTextColor.hxx @@ -24,30 +24,32 @@ #ifndef _SALOMEDSImpl_AttributeTextColor_HeaderFile #define _SALOMEDSImpl_AttributeTextColor_HeaderFile +#include "SALOMEDSImpl_Defines.hxx" #include "DF_Attribute.hxx" #include "DF_Label.hxx" #include #include #include "SALOMEDSImpl_GenericAttribute.hxx" -class SALOMEDSImpl_AttributeTextColor : public SALOMEDSImpl_GenericAttribute +class SALOMEDSIMPL_EXPORT SALOMEDSImpl_AttributeTextColor : + public SALOMEDSImpl_GenericAttribute { private: std::vector myValue; public: -Standard_EXPORT virtual std::string Save(); -Standard_EXPORT virtual void Load(const std::string&); -Standard_EXPORT static const std::string& GetID() ; -Standard_EXPORT SALOMEDSImpl_AttributeTextColor(); -Standard_EXPORT const std::string& ID() const; -Standard_EXPORT void SetTextColor(const double& R, const double& G, const double& B); -Standard_EXPORT std::vector TextColor(); -Standard_EXPORT void ChangeArray(const std::vector& newArray); -Standard_EXPORT void Restore(DF_Attribute* with) ; -Standard_EXPORT DF_Attribute* NewEmpty() const; -Standard_EXPORT void Paste( DF_Attribute* into); -Standard_EXPORT ~SALOMEDSImpl_AttributeTextColor() {} + virtual std::string Save(); + virtual void Load(const std::string&); + static const std::string& GetID() ; + SALOMEDSImpl_AttributeTextColor(); + const std::string& ID() const; + void SetTextColor(const double& R, const double& G, const double& B); + std::vector TextColor(); + void ChangeArray(const std::vector& newArray); + void Restore(DF_Attribute* with) ; + DF_Attribute* NewEmpty() const; + void Paste( DF_Attribute* into); + ~SALOMEDSImpl_AttributeTextColor() {} }; diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTextHighlightColor.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTextHighlightColor.hxx index d17e7f29c..017af2394 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTextHighlightColor.hxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTextHighlightColor.hxx @@ -24,6 +24,7 @@ #ifndef _SALOMEDSImpl_AttributeTextHighlightColor_HeaderFile #define _SALOMEDSImpl_AttributeTextHighlightColor_HeaderFile +#include "SALOMEDSImpl_Defines.hxx" #include "DF_Attribute.hxx" #include "DF_Label.hxx" #include @@ -31,24 +32,25 @@ #include "SALOMEDSImpl_GenericAttribute.hxx" -class SALOMEDSImpl_AttributeTextHighlightColor : public SALOMEDSImpl_GenericAttribute +class SALOMEDSIMPL_EXPORT SALOMEDSImpl_AttributeTextHighlightColor : + public SALOMEDSImpl_GenericAttribute { private: std::vector myValue; public: -Standard_EXPORT virtual std::string Save(); -Standard_EXPORT virtual void Load(const std::string&); -Standard_EXPORT static const std::string& GetID() ; -Standard_EXPORT SALOMEDSImpl_AttributeTextHighlightColor(); -Standard_EXPORT void SetTextHighlightColor(const double& R, const double& G, const double& B); -Standard_EXPORT std::vector TextHighlightColor(); -Standard_EXPORT void ChangeArray(const std::vector& newArray); -Standard_EXPORT const std::string& ID() const; -Standard_EXPORT void Restore(DF_Attribute* with) ; -Standard_EXPORT DF_Attribute* NewEmpty() const; -Standard_EXPORT void Paste(DF_Attribute* into); -Standard_EXPORT ~SALOMEDSImpl_AttributeTextHighlightColor() {} + virtual std::string Save(); + virtual void Load(const std::string&); + static const std::string& GetID() ; + SALOMEDSImpl_AttributeTextHighlightColor(); + void SetTextHighlightColor(const double& R, const double& G, const double& B); + std::vector TextHighlightColor(); + void ChangeArray(const std::vector& newArray); + const std::string& ID() const; + void Restore(DF_Attribute* with) ; + DF_Attribute* NewEmpty() const; + void Paste(DF_Attribute* into); + ~SALOMEDSImpl_AttributeTextHighlightColor() {} }; #endif diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTreeNode.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTreeNode.hxx index 88d6a6b0d..8555b1bb0 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTreeNode.hxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTreeNode.hxx @@ -24,71 +24,73 @@ #ifndef _SALOMEDSImpl_AttributeTreeNode_HeaderFile #define _SALOMEDSImpl_AttributeTreeNode_HeaderFile +#include "SALOMEDSImpl_Defines.hxx" #include "DF_Attribute.hxx" #include "DF_Label.hxx" #include #include "SALOMEDSImpl_GenericAttribute.hxx" -class SALOMEDSImpl_AttributeTreeNode : public SALOMEDSImpl_GenericAttribute +class SALOMEDSIMPL_EXPORT SALOMEDSImpl_AttributeTreeNode : + public SALOMEDSImpl_GenericAttribute { public: -Standard_EXPORT const static std::string& GetDefaultTreeID(); -Standard_EXPORT static SALOMEDSImpl_AttributeTreeNode* Set(const DF_Label& L, const std::string& ID); - -Standard_EXPORT SALOMEDSImpl_AttributeTreeNode(); -Standard_EXPORT void SetFather(const SALOMEDSImpl_AttributeTreeNode* value); -Standard_EXPORT void SetPrevious(const SALOMEDSImpl_AttributeTreeNode* value); -Standard_EXPORT void SetNext(const SALOMEDSImpl_AttributeTreeNode* value); -Standard_EXPORT void SetFirst(const SALOMEDSImpl_AttributeTreeNode* value); -Standard_EXPORT void SetTreeID(const std::string& value); - -Standard_EXPORT bool Append(SALOMEDSImpl_AttributeTreeNode* value); -Standard_EXPORT bool Prepend(SALOMEDSImpl_AttributeTreeNode* value); -Standard_EXPORT bool Remove(); -Standard_EXPORT bool InsertBefore(SALOMEDSImpl_AttributeTreeNode* value); -Standard_EXPORT bool InsertAfter(SALOMEDSImpl_AttributeTreeNode* value); - -Standard_EXPORT SALOMEDSImpl_AttributeTreeNode* GetFather() const { return myFather; } -Standard_EXPORT SALOMEDSImpl_AttributeTreeNode* GetPrevious() const { return myPrevious; } -Standard_EXPORT SALOMEDSImpl_AttributeTreeNode* GetNext() const { return myNext; } -Standard_EXPORT SALOMEDSImpl_AttributeTreeNode* GetFirst() const { return myFirst; } - -Standard_EXPORT bool HasFather() { return (myFather); } -Standard_EXPORT bool HasPrevious() { return (myPrevious); } -Standard_EXPORT bool HasNext() {return (myNext); } -Standard_EXPORT bool HasFirst() { return (myFirst); } -Standard_EXPORT const std::string& GetTreeID() { return ID(); } -Standard_EXPORT int Depth() const; -Standard_EXPORT bool IsRoot() const ; -Standard_EXPORT SALOMEDSImpl_AttributeTreeNode* Root() const; -Standard_EXPORT bool IsAscendant (const SALOMEDSImpl_AttributeTreeNode* ofTN) const; -Standard_EXPORT bool IsDescendant(const SALOMEDSImpl_AttributeTreeNode* value) const; -Standard_EXPORT bool IsFather(const SALOMEDSImpl_AttributeTreeNode* value) const; -Standard_EXPORT bool IsChild(const SALOMEDSImpl_AttributeTreeNode* value) const; - -Standard_EXPORT virtual std::string Save(); -Standard_EXPORT virtual void Load(const std::string&); -Standard_EXPORT virtual std::string Type(); - -Standard_EXPORT const std::string& ID() const; -Standard_EXPORT void Restore(DF_Attribute* with) ; -Standard_EXPORT void Paste(DF_Attribute* into); -Standard_EXPORT DF_Attribute* NewEmpty() const; -Standard_EXPORT ~SALOMEDSImpl_AttributeTreeNode() {;} - -Standard_EXPORT virtual void AfterAddition(); -Standard_EXPORT virtual void BeforeForget(); + const static std::string& GetDefaultTreeID(); + static SALOMEDSImpl_AttributeTreeNode* Set(const DF_Label& L, const std::string& ID); + + SALOMEDSImpl_AttributeTreeNode(); + void SetFather(const SALOMEDSImpl_AttributeTreeNode* value); + void SetPrevious(const SALOMEDSImpl_AttributeTreeNode* value); + void SetNext(const SALOMEDSImpl_AttributeTreeNode* value); + void SetFirst(const SALOMEDSImpl_AttributeTreeNode* value); + void SetTreeID(const std::string& value); + + bool Append(SALOMEDSImpl_AttributeTreeNode* value); + bool Prepend(SALOMEDSImpl_AttributeTreeNode* value); + bool Remove(); + bool InsertBefore(SALOMEDSImpl_AttributeTreeNode* value); + bool InsertAfter(SALOMEDSImpl_AttributeTreeNode* value); + + SALOMEDSImpl_AttributeTreeNode* GetFather() const { return myFather; } + SALOMEDSImpl_AttributeTreeNode* GetPrevious() const { return myPrevious; } + SALOMEDSImpl_AttributeTreeNode* GetNext() const { return myNext; } + SALOMEDSImpl_AttributeTreeNode* GetFirst() const { return myFirst; } + + bool HasFather() { return (myFather); } + bool HasPrevious() { return (myPrevious); } + bool HasNext() {return (myNext); } + bool HasFirst() { return (myFirst); } + const std::string& GetTreeID() { return ID(); } + int Depth() const; + bool IsRoot() const ; + SALOMEDSImpl_AttributeTreeNode* Root() const; + bool IsAscendant (const SALOMEDSImpl_AttributeTreeNode* ofTN) const; + bool IsDescendant(const SALOMEDSImpl_AttributeTreeNode* value) const; + bool IsFather(const SALOMEDSImpl_AttributeTreeNode* value) const; + bool IsChild(const SALOMEDSImpl_AttributeTreeNode* value) const; + + virtual std::string Save(); + virtual void Load(const std::string&); + virtual std::string Type(); + + const std::string& ID() const; + void Restore(DF_Attribute* with) ; + void Paste(DF_Attribute* into); + DF_Attribute* NewEmpty() const; + ~SALOMEDSImpl_AttributeTreeNode() {;} + + virtual void AfterAddition(); + virtual void BeforeForget(); private: -std::string myTreeID; -SALOMEDSImpl_AttributeTreeNode* myFather; -SALOMEDSImpl_AttributeTreeNode* myPrevious; -SALOMEDSImpl_AttributeTreeNode* myNext; -SALOMEDSImpl_AttributeTreeNode* myFirst; + std::string myTreeID; + SALOMEDSImpl_AttributeTreeNode* myFather; + SALOMEDSImpl_AttributeTreeNode* myPrevious; + SALOMEDSImpl_AttributeTreeNode* myNext; + SALOMEDSImpl_AttributeTreeNode* myFirst; -friend class SALOMEDSImpl_ChildNodeIterator; + friend class SALOMEDSImpl_ChildNodeIterator; }; diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeUserID.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeUserID.hxx index 8d3ab95ac..5bf9b27c3 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeUserID.hxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeUserID.hxx @@ -24,36 +24,38 @@ #ifndef _SALOMEDSImpl_AttributeUserID_HeaderFile #define _SALOMEDSImpl_AttributeUserID_HeaderFile +#include "SALOMEDSImpl_Defines.hxx" #include "DF_Attribute.hxx" #include "DF_Label.hxx" #include #include "SALOMEDSImpl_GenericAttribute.hxx" -class SALOMEDSImpl_AttributeUserID : public SALOMEDSImpl_GenericAttribute +class SALOMEDSIMPL_EXPORT SALOMEDSImpl_AttributeUserID : + public SALOMEDSImpl_GenericAttribute { private: -std::string myID; + std::string myID; public: -SALOMEDSImpl_AttributeUserID():SALOMEDSImpl_GenericAttribute("AttributeUserID") {} -static SALOMEDSImpl_AttributeUserID* Set (const DF_Label& L, const std::string& ID); -static const std::string& DefaultID() -{ - static std::string SALOMEDSImpl_DefaultUserAttributeID ("FFFFFFFF-D9CD-11d6-945D-1050DA506788"); - return SALOMEDSImpl_DefaultUserAttributeID; -} - -Standard_EXPORT const std::string& Value() const { return ID(); } -Standard_EXPORT void SetValue(const std::string& value); - -Standard_EXPORT virtual std::string Type(); - -Standard_EXPORT const std::string& ID() const; -Standard_EXPORT void Restore(DF_Attribute* with) ; -Standard_EXPORT DF_Attribute* NewEmpty() const; -Standard_EXPORT void Paste(DF_Attribute* into); -Standard_EXPORT ~SALOMEDSImpl_AttributeUserID() {} + SALOMEDSImpl_AttributeUserID():SALOMEDSImpl_GenericAttribute("AttributeUserID") {} + static SALOMEDSImpl_AttributeUserID* Set (const DF_Label& L, const std::string& ID); + static const std::string& DefaultID() + { + static std::string SALOMEDSImpl_DefaultUserAttributeID ("FFFFFFFF-D9CD-11d6-945D-1050DA506788"); + return SALOMEDSImpl_DefaultUserAttributeID; + } + + const std::string& Value() const { return ID(); } + void SetValue(const std::string& value); + + virtual std::string Type(); + + const std::string& ID() const; + void Restore(DF_Attribute* with) ; + DF_Attribute* NewEmpty() const; + void Paste(DF_Attribute* into); + ~SALOMEDSImpl_AttributeUserID() {} }; diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_Attributes.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_Attributes.hxx index ff366e786..895bae5ea 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_Attributes.hxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_Attributes.hxx @@ -24,15 +24,7 @@ #ifndef __SALOMEDSIMPL_ATTRIBUTES__H__ #define __SALOMEDSIMPL_ATTRIBUTES__H__ -#ifdef WNT -# ifdef SALOMEDSIMPL_EXPORTS -# define SALOMEDSIMPL_EXPORT __declspec( dllexport ) -# else -# define SALOMEDSIMPL_EXPORT __declspec( dllimport ) -# endif -#else -# define SALOMEDSIMPL_EXPORT -#endif +#include "SALOMEDSImpl_Defines.hxx" #include class SALOMEDSIMPL_EXPORT LockProtection diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_Callback.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_Callback.hxx index 313d1d305..22ae44b6c 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_Callback.hxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_Callback.hxx @@ -24,30 +24,30 @@ #ifndef __SALOMEDSIMPL_CALLBACK_H__ #define __SALOMEDSIMPL_CALLBACK_H__ - +#include "SALOMEDSImpl_Defines.hxx" #include "SALOMEDSImpl_UseCaseBuilder.hxx" -class SALOMEDSImpl_Callback +class SALOMEDSIMPL_EXPORT SALOMEDSImpl_Callback { private: SALOMEDSImpl_UseCaseBuilder* _builder; public: - SALOMEDSImpl_Callback(SALOMEDSImpl_UseCaseBuilder* builder) - { - _builder = builder; - } + SALOMEDSImpl_Callback(SALOMEDSImpl_UseCaseBuilder* builder) + { + _builder = builder; + } - virtual void OnAddSObject(const SALOMEDSImpl_SObject& theObject) - { - if(_builder != NULL && theObject) _builder->Append(theObject); - } + virtual void OnAddSObject(const SALOMEDSImpl_SObject& theObject) + { + if(_builder != NULL && theObject) _builder->Append(theObject); + } - virtual void OnRemoveSObject(const SALOMEDSImpl_SObject& theObject) - { - if(_builder != NULL && theObject) _builder->Remove(theObject); - } + virtual void OnRemoveSObject(const SALOMEDSImpl_SObject& theObject) + { + if(_builder != NULL && theObject) _builder->Remove(theObject); + } }; diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_ChildIterator.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_ChildIterator.hxx index e3c50b9b0..9e3d5b568 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_ChildIterator.hxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_ChildIterator.hxx @@ -24,12 +24,12 @@ #ifndef __SALOMEDSImpl_CHILDITERATOR_H__ #define __SALOMEDSImpl_CHILDITERATOR_H__ - +#include "SALOMEDSImpl_Defines.hxx" #include "SALOMEDSImpl_SObject.hxx" #include "DF_ChildIterator.hxx" #include "DF_Label.hxx" -class SALOMEDSImpl_ChildIterator +class SALOMEDSIMPL_EXPORT SALOMEDSImpl_ChildIterator { private: DF_ChildIterator _it; @@ -37,20 +37,20 @@ private: public: - Standard_EXPORT SALOMEDSImpl_ChildIterator() {} - Standard_EXPORT SALOMEDSImpl_ChildIterator(const SALOMEDSImpl_SObject& theSO); - Standard_EXPORT SALOMEDSImpl_ChildIterator(const DF_Label& theLabel); - Standard_EXPORT ~SALOMEDSImpl_ChildIterator() {}; - - Standard_EXPORT virtual void Init(); - Standard_EXPORT virtual void Init(const DF_Label& theLabel); - Standard_EXPORT virtual void InitEx(bool theAllLevels); - Standard_EXPORT virtual void InitEx(const DF_Label& theLabel, bool theAllLevels); - Standard_EXPORT virtual bool More(); - Standard_EXPORT virtual void Next(); - Standard_EXPORT virtual SALOMEDSImpl_SObject Value(); - Standard_EXPORT virtual DF_Label Label(); - - Standard_EXPORT SALOMEDSImpl_ChildIterator* GetPersistentCopy() const; + SALOMEDSImpl_ChildIterator() {} + SALOMEDSImpl_ChildIterator(const SALOMEDSImpl_SObject& theSO); + SALOMEDSImpl_ChildIterator(const DF_Label& theLabel); + ~SALOMEDSImpl_ChildIterator() {}; + + virtual void Init(); + virtual void Init(const DF_Label& theLabel); + virtual void InitEx(bool theAllLevels); + virtual void InitEx(const DF_Label& theLabel, bool theAllLevels); + virtual bool More(); + virtual void Next(); + virtual SALOMEDSImpl_SObject Value(); + virtual DF_Label Label(); + + SALOMEDSImpl_ChildIterator* GetPersistentCopy() const; }; #endif diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_ChildNodeIterator.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_ChildNodeIterator.hxx index 21651a4e7..452a60f84 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_ChildNodeIterator.hxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_ChildNodeIterator.hxx @@ -21,27 +21,28 @@ #ifndef _SALOMEDSImpl_ChildNodeIterator_HeaderFile #define _SALOMEDSImpl_ChildNodeIterator_HeaderFile +#include "SALOMEDSImpl_Defines.hxx" #include "SALOMEDSImpl_AttributeTreeNode.hxx" -class SALOMEDSImpl_ChildNodeIterator +class SALOMEDSIMPL_EXPORT SALOMEDSImpl_ChildNodeIterator { public: -Standard_EXPORT SALOMEDSImpl_ChildNodeIterator(); -Standard_EXPORT SALOMEDSImpl_ChildNodeIterator(const SALOMEDSImpl_AttributeTreeNode* aTreeNode, - const bool allLevels = false); -Standard_EXPORT void Initialize(const SALOMEDSImpl_AttributeTreeNode* aTreeNode, - const bool allLevels = false) ; -Standard_EXPORT bool More() const { return (myNode); } -Standard_EXPORT void Next() ; -Standard_EXPORT void NextBrother() ; -Standard_EXPORT SALOMEDSImpl_AttributeTreeNode* Value() const { return myNode; } + SALOMEDSImpl_ChildNodeIterator(); + SALOMEDSImpl_ChildNodeIterator(const SALOMEDSImpl_AttributeTreeNode* aTreeNode, + const bool allLevels = false); + void Initialize(const SALOMEDSImpl_AttributeTreeNode* aTreeNode, + const bool allLevels = false) ; + bool More() const { return (myNode); } + void Next() ; + void NextBrother() ; + SALOMEDSImpl_AttributeTreeNode* Value() const { return myNode; } private: -SALOMEDSImpl_AttributeTreeNode* myNode; -int myFirstLevel; + SALOMEDSImpl_AttributeTreeNode* myNode; + int myFirstLevel; }; diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_Defines.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_Defines.hxx new file mode 100755 index 000000000..ddd99cda6 --- /dev/null +++ b/src/SALOMEDSImpl/SALOMEDSImpl_Defines.hxx @@ -0,0 +1,39 @@ +// Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SALOMEDSImpl_Defines.hxx +// Author : Alexander A. BORODIN +// Module : KERNEL + +#ifndef _SALOMEDSImpl_Defines_HXX_ +#define _SALOMEDSImpl_Defines_HXX_ + +#ifdef WIN32 +# if defined SALOMEDSIMPL_EXPORTS +# define SALOMEDSIMPL_EXPORT __declspec( dllexport ) +# else +# define SALOMEDSIMPL_EXPORT __declspec( dllimport ) +# endif +#else +# define SALOMEDSIMPL_EXPORT +#endif + +#endif diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_Driver.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_Driver.hxx index 88fac75f5..a6ea569fe 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_Driver.hxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_Driver.hxx @@ -20,78 +20,79 @@ #ifndef __SALOMEDSIMPL_DRIVER_H__ #define __SALOMEDSIMPL_DRIVER_H__ +#include "SALOMEDSImpl_Defines.hxx" #include -#include -#include -#include +#include "SALOMEDSImpl_SComponent.hxx" +#include "SALOMEDSImpl_SObject.hxx" +#include "SALOMEDSImpl_TMPFile.hxx" -class SALOMEDSImpl_Driver +class SALOMEDSIMPL_EXPORT SALOMEDSImpl_Driver { public: virtual std::string GetIOR() = 0; virtual SALOMEDSImpl_TMPFile* Save(const SALOMEDSImpl_SComponent& theComponent, - const std::string& theURL, - long& theStreamLength, - bool isMultiFile) = 0; + const std::string& theURL, + long& theStreamLength, + bool isMultiFile) = 0; virtual SALOMEDSImpl_TMPFile* SaveASCII(const SALOMEDSImpl_SComponent& theComponent, - const std::string& theURL, - long& theStreamLength, - bool isMultiFile) = 0; - + const std::string& theURL, + long& theStreamLength, + bool isMultiFile) = 0; + virtual bool Load(const SALOMEDSImpl_SComponent& theComponent, - const unsigned char* theStream, - const long theStreamLength, - const std::string& theURL, - bool isMultiFile) = 0; + const unsigned char* theStream, + const long theStreamLength, + const std::string& theURL, + bool isMultiFile) = 0; virtual bool LoadASCII(const SALOMEDSImpl_SComponent& theComponent, - const unsigned char* theStream, - const long theStreamLength, - const std::string& theURL, - bool isMultiFile) = 0; + const unsigned char* theStream, + const long theStreamLength, + const std::string& theURL, + bool isMultiFile) = 0; virtual void Close(const SALOMEDSImpl_SComponent& theComponent) = 0; - + virtual std::string ComponentDataType() = 0; virtual std::string IORToLocalPersistentID(const SALOMEDSImpl_SObject& theSObject, - const std::string& IORString, - bool isMultiFile, - bool isASCII) = 0; + const std::string& IORString, + bool isMultiFile, + bool isASCII) = 0; virtual std::string LocalPersistentIDToIOR(const SALOMEDSImpl_SObject& theSObject, - const std::string& aLocalPersistentID, - bool isMultiFile, - bool isASCII) = 0; + const std::string& aLocalPersistentID, + bool isMultiFile, + bool isASCII) = 0; virtual bool CanCopy(const SALOMEDSImpl_SObject& theObject) = 0; virtual SALOMEDSImpl_TMPFile* CopyFrom(const SALOMEDSImpl_SObject& theObject, - int& theObjectID, - long& theStreamLength) = 0; - + int& theObjectID, + long& theStreamLength) = 0; + virtual bool CanPaste(const std::string& theComponentName, int theObjectID) = 0; virtual std::string PasteInto(const unsigned char* theStream, - const long theStreamLength, - int theObjectID, - const SALOMEDSImpl_SObject& theObject) = 0; + const long theStreamLength, + int theObjectID, + const SALOMEDSImpl_SObject& theObject) = 0; virtual SALOMEDSImpl_TMPFile* DumpPython(SALOMEDSImpl_Study* theStudy, - bool isPublished, - bool& isValidScript, - long& theStreamLength) = 0; + bool isPublished, + bool& isValidScript, + long& theStreamLength) = 0; }; class SALOMEDSImpl_DriverFactory { public: - + virtual SALOMEDSImpl_Driver* GetDriverByType(const std::string& theComponentType) = 0; virtual SALOMEDSImpl_Driver* GetDriverByIOR(const std::string& theIOR) = 0; diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_GenericAttribute.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_GenericAttribute.cxx index 168645bb0..37caac3fb 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_GenericAttribute.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_GenericAttribute.cxx @@ -28,16 +28,22 @@ using namespace std; -char* SALOMEDSImpl_GenericAttribute::Impl_GetType(DF_Attribute* theAttr) +string SALOMEDSImpl_GenericAttribute::Impl_GetType(DF_Attribute* theAttr) { SALOMEDSImpl_GenericAttribute* ga = dynamic_cast(theAttr); - return (char*)ga->Type().c_str(); + if (ga) + return ga->Type(); + + return ""; } -char* SALOMEDSImpl_GenericAttribute::Impl_GetClassType(DF_Attribute* theAttr) +string SALOMEDSImpl_GenericAttribute::Impl_GetClassType(DF_Attribute* theAttr) { SALOMEDSImpl_GenericAttribute* ga = dynamic_cast(theAttr); - return (char*)ga->GetClassType().c_str(); + if (ga) + return ga->GetClassType(); + + return ""; } void SALOMEDSImpl_GenericAttribute::Impl_CheckLocked(DF_Attribute* theAttr) diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_GenericAttribute.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_GenericAttribute.hxx index 345e0fd64..0fcdb3f5c 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_GenericAttribute.hxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_GenericAttribute.hxx @@ -24,13 +24,15 @@ #ifndef _GENERICIMPL_ATTRIBUTE_HXX_ #define _GENERICIMPL_ATTRIBUTE_HXX_ +#include "SALOMEDSImpl_Defines.hxx" #include "DF_Label.hxx" #include "DF_Attribute.hxx" #include #include "SALOMEDSImpl_SObject.hxx" -class SALOMEDSImpl_GenericAttribute: public DF_Attribute +class SALOMEDSIMPL_EXPORT SALOMEDSImpl_GenericAttribute: + public DF_Attribute { protected: @@ -38,19 +40,19 @@ protected: public: -Standard_EXPORT SALOMEDSImpl_GenericAttribute(const std::string& theType) -:_type(theType) -{} + SALOMEDSImpl_GenericAttribute(const std::string& theType) + :_type(theType) + {} -Standard_EXPORT virtual std::string Type(); -Standard_EXPORT virtual void CheckLocked(); -Standard_EXPORT std::string GetClassType() { return _type; } -Standard_EXPORT SALOMEDSImpl_SObject GetSObject(); -Standard_EXPORT void SetModifyFlag(); + virtual std::string Type(); + virtual void CheckLocked(); + std::string GetClassType() { return _type; } + SALOMEDSImpl_SObject GetSObject(); + void SetModifyFlag(); -Standard_EXPORT static char* Impl_GetType(DF_Attribute* theAttr); -Standard_EXPORT static char* Impl_GetClassType(DF_Attribute* theAttr); -Standard_EXPORT static void Impl_CheckLocked(DF_Attribute* theAttr); + static std::string Impl_GetType(DF_Attribute* theAttr); + static std::string Impl_GetClassType(DF_Attribute* theAttr); + static void Impl_CheckLocked(DF_Attribute* theAttr); }; diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_IParameters.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_IParameters.hxx index a197b28ef..69d8beaef 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_IParameters.hxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_IParameters.hxx @@ -19,6 +19,7 @@ #ifndef SALOMEDSImpl_IParameters_H #define SALOMEDSImpl_IParameters_H +#include "SALOMEDSImpl_Defines.hxx" #include #include #include @@ -27,9 +28,9 @@ #include "SALOMEDSImpl_Study.hxx" /*! - Class which an interface to store the parameters of the objects +Class which an interface to store the parameters of the objects */ -class Standard_EXPORT SALOMEDSImpl_IParameters +class SALOMEDSIMPL_EXPORT SALOMEDSImpl_IParameters { public: SALOMEDSImpl_IParameters(SALOMEDSImpl_AttributeParameter* ap); @@ -37,109 +38,109 @@ public: virtual ~SALOMEDSImpl_IParameters(); /*! - Appends a string value to a named list. - Returns a number of the added value. - Note: the name of the list MUST be unique - */ + Appends a string value to a named list. + Returns a number of the added value. + Note: the name of the list MUST be unique + */ virtual int append(const std::string& listName, const std::string& value); /*! - Returns a number elements in the list - */ + Returns a number elements in the list + */ virtual int nbValues(const std::string& listName); /*! - Returns a list of values in the list - */ + Returns a list of values in the list + */ virtual std::vector getValues(const std::string& listName); /*! - Returns a value with given %index, where %index is in range [0:nbValues-1] - */ + Returns a value with given %index, where %index is in range [0:nbValues-1] + */ virtual std::string getValue(const std::string& listName, int index); /*! - Returns a list all entries lists - */ + Returns a list all entries lists + */ virtual std::vector getLists(); /*! - Sets a new named parameter value for the given entry - */ + Sets a new named parameter value for the given entry + */ virtual void setParameter(const std::string& entry, const std::string& parameterName, const std::string& value); /*! - Gets a named parameter value for the given entry - */ + Gets a named parameter value for the given entry + */ virtual std::string getParameter(const std::string& entry, const std::string& parameterName); /*! - Returns all parameter names of the given entry - */ + Returns all parameter names of the given entry + */ virtual std::vector getAllParameterNames(const std::string& entry); /*! - Returns all parameter values of the given entry - */ + Returns all parameter values of the given entry + */ virtual std::vector getAllParameterValues(const std::string& entry); /*! - Returns a number of parameters of the given entry - */ + Returns a number of parameters of the given entry + */ virtual int getNbParameters(const std::string& entry); /*! - Returns a list all entries - */ + Returns a list all entries + */ virtual std::vector getEntries(); /*! - Sets a global named property value - */ + Sets a global named property value + */ virtual void setProperty(const std::string& name, const std::string& value); /*! - Gets a value of global named property - */ + Gets a value of global named property + */ virtual std::string getProperty(const std::string& name); /*! - Returns a list all properties - */ + Returns a list all properties + */ virtual std::vector getProperties(); /*! - Returns decoded entry that is an absolute entry - */ + Returns decoded entry that is an absolute entry + */ virtual std::string decodeEntry(const std::string& entry); /*! - Returns whether there is the dumping visual parameters - */ + Returns whether there is the dumping visual parameters + */ static bool isDumpPython(SALOMEDSImpl_Study* study, const std::string& theID = ""); /*! - Returns an ID of the last save point + Returns an ID of the last save point */ static int getLastSavePoint(SALOMEDSImpl_Study* study, const std::string& theID = ""); /*! - Returns a Python script for the study, which sets up visual parameters + Returns a Python script for the study, which sets up visual parameters */ static std::string getStudyScript(SALOMEDSImpl_Study* study, int savePoint, const std::string& theID = ""); /*! - Returns a default Python script that set ups visual parameters for the given module - shift is a string that contain spaces to make valid Python script indentaion + Returns a default Python script that set ups visual parameters for the given module + shift is a string that contain spaces to make valid Python script indentaion */ static std::string getDefaultScript(SALOMEDSImpl_Study* study, - const std::string& moduleName, - const std::string& shift, - const std::string& theID = ""); + const std::string& moduleName, + const std::string& shift, + const std::string& theID = ""); /*! - Returns a default name of the component where the visula parameters are stored. + Returns a default name of the component where the visula parameters are stored. */ static std::string getDefaultVisualComponent(); diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_SComponent.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_SComponent.hxx index 1803e537a..ecd8123dc 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_SComponent.hxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_SComponent.hxx @@ -25,33 +25,34 @@ #define __SALOMEDSIMPL_SCOMPONENT_H__ //SALOMEDSImpl headers +#include "SALOMEDSImpl_Defines.hxx" #include "SALOMEDSImpl_SObject.hxx" // std C++ headers #include #include -// Cascade headers #include "DF_Label.hxx" #include "SALOMEDSImpl_SObject.hxx" #include -class SALOMEDSImpl_SComponent : public virtual SALOMEDSImpl_SObject +class SALOMEDSIMPL_EXPORT SALOMEDSImpl_SComponent : + public virtual SALOMEDSImpl_SObject { public: - - Standard_EXPORT SALOMEDSImpl_SComponent(); - Standard_EXPORT SALOMEDSImpl_SComponent(const SALOMEDSImpl_SComponent& theSCO); - Standard_EXPORT SALOMEDSImpl_SComponent(const DF_Label& lab); - - Standard_EXPORT ~SALOMEDSImpl_SComponent(); - - Standard_EXPORT virtual std::string ComponentDataType(); - Standard_EXPORT virtual bool ComponentIOR(std::string& theID); - - Standard_EXPORT static bool IsA(const DF_Label& theLabel); - - Standard_EXPORT SALOMEDSImpl_SComponent* GetPersistentCopy() const; + + SALOMEDSImpl_SComponent(); + SALOMEDSImpl_SComponent(const SALOMEDSImpl_SComponent& theSCO); + SALOMEDSImpl_SComponent(const DF_Label& lab); + + ~SALOMEDSImpl_SComponent(); + + virtual std::string ComponentDataType(); + virtual bool ComponentIOR(std::string& theID); + + static bool IsA(const DF_Label& theLabel); + + SALOMEDSImpl_SComponent* GetPersistentCopy() const; }; #endif diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_SComponentIterator.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_SComponentIterator.hxx index 1194fc191..ec4386e48 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_SComponentIterator.hxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_SComponentIterator.hxx @@ -26,15 +26,15 @@ //SALOMEDSImpl headers +#include "SALOMEDSImpl_Defines.hxx" #include "SALOMEDSImpl_SComponent.hxx" -// Cascade headers #include "DF_ChildIterator.hxx" #include "DF_Label.hxx" #include "DF_Document.hxx" #include -class Standard_EXPORT SALOMEDSImpl_SComponentIterator +class SALOMEDSIMPL_EXPORT SALOMEDSImpl_SComponentIterator { private: @@ -42,7 +42,7 @@ private: DF_Label _lab; public: - + SALOMEDSImpl_SComponentIterator(const SALOMEDSImpl_SComponentIterator& theIterator) { _it = theIterator._it; @@ -50,11 +50,11 @@ public: } SALOMEDSImpl_SComponentIterator() {}; - + SALOMEDSImpl_SComponentIterator(DF_Document* theDocument); - + ~SALOMEDSImpl_SComponentIterator() {}; - + virtual void Init(); virtual bool More(); virtual void Next(); diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_SObject.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_SObject.hxx index e77436c81..9a718d3d7 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_SObject.hxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_SObject.hxx @@ -24,6 +24,8 @@ #ifndef __SALOMEDSIMPL_SOBJECT_H__ #define __SALOMEDSIMPL_SOBJECT_H__ +#include "SALOMEDSImpl_Defines.hxx" + #include "DF_Label.hxx" #include "DF_Attribute.hxx" #include @@ -33,7 +35,7 @@ class SALOMEDSImpl_SComponent; class SALOMEDSImpl_Study; -class SALOMEDSImpl_SObject +class SALOMEDSIMPL_EXPORT SALOMEDSImpl_SObject { protected: DF_Label _lab; @@ -42,45 +44,45 @@ protected: std::string _type; public: - - Standard_EXPORT SALOMEDSImpl_SObject(); - Standard_EXPORT SALOMEDSImpl_SObject(const DF_Label& theLabel); - Standard_EXPORT SALOMEDSImpl_SObject(const SALOMEDSImpl_SObject& theSObject); - Standard_EXPORT virtual ~SALOMEDSImpl_SObject(); - - Standard_EXPORT virtual std::string GetID() const; - Standard_EXPORT virtual SALOMEDSImpl_SComponent GetFatherComponent() const; - Standard_EXPORT virtual SALOMEDSImpl_SObject GetFather() const ; - Standard_EXPORT virtual bool FindAttribute(DF_Attribute*& theAttribute, const std::string& theTypeOfAttribute) const; - Standard_EXPORT virtual bool ReferencedObject(SALOMEDSImpl_SObject& theObject) const ; - Standard_EXPORT virtual bool FindSubObject(int theTag, SALOMEDSImpl_SObject& theObject); - Standard_EXPORT virtual SALOMEDSImpl_Study* GetStudy() const; - Standard_EXPORT virtual std::string Name() const { return _name; } - Standard_EXPORT virtual void Name(const std::string& theName) { _name = theName; } - Standard_EXPORT virtual std::vector GetAllAttributes() const; + SALOMEDSImpl_SObject(); + SALOMEDSImpl_SObject(const DF_Label& theLabel); + SALOMEDSImpl_SObject(const SALOMEDSImpl_SObject& theSObject); + virtual ~SALOMEDSImpl_SObject(); + + virtual std::string GetID() const; + virtual SALOMEDSImpl_SComponent GetFatherComponent() const; + virtual SALOMEDSImpl_SObject GetFather() const ; + virtual bool FindAttribute(DF_Attribute*& theAttribute, const std::string& theTypeOfAttribute) const; + virtual bool ReferencedObject(SALOMEDSImpl_SObject& theObject) const ; + virtual bool FindSubObject(int theTag, SALOMEDSImpl_SObject& theObject); + + virtual SALOMEDSImpl_Study* GetStudy() const; + virtual std::string Name() const { return _name; } + virtual void Name(const std::string& theName) { _name = theName; } + virtual std::vector GetAllAttributes() const; + + virtual std::string GetName() const ; + virtual std::string GetComment() const; + virtual std::string GetIOR() const; + + virtual int Tag() const { return _lab.Tag(); } + virtual int Depth() const { return _lab.Depth(); } - Standard_EXPORT virtual std::string GetName() const ; - Standard_EXPORT virtual std::string GetComment() const; - Standard_EXPORT virtual std::string GetIOR() const; + virtual DF_Label GetLabel() const { return _lab; } - Standard_EXPORT virtual int Tag() const { return _lab.Tag(); } - Standard_EXPORT virtual int Depth() const { return _lab.Depth(); } + bool IsNull() const { return _lab.IsNull(); } - Standard_EXPORT virtual DF_Label GetLabel() const { return _lab; } + bool IsComponent() const; - Standard_EXPORT bool IsNull() const { return _lab.IsNull(); } + operator SALOMEDSImpl_SComponent() const; - Standard_EXPORT bool IsComponent() const; + operator bool () const { return !IsNull(); } - Standard_EXPORT operator SALOMEDSImpl_SComponent() const; + SALOMEDSImpl_SObject* GetPersistentCopy() const; - Standard_EXPORT operator bool () const { return !IsNull(); } - - Standard_EXPORT SALOMEDSImpl_SObject* GetPersistentCopy() const; + static std::string GetGUID(const std::string& theTypeOfAttribute); - Standard_EXPORT static std::string GetGUID(const std::string& theTypeOfAttribute); - }; #endif diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_Study.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_Study.hxx index cfddeb627..a28f2d164 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_Study.hxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_Study.hxx @@ -30,12 +30,12 @@ #include #include -// Cascade headers #include "DF_Document.hxx" #include "DF_Label.hxx" #include //SALOMEDSImpl headers +#include "SALOMEDSImpl_Defines.hxx" #include "SALOMEDSImpl_SComponentIterator.hxx" #include "SALOMEDSImpl_SObject.hxx" #include "SALOMEDSImpl_StudyBuilder.hxx" @@ -51,7 +51,7 @@ class SALOMEDSImpl_StudyManager; class SALOMEDSImpl_GenericAttribute; -class SALOMEDSImpl_Study +class SALOMEDSIMPL_EXPORT SALOMEDSImpl_Study { private: std::string _name; @@ -70,194 +70,193 @@ private: std::map _mapOfSO; std::map _mapOfSCO; std::map myIORLabels; - + SALOMEDSImpl_SObject _FindObject(const SALOMEDSImpl_SObject& SO, - const std::string& anObjectName, - bool& _find); - + const std::string& anObjectName, + bool& _find); + SALOMEDSImpl_SObject _FindObjectIOR(const SALOMEDSImpl_SObject& SO, - const std::string& anObjectIOR, - bool& _find); + const std::string& anObjectIOR, + bool& _find); public: - Standard_EXPORT static SALOMEDSImpl_Study* GetStudy(const DF_Label& theLabel); - Standard_EXPORT static SALOMEDSImpl_SObject SObject(const DF_Label& theLabel); - Standard_EXPORT static SALOMEDSImpl_SComponent SComponent(const DF_Label& theLabel); - Standard_EXPORT static void IORUpdated(const SALOMEDSImpl_AttributeIOR* theAttribute); + static SALOMEDSImpl_Study* GetStudy(const DF_Label& theLabel); + static SALOMEDSImpl_SObject SObject(const DF_Label& theLabel); + static SALOMEDSImpl_SComponent SComponent(const DF_Label& theLabel); + static void IORUpdated(const SALOMEDSImpl_AttributeIOR* theAttribute); - //! standard constructor - Standard_EXPORT SALOMEDSImpl_Study(const DF_Document*, const std::string& study_name); + //! standard constructor + SALOMEDSImpl_Study(const DF_Document*, const std::string& study_name); //! standard destructor - Standard_EXPORT virtual ~SALOMEDSImpl_Study(); + virtual ~SALOMEDSImpl_Study(); //! method to Get persistent reference of study (idem URL()) - Standard_EXPORT virtual std::string GetPersistentReference(); + virtual std::string GetPersistentReference(); //! method to Get transient reference of study - Standard_EXPORT virtual std::string GetTransientReference(); + virtual std::string GetTransientReference(); - Standard_EXPORT virtual void SetTransientReference(const std::string& theIOR); + virtual void SetTransientReference(const std::string& theIOR); //! method to detect if a study is empty - Standard_EXPORT virtual bool IsEmpty(); + virtual bool IsEmpty(); //! method to Find a Component with ComponentDataType = aComponentName - Standard_EXPORT virtual SALOMEDSImpl_SComponent FindComponent (const std::string& aComponentName); + virtual SALOMEDSImpl_SComponent FindComponent (const std::string& aComponentName); //! method to Find a Component Find a Component from it's ID - Standard_EXPORT virtual SALOMEDSImpl_SComponent FindComponentID(const std::string& aComponentID); + virtual SALOMEDSImpl_SComponent FindComponentID(const std::string& aComponentID); //! method to Find an Object with SALOMEDSImpl::Name = anObjectName - Standard_EXPORT virtual SALOMEDSImpl_SObject FindObject(const std::string& anObjectName); + virtual SALOMEDSImpl_SObject FindObject(const std::string& anObjectName); //! method to Find Object(s) with SALOMEDSImpl::Name=anObjectName in a component with ComponentDataType = aComponentName - Standard_EXPORT virtual std::vector FindObjectByName( const std::string& anObjectName, + virtual std::vector FindObjectByName( const std::string& anObjectName, const std::string& aComponentName ) ; //! method to Find an Object with ID = anObjectID - Standard_EXPORT virtual SALOMEDSImpl_SObject FindObjectID(const std::string& anObjectID); - + virtual SALOMEDSImpl_SObject FindObjectID(const std::string& anObjectID); + //! method to Create an Object with ID = anObjectID - Standard_EXPORT virtual SALOMEDSImpl_SObject CreateObjectID(const std::string& anObjectID); + virtual SALOMEDSImpl_SObject CreateObjectID(const std::string& anObjectID); //! method to Find an Object with ID = anObjectIOR - Standard_EXPORT virtual SALOMEDSImpl_SObject FindObjectIOR(const std::string& anObjectIOR); + virtual SALOMEDSImpl_SObject FindObjectIOR(const std::string& anObjectIOR); //! method to Find an Object by its path - Standard_EXPORT virtual SALOMEDSImpl_SObject FindObjectByPath(const std::string& thePath); + virtual SALOMEDSImpl_SObject FindObjectByPath(const std::string& thePath); //! method to get a path of SObject - Standard_EXPORT virtual std::string GetObjectPath(const SALOMEDSImpl_SObject& theObject); + virtual std::string GetObjectPath(const SALOMEDSImpl_SObject& theObject); - Standard_EXPORT std::string GetObjectPathByIOR(const std::string& theIOR); + std::string GetObjectPathByIOR(const std::string& theIOR); //! method to set a context: root ('/') is UserData component - Standard_EXPORT virtual bool SetContext(const std::string& thePath); + virtual bool SetContext(const std::string& thePath); //! method to get a context - Standard_EXPORT virtual std::string GetContext(); + virtual std::string GetContext(); //! method to get all object names in the given context (or in the current context, if 'theContext' is empty) - Standard_EXPORT virtual std::vector GetObjectNames(const std::string& theContext); + virtual std::vector GetObjectNames(const std::string& theContext); //! method to get all directory names in the given context (or in the current context, if 'theContext' is empty) - Standard_EXPORT virtual std::vector GetDirectoryNames(const std::string& theContext); + virtual std::vector GetDirectoryNames(const std::string& theContext); //! method to get all file names in the given context (or in the current context, if 'theContext' is empty) - Standard_EXPORT virtual std::vector GetFileNames(const std::string& theContext); + virtual std::vector GetFileNames(const std::string& theContext); //! method to get all components names - Standard_EXPORT virtual std::vector GetComponentNames(const std::string& theContext); + virtual std::vector GetComponentNames(const std::string& theContext); //! method to Create a ChildIterator from an SObject - Standard_EXPORT virtual SALOMEDSImpl_ChildIterator NewChildIterator(const SALOMEDSImpl_SObject& aSO); + virtual SALOMEDSImpl_ChildIterator NewChildIterator(const SALOMEDSImpl_SObject& aSO); //! method to Create a SComponentIterator - Standard_EXPORT virtual SALOMEDSImpl_SComponentIterator NewComponentIterator(); + virtual SALOMEDSImpl_SComponentIterator NewComponentIterator(); //! method to Create a StudyBuilder - Standard_EXPORT virtual SALOMEDSImpl_StudyBuilder* NewBuilder(); + virtual SALOMEDSImpl_StudyBuilder* NewBuilder(); //! method to get study name - Standard_EXPORT virtual std::string Name(); + virtual std::string Name(); //! method to set study name - Standard_EXPORT virtual void Name(const std::string& name); - + virtual void Name(const std::string& name); + //! method to get if study has been saved - Standard_EXPORT virtual bool IsSaved(); + virtual bool IsSaved(); //! method to set if study has been saved - Standard_EXPORT virtual void IsSaved(bool save); + virtual void IsSaved(bool save); //! method to Detect if a Study has been modified since it has been saved - Standard_EXPORT virtual bool IsModified(); - + virtual bool IsModified(); + //! method to get URL of the study (idem GetPersistentReference) - Standard_EXPORT virtual std::string URL(); + virtual std::string URL(); //! method to set URL of the study - Standard_EXPORT virtual void URL(const std::string& url); - - Standard_EXPORT virtual bool IsLocked(); - - Standard_EXPORT virtual int StudyId(); - - Standard_EXPORT virtual void StudyId(int id); + virtual void URL(const std::string& url); - Standard_EXPORT virtual void UpdateIORLabelMap(const std::string& anIOR, const std::string& aLabel); + virtual bool IsLocked(); - Standard_EXPORT virtual std::vector FindDependances(const SALOMEDSImpl_SObject& anObject); - - Standard_EXPORT virtual SALOMEDSImpl_AttributeStudyProperties* GetProperties(); - - Standard_EXPORT virtual std::string GetLastModificationDate(); - - Standard_EXPORT virtual std::vector GetModificationsDate(); - - Standard_EXPORT virtual SALOMEDSImpl_UseCaseBuilder* GetUseCaseBuilder(); + virtual int StudyId(); - Standard_EXPORT virtual void Close(); - - Standard_EXPORT void EnableUseCaseAutoFilling(bool isEnabled); - - Standard_EXPORT virtual std::string GetErrorCode() { return _errorCode; } - Standard_EXPORT virtual bool IsError() { return _errorCode != ""; } - - Standard_EXPORT virtual SALOMEDSImpl_SComponent GetSComponent(const std::string& theEntry); - Standard_EXPORT virtual SALOMEDSImpl_SComponent GetSComponent(const DF_Label& theLabel); - Standard_EXPORT virtual SALOMEDSImpl_SObject GetSObject(const std::string& theEntry); - Standard_EXPORT virtual SALOMEDSImpl_SObject GetSObject(const DF_Label& theEntryLabel); - Standard_EXPORT virtual DF_Attribute* GetAttribute(const std::string& theEntry, + virtual void StudyId(int id); + + virtual void UpdateIORLabelMap(const std::string& anIOR, const std::string& aLabel); + + virtual std::vector FindDependances(const SALOMEDSImpl_SObject& anObject); + + virtual SALOMEDSImpl_AttributeStudyProperties* GetProperties(); + + virtual std::string GetLastModificationDate(); + + virtual std::vector GetModificationsDate(); + + virtual SALOMEDSImpl_UseCaseBuilder* GetUseCaseBuilder(); + + virtual void Close(); + + void EnableUseCaseAutoFilling(bool isEnabled); + + virtual std::string GetErrorCode() { return _errorCode; } + virtual bool IsError() { return _errorCode != ""; } + + virtual SALOMEDSImpl_SComponent GetSComponent(const std::string& theEntry); + virtual SALOMEDSImpl_SComponent GetSComponent(const DF_Label& theLabel); + virtual SALOMEDSImpl_SObject GetSObject(const std::string& theEntry); + virtual SALOMEDSImpl_SObject GetSObject(const DF_Label& theEntryLabel); + virtual DF_Attribute* GetAttribute(const std::string& theEntry, const std::string& theType); - Standard_EXPORT virtual bool HasCurrentContext() { return !_current.IsNull(); } + virtual bool HasCurrentContext() { return !_current.IsNull(); } - Standard_EXPORT virtual bool DumpStudy(const std::string& thePath, + virtual bool DumpStudy(const std::string& thePath, const std::string& theBaseName, bool isPublished, SALOMEDSImpl_DriverFactory* theFactory); - Standard_EXPORT static std::string GetDumpStudyComment(const char* theComponentName = 0); - - Standard_EXPORT virtual DF_Document* GetDocument() { return _doc; } + static std::string GetDumpStudyComment(const char* theComponentName = 0); + + virtual DF_Document* GetDocument() { return _doc; } //The method dump creates a txt file that contain a dump of the study, for debug use - Standard_EXPORT void dump(const std::string& theFileName); + void dump(const std::string& theFileName); //This method marks the study as being modified - Standard_EXPORT void Modify(); + void Modify(); - Standard_EXPORT SALOMEDSImpl_AttributeParameter* GetCommonParameters(const char* theID, int theSavePoint); + SALOMEDSImpl_AttributeParameter* GetCommonParameters(const char* theID, int theSavePoint); - Standard_EXPORT SALOMEDSImpl_AttributeParameter* GetModuleParameters(const char* theID, + SALOMEDSImpl_AttributeParameter* GetModuleParameters(const char* theID, const char* theModuleName, int theSavePoint); //Locks the study, theLockerID is identificator of the of the one who locked the study for ex. IOR - Standard_EXPORT void SetStudyLock(const char* theLockerID); + void SetStudyLock(const char* theLockerID); //Returns True if the study is locked - Standard_EXPORT bool IsStudyLocked(); + bool IsStudyLocked(); //Unlocks the study - Standard_EXPORT void UnLockStudy(const char* theLockerID); + void UnLockStudy(const char* theLockerID); //Returns an ID of the study locker - Standard_EXPORT std::vector GetLockerID(); + std::vector GetLockerID(); //Returns a callback - Standard_EXPORT SALOMEDSImpl_Callback* GetCallback() { return _cb; } + SALOMEDSImpl_Callback* GetCallback() { return _cb; } //Returns a list of IOR's stored in the study - Standard_EXPORT std::vector GetIORs(); - + std::vector GetIORs(); -friend class SALOMEDSImpl_StudyManager; -friend class SALOMEDSImpl_GenericAttribute; + friend class SALOMEDSImpl_StudyManager; + friend class SALOMEDSImpl_GenericAttribute; }; #endif diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_StudyBuilder.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_StudyBuilder.hxx index 781103cb6..e6a996e70 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_StudyBuilder.hxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_StudyBuilder.hxx @@ -24,17 +24,18 @@ #ifndef __SALOMEDSImpl_STUDYBUILDER_H__ #define __SALOMEDSImpl_STUDYBUILDER_H__ +#include "SALOMEDSImpl_Defines.hxx" // std C++ headers #include #include #include - + #include "SALOMEDSImpl_Callback.hxx" #include "SALOMEDSImpl_Driver.hxx" class SALOMEDSImpl_Study; -class SALOMEDSImpl_StudyBuilder +class SALOMEDSIMPL_EXPORT SALOMEDSImpl_StudyBuilder { private: DF_Document* _doc; @@ -44,74 +45,74 @@ private: std::string _errorCode; public: - - Standard_EXPORT SALOMEDSImpl_StudyBuilder(const SALOMEDSImpl_Study* theOwner); - Standard_EXPORT ~SALOMEDSImpl_StudyBuilder(); + SALOMEDSImpl_StudyBuilder(const SALOMEDSImpl_Study* theOwner); + + ~SALOMEDSImpl_StudyBuilder(); + + virtual SALOMEDSImpl_SComponent NewComponent(const std::string& ComponentDataType); - Standard_EXPORT virtual SALOMEDSImpl_SComponent NewComponent(const std::string& ComponentDataType); + virtual bool DefineComponentInstance (const SALOMEDSImpl_SComponent&, const std::string& ComponentIOR); - Standard_EXPORT virtual bool DefineComponentInstance (const SALOMEDSImpl_SComponent&, const std::string& ComponentIOR); - - Standard_EXPORT virtual bool RemoveComponent(const SALOMEDSImpl_SComponent& aComponent); + virtual bool RemoveComponent(const SALOMEDSImpl_SComponent& aComponent); - Standard_EXPORT virtual SALOMEDSImpl_SObject NewObject(const SALOMEDSImpl_SObject& theFatherObject); + virtual SALOMEDSImpl_SObject NewObject(const SALOMEDSImpl_SObject& theFatherObject); - Standard_EXPORT virtual SALOMEDSImpl_SObject NewObjectToTag(const SALOMEDSImpl_SObject& theFatherObject, - const int theTag); + virtual SALOMEDSImpl_SObject NewObjectToTag(const SALOMEDSImpl_SObject& theFatherObject, + const int theTag); //! The methods adds a new subdirectory, the path can be absolute or relative (then the current context is used) - Standard_EXPORT virtual bool AddDirectory(const std::string& thePath); + virtual bool AddDirectory(const std::string& thePath); - Standard_EXPORT virtual bool LoadWith(const SALOMEDSImpl_SComponent& sco, SALOMEDSImpl_Driver* Engine); - Standard_EXPORT virtual bool Load(const SALOMEDSImpl_SObject& sco); + virtual bool LoadWith(const SALOMEDSImpl_SComponent& sco, SALOMEDSImpl_Driver* Engine); + virtual bool Load(const SALOMEDSImpl_SObject& sco); - Standard_EXPORT virtual bool RemoveObject(const SALOMEDSImpl_SObject& anObject); - Standard_EXPORT virtual bool RemoveObjectWithChildren(const SALOMEDSImpl_SObject& anObject); + virtual bool RemoveObject(const SALOMEDSImpl_SObject& anObject); + virtual bool RemoveObjectWithChildren(const SALOMEDSImpl_SObject& anObject); - Standard_EXPORT virtual DF_Attribute* FindOrCreateAttribute(const SALOMEDSImpl_SObject& anObject, - const std::string& aTypeOfAttribute); - Standard_EXPORT virtual bool FindAttribute(const SALOMEDSImpl_SObject& anObject, - DF_Attribute*& anAttribute, - const std::string& aTypeOfAttribute); + virtual DF_Attribute* FindOrCreateAttribute(const SALOMEDSImpl_SObject& anObject, + const std::string& aTypeOfAttribute); + virtual bool FindAttribute(const SALOMEDSImpl_SObject& anObject, + DF_Attribute*& anAttribute, + const std::string& aTypeOfAttribute); - Standard_EXPORT virtual bool RemoveAttribute(const SALOMEDSImpl_SObject& anObject, const std::string& aTypeOfAttribute); + virtual bool RemoveAttribute(const SALOMEDSImpl_SObject& anObject, const std::string& aTypeOfAttribute); - Standard_EXPORT virtual bool Addreference(const SALOMEDSImpl_SObject& me, - const SALOMEDSImpl_SObject& thereferencedObject); + virtual bool Addreference(const SALOMEDSImpl_SObject& me, + const SALOMEDSImpl_SObject& thereferencedObject); - Standard_EXPORT virtual bool RemoveReference(const SALOMEDSImpl_SObject& me); + virtual bool RemoveReference(const SALOMEDSImpl_SObject& me); - Standard_EXPORT virtual bool SetGUID(const SALOMEDSImpl_SObject& anObject, const std::string& theGUID); - Standard_EXPORT virtual bool IsGUID(const SALOMEDSImpl_SObject& anObject, const std::string& theGUID); + virtual bool SetGUID(const SALOMEDSImpl_SObject& anObject, const std::string& theGUID); + virtual bool IsGUID(const SALOMEDSImpl_SObject& anObject, const std::string& theGUID); - Standard_EXPORT virtual void NewCommand(); - Standard_EXPORT virtual void CommitCommand(); - Standard_EXPORT virtual bool HasOpenCommand(); - Standard_EXPORT virtual void AbortCommand(); - Standard_EXPORT virtual void Undo(); - Standard_EXPORT virtual void Redo(); - Standard_EXPORT bool GetAvailableUndos(); - Standard_EXPORT bool GetAvailableRedos(); - Standard_EXPORT bool IsSaved(); - Standard_EXPORT bool IsModified(); - Standard_EXPORT virtual int UndoLimit(); - Standard_EXPORT virtual void UndoLimit(const int); + virtual void NewCommand(); + virtual void CommitCommand(); + virtual bool HasOpenCommand(); + virtual void AbortCommand(); + virtual void Undo(); + virtual void Redo(); + bool GetAvailableUndos(); + bool GetAvailableRedos(); + bool IsSaved(); + bool IsModified(); + virtual int UndoLimit(); + virtual void UndoLimit(const int); - Standard_EXPORT void CheckLocked(); + void CheckLocked(); - Standard_EXPORT virtual SALOMEDSImpl_Callback* SetOnAddSObject(const SALOMEDSImpl_Callback* theCallback); - Standard_EXPORT virtual SALOMEDSImpl_Callback* SetOnRemoveSObject(const SALOMEDSImpl_Callback* theCallback); + virtual SALOMEDSImpl_Callback* SetOnAddSObject(const SALOMEDSImpl_Callback* theCallback); + virtual SALOMEDSImpl_Callback* SetOnRemoveSObject(const SALOMEDSImpl_Callback* theCallback); - Standard_EXPORT virtual bool SetName(const SALOMEDSImpl_SObject& theSO, const std::string& theValue); + virtual bool SetName(const SALOMEDSImpl_SObject& theSO, const std::string& theValue); - Standard_EXPORT virtual bool SetComment(const SALOMEDSImpl_SObject& theSO, const std::string& theValue); + virtual bool SetComment(const SALOMEDSImpl_SObject& theSO, const std::string& theValue); - Standard_EXPORT virtual bool SetIOR(const SALOMEDSImpl_SObject& theSO, const std::string& theValue); + virtual bool SetIOR(const SALOMEDSImpl_SObject& theSO, const std::string& theValue); - Standard_EXPORT virtual std::string GetErrorCode() { return _errorCode; } - Standard_EXPORT virtual bool IsError() { return _errorCode != ""; } + virtual std::string GetErrorCode() { return _errorCode; } + virtual bool IsError() { return _errorCode != ""; } - Standard_EXPORT virtual SALOMEDSImpl_Study* GetOwner() { return _study; } + virtual SALOMEDSImpl_Study* GetOwner() { return _study; } }; #endif diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_StudyHandle.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_StudyHandle.hxx index 5d8cff6a2..fe13af984 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_StudyHandle.hxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_StudyHandle.hxx @@ -24,37 +24,35 @@ #ifndef SALOMEDSImpl_StudyHandle_HeaderFile #define SALOMEDSImpl_StudyHandle_HeaderFile +#include "SALOMEDSImpl_Defines.hxx" #include "DF_Attribute.hxx" #include "DF_Label.hxx" /* - Class : SALOMEDSImpl_StudyHandle - Description : PRIVATE: This class is intended for storing of the study handle +Class : SALOMEDSImpl_StudyHandle +Description : PRIVATE: This class is intended for storing of the study handle */ #include "SALOMEDSImpl_Study.hxx" -#ifndef WNT -class Standard_EXPORT SALOMEDSImpl_StudyHandle : public DF_Attribute -#else -class SALOMEDSImpl_StudyHandle : public DF_Attribute -#endif +class SALOMEDSIMPL_EXPORT SALOMEDSImpl_StudyHandle : + public DF_Attribute { public: -Standard_EXPORT SALOMEDSImpl_StudyHandle(); -Standard_EXPORT ~SALOMEDSImpl_StudyHandle() {; } - -Standard_EXPORT static SALOMEDSImpl_StudyHandle* Set(const DF_Label& theLabel, SALOMEDSImpl_Study* theStudy); -Standard_EXPORT static const std::string& GetID() ; - -Standard_EXPORT void Set(SALOMEDSImpl_Study* theStudy) { myHandle = theStudy; } -Standard_EXPORT SALOMEDSImpl_Study* Get() { return myHandle; } -Standard_EXPORT const std::string& ID() const; -Standard_EXPORT void Restore( DF_Attribute* theWith ); -Standard_EXPORT DF_Attribute* NewEmpty() const; -Standard_EXPORT void Paste( DF_Attribute* theInto); - + SALOMEDSImpl_StudyHandle(); + ~SALOMEDSImpl_StudyHandle() {; } + + static SALOMEDSImpl_StudyHandle* Set(const DF_Label& theLabel, SALOMEDSImpl_Study* theStudy); + static const std::string& GetID() ; + + void Set(SALOMEDSImpl_Study* theStudy) { myHandle = theStudy; } + SALOMEDSImpl_Study* Get() { return myHandle; } + const std::string& ID() const; + void Restore( DF_Attribute* theWith ); + DF_Attribute* NewEmpty() const; + void Paste( DF_Attribute* theInto); + private: SALOMEDSImpl_Study* myHandle; diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_StudyManager.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_StudyManager.cxx index 428c5b636..50099bcc9 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_StudyManager.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_StudyManager.cxx @@ -134,18 +134,12 @@ SALOMEDSImpl_Study* SALOMEDSImpl_StudyManager::Open(const string& aUrl) } catch (HDFexception) { -//#ifndef WNT -// char eStr[strlen(aUrl.ToCString())+17]; -//#else - char *eStr; - eStr = new char[strlen(aUrl.c_str())+17]; -//#endif - sprintf(eStr,"Can't open file %s",aUrl.c_str()); -//#ifdef WNT - delete [] eStr; -//#endif - _errorCode = string(eStr); - return NULL; + char *eStr; + eStr = new char[strlen(aUrl.c_str())+17]; + sprintf(eStr,"Can't open file %s",aUrl.c_str()); + delete [] eStr; + _errorCode = string(eStr); + return NULL; } // Temporary aStudyUrl in place of study name @@ -174,11 +168,7 @@ SALOMEDSImpl_Study* SALOMEDSImpl_StudyManager::Open(const string& aUrl) } catch (HDFexception) { -//#ifndef WNT -// char eStr[strlen(aUrl.ToCString())+17]; -//#else - char *eStr = new char [strlen(aUrl.c_str())+17]; -//#endif + char *eStr = new char [strlen(aUrl.c_str())+17]; sprintf(eStr,"Can't open file %s", aUrl.c_str()); _errorCode = string(eStr); return NULL; @@ -462,7 +452,7 @@ bool SALOMEDSImpl_StudyManager::Impl_SaveAs(const string& aUrl, HDFdataset *hdf_dataset =0; hdf_size size[1]; hdf_int32 name_len = 0; - char *component_name = 0; + string component_name; if(!aStudy) { _errorCode = "Study is null"; @@ -609,12 +599,12 @@ bool SALOMEDSImpl_StudyManager::Impl_SaveAs(const string& aUrl, hdf_sco_group2->CreateOnDisk(); SaveAttributes(SC, hdf_sco_group2); // ComponentDataType treatment - component_name = (char*)SC.ComponentDataType().c_str(); - name_len = (hdf_int32)strlen(component_name); + component_name = SC.ComponentDataType(); + name_len = (hdf_int32)component_name.length(); size[0] = name_len +1 ; hdf_dataset = new HDFdataset("COMPONENTDATATYPE",hdf_sco_group2,HDF_STRING,size,1); hdf_dataset->CreateOnDisk(); - hdf_dataset->WriteOnDisk(component_name); + hdf_dataset->WriteOnDisk((char*)component_name.c_str()); hdf_dataset->CloseOnDisk(); hdf_dataset=0; //will be deleted by hdf_sco_group destructor Impl_SaveObject(SC, hdf_sco_group2); @@ -638,12 +628,12 @@ bool SALOMEDSImpl_StudyManager::Impl_SaveAs(const string& aUrl, //----------------------------------------------------------------------- //5 - Write the Study Properties //----------------------------------------------------------------------- - name_len = (hdf_int32) aStudy->Name().size(); + string study_name = aStudy->Name(); + name_len = (hdf_int32) study_name.size(); size[0] = name_len +1 ; hdf_dataset = new HDFdataset("STUDY_NAME",hdf_group_study_structure,HDF_STRING,size,1); hdf_dataset->CreateOnDisk(); - char* studid = (char*)aStudy->Name().c_str(); - hdf_dataset->WriteOnDisk(studid); + hdf_dataset->WriteOnDisk((char*)study_name.c_str()); hdf_dataset->CloseOnDisk(); hdf_dataset=0; // will be deleted by hdf_group_study_structure destructor @@ -717,8 +707,8 @@ bool SALOMEDSImpl_StudyManager::Impl_SaveObject(const SALOMEDSImpl_SObject& SC, SALOMEDSImpl_SObject SO = SALOMEDSImpl_Study::SObject(itchild.Value()); - char* scoid = (char*) SO.GetID().c_str(); - hdf_group_sobject = new HDFgroup(scoid, hdf_group_datatype); + string scoid = SO.GetID(); + hdf_group_sobject = new HDFgroup(scoid.c_str(), hdf_group_datatype); hdf_group_sobject->CreateOnDisk(); SaveAttributes(SO, hdf_group_sobject); Impl_SaveObject(SO, hdf_group_sobject); diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_StudyManager.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_StudyManager.hxx index 190317bbc..b42dd8451 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_StudyManager.hxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_StudyManager.hxx @@ -24,6 +24,8 @@ #ifndef __SALOMEDSImpl_STUDYMANAGER_I_H__ #define __SALOMEDSImpl_STUDYMANAGER_I_H__ +#include "SALOMEDSImpl_Defines.hxx" + // std C++ headers #include #include @@ -39,7 +41,7 @@ class HDFgroup; -class SALOMEDSImpl_StudyManager +class SALOMEDSIMPL_EXPORT SALOMEDSImpl_StudyManager { private: @@ -52,87 +54,87 @@ private: public: //! standard constructor - Standard_EXPORT SALOMEDSImpl_StudyManager(); + SALOMEDSImpl_StudyManager(); //! standard destructor - Standard_EXPORT virtual ~SALOMEDSImpl_StudyManager(); + virtual ~SALOMEDSImpl_StudyManager(); //! method to Create a New Study of name study_name - Standard_EXPORT virtual SALOMEDSImpl_Study* NewStudy(const std::string& study_name); + virtual SALOMEDSImpl_Study* NewStudy(const std::string& study_name); //! method to Open a Study from it's persistent reference - Standard_EXPORT virtual SALOMEDSImpl_Study* Open(const std::string& aStudyUrl); + virtual SALOMEDSImpl_Study* Open(const std::string& aStudyUrl); //! method to close a Study - Standard_EXPORT virtual void Close(SALOMEDSImpl_Study* aStudy); + virtual void Close(SALOMEDSImpl_Study* aStudy); //! method to save a Study - Standard_EXPORT virtual bool Save(SALOMEDSImpl_Study* aStudy, SALOMEDSImpl_DriverFactory* aFactory, bool theMultiFile); + virtual bool Save(SALOMEDSImpl_Study* aStudy, SALOMEDSImpl_DriverFactory* aFactory, bool theMultiFile); - Standard_EXPORT virtual bool SaveASCII(SALOMEDSImpl_Study* aStudy, - SALOMEDSImpl_DriverFactory* aFactory, - bool theMultiFile); + virtual bool SaveASCII(SALOMEDSImpl_Study* aStudy, + SALOMEDSImpl_DriverFactory* aFactory, + bool theMultiFile); //! method to save a Study to the persistent reference aUrl - Standard_EXPORT virtual bool SaveAs(const std::string& aUrl, - SALOMEDSImpl_Study* aStudy, - SALOMEDSImpl_DriverFactory* aFactory, - bool theMultiFile); + virtual bool SaveAs(const std::string& aUrl, + SALOMEDSImpl_Study* aStudy, + SALOMEDSImpl_DriverFactory* aFactory, + bool theMultiFile); - Standard_EXPORT virtual bool SaveAsASCII(const std::string& aUrl, - SALOMEDSImpl_Study* aStudy, - SALOMEDSImpl_DriverFactory* aFactory, - bool theMultiFile); + virtual bool SaveAsASCII(const std::string& aUrl, + SALOMEDSImpl_Study* aStudy, + SALOMEDSImpl_DriverFactory* aFactory, + bool theMultiFile); //! method to Get name list of open studies in the session - Standard_EXPORT virtual std::vector GetOpenStudies(); + virtual std::vector GetOpenStudies(); //! method to get a Study from it's name - Standard_EXPORT virtual SALOMEDSImpl_Study* GetStudyByName(const std::string& aStudyName) ; + virtual SALOMEDSImpl_Study* GetStudyByName(const std::string& aStudyName) ; //! method to get a Study from it's ID - Standard_EXPORT virtual SALOMEDSImpl_Study* GetStudyByID(int aStudyID) ; - - - Standard_EXPORT DF_Document* GetDocumentOfStudy(SALOMEDSImpl_Study* theStudy); - - Standard_EXPORT DF_Document* GetClipboard() { return _clipboard; } - - Standard_EXPORT bool CopyLabel(SALOMEDSImpl_Study* theSourceStudy, - SALOMEDSImpl_Driver* theEngine, - const int theSourceStartDepth, - const DF_Label& theSource, - const DF_Label& theDestinationMain); - - Standard_EXPORT DF_Label PasteLabel(SALOMEDSImpl_Study* theDestinationStudy, - SALOMEDSImpl_Driver* theEngine, - const DF_Label& theSource, - const DF_Label& theDestinationStart, - const int theCopiedStudyID, - const bool isFirstElement); - - Standard_EXPORT virtual bool CanCopy(const SALOMEDSImpl_SObject& theObject, SALOMEDSImpl_Driver* Engine); - Standard_EXPORT virtual bool Copy(const SALOMEDSImpl_SObject& theObject, SALOMEDSImpl_Driver* Engine); - Standard_EXPORT virtual bool CanPaste(const SALOMEDSImpl_SObject& theObject, SALOMEDSImpl_Driver* Engine); - Standard_EXPORT virtual SALOMEDSImpl_SObject Paste(const SALOMEDSImpl_SObject& theObject, SALOMEDSImpl_Driver* Engine); + virtual SALOMEDSImpl_Study* GetStudyByID(int aStudyID) ; + + + DF_Document* GetDocumentOfStudy(SALOMEDSImpl_Study* theStudy); + + DF_Document* GetClipboard() { return _clipboard; } + + bool CopyLabel(SALOMEDSImpl_Study* theSourceStudy, + SALOMEDSImpl_Driver* theEngine, + const int theSourceStartDepth, + const DF_Label& theSource, + const DF_Label& theDestinationMain); + + DF_Label PasteLabel(SALOMEDSImpl_Study* theDestinationStudy, + SALOMEDSImpl_Driver* theEngine, + const DF_Label& theSource, + const DF_Label& theDestinationStart, + const int theCopiedStudyID, + const bool isFirstElement); + + virtual bool CanCopy(const SALOMEDSImpl_SObject& theObject, SALOMEDSImpl_Driver* Engine); + virtual bool Copy(const SALOMEDSImpl_SObject& theObject, SALOMEDSImpl_Driver* Engine); + virtual bool CanPaste(const SALOMEDSImpl_SObject& theObject, SALOMEDSImpl_Driver* Engine); + virtual SALOMEDSImpl_SObject Paste(const SALOMEDSImpl_SObject& theObject, SALOMEDSImpl_Driver* Engine); // _SaveAs private function called by Save and SaveAs - Standard_EXPORT virtual bool Impl_SaveAs(const std::string& aUrl, - SALOMEDSImpl_Study* aStudy, - SALOMEDSImpl_DriverFactory* aFactory, - bool theMultiFile, - bool theASCII); + virtual bool Impl_SaveAs(const std::string& aUrl, + SALOMEDSImpl_Study* aStudy, + SALOMEDSImpl_DriverFactory* aFactory, + bool theMultiFile, + bool theASCII); // _SaveObject private function called by _SaveAs - Standard_EXPORT virtual bool Impl_SaveObject(const SALOMEDSImpl_SObject& SC, HDFgroup *hdf_group_datatype); + virtual bool Impl_SaveObject(const SALOMEDSImpl_SObject& SC, HDFgroup *hdf_group_datatype); // _SubstituteSlash function called by Open and GetStudyByName - Standard_EXPORT virtual std::string Impl_SubstituteSlash(const std::string& aUrl); + virtual std::string Impl_SubstituteSlash(const std::string& aUrl); - Standard_EXPORT virtual bool Impl_SaveProperties(SALOMEDSImpl_Study* aStudy, HDFgroup *hdf_group); + virtual bool Impl_SaveProperties(SALOMEDSImpl_Study* aStudy, HDFgroup *hdf_group); - Standard_EXPORT std::string GetErrorCode() { return _errorCode; } - Standard_EXPORT virtual bool IsError() { return _errorCode != ""; } + std::string GetErrorCode() { return _errorCode; } + virtual bool IsError() { return _errorCode != ""; } }; diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_TMPFile.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_TMPFile.hxx index 3d63b66cd..a9ee8d706 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_TMPFile.hxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_TMPFile.hxx @@ -21,19 +21,20 @@ #ifndef __SALOMEDSIMPL_TMPFILE_H__ #define __SALOMEDSIMPL_TMPFILE_H__ +#include "SALOMEDSImpl_Defines.hxx" #include "DF_definitions.hxx" -struct SALOMEDSImpl_TMPFile +struct SALOMEDSIMPL_EXPORT SALOMEDSImpl_TMPFile { typedef unsigned char TOctet; //typedef unsigned int size_t; - Standard_EXPORT virtual size_t Size() = 0; + virtual size_t Size() = 0; - Standard_EXPORT virtual TOctet* Data(); + virtual TOctet* Data(); - Standard_EXPORT virtual TOctet& Get(size_t) = 0; + virtual TOctet& Get(size_t) = 0; }; diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_Tool.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_Tool.cxx index 7d817c961..b65ad7bd5 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_Tool.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_Tool.cxx @@ -24,14 +24,14 @@ // Project : SALOME // Module : SALOMEDSImpl -#include "SALOMEDSImpl_Tool.hxx" - #include #include #include +#include +#include "SALOMEDSImpl_Tool.hxx" -#ifndef WNT +#ifndef WIN32 #include #include #include @@ -40,17 +40,17 @@ #else #include #include +//#include +#include #endif -#include - using namespace std; bool Exists(const string thePath) { -#ifdef WNT +#ifdef WIN32 if ( GetFileAttributes ( thePath.c_str() ) == 0xFFFFFFFF ) { if ( GetLastError () != ERROR_FILE_NOT_FOUND ) { return false; @@ -118,7 +118,7 @@ string SALOMEDSImpl_Tool::GetTmpDir() #endif -#ifdef WNT +#ifdef WIN32 CreateDirectory(aDir.c_str(), NULL); #else mkdir(aDir.c_str(), 0x1ff); @@ -143,7 +143,7 @@ void SALOMEDSImpl_Tool::RemoveTemporaryFiles(const string& theDirectory, aFile += theFiles[i-1]; if(!Exists(aFile)) continue; -#ifdef WNT +#ifdef WIN32 DeleteFile(aFile.c_str()); #else unlink(aFile.c_str()); @@ -152,8 +152,8 @@ void SALOMEDSImpl_Tool::RemoveTemporaryFiles(const string& theDirectory, if(IsDirDeleted) { if(Exists(aDirName)) { -#ifdef WNT - RemoveDirectory(aDireName.c_str()); +#ifdef WIN32 + RemoveDirectory(aDirName.c_str()); #else rmdir(aDirName.c_str()); #endif @@ -201,8 +201,8 @@ string SALOMEDSImpl_Tool::GetDirFromPath(const string& thePath) { path = thePath+"/"; } -#ifdef WNT //Check if the only disk letter is given as path - if(path.size() == 2 && path[1] == ":") path +='\\'; +#ifdef WIN32 //Check if the only disk letter is given as path + if(path.size() == 2 && path[1] == ':') path +='\\'; #endif for(int i = 0, len = path.size(); i SALOMEDSImpl_Tool::splitString(const string& theValue, char separ void SALOMEDSImpl_Tool::GetSystemDate(int& year, int& month, int& day, int& hours, int& minutes, int& seconds) { -#ifdef WNT +#ifdef WIN32 SYSTEMTIME st; GetLocalTime ( &st ); @@ -268,13 +268,17 @@ void SALOMEDSImpl_Tool::GetSystemDate(int& year, int& month, int& day, int& hour #endif } +//Warning undef of Ascii Winwows define +#ifdef WIN32 +# undef GetUserName +#endif string SALOMEDSImpl_Tool::GetUserName() { -#ifdef WNT +#ifdef WIN32 char* pBuff = new char[UNLEN + 1]; DWORD dwSize = UNLEN + 1; string retVal; - GetUserName ( pBuff, &dwSize ); + ::GetUserNameA( pBuff, &dwSize ); string theTmpUserName(pBuff,(int)dwSize -1 ); retVal = theTmpUserName; delete [] pBuff; diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_Tool.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_Tool.hxx index 12ec13542..5c7e460ae 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_Tool.hxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_Tool.hxx @@ -28,18 +28,20 @@ #ifndef __SALOMEDSIMPL_TOOL_H__ #define __SALOMEDSIMPL_TOOL_H__ +#include "SALOMEDSImpl_Defines.hxx" + #include #include #include "DF_Label.hxx" #include -class SALOMEDSImpl_Tool +class SALOMEDSIMPL_EXPORT SALOMEDSImpl_Tool { public: // Returns the unique temporary directory, that is defined in SALOME_TMP_DIR if this variable is set - // otherwise return /tmp/something/ for Unix or c:\something\ for WNT + // otherwise return /tmp/something/ for Unix or c:\something\ for WIN32 static std::string GetTmpDir(); diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_UseCaseBuilder.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_UseCaseBuilder.hxx index c54a5dd93..d9413c443 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_UseCaseBuilder.hxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_UseCaseBuilder.hxx @@ -24,6 +24,8 @@ #ifndef __SALOMEDSIMPL_USECaseBuilder_H__ #define __SALOMEDSIMPL_USECaseBuilder_H__ +#include "SALOMEDSImpl_Defines.hxx" + #include #include "DF_Document.hxx" @@ -31,7 +33,7 @@ #include "SALOMEDSImpl_AttributeTreeNode.hxx" #include "SALOMEDSImpl_UseCaseIterator.hxx" -class SALOMEDSImpl_UseCaseBuilder +class SALOMEDSIMPL_EXPORT SALOMEDSImpl_UseCaseBuilder { private: @@ -41,38 +43,38 @@ private: public: //! standard constructor - Standard_EXPORT SALOMEDSImpl_UseCaseBuilder(DF_Document* theDocument); - + SALOMEDSImpl_UseCaseBuilder(DF_Document* theDocument); + //! standard destructor - Standard_EXPORT ~SALOMEDSImpl_UseCaseBuilder(); - - Standard_EXPORT virtual bool Append(const SALOMEDSImpl_SObject& theObject); + ~SALOMEDSImpl_UseCaseBuilder(); + + virtual bool Append(const SALOMEDSImpl_SObject& theObject); + + virtual bool Remove(const SALOMEDSImpl_SObject& theObject); - Standard_EXPORT virtual bool Remove(const SALOMEDSImpl_SObject& theObject); + virtual bool AppendTo(const SALOMEDSImpl_SObject& theFather, const SALOMEDSImpl_SObject& theObject); - Standard_EXPORT virtual bool AppendTo(const SALOMEDSImpl_SObject& theFather, const SALOMEDSImpl_SObject& theObject); + virtual bool InsertBefore(const SALOMEDSImpl_SObject& theFirst, const SALOMEDSImpl_SObject& theNext); - Standard_EXPORT virtual bool InsertBefore(const SALOMEDSImpl_SObject& theFirst, const SALOMEDSImpl_SObject& theNext); + virtual bool SetCurrentObject(const SALOMEDSImpl_SObject& theObject); - Standard_EXPORT virtual bool SetCurrentObject(const SALOMEDSImpl_SObject& theObject); - - Standard_EXPORT virtual bool SetRootCurrent(); + virtual bool SetRootCurrent(); - Standard_EXPORT virtual bool HasChildren(const SALOMEDSImpl_SObject& theObject); + virtual bool HasChildren(const SALOMEDSImpl_SObject& theObject); - Standard_EXPORT virtual bool IsUseCase(const SALOMEDSImpl_SObject& theObject); + virtual bool IsUseCase(const SALOMEDSImpl_SObject& theObject); - Standard_EXPORT virtual bool SetName(const std::string& theName); + virtual bool SetName(const std::string& theName); - Standard_EXPORT virtual SALOMEDSImpl_SObject GetCurrentObject(); + virtual SALOMEDSImpl_SObject GetCurrentObject(); - Standard_EXPORT virtual std::string GetName(); + virtual std::string GetName(); - Standard_EXPORT virtual SALOMEDSImpl_SObject AddUseCase(const std::string& theName); + virtual SALOMEDSImpl_SObject AddUseCase(const std::string& theName); - Standard_EXPORT virtual SALOMEDSImpl_UseCaseIterator GetUseCaseIterator(const SALOMEDSImpl_SObject& anObject); + virtual SALOMEDSImpl_UseCaseIterator GetUseCaseIterator(const SALOMEDSImpl_SObject& anObject); - Standard_EXPORT SALOMEDSImpl_SObject GetSObject(const std::string& theEntry); + SALOMEDSImpl_SObject GetSObject(const std::string& theEntry); }; #endif diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_UseCaseIterator.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_UseCaseIterator.hxx index a01cb1040..7d0182eb0 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_UseCaseIterator.hxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_UseCaseIterator.hxx @@ -24,13 +24,15 @@ #ifndef __SALOMEDSIMPL_USECASEITERATOR_H__ #define __SALOMEDSIMPL_USECASEITERATOR_H__ +#include "SALOMEDSImpl_Defines.hxx" + #include "SALOMEDSImpl_SObject.hxx" #include "DF_ChildIterator.hxx" #include "SALOMEDSImpl_ChildNodeIterator.hxx" #include -class Standard_EXPORT SALOMEDSImpl_UseCaseIterator +class SALOMEDSIMPL_EXPORT SALOMEDSImpl_UseCaseIterator { private: @@ -45,12 +47,12 @@ public: //! standard constructor SALOMEDSImpl_UseCaseIterator(const DF_Label& theLabel, - const std::string& theGUID, - const bool allLevels); - + const std::string& theGUID, + const bool allLevels); + //! standard destructor ~SALOMEDSImpl_UseCaseIterator(); - + virtual void Init(bool); virtual bool More(); virtual void Next(); diff --git a/src/SALOMELocalTrace/BaseTraceCollector.cxx b/src/SALOMELocalTrace/BaseTraceCollector.cxx index 5980a4075..9c3b222cb 100644 --- a/src/SALOMELocalTrace/BaseTraceCollector.cxx +++ b/src/SALOMELocalTrace/BaseTraceCollector.cxx @@ -37,7 +37,7 @@ using namespace std; // Class attributes initialisation, for class method BaseTraceCollector::run BaseTraceCollector* BaseTraceCollector::_singleton = 0; -#ifndef WNT +#ifndef WIN32 pthread_mutex_t BaseTraceCollector::_singletonMutex; #else pthread_mutex_t BaseTraceCollector::_singletonMutex = diff --git a/src/SALOMELocalTrace/FileTraceCollector.cxx b/src/SALOMELocalTrace/FileTraceCollector.cxx index 6646fbba6..42eac1161 100644 --- a/src/SALOMELocalTrace/FileTraceCollector.cxx +++ b/src/SALOMELocalTrace/FileTraceCollector.cxx @@ -124,7 +124,7 @@ void* FileTraceCollector::run(void *bid) myTraceBuffer->retrieve(myTrace); if (myTrace.traceType == ABORT_MESS) { -#ifndef WNT +#ifndef WIN32 traceFile << "INTERRUPTION from thread " << myTrace.threadId << " : " << myTrace.trace; #else @@ -134,7 +134,7 @@ void* FileTraceCollector::run(void *bid) #endif traceFile.close(); cout << flush ; -#ifndef WNT +#ifndef WIN32 cerr << "INTERRUPTION from thread " << myTrace.threadId << " : " << myTrace.trace; #else @@ -146,7 +146,7 @@ void* FileTraceCollector::run(void *bid) } else { -#ifndef WNT +#ifndef WIN32 traceFile << "th. " << myTrace.threadId << " " << myTrace.trace; #else diff --git a/src/SALOMELocalTrace/LocalTraceBufferPool.cxx b/src/SALOMELocalTrace/LocalTraceBufferPool.cxx index 21908c516..ad4bd7697 100644 --- a/src/SALOMELocalTrace/LocalTraceBufferPool.cxx +++ b/src/SALOMELocalTrace/LocalTraceBufferPool.cxx @@ -29,7 +29,7 @@ #include #include -#ifndef WNT +#ifndef WIN32 #include #else #include @@ -53,7 +53,7 @@ using namespace std; // Class static attributes initialisation LocalTraceBufferPool* LocalTraceBufferPool::_singleton = 0; -//#ifndef WNT +//#ifndef WIN32 //pthread_mutex_t LocalTraceBufferPool::_singletonMutex; //#else pthread_mutex_t LocalTraceBufferPool::_singletonMutex = @@ -111,7 +111,7 @@ LocalTraceBufferPool* LocalTraceBufferPool::instance() } else // --- try a dynamic library { -#ifndef WNT +#ifndef WIN32 void* handle; string impl_name = string ("lib") + traceKind + string("TraceCollector.so"); @@ -124,7 +124,7 @@ LocalTraceBufferPool* LocalTraceBufferPool::instance() if ( handle ) { typedef BaseTraceCollector * (*FACTORY_FUNCTION) (void); -#ifndef WNT +#ifndef WIN32 FACTORY_FUNCTION TraceCollectorFactory = (FACTORY_FUNCTION) dlsym(handle, "SingletonInstance"); #else @@ -134,7 +134,7 @@ LocalTraceBufferPool* LocalTraceBufferPool::instance() if ( !TraceCollectorFactory ) { cerr << "Can't resolve symbol: SingletonInstance" < #include -#ifdef WNT +#ifdef WIN32 #include #endif @@ -113,7 +113,7 @@ CORBA::Object_ptr TraceCollector_WaitForServerReadiness(CORBA::ORB_ptr orb, cout << "Caught exception: Naming Service can't found Logger"; } } -#ifndef WNT +#ifndef WIN32 nanosleep(&ts_req,&ts_rem); #else Sleep(TIMESleep / 1000000); diff --git a/src/TOOLSDS/SALOMEDS_Tool.cxx b/src/TOOLSDS/SALOMEDS_Tool.cxx index 172e8359c..92f4ecae3 100644 --- a/src/TOOLSDS/SALOMEDS_Tool.cxx +++ b/src/TOOLSDS/SALOMEDS_Tool.cxx @@ -27,13 +27,12 @@ #include "SALOMEDS_Tool.hxx" #include "utilities.h" +#include "Basics_DirUtils.hxx" -#ifndef WNT +#ifndef WIN32 #include #include #include -#include -#include #include #include #else @@ -41,6 +40,8 @@ #include #endif +#include +#include #include #include @@ -50,9 +51,9 @@ using namespace std; bool Exists(const string thePath) { -#ifdef WNT +#ifdef WIN32 if ( GetFileAttributes ( thePath.c_str() ) == 0xFFFFFFFF ) { - if ( GetLastError () != ERROR_FILE_NOT_FOUND ) { + if ( GetLastError () == ERROR_FILE_NOT_FOUND ) { return false; } } @@ -70,9 +71,10 @@ bool Exists(const string thePath) //============================================================================ std::string SALOMEDS_Tool::GetTmpDir() { + return Kernel_Utils::GetTmpDirByEnv("SALOME_TMP_DIR"); //Find a temporary directory to store a file - string aTmpDir = ""; + /*string aTmpDir = ""; char *Tmp_dir = getenv("SALOME_TMP_DIR"); if(Tmp_dir != NULL) { @@ -116,13 +118,13 @@ std::string SALOMEDS_Tool::GetTmpDir() #endif -#ifdef WNT +#ifdef WIN32 CreateDirectory(aDir.c_str(), NULL); #else mkdir(aDir.c_str(), 0x1ff); #endif - return aDir; + return aDir;*/ } //============================================================================ @@ -141,7 +143,7 @@ void SALOMEDS_Tool::RemoveTemporaryFiles(const std::string& theDirectory, aFile += theFiles[i-1]; if(!Exists(aFile)) continue; -#ifdef WNT +#ifdef WIN32 DeleteFile(aFile.c_str()); #else unlink(aFile.c_str()); @@ -150,8 +152,8 @@ void SALOMEDS_Tool::RemoveTemporaryFiles(const std::string& theDirectory, if(IsDirDeleted) { if(Exists(aDirName)) { -#ifdef WNT - RemoveDirectory(aDireName.c_str()); +#ifdef WIN32 + RemoveDirectory(aDirName.c_str()); #else rmdir(aDirName.c_str()); #endif @@ -195,7 +197,7 @@ namespace if (!theNamesOnly) { // mpv 15.01.2003: if only file names must be stroed, then size of files is zero string aFullPath = aTmpDir + const_cast(theFiles[i].in()); if(!Exists(aFullPath)) continue; -#ifdef WNT +#ifdef WIN32 ifstream aFile(aFullPath.c_str(), ios::binary); #else ifstream aFile(aFullPath.c_str()); @@ -229,7 +231,7 @@ namespace if (!theNamesOnly) { // mpv 15.01.2003: we don't open any file if theNamesOnly = true string aFullPath = aTmpDir + const_cast(theFiles[i].in()); if(!Exists(aFullPath)) continue; -#ifdef WNT +#ifdef WIN32 aFile = new ifstream(aFullPath.c_str(), ios::binary); #else aFile = new ifstream(aFullPath.c_str()); @@ -336,7 +338,7 @@ SALOMEDS_Tool::PutStreamToFiles(const SALOMEDS::TMPFile& theStream, aCurrentPos += 8; string aFullPath = aTmpDir + aFileName; -#ifdef WNT +#ifdef WIN32 ofstream aFile(aFullPath.c_str(), ios::binary); #else ofstream aFile(aFullPath.c_str()); @@ -407,8 +409,8 @@ std::string SALOMEDS_Tool::GetDirFromPath(const std::string& thePath) { path = thePath+"/"; } -#ifdef WNT //Check if the only disk letter is given as path - if(path.size() == 2 && path[1] == ":") path +='\\'; +#ifdef WIN32 //Check if the only disk letter is given as path + if(path.size() == 2 && path[1] == ':') path +='\\'; #endif for(int i = 0, len = path.size(); i +#include "SALOME_Utils.hxx" -#include - -UTILS_EXPORT std::string GetHostname(); UTILS_EXPORT const char *duplicate(const char * const); #endif diff --git a/src/Utils/SALOME_Utils.hxx b/src/Utils/SALOME_Utils.hxx index d6c28d278..3ae0e6f02 100755 --- a/src/Utils/SALOME_Utils.hxx +++ b/src/Utils/SALOME_Utils.hxx @@ -26,7 +26,7 @@ #ifndef _SALOME_UTILS_HXX_ #define _SALOME_UTILS_HXX_ -#ifdef WNT +#ifdef WIN32 # if defined UTILS_EXPORTS # define UTILS_EXPORT __declspec( dllexport ) # else diff --git a/src/Utils/Utils_ExceptHandlers.hxx b/src/Utils/Utils_ExceptHandlers.hxx index 8ac5aa8e5..ff40370f1 100644 --- a/src/Utils/Utils_ExceptHandlers.hxx +++ b/src/Utils/Utils_ExceptHandlers.hxx @@ -29,7 +29,7 @@ #ifndef Utils_ExceptHandlers_HeaderFile #define Utils_ExceptHandlers_HeaderFile -#include +#include "SALOME_Utils.hxx" #include @@ -38,7 +38,7 @@ typedef void (*PVF)(); class UTILS_EXPORT Unexpect { //save / retrieve unexpected exceptions treatment PVF old; public : -#ifndef WNT +#ifndef WIN32 Unexpect( PVF f ) { old = std::set_unexpected(f); } ~Unexpect() { std::set_unexpected(old); } @@ -53,7 +53,7 @@ class UTILS_EXPORT Terminate {//save / retrieve terminate function PVF old; public : -#ifndef WNT +#ifndef WIN32 Terminate( PVF f ) { old = std::set_terminate(f); } ~Terminate() { std::set_terminate(old); } diff --git a/src/Utils/Utils_Identity.cxx b/src/Utils/Utils_Identity.cxx index d95ea641c..1c26a600a 100644 --- a/src/Utils/Utils_Identity.cxx +++ b/src/Utils/Utils_Identity.cxx @@ -34,12 +34,12 @@ extern "C" { # include -#ifndef WNT /* unix functionality */ +#ifndef WIN32 /* unix functionality */ # include #endif } -#ifndef WNT /* unix functionality */ +#ifndef WIN32 /* unix functionality */ # include # include @@ -153,7 +153,7 @@ PSID getuid() { #define getcwd _getcwd #define getpid _getpid -#endif /* WNT */ +#endif /* WIN32 */ Identity::Identity( const char *name ): _name(duplicate(name)),\ @@ -197,7 +197,7 @@ const char* const Identity::name (void) const { return _name ; } -#ifndef WNT +#ifndef WIN32 const pid_t& Identity::pid(void) const #else const DWORD& Identity::pid(void) const @@ -206,7 +206,7 @@ const char* const Identity::name (void) const return _pid ; } -#ifndef WNT +#ifndef WIN32 const struct utsname &Identity::hostid(void) const #else const char* const Identity::hostid(void) const @@ -215,7 +215,7 @@ const char* const Identity::name (void) const return _hostid ; } -#ifndef WNT +#ifndef WIN32 const uid_t& Identity::uid(void) const #else const PSID& Identity::uid(void) const @@ -246,7 +246,7 @@ const char* const Identity::adip (void) const const char* Identity::host_char( void ) const { -#ifndef WNT +#ifndef WIN32 return _hostid.nodename; #else return _hostid; @@ -266,7 +266,7 @@ std::ostream & operator<< ( std::ostream& os , const Identity& monid ) os << '\t' << "Numero de PID : " << monid._pid << std::endl; os << '\t' << "Uid utilisateur : " << monid._uid << std::endl; os << '\t' << "nom utilisateur : " << monid._pwname << std::endl; -#ifndef WNT +#ifndef WIN32 os << '\t' << "Nom de machine : " << monid._hostid.nodename << std::endl; #else os << '\t' << "Nom de machine : " << monid._hostid << std::endl; diff --git a/src/Utils/Utils_Identity.hxx b/src/Utils/Utils_Identity.hxx index 5e508a47f..5bce751ff 100644 --- a/src/Utils/Utils_Identity.hxx +++ b/src/Utils/Utils_Identity.hxx @@ -35,7 +35,7 @@ extern "C" { # include # include -#ifndef WNT +#ifndef WIN32 # include # include #else @@ -50,7 +50,7 @@ protected : const char* const _name ; const char* const _adip; // Internet address -#ifndef WNT +#ifndef WIN32 const struct utsname _hostid; const pid_t _pid ; const uid_t _uid ; @@ -73,7 +73,7 @@ public : ~Identity(); friend std::ostream & operator<< ( std::ostream& os , const Identity& monid ); -#ifndef WNT +#ifndef WIN32 const pid_t& pid(void) const; const struct utsname& hostid(void) const; const uid_t& uid(void) const; diff --git a/src/Utils/Utils_Mutex.cxx b/src/Utils/Utils_Mutex.cxx index 88a0c5747..8fa7ec33c 100644 --- a/src/Utils/Utils_Mutex.cxx +++ b/src/Utils/Utils_Mutex.cxx @@ -45,7 +45,7 @@ void Utils_Mutex::lock() { pthread_mutex_lock( &myHelperMutex ); -#ifndef WNT +#ifndef WIN32 if ( myCount > 0 && myThread == pthread_self() ) { #else if ( myCount > 0 && myThread.p == pthread_self().p ) { @@ -67,7 +67,7 @@ void Utils_Mutex::unlock() { pthread_mutex_lock( &myHelperMutex ); -#ifndef WNT +#ifndef WIN32 if ( myThread == pthread_self() ) { #else if ( myThread.p == pthread_self().p ) { diff --git a/src/Utils/Utils_SALOME_Exception.cxx b/src/Utils/Utils_SALOME_Exception.cxx index aacd15166..8f6faf2a5 100644 --- a/src/Utils/Utils_SALOME_Exception.cxx +++ b/src/Utils/Utils_SALOME_Exception.cxx @@ -30,14 +30,14 @@ #include "Utils_SALOME_Exception.hxx" #include "utilities.h" -#ifndef WNT +#ifndef WIN32 extern "C" { #endif #include #include #include -#ifndef WNT +#ifndef WIN32 } #endif diff --git a/src/Utils/Utils_SALOME_Exception.hxx b/src/Utils/Utils_SALOME_Exception.hxx index 979b3e137..eeb9dc13c 100644 --- a/src/Utils/Utils_SALOME_Exception.hxx +++ b/src/Utils/Utils_SALOME_Exception.hxx @@ -46,8 +46,8 @@ //swig tool on Linux doesn't pass defines from header SALOME_Utils.hxx //therefore (temporary solution) defines are placed below -#ifdef WNT -# if defined UTILS_EXPORTS +#ifdef WIN32 +# ifdef UTILS_EXPORTS # define UTILS_EXPORT __declspec( dllexport ) # else # define UTILS_EXPORT __declspec( dllimport ) diff --git a/src/Utils/Utils_Timer.cxx b/src/Utils/Utils_Timer.cxx index e15c89a55..41b90d24e 100644 --- a/src/Utils/Utils_Timer.cxx +++ b/src/Utils/Utils_Timer.cxx @@ -30,7 +30,7 @@ #include "utilities.h" -#ifndef WNT +#ifndef WIN32 static struct timezone *tz=(struct timezone*) malloc(sizeof(struct timezone)); #else //timezone *tz=_timezone; @@ -41,7 +41,7 @@ static struct timezone *tz=(struct timezone*) malloc(sizeof(struct timezone)); #endif Utils_Timer::Utils_Timer() { -#ifndef WNT +#ifndef WIN32 RefToInitialTMS = new tms; RefToCurrentTMS = new tms; @@ -70,7 +70,7 @@ Utils_Timer::~Utils_Timer() { void Utils_Timer::Start() { if (Stopped) { Stopped = 0; -#ifndef WNT +#ifndef WIN32 times(RefToInitialTMS); gettimeofday(RefToInitialTimeB,tz); #else @@ -84,7 +84,7 @@ void Utils_Timer::Start() { void Utils_Timer::Stop() { if (!Stopped) { -#ifndef WNT +#ifndef WIN32 times(RefToCurrentTMS); int diffr_user = RefToCurrentTMS->tms_utime - RefToInitialTMS->tms_utime; int diffr_sys = RefToCurrentTMS->tms_stime - RefToInitialTMS->tms_stime; @@ -119,7 +119,7 @@ void Utils_Timer::Reset() { void Utils_Timer::ShowAbsolute(){ #if defined(_DEBUG_) || defined(_DEBUG) -#ifndef WNT +#ifndef WIN32 unsigned long Absolute_user = (unsigned long) ((timeval*)RefToCurrentTimeB)->tv_sec ; #else unsigned long Absolute_user = *RefToCurrentTimeB; diff --git a/src/Utils/Utils_Timer.hxx b/src/Utils/Utils_Timer.hxx index a8363e030..84edf590d 100644 --- a/src/Utils/Utils_Timer.hxx +++ b/src/Utils/Utils_Timer.hxx @@ -29,7 +29,7 @@ #include #include -#ifndef WNT +#ifndef WIN32 # include # include # include @@ -53,7 +53,7 @@ class UTILS_EXPORT Utils_Timer { double Cumul_user; double Cumul_sys; bool Stopped; -#ifndef WNT +#ifndef WIN32 tms *RefToCurrentTMS, *RefToInitialTMS; timeval *RefToCurrentTimeB, *RefToInitialTimeB; #else diff --git a/src/win32pm/setup.py b/src/win32pm/setup.py new file mode 100755 index 000000000..c285b9b88 --- /dev/null +++ b/src/win32pm/setup.py @@ -0,0 +1,10 @@ +from distutils.core import setup, Extension + +module1 = Extension('win32pm', + libraries = ['kernel32'], + sources = ['win32pm.c']) + +setup (name = 'win32pm', + version = '1.0', + description = 'Win32 process managment package', + ext_modules = [module1]) diff --git a/src/win32pm/win32pm.c b/src/win32pm/win32pm.c new file mode 100755 index 000000000..7fd227dc1 --- /dev/null +++ b/src/win32pm/win32pm.c @@ -0,0 +1,139 @@ +#include +#include + +static PyObject * win32pm_spawnhandle( PyObject *self, PyObject *args ) +{ + char *argv; + char *flags; + STARTUPINFO si; + PROCESS_INFORMATION pi; + DWORD dwProcessFlags = CREATE_NEW_CONSOLE; + /* Default value as in Python sources: + CREATE_NEW_CONSOLE has been known to + cause random failures on win9x. Specifically a + dialog: + "Your program accessed mem currently in use at xxx" + and a hopeful warning about the stability of your + system. + Cost is Ctrl+C wont kill children, but anyone + who cares can have a go! + */ + + if (!PyArg_ParseTuple(args, "s|s", &argv, &flags)) + return NULL; + if ( flags && !strcmp( flags, "-nc" ) ) // no console + dwProcessFlags = 0; + + ZeroMemory( &si, sizeof(si) ); + si.cb = sizeof(si); + ZeroMemory( &pi, sizeof(pi) ); + + if ( !CreateProcess( NULL, argv, + NULL, // Process handle not inheritable. + NULL, // Thread handle not inheritable. + TRUE, + dwProcessFlags, // Creation flags. + NULL, // Use parent's environment block. + NULL, // Use parent's starting directory. + &si, // Pointer to STARTUPINFO structure. + &pi ) ) // Pointer to PROCESS_INFORMATION structure. + return NULL; + return Py_BuildValue("i", pi.hProcess); +} + +static PyObject * win32pm_spawnpid( PyObject *self, PyObject *args ) +{ + char* argv; + char *flags; + STARTUPINFO si; + PROCESS_INFORMATION pi; + DWORD dwProcessFlags = CREATE_NEW_CONSOLE; + /* Default value as in Python sources: + CREATE_NEW_CONSOLE has been known to + cause random failures on win9x. Specifically a + dialog: + "Your program accessed mem currently in use at xxx" + and a hopeful warning about the stability of your + system. + Cost is Ctrl+C wont kill children, but anyone + who cares can have a go! + */ + + if (!PyArg_ParseTuple(args, "s|s", &argv, &flags)) + return NULL; + if ( flags && !strcmp( flags, "-nc" ) ) // no console + dwProcessFlags = 0; + + ZeroMemory( &si, sizeof(si) ); + si.cb = sizeof(si); + ZeroMemory( &pi, sizeof(pi) ); + + if ( !CreateProcess( NULL, argv, + NULL, // Process handle not inheritable. + NULL, // Thread handle not inheritable. + TRUE, + dwProcessFlags, // Creation flags. + NULL, // Use parent's environment block. + NULL, // Use parent's starting directory. + &si, // Pointer to STARTUPINFO structure. + &pi ) ) // Pointer to PROCESS_INFORMATION structure. + return NULL; + return Py_BuildValue("i", pi.dwProcessId); +} + +static PyObject * win32pm_handle( PyObject *self, PyObject *args ) +{ + int argv1 = 0; + int argv2 = 0; + HANDLE ph = 0; + int pid = 0; + if (!PyArg_ParseTuple(args, "i|i", &argv1, &argv2)) + return NULL; + ph = OpenProcess( 1, (BOOL)argv2, argv1 ); + return Py_BuildValue("i", (int)ph ); +} + +static PyObject * win32pm_killpid( PyObject *self, PyObject *args ) +{ + int pid = 0; + int exitCode = 0; + HANDLE ph = 0; + BOOL stat = 0; + if (!PyArg_ParseTuple(args, "i|i", &pid, &exitCode)) + return NULL; + ph = OpenProcess( 1, 0, pid ); + stat = TerminateProcess( ph, exitCode ); + return Py_BuildValue("i", (int)stat ); +} + +static PyObject * win32pm_killhandle( PyObject *self, PyObject *args ) +{ + int phId = 0; + int exitCode = 0; + BOOL stat = 0; + if (!PyArg_ParseTuple(args, "i|i", &phId, &exitCode)) + return NULL; + + stat = TerminateProcess( (void*)phId, exitCode ); + return Py_BuildValue("i", (int)stat ); +} + +static PyMethodDef win32pmMethods[] = { + {"spawnhandle", win32pm_spawnhandle, METH_VARARGS, + "Creates new process. Returns windows handle of new process."}, + {"spawnpid", win32pm_spawnpid, METH_VARARGS, + "Creates new process. Returns PID of new process."}, + {"handle", win32pm_handle, METH_VARARGS, + "Returns windows handle of indicated process PID."}, + {"killpid", win32pm_killpid, METH_VARARGS, + "Terminate process by PID."}, + {"killhandle", win32pm_killhandle, METH_VARARGS, + "Terminate process by windows process handle."}, + {NULL, NULL, 0, NULL} /* Sentinel */ +}; + +PyMODINIT_FUNC +initwin32pm(void) +{ + Py_InitModule("win32pm", win32pmMethods); +}