From e1bf003aa9950cfc29bb23db9e88e347be6390ae Mon Sep 17 00:00:00 2001 From: smh Date: Thu, 26 May 2005 13:55:37 +0000 Subject: [PATCH] SMH: Merge with development version = NEW GUI, POLY_WORK, OCC_development_02, BR_LyfeCycle, HEAD --- INSTALL | 7 +- Makefile.in | 68 +- bin/VERSION | 2 +- bin/killSalomeWithPort.py | 2 +- bin/launchConfigureParser.py | 215 ++-- bin/orbmodule.py | 25 +- bin/runNS.sh | 2 +- bin/runSalome | 8 +- bin/runSalome.py | 182 ++-- bin/salome.launch | 1 - bin/salomeConsole.py | 2 +- configure.in.base | 4 +- doc/salome/tui/KERNEL/doxyfile | 1 - idl/Makefile.in | 1 - idl/SALOMEDS.idl | 106 +- idl/SALOME_Component.idl | 309 ++++-- idl/SALOME_ContainerManager.idl | 11 +- resources/KERNELCatalog.xml | 6 +- salome_adm/unix/SALOMEconfig.h.in | 8 + .../unix/config_files/ac_cxx_depend_flag.m4 | 3 + salome_adm/unix/config_files/check_boost.m4 | 5 +- salome_adm/unix/config_files/check_cas.m4 | 51 +- salome_adm/unix/config_files/check_lsf.m4 | 3 + salome_adm/unix/config_files/check_med2.m4 | 10 +- salome_adm/unix/config_files/check_openpbs.m4 | 3 + salome_adm/unix/config_files/check_pyqt.m4 | 243 ++++- salome_adm/unix/config_files/check_qt.m4 | 6 + salome_adm/unix/config_files/check_qwt.m4 | 32 +- salome_adm/unix/config_files/check_sip.m4 | 158 ++- salome_adm/unix/config_files/check_vtk.m4 | 9 +- salome_adm/unix/make_commence.in | 2 + salome_adm/unix/make_conclude.in | 32 +- src/CASCatch/CASCatch_SignalsHandler.cxx | 6 +- src/Container/Component_i.cxx | 711 +++++++++---- src/Container/Container_i.cxx | 970 +++++++++++++----- src/Container/Makefile.in | 15 +- src/Container/SALOME_ComponentPy.py | 5 + src/Container/SALOME_Component_i.hxx | 13 +- src/Container/SALOME_Container.cxx | 33 +- src/Container/SALOME_ContainerManager.cxx | 12 +- src/Container/SALOME_Container_i.hxx | 67 +- src/DataTypeCatalog/Makefile.in | 3 +- .../SALOME_DataTypeCatalog_Server.cxx | 4 +- src/LifeCycleCORBA/Launchers.cxx | 9 + src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx | 502 ++++++--- src/LifeCycleCORBA/SALOME_LifeCycleCORBA.hxx | 59 +- src/LifeCycleCORBA/TestLifeCycleCORBA.cxx | 2 +- src/Logger/SALOME_Logger_Server.cxx | 107 +- src/Logger/SALOME_Trace.cxx | 2 +- src/Logger/SALOME_Trace.py | 2 +- src/MEDWrapper/Base/MED_Common.hxx | 14 +- src/MEDWrapper/Base/MED_Wrapper.hxx | 3 + src/MEDWrapper/Base/Makefile.in | 2 +- src/MEDWrapper/V2_1/MED_V2_1_Wrapper.cxx | 94 +- src/MEDWrapper/V2_1/MEDdatasetNumEcrire.cxx | 1 + src/MEDWrapper/V2_1/MEDdatasetNumLire.cxx | 1 + src/MEDWrapper/V2_1/Makefile.in | 2 +- src/MEDWrapper/V2_2/MED_V2_2_Wrapper.cxx | 194 ++-- .../SALOME_MPILifeCycleCORBA.cxx | 2 +- src/Makefile.in | 26 +- src/ModuleCatalog/Makefile.in | 6 +- .../SALOME_ModuleCatalog_Server.cxx | 4 +- .../NamingService_WaitForServerReadiness.cxx | 2 +- src/NamingService/SALOME_NamingService.cxx | 139 ++- src/NamingService/SALOME_NamingService.hxx | 6 + src/NamingService/SALOME_NamingServicePy.py | 18 +- src/Notification/NOTIFICATION.cxx | 4 +- src/Registry/SALOME_Registry_Server.cxx | 4 +- .../SALOME_ResourcesManager.cxx | 1 + src/RessourcesCatalog/Makefile.in | 3 +- .../SALOME_RessourcesCatalog_Server.cxx | 6 +- src/SALOMELocalTrace/utilities.h | 10 +- .../TraceCollector_WaitForServerReadiness.cxx | 4 +- src/TOOLSDS/Makefile.in | 6 +- src/TOOLSDS/SALOMEDS_Tool.cxx | 89 +- src/TOOLSDS/SALOMEDS_Tool.hxx | 19 + src/TestContainer/Makefile.in | 3 +- src/TestContainer/SALOME_TestComponent_i.cxx | 7 +- src/TestContainer/TestComponentPy.py | 4 +- src/TestContainer/TestContainer.cxx | 189 ++-- src/Utils/Makefile.in | 6 +- src/Utils/OpUtil.cxx | 16 +- src/Utils/Utils_CorbaException.hxx | 2 +- src/Utils/Utils_DESTRUCTEUR_GENERIQUE.cxx | 37 +- src/Utils/Utils_DESTRUCTEUR_GENERIQUE.hxx | 7 +- src/Utils/Utils_ExceptHandlers.hxx | 12 + src/Utils/Utils_Identity.cxx | 119 ++- src/Utils/Utils_Identity.hxx | 34 +- src/Utils/Utils_ORB_INIT.cxx | 16 +- src/Utils/Utils_SALOME_Exception.cxx | 8 +- src/Utils/Utils_SINGLETON.hxx | 4 +- src/Utils/Utils_SignalsHandler.cxx | 12 +- src/Utils/Utils_Timer.cxx | 39 +- src/Utils/Utils_Timer.hxx | 12 + src/Utils/duplicate.cxx | 9 +- 95 files changed, 3579 insertions(+), 1656 deletions(-) diff --git a/INSTALL b/INSTALL index f3e4b6917..05534d4c7 100644 --- a/INSTALL +++ b/INSTALL @@ -1,7 +1,10 @@ -This is the version 2.2.0 of KERNEL +This is the version 3.0.0 of KERNEL Previous versions : - - 2.1.0 + - 2.2.2 + - 2.2.0 + - 2.1.1 + - 2.1.0 - 2.0.0 - 1.4.1 - 1.3.0 diff --git a/Makefile.in b/Makefile.in index 5c92e402e..9e1043278 100644 --- a/Makefile.in +++ b/Makefile.in @@ -17,73 +17,11 @@ VPATH=.:@srcdir@:@top_srcdir@/bin:./bin/salome:@top_srcdir@/resources:./bin:@top SUBDIRS = idl src examples doc salome_adm RESOURCES_FILES = \ -back.xpm \ -cascade.png \ CatalogDataType.xml \ KERNELCatalog.xml \ -CatalogResources.xml \ CatalogRessources.xml \ -close.png \ config \ -default.png \ -dl_delete.png \ -dl_insert.png \ -dl_moveup.png \ -dl_movedown.png \ -forward.xpm \ -help.png \ -home.xpm \ -new.png \ -open.png \ -print.png \ -redo.png \ -reset.png \ -Application-Logo.png \ -Application-Splash.png \ -Application-About.png \ -save.png \ -select1.png \ -tile.png \ -Tools_en.xml \ -undo.png \ -view_back.png \ -view_bottom.png \ -view_camera_dump.png \ -view_fitall.png \ -view_fitarea.png \ -view_front.png \ -view_glpan.png \ -view_left.png \ -view_pan.png \ -view_reset.png \ -view_right.png \ -view_rotate.png \ -view_top.png \ -view_triedre.png \ -view_zoom.png \ -copy.png \ -paste.png \ -plot2d_dump.png \ -plot2d_fitall.png \ -plot2d_fitarea.png \ -plot2d_legend.png \ -plot2d_linear.png \ -plot2d_linear_y.png \ -plot2d_lines.png \ -plot2d_log.png \ -plot2d_log_y.png \ -plot2d_pan.png \ -plot2d_points.png \ -plot2d_settings.png \ -plot2d_splines.png \ -plot2d_zoom.png \ -uc_add.png \ -uc_current.png \ -uc_del.png \ -uc_new.png \ -uc_clear.png \ channel.cfg \ -Plugin \ SALOMEDS_Resources BIN_SCRIPT= \ @@ -175,6 +113,10 @@ install-bin: $(BIN_SCRIPT) $(INSTALL) -d $(bindir) $(INSTALL_PROGRAM) $^ $(bindir) +# install Plugin file +install-plugin: $(top_builddir)/resources/Plugin + ($(INSTALL_DATA) $^ $(datadir)/resources/. || exit 1); \ + uninstall: uninstall-idl uninstall-idl: @@ -190,5 +132,5 @@ distclean-other: @MODULE@ -install: install-bin install-include install-make install-end +install: install-bin install-include install-make install-plugin install-end diff --git a/bin/VERSION b/bin/VERSION index 9f5dca975..06fe77b17 100755 --- a/bin/VERSION +++ b/bin/VERSION @@ -1 +1 @@ -THIS IS SALOME - KERNEL VERSION: 2.2.0 +THIS IS SALOME - KERNEL VERSION: 3.0.0 diff --git a/bin/killSalomeWithPort.py b/bin/killSalomeWithPort.py index 7c8dcd2ed..f417c7a12 100755 --- a/bin/killSalomeWithPort.py +++ b/bin/killSalomeWithPort.py @@ -13,7 +13,7 @@ def killMyPort(port): pass if found: - a = os.system("pid=`ps -eo pid,command | egrep \"[0-9] omniNames -start "+str(port)+"\" | sed -e \"s%[^0-9]*\([0-9]*\) .*%\\1%g\"`; kill -9 $pid") + a = os.system("pid=`ps -eo pid,command | egrep \"[0-9] omniNames -start "+str(port)+"\" | sed -e \"s%[^0-9]*\([0-9]*\) .*%\\1%g\"`; kill -9 $pid >& /dev/null") try: process_ids=pickle.load(fpid) fpid.close() diff --git a/bin/launchConfigureParser.py b/bin/launchConfigureParser.py index 403e0299b..060ed1745 100755 --- a/bin/launchConfigureParser.py +++ b/bin/launchConfigureParser.py @@ -1,20 +1,60 @@ -import os, glob, string, sys +import os, glob, string, sys, re import xml.sax +# names of tags in XML configuration file +doc_tag = "document" +sec_tag = "section" +par_tag = "parameter" + +# names of attributes in XML configuration file +nam_att = "name" +val_att = "value" + +# certain values in XML configuration file ("launch" section) +lanch_nam = "launch" +gui_nam = "gui" +logger_nam = "logger" +xterm_nam = "xterm" +file_nam = "file" +portkill_nam = "portkill" +killall_nam = "killall" +modules_nam = "modules" +pyModules_nam = "pyModules" +embedded_nam = "embedded" +standalone_nam = "standalone" +containers_nam = "containers" +key_nam = "key" +interp_nam = "interp" + +# values passed as arguments, NOT read from XML config file, but set from within this script +appname_nam = "appname" +port_nam = "port" +appname = "SalomeApp" + +# values of boolean type (must be '0' or '1'). +# xml_parser.boolValue() is used for correct setting +boolKeys = ( gui_nam, logger_nam, file_nam, xterm_nam, portkill_nam, killall_nam, interp_nam ) + +# values of list type +listKeys = ( containers_nam, embedded_nam, key_nam, modules_nam, standalone_nam ) + + # ----------------------------------------------------------------------------- ### xml reader for launch configuration file usage class xml_parser: - def __init__(self, fileName): + def __init__(self, fileName, _opts ): + print "Processing ",fileName self.space = [] - self.opts = {} + self.opts = _opts + self.do = 0 parser = xml.sax.make_parser() parser.setContentHandler(self) parser.parse(fileName) pass - def CorrectBoolean(self, str): + def boolValue( self, str ): if str in ("yes", "y", "1"): return 1 elif str in ("no", "n", "0"): @@ -24,56 +64,39 @@ class xml_parser: pass def startElement(self, name, attrs): - #print "startElement name=",name - #print "startElement attrs=",attrs.getNames() self.space.append(name) self.current = None - if self.space[:2] == ["Configuration-list","launchoptions"] and len(self.space) == 3: - self.current = name - elif self.space == ["Configuration-list","modules-list"]: - self.opts["modules"] = [] - elif self.space == ["Configuration-list","modules-list","module"] and "name" in attrs.getNames(): - for field in attrs.getNames(): - if field == "name": - self.currentModuleName = str(attrs.getValue("name")) - self.opts["modules"].append(self.currentModuleName) - else: - self.opts[str(attrs.getValue("name"))+"_"+str(field)] = self.CorrectBoolean(attrs.getValue(field)) - pass - pass - elif self.space == ["Configuration-list","modules-list","module","plugin"] and "name" in attrs.getNames(): - key = str(self.currentModuleName)+"_plugins" - if not self.opts.has_key(key): - self.opts[key]=[] - pass - self.opts[key].append(attrs.getValue("name")) - elif self.space == ["Configuration-list","embedded-list"]: - self.opts["embedded"] = [] - pass - elif self.space == ["Configuration-list","standalone-list"]: - self.opts["standalone"] = [] - pass - elif self.space == ["Configuration-list","containers-list"]: - self.opts["containers"] = [] + # if we are analyzing "section" element and its "name" attribute is "launch" -- set "do" to 1 + if self.space == [doc_tag, sec_tag] and \ + nam_att in attrs.getNames() and \ + attrs.getValue( nam_att ) == lanch_nam: + self.do = 1 + # if we are analyzing "parameter" elements - children of "section launch" element, then store them + # in self.opts assiciative array (key = value of "name" attribute) + elif self.do == 1 and \ + self.space == [doc_tag, sec_tag, par_tag] and \ + nam_att in attrs.getNames() and \ + val_att in attrs.getNames(): + nam = attrs.getValue( nam_att ) + val = attrs.getValue( val_att ) + if nam in boolKeys: + self.opts[nam] = self.boolValue( val ) # assign boolean value: 0 or 1 + elif nam in listKeys: + self.opts[nam] = val.split( ',' ) # assign list value: [] + else: + self.opts[nam] = val; pass pass def endElement(self, name): p = self.space.pop() self.current = None + if self.do == 1 and name == sec_tag: + self.do = 0 pass def characters(self, content): - #print "Characters content:",content - if self.current: - self.opts[self.current] = self.CorrectBoolean(content) - elif self.space == ["Configuration-list","embedded-list", "embeddedserver"]: - self.opts["embedded"].append(content) - elif self.space == ["Configuration-list","standalone-list", "standaloneserver"]: - self.opts["standalone"].append(content) - elif self.space == ["Configuration-list","containers-list", "containertype"]: - self.opts["containers"].append(content) pass def processingInstruction(self, target, data): @@ -92,45 +115,61 @@ class xml_parser: # ----------------------------------------------------------------------------- -### searching for launch configuration file : $HOME/applipath()/salome.launch - -appname="salome" -import Utils_Identity -versnb=Utils_Identity.version() -dirname = os.path.join(os.environ["HOME"],Utils_Identity.getapplipath()) -filename=os.path.join(dirname,"salome.launch") - -if not os.path.exists(filename): - print "Launch configuration file does not exist. Create default:",filename - os.system("mkdir -p "+dirname) - os.system("cp -f "+os.environ["KERNEL_ROOT_DIR"]+"/bin/salome/salome.launch "+filename) - -### get options from launch configuration file - +### searching for launch configuration files +# the rule: +# - environment variable {'appname'+'Config'} (SalomeAppConfig) contains list of directories (';' as devider) +# - these directories contain 'appname'+'.xml' (SalomeApp.xml) configuration files +# - these files are analyzed beginning with the last one (last directory in the list) +# - if a key is found in next analyzed cofiguration file - it will be replaced +# - the last configuration file to be analyzed - ~/.'appname'+'rc' (~/SalomeApprc) (if it exists) +# - but anyway, if user specifies a certain option in a command line - it will replace the values +# - specified in configuration file(s) +# - once again the order of settings (next setting replaces the previous ones): +# - SalomeApp.xml files in directories specified by SalomeAppConfig env variable +# - .SalomeApprc file in user's catalogue +# - command line + +config_var = appname+'Config' +dirs = os.environ[config_var] +dirs = dirs.split( ';' ) +dirs.reverse() # reverse order, like in "path" variable - FILO-style processing + +_opts = {} # assiciative array of options to be filled + +# SalomeApp.xml files in directories specified by SalomeAppConfig env variable +for dir in dirs: + filename = dir+'/'+appname+'.xml' + try: + p = xml_parser(filename, _opts) + except: + print 'Can not read launch configuration file ', filename + continue + _opts = p.opts + +# SalomeApprc file in user's catalogue +filename = os.environ['HOME']+'/.'+appname+'rc' try: - p = xml_parser(filename) + p = xml_parser(filename, _opts) except: print 'Can not read launch configuration file ', filename - filename = None - pass -if filename: - args = p.opts -else: - args = {} - pass -# --- args completion -for aKey in ("containers","embedded","key","modules","standalone"): - if not args.has_key(aKey): +args = p.opts + +# --- setting default values of keys if they were NOT set in config files --- +for aKey in listKeys: + if not args.has_key( aKey ): args[aKey]=[] -for aKey in ("gui","logger","file","xterm","portkill","killall","interp"): - if not args.has_key(aKey): + +for aKey in boolKeys: + if not args.has_key( aKey ): args[aKey]=0 -if args["file"]: - afile=args["file"] - args["file"]=[afile] -args["appname"] = appname + +if args[file_nam]: + afile=args[file_nam] + args[file_nam]=[afile] + +args[appname_nam] = appname ### searching for my port @@ -140,7 +179,7 @@ try: s = file.read() while len(s): l = string.split(s, ":") - if string.split(l[0], " ")[0] == "ORBInitRef": + if string.split(l[0], " ")[0] == "ORBInitRef" or string.split(l[0], " ")[0] == "InitRef" : my_port = int(l[len(l)-1]) pass s = file.read() @@ -148,7 +187,7 @@ try: except: pass -args["port"] = my_port +args[port_nam] = my_port # ----------------------------------------------------------------------------- @@ -246,33 +285,33 @@ if opts.has_key("h"): ### apply command-line options to the arguments for opt in opts: if opt == 'g': - args['gui'] = 1 + args[gui_nam] = 1 elif opt == 'l': - args['logger'] = 1 + args[logger_nam] = 1 elif opt == 'f': - args['file'] = opts['f'] + args[file_nam] = opts['f'] elif opt == 'x': - args['xterm'] = 1 + args[xterm_nam] = 1 elif opt == 'i': - args['interp'] = opts['i'] + args[interp_nam] = opts['i'] elif opt == 'm': - args['modules'] = opts['m'] + args[modules_nam] = opts['m'] elif opt == 'e': - args['embedded'] = opts['e'] + args[embedded_nam] = opts['e'] elif opt == 's': - args['standalone'] = opts['s'] + args[standalone_nam] = opts['s'] elif opt == 'c': - args['containers'] = opts['c'] + args[containers_nam] = opts['c'] elif opt == 'p': - args['portkill'] = 1 + args[portkill_nam] = 1 elif opt == 'k': - args['killall'] = 1 + args[killall_nam] = 1 pass pass # 'terminal' must be processed in the end: to deny any 'gui' options if 't' in opts: - args['gui'] = 0 + args[gui_nam] = 0 pass print "args=",args diff --git a/bin/orbmodule.py b/bin/orbmodule.py index 627a90987..fdc254472 100755 --- a/bin/orbmodule.py +++ b/bin/orbmodule.py @@ -47,7 +47,7 @@ class client: try: self.rootContext = obj._narrow(CosNaming.NamingContext) return - except CORBA.COMM_FAILURE: + except (CORBA.TRANSIENT,CORBA.OBJECT_NOT_EXIST,CORBA.COMM_FAILURE): self.rootContext = None print "Lancement du Naming Service", @@ -62,7 +62,7 @@ class client: obj = self.orb.resolve_initial_references("NameService") self.rootContext = obj._narrow(CosNaming.NamingContext) break - except (CORBA.COMM_FAILURE,CORBA.OBJECT_NOT_EXIST): + except (CORBA.TRANSIENT,CORBA.OBJECT_NOT_EXIST,CORBA.COMM_FAILURE): self.rootContext = None sys.stdout.write('+') sys.stdout.flush() @@ -77,15 +77,16 @@ class client: def showNScontext(self,context,dec=''): bl,bi=context.list(0) - ok,b=bi.next_one() - while(ok): - for s in b.binding_name : - print "%s%s.%s" %(dec,s.id,s.kind) - if s.kind == "dir": - obj=context.resolve([s]) - scontext = obj._narrow(CosNaming.NamingContext) - self.showNScontext(scontext,dec=dec+' ') + if bi is not None: ok,b=bi.next_one() + while(ok): + for s in b.binding_name : + print "%s%s.%s" %(dec,s.id,s.kind) + if s.kind == "dir": + obj=context.resolve([s]) + scontext = obj._narrow(CosNaming.NamingContext) + self.showNScontext(scontext,dec=dec+' ') + ok,b=bi.next_one() # -------------------------------------------------------------------------- @@ -112,7 +113,7 @@ class client: obj = None except CosNaming.NamingContext.CannotProceed, ex: obj = None - except CORBA.COMM_FAILURE, ex: + except (CORBA.TRANSIENT,CORBA.OBJECT_NOT_EXIST,CORBA.COMM_FAILURE): obj = None return obj @@ -155,7 +156,7 @@ class client: obj = None except CosNaming.NamingContext.CannotProceed, ex: obj = None - except CORBA.COMM_FAILURE, ex: + except (CORBA.TRANSIENT,CORBA.OBJECT_NOT_EXIST,CORBA.COMM_FAILURE): obj = None return obj diff --git a/bin/runNS.sh b/bin/runNS.sh index 76b7452bf..b5c155a6c 100755 --- a/bin/runNS.sh +++ b/bin/runNS.sh @@ -17,7 +17,7 @@ touch ${BaseDir}/logs/${Username}/dummy \rm -f ${BaseDir}/logs/${Username}/omninames* ${BaseDir}/logs/${Username}/dummy ${BaseDir}/logs/${Username}/*.log echo "Name Service... " -aSedCommand="s/ORBInitRef NameService=corbaname::`hostname`:\([[:digit:]]*\)/\1/" +aSedCommand="s/.*NameService=corbaname::`hostname`:\([[:digit:]]*\)/\1/" aPort=`sed -e"$aSedCommand" $OMNIORB_CONFIG` omniNames -start $aPort -logdir ${BaseDir}/logs/${Username} & diff --git a/bin/runSalome b/bin/runSalome index 7505e8b89..ff478c1a0 100755 --- a/bin/runSalome +++ b/bin/runSalome @@ -12,8 +12,12 @@ searchFreePort() { echo ${NSPORT} - Ok local myhost=`hostname` export OMNIORB_CONFIG=${HOME}/.omniORB_${myhost}_${NSPORT}.cfg - local initref="NameService=corbaname::"`hostname`":$NSPORT" - echo "ORBInitRef $initref" > $OMNIORB_CONFIG + local initref="NameService=corbaname::"`hostname`":$NSPORT" + if [[ `python -c "import CORBA; print CORBA.ORB_ID"` == "omniORB4" ]]; then + echo "InitRef = $initref" > $OMNIORB_CONFIG + else + echo "ORBInitRef $initref" > $OMNIORB_CONFIG + fi break fi echo -n "${NSPORT} " diff --git a/bin/runSalome.py b/bin/runSalome.py index e423d97ba..1797f9e36 100755 --- a/bin/runSalome.py +++ b/bin/runSalome.py @@ -5,6 +5,11 @@ import orbmodule process_id = {} +# salome_subdir variable is used for composing paths like $KERNEL_ROOT_DIR/share/salome/resources, etc. +# before moving to SUIT-based gui, instead of salome_subdir there was args['appname'] used. +# but after - 'appname' = "SalomeApp", so using it in making the subdirectory is an error. +salome_subdir = "salome" + # ----------------------------------------------------------------------------- def add_path(directory, variable_name): @@ -97,22 +102,22 @@ def set_env(args, modules_list, modules_root_dir): for module in modules_list : module_root_dir = modules_root_dir[module] modules_root_dir_list[:0] = [module_root_dir] - add_path(os.path.join(module_root_dir,"lib",args['appname']), + add_path(os.path.join(module_root_dir,"lib",salome_subdir), "LD_LIBRARY_PATH") - add_path(os.path.join(module_root_dir,"bin",args['appname']), + add_path(os.path.join(module_root_dir,"bin",salome_subdir), "PATH") if os.path.exists(module_root_dir + "/examples") : add_path(os.path.join(module_root_dir,"examples"), "PYTHONPATH") - add_path(os.path.join(module_root_dir,"bin",args['appname']), + add_path(os.path.join(module_root_dir,"bin",salome_subdir), "PYTHONPATH") add_path(os.path.join(module_root_dir,"lib", - python_version,"site-packages",args['appname']), + python_version,"site-packages",salome_subdir), "PYTHONPATH") - add_path(os.path.join(module_root_dir,"lib",args['appname']), + add_path(os.path.join(module_root_dir,"lib",salome_subdir), "PYTHONPATH") add_path(os.path.join(module_root_dir,"lib", - python_version,"site-packages",args['appname'], + python_version,"site-packages",salome_subdir, "shared_modules"), "PYTHONPATH") @@ -128,7 +133,7 @@ def set_env(args, modules_list, modules_root_dir): locdir=os.environ['PWD'] libtracedir=os.path.join(locdir,"libSalomeTrace") libtrace = os.path.join(modules_root_dir["KERNEL"],"lib", - args['appname'], + salome_subdir, "libSALOMELoggerClient.so.0.0.0") libtraceln = os.path.join(libtracedir,"libSALOMELocalTrace.so") aCommand = 'rm -rf ' + libtracedir + "; " @@ -157,15 +162,15 @@ def set_env(args, modules_list, modules_root_dir): os.environ["SALOME_"+plugin+"Resources"] \ = plugin_root+"/share/"+args["appname"]+"/resources" add_path(os.path.join(plugin_root,"lib",python_version, - "site-packages",args['appname']), + "site-packages",salome_subdir), "PYTHONPATH") - add_path(os.path.join(plugin_root,"lib",args['appname']), + add_path(os.path.join(plugin_root,"lib",salome_subdir), "PYTHONPATH") - add_path(os.path.join(plugin_root,"lib",args['appname']), + add_path(os.path.join(plugin_root,"lib",salome_subdir), "LD_LIBRARY_PATH") - add_path(os.path.join(plugin_root,"bin",args['appname']), + add_path(os.path.join(plugin_root,"bin",salome_subdir), "PYTHONPATH") - add_path(os.path.join(plugin_root,"bin",args['appname']), + add_path(os.path.join(plugin_root,"bin",salome_subdir), "PATH") pass pass @@ -222,7 +227,7 @@ def kill_salome(args): # ----------------------------------------------------------------------------- # -# Définition des classes d'objets pour le lancement des Server CORBA +# Definition des classes d'objets pour le lancement des Server CORBA # class Server: @@ -248,7 +253,7 @@ class Server: + os.getenv("LD_LIBRARY_PATH")] myargs = myargs +['-T']+self.CMD[:1]+['-e'] + env_ld_library_path command = myargs + self.CMD - # print "command = ", command + print "command = ", command pid = os.spawnvp(os.P_NOWAIT, command[0], command) process_id[pid]=self.CMD @@ -274,8 +279,10 @@ class CatalogServer(Server): self.args=args self.initArgs() self.SCMD1=['SALOME_ModuleCatalog_Server','-common'] - self.SCMD2=['-personal', - '${HOME}/Salome/resources/CatalogModulePersonnel.xml'] + self.SCMD2=[] + home_dir=os.getenv('HOME') + if home_dir is not None: + self.SCMD2=['-personal',os.path.join(home_dir,'Salome/resources/CatalogModulePersonnel.xml')] def setpath(self,modules_list,modules_root_dir): cata_path=[] @@ -287,7 +294,7 @@ class CatalogServer(Server): print " ", module_cata cata_path.extend( glob.glob(os.path.join(module_root_dir, - "share",self.args['appname'], + "share",salome_subdir, "resources",module_cata))) self.CMD=self.SCMD1 + [string.join(cata_path,':')] + self.SCMD2 @@ -372,12 +379,16 @@ class SessionServer(Server): '(','--salome_session','theSession',')'] if 'moduleCatalog' in self.args['embedded']: self.SCMD1+=['--with','ModuleCatalog','(','-common'] - self.SCMD2+=['-personal', - '${HOME}/Salome/resources/CatalogModulePersonnel.xml',')'] + home_dir=os.getenv('HOME') + if home_dir is not None: + self.SCMD2+=['-personal',os.path.join(home_dir,'Salome/resources/CatalogModulePersonnel.xml')] + self.SCMD2+=[')'] if 'study' in self.args['embedded']: self.SCMD2+=['--with','SALOMEDS','(',')'] if 'cppContainer' in self.args['embedded']: self.SCMD2+=['--with','Container','(','FactoryServer',')'] + if 'SalomeAppEngine' in self.args['embedded']: + self.SCMD2+=['--with','SalomeAppEngine','(',')'] def setpath(self,modules_list,modules_root_dir): cata_path=[] @@ -389,26 +400,61 @@ class SessionServer(Server): print " ", module_cata cata_path.extend( glob.glob(os.path.join(module_root_dir,"share", - self.args['appname'],"resources", + salome_subdir,"resources", module_cata))) if 'moduleCatalog' in self.args['embedded']: self.CMD=self.SCMD1 + [string.join(cata_path,':')] + self.SCMD2 else: self.CMD=self.SCMD1 + self.SCMD2 -## # arguments SALOME_Session_Server pour ddd -## comm_ddd="" -## for mot in self.CMD: -## if mot == "(": -## comm_ddd+='"(" ' -## elif mot == ")": -## comm_ddd+='")" ' -## else: -## comm_ddd+=mot+" " -## print comm_ddd + # arguments SALOME_Session_Server pour ddd + comm_ddd="" + for mot in self.CMD: + if mot == "(": + comm_ddd+='"(" ' + elif mot == ")": + comm_ddd+='")" ' + else: + comm_ddd+=mot+" " + print comm_ddd # --- +class ContainerManagerServer(Server): + def __init__(self,args): + self.args=args + self.initArgs() + self.SCMD1=['SALOME_ContainerManagerServer'] + self.SCMD2=[] + if 'registry' in self.args['embedded']: + self.SCMD1+=['--with','Registry', + '(','--salome_session','theSession',')'] + if 'moduleCatalog' in self.args['embedded']: + self.SCMD1+=['--with','ModuleCatalog','(','-common'] + self.SCMD2+=['-personal', + '${HOME}/Salome/resources/CatalogModulePersonnel.xml',')'] + if 'study' in self.args['embedded']: + self.SCMD2+=['--with','SALOMEDS','(',')'] + if 'cppContainer' in self.args['embedded']: + self.SCMD2+=['--with','Container','(','FactoryServer',')'] + + def setpath(self,modules_list,modules_root_dir): + cata_path=[] + list_modules = modules_list[:] + list_modules.reverse() + for module in ["KERNEL"] + list_modules: + module_root_dir=modules_root_dir[module] + module_cata=module+"Catalog.xml" + print " ", module_cata + cata_path.extend( + glob.glob(os.path.join(module_root_dir,"share", + self.args['appname'],"resources", + module_cata))) + if 'moduleCatalog' in self.args['embedded']: + self.CMD=self.SCMD1 + [string.join(cata_path,':')] + self.SCMD2 + else: + self.CMD=self.SCMD1 + self.SCMD2 + class NotifyServer(Server): def __init__(self,args,modules_root_dir): self.args=args @@ -429,6 +475,7 @@ class NotifyServer(Server): def startGUI(): """Salome Session Graphic User Interface activation""" import SALOME + import SALOME_Session_idl session=clt.waitNS("/Kernel/Session",SALOME.Session) session.GetInterface() @@ -444,9 +491,9 @@ def startSalome(args, modules_list, modules_root_dir): print "startSalome ", args - if args['gui']: - myServer=SessionLoader(args) - myServer.run() + #if args['gui']: + # myServer=SessionLoader(args) + # myServer.run() # # Initialisation ORB et Naming Service @@ -473,7 +520,7 @@ def startSalome(args, modules_list, modules_root_dir): # # Lancement Registry Server, - # attente de la disponibilité du Registry dans le Naming Service + # attente de la disponibilite du Registry dans le Naming Service # if 'registry' not in args['embedded']: @@ -483,7 +530,7 @@ def startSalome(args, modules_list, modules_root_dir): # # Lancement Catalog Server, - # attente de la disponibilité du Catalog Server dans le Naming Service + # attente de la disponibilite du Catalog Server dans le Naming Service # @@ -496,47 +543,41 @@ def startSalome(args, modules_list, modules_root_dir): # # Lancement SalomeDS Server, - # attente de la disponibilité du SalomeDS dans le Naming Service + # attente de la disponibilite du SalomeDS dans le Naming Service # os.environ["CSF_PluginDefaults"] \ = os.path.join(modules_root_dir["KERNEL"],"share", - args['appname'],"resources") + salome_subdir,"resources") os.environ["CSF_SALOMEDS_ResourcesDefaults"] \ = os.path.join(modules_root_dir["KERNEL"],"share", - args['appname'],"resources") + salome_subdir,"resources") if "GEOM" in modules_list: print "GEOM OCAF Resources" os.environ["CSF_GEOMDS_ResourcesDefaults"] \ = os.path.join(modules_root_dir["GEOM"],"share", - args['appname'],"resources") + salome_subdir,"resources") print "GEOM Shape Healing Resources" os.environ["CSF_ShHealingDefaults"] \ = os.path.join(modules_root_dir["GEOM"],"share", - args['appname'],"resources") + salome_subdir,"resources") + print "ARGS = ",args if 'study' not in args['embedded']: + print "RunStudy" myServer=SalomeDSServer(args) myServer.run() clt.waitNS("/myStudyManager") # - # Lancement Session Server - # - - mySessionServ = SessionServer(args) - mySessionServ.setpath(modules_list,modules_root_dir) - mySessionServ.run() - - #macomm2=['ddd'] - #pid = os.spawnvp(os.P_NOWAIT, macomm2[0], macomm2) - # - # Attente de la disponibilité du Session Server dans le Naming Service + # Lancement ContainerManagerServer # + + myCmServer = ContainerManagerServer(args) + myCmServer.setpath(modules_list,modules_root_dir) + myCmServer.run() - import SALOME - session=clt.waitNS("/Kernel/Session",SALOME.Session) from Utils_Identity import getShortHostName @@ -550,7 +591,7 @@ def startSalome(args, modules_list, modules_root_dir): # # Lancement Container C++ local, - # attente de la disponibilité du Container C++ local dans le Naming Service + # attente de la disponibilite du Container C++ local dans le Naming Service # if 'cppContainer' in args['standalone']: @@ -560,7 +601,7 @@ def startSalome(args, modules_list, modules_root_dir): # # Lancement Container Python local, - # attente de la disponibilité du Container Python local + # attente de la disponibilite du Container Python local # dans le Naming Service # @@ -571,7 +612,7 @@ def startSalome(args, modules_list, modules_root_dir): # # Lancement Container Supervision local, - # attente de la disponibilité du Container Supervision local + # attente de la disponibilite du Container Supervision local # dans le Naming Service # @@ -579,12 +620,35 @@ def startSalome(args, modules_list, modules_root_dir): myServer=ContainerSUPERVServer(args) myServer.run() clt.waitNS("/Containers/" + theComputer + "/SuperVisionContainer") +##---------------- + + # + # Lancement Session Server + # + mySessionServ = SessionServer(args) + mySessionServ.setpath(modules_list,modules_root_dir) + mySessionServ.run() + + #macomm2=['ddd'] + #pid = os.spawnvp(os.P_NOWAIT, macomm2[0], macomm2) + # + # Attente de la disponibilité du Session Server dans le Naming Service + # + + import SALOME + import SALOME_Session_idl + session=clt.waitNS("/Kernel/Session",SALOME.Session) end_time = os.times() print print "Start SALOME, elapsed time : %5.1f seconds"% (end_time[4] - init_time[4]) + # ASV start GUI without Loader + if args['gui']: + session.GetInterface() + + # # additionnal external python interpreters # @@ -631,9 +695,11 @@ def useSalome(args, modules_list, modules_root_dir): #print process_id +# filedict = '/tmp/' + os.getenv('USER') + "_" + str(args['port']) \ +# + '_' + args['appname'].upper() + '_pidict' +# replaced args['appname'] by "SALOME" because in killSalome.py use of 'SALOME' in file name is hardcoded. filedict = '/tmp/' + os.getenv('USER') + "_" + str(args['port']) \ - + '_' + args['appname'].upper() + '_pidict' - + + '_' + 'SALOME' + '_pidict' process_ids = [] try: fpid=open(filedict, 'r') diff --git a/bin/salome.launch b/bin/salome.launch index 92c5eab6d..1b5bbdd1b 100644 --- a/bin/salome.launch +++ b/bin/salome.launch @@ -2,7 +2,6 @@ yes no - no yes no diff --git a/bin/salomeConsole.py b/bin/salomeConsole.py index 03c0a5e51..5ce7cec64 100755 --- a/bin/salomeConsole.py +++ b/bin/salomeConsole.py @@ -66,7 +66,7 @@ class client(orbmodule.client): try: self.rootContext = obj._narrow(CosNaming.NamingContext) return - except CORBA.COMM_FAILURE: + except (CORBA.TRANSIENT,CORBA.OBJECT_NOT_EXIST,CORBA.COMM_FAILURE): print "It's not a valid naming service" self.rootContext = None raise diff --git a/configure.in.base b/configure.in.base index 687d5d093..9ba416b5a 100644 --- a/configure.in.base +++ b/configure.in.base @@ -182,7 +182,7 @@ echo testing OpenPBS echo --------------------------------------------- echo -openpbs_ok=no +dnl openpbs_ok=no CHECK_OPENPBS dnl openpbs_ok is set to yes by CHECK_OPENPBS @@ -198,7 +198,7 @@ echo testing LSF echo --------------------------------------------- echo -lsf_ok=no +dnl lsf_ok=no CHECK_LSF dnl lsf_ok is set to yes by CHECK_LSF diff --git a/doc/salome/tui/KERNEL/doxyfile b/doc/salome/tui/KERNEL/doxyfile index 29f6496ce..64247b6b5 100755 --- a/doc/salome/tui/KERNEL/doxyfile +++ b/doc/salome/tui/KERNEL/doxyfile @@ -60,7 +60,6 @@ INPUT = ../../../share/salome/idl/SALOME_ModuleCatalog.idl \ ../../../share/salome/idl/SALOMEDS.idl \ ../../../share/salome/idl/SALOME_Exception.idl \ ../../../share/salome/idl/SALOMEDS_Attributes.idl \ - ../../../share/salome/idl/SALOME_Session.idl \ ../../../share/salome/idl/SALOME_Component.idl \ ../../../share/salome/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.hxx \ ../../../share/salome/src/NamingService/SALOME_NamingService.hxx \ diff --git a/idl/Makefile.in b/idl/Makefile.in index 40542236a..9ac8e2c24 100644 --- a/idl/Makefile.in +++ b/idl/Makefile.in @@ -18,7 +18,6 @@ IDL_FILES = \ SALOME_RessourcesCatalog.idl \ SALOMEDS.idl \ SALOMEDS_Attributes.idl \ - SALOME_Session.idl \ SALOME_Component.idl \ SALOME_ContainerManager.idl \ SALOME_TestComponent.idl \ diff --git a/idl/SALOMEDS.idl b/idl/SALOMEDS.idl index 15e651164..7c0844a31 100644 --- a/idl/SALOMEDS.idl +++ b/idl/SALOMEDS.idl @@ -36,6 +36,7 @@ #define _SALOMEDS_IDL_ #include "SALOME_Exception.idl" +#include "SALOME_GenericObj.idl" /*! This package contains the interfaces used for creation, managment @@ -98,7 +99,6 @@ during each working session. interface AttributeStudyProperties; interface UseCaseIterator; interface UseCaseBuilder; - interface Callback; /*! List of attributes of %SObjects */ @@ -367,6 +367,17 @@ during each working session. void RemovePostponed(in long theUndoLimit); void UndoPostponed(in long theWay); + + boolean DumpStudy(in string thePath, in string theBaseName, in boolean isPublished); + +/*! + Private method, returns an implementation of this Study. + \param theHostname is a hostname of the caller + \param thePID is a process ID of the caller + \param isLocal is set True if the Study is launched locally with the caller +*/ + long GetLocalImpl(in string theHostname, in long thePID, out boolean isLocal); + }; //========================================================================== @@ -403,6 +414,7 @@ during each working session. Defines the instance to the %SComponent. */ void DefineComponentInstance (in SComponent aComponent,in Object ComponentIOR) raises(LockProtection); + /*! \brief Deletion of a %SComponent Removes a %SComponent. @@ -605,22 +617,6 @@ Searches for a definite %SObject with a definite GUID and returns True if it fin */ boolean GetAvailableRedos(); -/*! - This method is called when adding an object into study. - It sets the callback for addition of the given %SObject. - \param theCallback New assigned callback. - \return The previous callback. -*/ - Callback SetOnAddSObject(in Callback theCallback); -/*! - This method is called when adding an object into study. - It sets the callback for removal of the given %SObject. - - \return The previous callback. - \param theCallback New assigned callback. -*/ - Callback SetOnRemoveSObject(in Callback theCallback); - /*! Puts name attribute with the given string value to the given %SObject @@ -778,6 +774,29 @@ Gets the list of open studies an object into a study, which is protected for modifications. */ SObject Paste(in SObject theObject) raises (SALOMEDS::StudyBuilder::LockProtection); + +/*! \brief Object conversion. + + Converts an object into IOR. + \return IOR +*/ + string ConvertObjectToIOR(in Object theObject); +/*! \brief Object conversion. + + Converts IOR into an object. + \return An object +*/ + Object ConvertIORToObject(in string theIOR); + +/*! + Private method, returns an implementation of this StudyManager. + \param theHostname is a hostname of the caller + \param thePID is a process ID of the caller + \param isLocal is set True if the StudyManager is launched locally with the caller +*/ + long GetLocalImpl(in string theHostname, in long thePID, out boolean isLocal); + + }; @@ -795,7 +814,7 @@ Gets the list of open studies */ //========================================================================== - interface SObject + interface SObject : SALOME::GenericObj { /*! Name of the %SObject */ @@ -885,6 +904,14 @@ Gets the list of open studies Returns empty string if there is no IOR attribute. */ string GetIOR(); + +/*! + Private method, returns an implementation of this SObject. + \param theHostname is a hostname of the caller + \param thePID is a process ID of the caller + \param isLocal is set True if the SObject is launched locally with the caller +*/ + long GetLocalImpl(in string theHostname, in long thePID, out boolean isLocal); }; @@ -894,7 +921,7 @@ Gets the list of open studies %Generic attribute is a base interface for all attributes which can be assigned to the SObjects created in the study. */ //========================================================================== - interface GenericAttribute + interface GenericAttribute : SALOME::GenericObj { /*! \brief Exception locking all changes @@ -909,13 +936,19 @@ Gets the list of open studies */ void CheckLocked() raises (LockProtection); - string Store(); - - void Restore(in string theData); - string Type(); + string GetClassType(); + SObject GetSObject(); + +/*! + Private method, returns an implementation of this GenericAttribute. + \param theHostname is a hostname of the caller + \param thePID is a process ID of the caller + \param isLocal is set True if the GenericAttribute is launched locally with the caller +*/ + long GetLocalImpl(in string theHostname, in long thePID, out boolean isLocal); }; @@ -951,7 +984,7 @@ Gets the list of open studies The search is started from the first %SComponent in the list. */ //========================================================================== - interface SComponentIterator + interface SComponentIterator : SALOME::GenericObj { /*! Activates the %SComponentIterator. @@ -982,7 +1015,7 @@ Moves the iterator to the next %SComponent in the list. levels. */ //========================================================================== - interface ChildIterator + interface ChildIterator : SALOME::GenericObj { /*! @@ -1017,7 +1050,7 @@ Activates the %ChildIterator for all child levels. This interface contains a set of methods used for iteration over the objects in the use case. */ - interface UseCaseIterator + interface UseCaseIterator : SALOME::GenericObj { /*! Activates the %UseCaseIterator. @@ -1046,7 +1079,7 @@ Activates the %UseCaseIterator. Use case in the study represents a user-managed subtree, containing all or some of the objects which exist in the study. The %UseCaseBuilder interface contains a set of methods used for management of the use case in the study. */ - interface UseCaseBuilder + interface UseCaseBuilder : SALOME::GenericObj { /*! Adds to the use case an object as a child of the current object of the use case. @@ -1108,25 +1141,6 @@ Activates the %UseCaseIterator. UseCaseIterator GetUseCaseIterator(in SObject theObject); }; //========================================================================== - //========================================================================== -/*! \brief The callback interface - - The %StudyBuilder can be created with the method NewBuilder. While invocation of this method a new object of the class Callback is created - and this object is assigned to the newly created Builder as callback which should be called when adding and removing of the ojects. -*/ - interface Callback - { -/*! - Invokes the corresponding method Append of the %UseCaseBuilder. -*/ - void OnAddSObject(in SObject theObject); -/*! - Invokes the corresponding method Remove of the %UseCaseBuilder. -*/ - void OnRemoveSObject(in SObject theObject); - }; - - //========================================================================== /*! \brief %Driver interface This class represents a common tool for all components integrated into SALOME application, that allows them to communicate with the study. It contains a set of methods which diff --git a/idl/SALOME_Component.idl b/idl/SALOME_Component.idl index f60922c42..3d305ab77 100644 --- a/idl/SALOME_Component.idl +++ b/idl/SALOME_Component.idl @@ -21,20 +21,26 @@ // // File : SALOME_Component.idl // Author : Paul RASCLE, EDF -// $Header: /dn05/salome/CVS/SALOME_ROOT/idl/SALOME_Component.idl +// $Header: #ifndef _SALOME_COMPONENT_IDL_ #define _SALOME_COMPONENT_IDL_ /*! - -This is a package of interfaces used for connecting new components to %SALOME application. It also contains a set of interfaces used -for management of %MED component in %SALOME application. +This is a package of interfaces used for connecting new components to %SALOME +application. It also contains a set of interfaces used for management of %MED +component in %SALOME application. */ module Engines { -/*! + /*! + A byte stream which is used for binary data transfer between different components + + */ + typedef sequence TMPFile; + + /*! General Key Value Structure to set or get properties, for component -*/ + */ struct KeyValuePair { string key; @@ -45,135 +51,232 @@ module Engines interface Component ; -/*! \brief Interface of the %Container + /*! \brief Interface of the %Container + This interface defines the process of loading and registration + of new components in %SALOME application + */ - This interface defines the process of loading and registration - of new components in %SALOME application -*/ interface Container { -/*! - Loads into the container a new component, registers it and starts it's CORBA servant. - \param nameToRegister Name of the component which will be registered in Registry (or Name Service) - \param componentName Name of the constructed library of the %component - \return a loaded component -*/ - Component load_impl(in string nameToRegister, in string componentName); + /*! + Loads a new component class (dynamic library). + \param componentName like COMPONENT, (Python or C++ implementation) + try to make a Python import of COMPONENT, + then a lib open of libCOMPONENTEngine.so + \return true if load successfull or already done, false otherwise + */ + boolean load_component_Library(in string componentName); -/*! - Loads into the container a new component, registers it and starts it's CORBA servant. - \param nameToRegister Name used to register in Naming Service, the component instance - \param componentName Name of the %component - \return a new instance of the component or the registered component if already registered or Nil if not possible -*/ - Component instance(in string nameToRegister, in string componentName); + /*! + Creates a new servant instance of a component. + Component library must be loaded. + \param comoponentName Name of the component which will be registered + in Registry and Name Service, + (instance number suffix added to the registered name) + \param studyId 0 if instance is not associated to a study, + >0 otherwise (== study id) + \return a loaded component + */ + Component create_component_instance(in string componentName, + in long studyId); -/*! - Stops the component servant, and deletes all related objects - \param component_i Component to be removed -*/ + /*! + 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 + */ + Component find_component_instance(in string registeredName, + in long studyId); + + /*! + Find a servant instance of a component, or create a new one. + Loads the component library if needed. + Only applicable to multiStudy components. + \param nameToRegister Name of the component which will be registered + in Registry (or Name Service) + \param componentName Name of the constructed library of the %component + (not used any more, give empty string) + \return a loaded component + */ + Component load_impl(in string nameToRegister, + in string componentName); + + /*! + Stops the component servant, and deletes all related objects + \param component_i Component to be removed + */ void remove_impl(in Component component_i); -/*! - Discharges all components from the container. -*/ + /*! + Discharges all components from the container. + */ void finalize_removal() ; -/*! - Determines whether the server has been loaded or not. -*/ + /*! + Determines whether the server has been loaded or not. + */ void ping(); -/*! - Name of the %container -*/ + + /*! + Name of the %container + */ readonly attribute string name ; -/*! - Name of the machine containing this container (location of the container). -*/ - readonly attribute string machineName ; -/*! - Returns True if the %container has been killed -*/ - boolean Kill_impl() ; -/*! - Shutdown the Container process. -*/ + + /*! + Shutdown the Container process. + */ oneway void Shutdown(); -/*! - Returns the hostname of the container -*/ + + /*! + Returns the hostname of the container + */ string getHostName(); -/*! - Returns the PID of the container -*/ + + /*! + Returns the PID of the container + */ long getPID(); + + /*! + Returns True if the %container has been killed. + Kept for Superv compilation but can't work, unless oneway... + TO REMOVE ! + */ + boolean Kill_impl() ; + + // -------------------------- removed ------------------------------- + + /*! + Loads into the container a new component, registers it and starts it's + CORBA servant. + \param nameToRegister Name used to register in Naming Service, + the component instance + \param componentName Name of the %component + \return a new instance of the component or the registered component + if already registered or Nil if not possible + */ + // Component instance(in string nameToRegister, in string componentName); + + + /*! + Name of the machine containing this container (location of the container). + */ + // readonly attribute string machineName ; + + }; -/*! \brief Interface of the %component - This interface is used for interaction between the %container and the %component and between - the components inside the container. -*/ + + + /*! \brief Interface of the %component + This interface is used for interaction between the %container and the + %component and between the components inside the container. + */ interface Component { -/*! - The name of the instance of the %Component -*/ + /*! + The name of the instance of the %Component + */ readonly attribute string instanceName ; -/*! - The name of the interface of the %Component -*/ + + /*! + The name of the interface of the %Component + */ readonly attribute string interfaceName ; -/*! - Determines whether the server has already been loaded or not. -*/ + + /*! + Determines whether the server has already been loaded or not. + */ void ping(); -/*! - Deactivates the %Component. -*/ + +// /*! +// Set study associated to component instance +// \param studyId +// (=0: multistudy component instance, +// >0: study id associated to this instance +// \return false if already set with a different value (change not possible) +// */ +// boolean setStudyId(in long studyId); + + /*! + get study associated to component instance + \return -1: not initialised (Internal Error) + 0: multistudy component instance + >0: study id associated to this instance + */ + long getStudyId(); + + /*! + Deactivates the %Component. + -- TO BE USED BY CONTAINER ONLY (Container housekeeping) -- + use remove_impl from Container instead ! + */ void destroy() ; -/*! - Returns the container that the %Component refers to. -*/ + + /*! + Returns the container that the %Component refers to. + */ Container GetContainerRef() ; -/*! - Gives a sequence of (key=string,value=any) to the component. - Base class component stores the sequence in a map. - The map is cleared before. - This map is for use by derived classes. -*/ + + /*! + Gives a sequence of (key=string,value=any) to the component. + Base class component stores the sequence in a map. + The map is cleared before. + This map is for use by derived classes. + */ void setProperties(in FieldsDict dico); -/*! - returns a previously stored map (key=string,value=any) as a sequence. - See setProperties(in FieldsDict dico). -*/ + + /*! + returns a previously stored map (key=string,value=any) as a sequence. + See setProperties(in FieldsDict dico). + */ FieldsDict getProperties(); -/*! - This method is used by the %SUPERVISOR component. It sets the names of the graph and of the node. - \param aGraphName Name of graph - \param aNodeName Name of node -*/ + + /*! + This method is used by the %SUPERVISOR component. It sets the names of + the graph and of the node. + \param aGraphName + Name of graph + \param aNodeName Name of node + */ void Names( in string aGraphName , in string aNodeName ) ; -/*! - Returns True if the %Component has been killed. -*/ + + /*! + Returns True if the %Component has been killed. + */ boolean Kill_impl() ; -/*! - Returns True if the activity of the %Component has been stopped. (It's action can't be resumed) -*/ + + /*! + Returns True if the activity of the %Component has been stopped. + (It's action can't be resumed) + */ boolean Stop_impl() ; -/*! - Returns True if the activity of the %Component has been suspended. (It's action can be resumed) -*/ + + /*! + Returns True if the activity of the %Component has been suspended. + (It's action can be resumed) + */ boolean Suspend_impl() ; -/*! - Returns True if the activity of the %Component has been resumed. -*/ + + /*! + Returns True if the activity of the %Component has been resumed. + */ boolean Resume_impl() ; -/*! - Returns the Cpu used (long does not run with python !...) -*/ + + /*! + Returns the Cpu used (long does not run with python !...) + */ long CpuUsed_impl() ; + + /*! + Returns a python script, which is being played back reproduces the data model of component + */ + TMPFile DumpPython(in Object theStudy, in boolean isPublished, out boolean isValidScript); + } ; } ; diff --git a/idl/SALOME_ContainerManager.idl b/idl/SALOME_ContainerManager.idl index d8a57247e..9e9ca413a 100644 --- a/idl/SALOME_ContainerManager.idl +++ b/idl/SALOME_ContainerManager.idl @@ -9,7 +9,8 @@ module Engines /*! Type to describe properties of wanted resource. */ -struct MachineParameters { +struct MachineParameters +{ string container_name; string hostname; string OS; @@ -29,9 +30,13 @@ struct MachineParameters { */ interface ContainerManager { - Container FindOrStartContainer( in string containerName, in MachineList possibleComputers); + Container FindOrStartContainer( in string containerName, + in MachineList possibleComputers); + string FindBest(in MachineList possibleComputers); - MachineList GetFittingResources( in MachineParameters params, in string componentName ); + + MachineList GetFittingResources( in MachineParameters params, + in string componentName ); void Shutdown(); void ShutdownContainers(); } ; diff --git a/resources/KERNELCatalog.xml b/resources/KERNELCatalog.xml index 4bad252ff..7b837d118 100644 --- a/resources/KERNELCatalog.xml +++ b/resources/KERNELCatalog.xml @@ -16,7 +16,7 @@ Salome Other NRI - 2.2.0 + 3.0.0 GUI Neutral Context 1 @@ -27,7 +27,7 @@ SalomeTestComponent Other NRI - 2.1.0 + 3.0.0 GUI Neutral Context 1 'linux' ~ OS @@ -37,7 +37,7 @@ SALOME_TestComponentPy Other NRI - 2.1.0 + 3.0.0 GUI Neutral Context 1 'linux' ~ OS diff --git a/salome_adm/unix/SALOMEconfig.h.in b/salome_adm/unix/SALOMEconfig.h.in index e79eb7ae8..c1be35bd0 100644 --- a/salome_adm/unix/SALOMEconfig.h.in +++ b/salome_adm/unix/SALOMEconfig.h.in @@ -19,9 +19,17 @@ See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org ------------------------------------------------------------------------------------*/ +#ifndef SALOME_CONFIG_H +#define SALOME_CONFIG_H + #define DEBUG #define QUOTE(x) #x #define CORBA_CLIENT_HEADER(x) QUOTE(x@IDL_CLN_H@) #define CORBA_SERVER_HEADER(x) QUOTE(x@IDL_SRV_H@) +#ifndef @MACHINE@ + #define @MACHINE@ +#endif + +#endif diff --git a/salome_adm/unix/config_files/ac_cxx_depend_flag.m4 b/salome_adm/unix/config_files/ac_cxx_depend_flag.m4 index 9e3d4ecc9..ee49cd8a3 100644 --- a/salome_adm/unix/config_files/ac_cxx_depend_flag.m4 +++ b/salome_adm/unix/config_files/ac_cxx_depend_flag.m4 @@ -44,12 +44,14 @@ dnl on utilise donc gnu pour generer les dependances. DEPCXX=g++ DEPCXXFLAGS="-Wno-deprecated" DIFFFLAGS="-w" + MACHINE="OSF1" ;; *) DEPCC=${CC-cc} DEPCXX=${CXX-c++} DEPCXXFLAGS="\${CXXFLAGS}" DIFFFLAGS="-b -B" + MACHINE="PCLINUX" ;; esac C_DEPEND_FLAG= @@ -137,5 +139,6 @@ dnl use g++ option -MG : asume unknown file will be construct later AC_SUBST(DEPCXXFLAGS) AC_SUBST(C_DEPEND_FLAG) AC_SUBST(CXX_DEPEND_FLAG) + AC_SUBST(MACHINE) ]) ]) diff --git a/salome_adm/unix/config_files/check_boost.m4 b/salome_adm/unix/config_files/check_boost.m4 index 789167b4c..215ce8cf5 100644 --- a/salome_adm/unix/config_files/check_boost.m4 +++ b/salome_adm/unix/config_files/check_boost.m4 @@ -31,7 +31,10 @@ BOOST_CPPFLAGS="" boost_ok=no if test -z ${BOOSTDIR}; then - AC_MSG_WARN(You must provide BOOSTDIR variable) + AC_CHECK_HEADER(boost/shared_ptr.hpp,boost_ok=yes,boost_ok=no) + if test boost_ok = no ; then + AC_MSG_WARN(You must provide BOOSTDIR variable) + fi else AC_MSG_RESULT(\$BOOSTDIR = ${BOOSTDIR}) AC_CHECKING(for boost/shared_ptr.hpp header file) diff --git a/salome_adm/unix/config_files/check_cas.m4 b/salome_adm/unix/config_files/check_cas.m4 index 3b3f654f9..3484dc7cd 100644 --- a/salome_adm/unix/config_files/check_cas.m4 +++ b/salome_adm/unix/config_files/check_cas.m4 @@ -37,6 +37,7 @@ AC_SUBST(CAS_OCAF) AC_SUBST(CAS_DATAEXCHANGE) AC_SUBST(CAS_LDFLAGS) AC_SUBST(CAS_LDPATH) +AC_SUBST(CAS_STDPLUGIN) OWN_CONFIG_H=no @@ -72,6 +73,19 @@ case $host_os in esac AC_MSG_CHECKING(for OpenCascade directories) + +if test -z $CASROOT; then + AC_MSG_RESULT(CASROOT not defined) + for d in `echo $LD_LIBRARY_PATH | sed -e "s/:/ /g"` ; do + if test -f $d/libTKernel.so ; then + AC_MSG_RESULT(libTKernel.so detected in $d) + CASROOT=$d + CASROOT=`echo ${CASROOT} | sed -e "s,[[^/]]*$,,;s,/$,,;s,^$,.,"` + break + fi + done +fi + if test -d ${CASROOT}/${casdir}/lib; then CAS_LDPATH="-L$CASROOT/$casdir/lib " AC_MSG_RESULT(yes) @@ -91,12 +105,17 @@ if test -z $CASROOT; then else occ_ok=yes OCC_VERSION_MAJOR=0 + OCC_VERSION_MINOR=0 ff=$CASROOT/inc/Standard_Version.hxx if test -f $ff ; then grep "define OCC_VERSION_MAJOR" $ff > /dev/null if test $? = 0 ; then OCC_VERSION_MAJOR=`grep "define OCC_VERSION_MAJOR" $ff | awk '{i=3 ; print $i}'` fi + grep "define OCC_VERSION_MINOR" $ff > /dev/null + if test $? = 0 ; then + OCC_VERSION_MINOR=`grep "define OCC_VERSION_MINOR" $ff | awk '{i=3 ; print $i}'` + fi fi fi @@ -113,9 +132,24 @@ dnl test c++ compiler flag for unsigned character dnl cascade headers CPPFLAGS_old="$CPPFLAGS" - CAS_CPPFLAGS="-DOCC_VERSION_MAJOR=$OCC_VERSION_MAJOR -DLIN -DLINTEL -DCSFDB -DNO_CXX_EXCEPTION -DNo_exception -DHAVE_CONFIG_H -DHAVE_LIMITS_H -DHAVE_WOK_CONFIG_H -I$CASROOT/inc" +case $host_os in + linux*) + CAS_CPPFLAGS="-DOCC_VERSION_MAJOR=$OCC_VERSION_MAJOR -DLIN -DLINTEL -DCSFDB -DNO_CXX_EXCEPTION -DNo_exception -DHAVE_CONFIG_H -DHAVE_LIMITS_H -DHAVE_WOK_CONFIG_H -I$CASROOT/inc" + ;; + osf*) + CAS_CPPFLAGS="-DOCC_VERSION_MAJOR=$OCC_VERSION_MAJOR -DLIN -DLINTEL -DCSFDB -DNo_exception -DHAVE_CONFIG_H -DHAVE_LIMITS_H -DHAVE_WOK_CONFIG_H -I$CASROOT/inc" + ;; +esac CPPFLAGS="$CPPFLAGS $CAS_CPPFLAGS" + if test -z $KERNEL_ROOT_DIR; then + if test -d $KERNEL_ROOT_DIR/include/salome; then + CAS_CPPFLAGS="$CAS_CPPFLAGS -I$KERNEL_ROOT_DIR/include/salome" + fi + fi + CAS_CPPFLAGS="$CAS_CPPFLAGS -I${ROOT_BUILDDIR}/include/salome" + CPPFLAGS="$CPPFLAGS -I${ROOT_BUILDDIR}/salome_adm/unix" + echo echo echo testing config.h @@ -179,14 +213,23 @@ else CAS_KERNEL="$CAS_LDPATH -lTKernel -lTKMath" # E.A. compatibility version 4 and 5.x - CAS_OCAF="$CAS_LDPATH -lPTKernel -lTKCAF -lFWOSPlugin -lTKPShape -lTKPCAF -lTKStdSchema -lTKShapeSchema -lPAppStdPlugin" + CAS_OCAF="$CAS_LDPATH -lPTKernel -lTKPShape -lTKCDF -lTKCAF -lTKShapeSchema -lTKPCAF -lFWOSPlugin -lTKStdSchema" if test $OCC_VERSION_MAJOR -lt 5 ; then CAS_OCAF="$CAS_OCAF -lTKPAppStd" fi - CAS_OCAF="$CAS_OCAF -lTKCDF" + if test -f $CASROOT/$casdir/lib/libPAppStdPlugin.so ; then + # this library is absent in CASCADE 5.2.3 + CAS_OCAF="$CAS_OCAF -lPAppStdPlugin" + CAS_STDPLUGIN="PAppStdPlugin" + fi + if test -f $CASROOT/$casdir/lib/libStdPlugin.so ; then + # this libraries are only for CASCADE 5.2.3 + CAS_STDPLUGIN="StdPlugin" + CAS_OCAF="$CAS_OCAF -lStdPlugin -lStdLPlugin -lTKLCAF -lTKPLCAF -lTKStdLSchema" + fi CAS_VIEWER="$CAS_LDPATH -lTKOpenGl -lTKV3d -lTKService" - CAS_MODELER="$CAS_LDPATH -lTKG2d -lTKG3d -lTKGeomBase -lTKBRep -lTKGeomAlgo -lTKTopAlgo -lTKPrim -lTKBool -lTKHLR -lTKFillet -lTKOffset" + CAS_MODELER="$CAS_LDPATH -lTKG2d -lTKG3d -lTKGeomBase -lTKBRep -lTKGeomAlgo -lTKTopAlgo -lTKPrim -lTKBO -lTKBool -lTKHLR -lTKFillet -lTKOffset -lTKFeat" # E.A. compatibility version 4 and 5.x CAS_DATAEXCHANGE="$CAS_LDPATH -lTKXSBase -lTKIGES -lTKSTEP -lTKShHealing" diff --git a/salome_adm/unix/config_files/check_lsf.m4 b/salome_adm/unix/config_files/check_lsf.m4 index 5fb9e0b10..9e1dc55e6 100755 --- a/salome_adm/unix/config_files/check_lsf.m4 +++ b/salome_adm/unix/config_files/check_lsf.m4 @@ -70,6 +70,9 @@ AC_DEFUN([CHECK_LSF], dnl AM_CONDITIONAL(WITH_LSF, test $WITH_LSF = 1) lsf_ok=$WITH_LSF + if test $lsf_ok = no ; then + lsf_ok= + fi AC_SUBST(WITH_LSF) ]) diff --git a/salome_adm/unix/config_files/check_med2.m4 b/salome_adm/unix/config_files/check_med2.m4 index 6e8192b44..93531d708 100644 --- a/salome_adm/unix/config_files/check_med2.m4 +++ b/salome_adm/unix/config_files/check_med2.m4 @@ -49,7 +49,15 @@ LOCAL_LIBS="-lmed $HDF5_LIBS" if test -z $MED2HOME then AC_MSG_WARN(undefined MED2HOME variable which specify med2 installation directory) -else + AC_PATH_PROG(MDUMP, mdump) + if test "xMDUMP" != "x" ; then + MED2HOME=$MDUMP + MED2HOME=`echo ${MED2HOME} | sed -e "s,[[^/]]*$,,;s,/$,,;s,^$,.,"` + MED2HOME=`echo ${MED2HOME} | sed -e "s,[[^/]]*$,,;s,/$,,;s,^$,.,"` + fi +fi +if test ! -z $MED2HOME +then LOCAL_INCLUDES="$LOCAL_INCLUDES -I$MED2HOME/include" LOCAL_LIBS="-L$MED2HOME/lib $LOCAL_LIBS" fi diff --git a/salome_adm/unix/config_files/check_openpbs.m4 b/salome_adm/unix/config_files/check_openpbs.m4 index 9598285c9..41e5bb399 100644 --- a/salome_adm/unix/config_files/check_openpbs.m4 +++ b/salome_adm/unix/config_files/check_openpbs.m4 @@ -51,6 +51,9 @@ AC_DEFUN([CHECK_OPENPBS], fi WITHOPENPBS=$openpbs_ok + if test x$WITHOPENPBS = x ; then + WITHOPENPBS=no + fi AC_SUBST(WITHOPENPBS) ]) diff --git a/salome_adm/unix/config_files/check_pyqt.m4 b/salome_adm/unix/config_files/check_pyqt.m4 index cb99775f8..f16a4df7e 100644 --- a/salome_adm/unix/config_files/check_pyqt.m4 +++ b/salome_adm/unix/config_files/check_pyqt.m4 @@ -2,6 +2,8 @@ dnl Copyright (C) 2003 CEA/DEN, EDF R&D AC_DEFUN([CHECK_PYQT],[ AC_REQUIRE([CHECK_PYTHON])dnl +AC_REQUIRE([CHECK_QT])dnl +AC_REQUIRE([CHECK_SIP])dnl AC_ARG_WITH(pyqt, [ --with-pyqt=DIR root directory path to PyQt installation ], @@ -24,68 +26,219 @@ AC_ARG_WITH(pyuic, AC_CHECKING(for pyqt) -pyqt_ok=no +pyqt_ok=yes -if test "x$PYQTDIR" = x; then - PYQTDIR="/usr" +dnl look for pyuic +pyqt_uic_ok=no +if test "x$PYUIC" != x; then + dnl try withval value + AC_CHECK_FILE($PYUIC,pyqt_uic_ok=yes,pyqt_uic_ok=no) fi - -if test "x$PYQT_SIPS" = x; then - PYQT_SIPS="/usr/share/sip/qt" +if test "x$pyqt_uic_ok" == "xno"; then + dnl try ${PYQTDIR} + if test "x${PYQTDIR}" != "x"; then + if test -d ${PYQTDIR} ; then + AC_CHECK_FILE(${PYQTDIR}/pyuic,pyqt_uic_ok=yes,pyqt_uic_ok=no) + if test "x$pyqt_uic_ok" == "xyes"; then + PYUIC="${PYQTDIR}/pyuic" + fi + fi + fi fi - -if test -d $PYQTDIR/lib/python${PYTHON_VERSION}/site-packages; then - PYQTLIB=$PYQTDIR/lib/python${PYTHON_VERSION}/site-packages -else - if test -d $PYQTDIR/lib; then - PYQTLIB=$PYQTDIR/lib - else - PYQTLIB=$PYQTDIR +if test "x$pyqt_uic_ok" == "xno"; then + dnl try ${SIPDIR} + if test "x${SIPDIR}" != "x"; then + if test -d ${SIPDIR} ; then + AC_CHECK_FILE(${SIPDIR}/pyuic,pyqt_uic_ok=yes,pyqt_uic_ok=no) + if test "x$pyqt_uic_ok" == "xyes"; then + PYUIC="${SIPDIR}/pyuic" + fi + fi + fi +fi +if test "x$pyqt_uic_ok" == "xno"; then + dnl try ${PYTHONHOME}/bin + if test "x${PYTHONHOME}" != "x"; then + if test -d ${PYTHONHOME}/bin ; then + AC_CHECK_FILE(${PYTHONHOME}/bin/pyuic,pyqt_uic_ok=yes,pyqt_uic_ok=no) + if test "x$pyqt_uic_ok" == "xyes"; then + PYUIC="${PYTHONHOME}/bin/pyuic" + fi + fi + fi +fi +if test "x$pyqt_uic_ok" == "xno"; then + dnl try /usr/bin + AC_CHECK_FILE(/usr/bin/pyuic,pyqt_uic_ok=yes,pyqt_uic_ok=no) + if test "x$pyqt_uic_ok" == "xyes"; then + PYUIC="/usr/bin/pyuic" fi fi - -if test -d $PYQTDIR/bin; then - PYQTBIN=$PYQTDIR/bin -else - PYQTBIN=$PYQTDIR +if test "x$pyqt_uic_ok" == "xno"; then + pyqt_ok=no fi -if test "x$PYUIC" = x; then - PYUIC="$PYQTBIN/pyuic" +dnl look for PyQt libs +pyqt_lib_ok=no +if test "x${PYQTDIR}" != "x"; then + dnl try {PYQTDIR} + AC_CHECK_FILE(${PYQTDIR}/libqtcmodule.so,pyqt_lib_ok=yes,pyqt_lib_ok=no) + if test "x$pyqt_lib_ok" == "xyes"; then + PYQT_LIBS="-L${PYQTDIR} -lqtcmodule" + else + AC_CHECK_FILE(${PYQTDIR}/qt.so,pyqt_lib_ok=yes,pyqt_lib_ok=no) + if test "x$pyqt_lib_ok" == "xyes"; then + PYQT_LIBS="-L${PYQTDIR}" + fi + fi + if test "x$pyqt_lib_ok" == "xno"; then + dnl try {PYQTDIR}/lib + if test -d {PYQTDIR}/lib; then + AC_CHECK_FILE(${PYQTDIR}/lib/libqtcmodule.so,pyqt_lib_ok=yes,pyqt_lib_ok=no) + if test "x$pyqt_lib_ok" == "xyes"; then + PYQT_LIBS="-L${PYQTDIR}/lib -lqtcmodule" + else + AC_CHECK_FILE(${PYQTDIR}/lib/qt.so,pyqt_lib_ok=yes,pyqt_lib_ok=no) + if test "x$pyqt_lib_ok" == "xyes"; then + PYQT_LIBS="-L${PYQTDIR}/lib" + fi + fi + fi + fi + if test "x$pyqt_lib_ok" == "xno"; then + dnl try {PYQTDIR}/lib/python${PYTHON_VERSION}/site-packages + if test -d {PYQTDIR}/lib/python${PYTHON_VERSION}/site-packages; then + AC_CHECK_FILE(${PYQTDIR}/lib/python${PYTHON_VERSION}/site-packages/libqtcmodule.so,pyqt_lib_ok=yes,pyqt_lib_ok=no) + if test "x$pyqt_lib_ok" == "xyes"; then + PYQT_LIBS="-L${PYQTDIR}/lib/python${PYTHON_VERSION}/site-packages -lqtcmodule" + else + AC_CHECK_FILE(${PYQTDIR}/lib/python${PYTHON_VERSION}/site-packages/qt.so,pyqt_lib_ok=yes,pyqt_lib_ok=no) + if test "x$pyqt_lib_ok" == "xyes"; then + PYQT_LIBS="-L${PYQTDIR}/lib/python${PYTHON_VERSION}/site-packages" + fi + fi + fi + fi fi - -AC_CHECK_FILE("$PYUIC",pyqt_ok=yes,pyqt_ok=no) - -if test "x$pyqt_ok" = xyes ; then - AC_CHECK_FILES("$PYQTLIB/qt.py",pyqt_ok=yes,pyqt_ok=no) +if test "x$pyqt_lib_ok" == "xno"; then + dnl try ${SIPDIR} + if test "x${SIPDIR}" != "x"; then + if test -d ${SIPDIR} ; then + AC_CHECK_FILE(${SIPDIR}/libqtcmodule.so,pyqt_lib_ok=yes,pyqt_lib_ok=no) + if test "x$pyqt_lib_ok" == "xyes"; then + PYQT_LIBS="-L${SIPDIR} -lqtcmodule" + else + AC_CHECK_FILE(${SIPDIR}/qt.so,pyqt_lib_ok=yes,pyqt_lib_ok=no) + if test "x$pyqt_lib_ok" == "xyes"; then + PYQT_LIBS="-L${SIPDIR}" + fi + fi + fi + fi fi - -if test "x$pyqt_ok" = xno ; then - AC_CHECK_FILES("$PYQTLIB/qt/qt.py",pyqt_ok=yes,pyqt_ok=no) +if test "x$pyqt_lib_ok" == "xno"; then + dnl try ${PYTHONHOME}/lib/python${PYTHON_VERSION}/site-packages + if test "x${PYTHONHOME}" != "x"; then + if test -d ${PYTHONHOME}/lib/python${PYTHON_VERSION}/site-packages ; then + AC_CHECK_FILE(${PYTHONHOME}/lib/python${PYTHON_VERSION}/site-packages/libqtcmodule.so,pyqt_lib_ok=yes,pyqt_lib_ok=no) + if test "x$pyqt_lib_ok" == "xyes"; then + PYQT_LIBS="-L${PYTHONHOME}/lib/python${PYTHON_VERSION}/site-packages -lqtcmodule" + else + AC_CHECK_FILE(${PYTHONHOME}/lib/python${PYTHON_VERSION}/site-packages/qt.so,pyqt_lib_ok=yes,pyqt_lib_ok=no) + if test "x$pyqt_lib_ok" == "xyes"; then + PYQT_LIBS="-L${PYTHONHOME}/lib/python${PYTHON_VERSION}/site-packages" + fi + fi + fi + fi fi - -if test "x$pyqt_ok" = xyes ; then - AC_CHECK_FILE("$PYQTLIB/libqtcmodule.so",pyqt_ok=yes,pyqt_ok=no) +if test "x$pyqt_lib_ok" == "xno"; then + dnl try /usr/lib/python${PYTHON_VERSION}/site-packages + AC_CHECK_FILE(/usr/lib/python${PYTHON_VERSION}/site-packages/libqtcmodule.so,pyqt_lib_ok=yes,pyqt_lib_ok=no) + if test "x$pyqt_lib_ok" == "xyes"; then + PYQT_LIBS="-L/usr/lib/python${PYTHON_VERSION}/site-packages -lqtcmodule" + else + AC_CHECK_FILE(/usr/lib/python${PYTHON_VERSION}/site-packages/qt.so,pyqt_lib_ok=yes,pyqt_lib_ok=no) + if test "x$pyqt_lib_ok" == "xyes"; then + PYQT_LIBS="-L/usr/lib/python${PYTHON_VERSION}/site-packages" + fi + fi +fi +if test "x$pyqt_lib_ok" == "xno"; then + pyqt_ok=no fi -if test "x$pyqt_ok" = xyes ; then - AC_CHECK_FILES("$PYQT_SIPS/qtmod.sip",pyqt_ok=yes,pyqt_ok=no) +dnl look for PyQt sips +pyqt_sips_ok=no +dnl try ${PYQT_SIPS} or ${PYQT_SIPS}/qt +if test "x${PYQT_SIPS}" != "x"; then + AC_CHECK_FILE(${PYQT_SIPS}/qglobal.sip,pyqt_sips_ok=yes,pyqt_sips_ok=no) + if test "x$pyqt_sips_ok" == "xno"; then + AC_CHECK_FILE(${PYQT_SIPS}/qt/qglobal.sip,pyqt_sips_ok=yes,pyqt_sips_ok=no) + if test "x$pyqt_sips_ok" == "xyes"; then + PYQT_SIPS="${PYQT_SIPS}/qt" + fi + fi fi -if test "x$pyqt_ok" = xyes ; then - AC_CHECK_FILE("$PYQT_SIPS/copying.sip",pyqt_ok=yes,pyqt_ok=no) +if test "x$pyqt_sips_ok" == "xno"; then + dnl try ${PYQTDIR}/sip + if test "x${PYQTDIR}" != "x"; then + if test -d ${PYQTDIR}/sip ; then + AC_CHECK_FILE(${PYQTDIR}/sip/qglobal.sip,pyqt_sips_ok=yes,pyqt_sips_ok=no) + if test "x$pyqt_sips_ok" == "xyes"; then + PYQT_SIPS="${PYQTDIR}/sip" + else + AC_CHECK_FILE(${PYQTDIR}/sip/qt/qglobal.sip,pyqt_sips_ok=yes,pyqt_sips_ok=no) + if test "x$pyqt_sips_ok" == "xyes"; then + PYQT_SIPS="${PYQTDIR}/sip/qt" + fi + fi + fi + fi fi - -if test "x$pyqt_ok" = xyes ; then - PYQT_ROOT=$PYQTDIR +if test "x$pyqt_sips_ok" == "xno"; then + dnl try ${SIPDIR}/sip + if test "x${SIPDIR}" != "x"; then + if test -d ${SIPDIR}/sip ; then + AC_CHECK_FILE(${SIPDIR}/sip/qglobal.sip,pyqt_sips_ok=yes,pyqt_sips_ok=no) + if test "x$pyqt_sips_ok" == "xyes"; then + PYQT_SIPS="${SIPDIR}/sip" + else + AC_CHECK_FILE(${SIPDIR}/sip/qt/qglobal.sip,pyqt_sips_ok=yes,pyqt_sips_ok=no) + if test "x$pyqt_sips_ok" == "xyes"; then + PYQT_SIPS="${SIPDIR}/sip/qt" + fi + fi + fi + fi +fi +if test "x$pyqt_sips_ok" == "xno"; then + dnl try /usr/share/sip + if test -d /usr/share/sip ; then + AC_CHECK_FILE(/usr/share/sip/qglobal.sip,pyqt_sips_ok=yes,pyqt_sips_ok=no) + if test "x$pyqt_sips_ok" == "xyes"; then + PYQT_SIPS="/usr/share/sip" + else + AC_CHECK_FILE(/usr/share/sip/qt/qglobal.sip,pyqt_sips_ok=yes,pyqt_sips_ok=no) + if test "x$pyqt_sips_ok" == "xyes"; then + PYQT_SIPS="/usr/share/sip/qt" + fi + fi + fi +fi +if test "x$pyqt_sips_ok" == "xno"; then + pyqt_ok=no +else PYQT_INCLUDES="-I$PYQT_SIPS" - PYQT_LIBS="-L$PYQTLIB -lqtcmodule" - AC_SUBST(PYQT_ROOT) - AC_SUBST(PYQT_INCLUDES) - AC_SUBST(PYQT_LIBS) - AC_SUBST(PYQT_SIPS) - AC_SUBST(PYUIC) fi +AC_SUBST(PYQT_INCLUDES) +AC_SUBST(PYQT_LIBS) +AC_SUBST(PYQT_SIPS) +AC_SUBST(PYUIC) + +AC_MSG_RESULT(for pyqt: $pyqt_ok) + ])dnl dnl diff --git a/salome_adm/unix/config_files/check_qt.m4 b/salome_adm/unix/config_files/check_qt.m4 index b27de2779..1e4d90ad6 100644 --- a/salome_adm/unix/config_files/check_qt.m4 +++ b/salome_adm/unix/config_files/check_qt.m4 @@ -37,6 +37,11 @@ if test "x$QTDIR" = "x" then AC_MSG_RESULT(please define QTDIR variable) qt_ok=no +else + AC_MSG_RESULT(QTDIR is $QTDIR) + QT_VERS=`grep "QT_VERSION_STR" ${QTDIR}/include/qglobal.h | sed -e 's%^#define QT_VERSION_STR\([[:space:]]*\)%%g' -e 's%\"%%g'` + AC_MSG_RESULT(Qt version is $QT_VERS) + QT_VERS="Qt_"`echo $QT_VERS | sed -e 's%\"%%g' -e 's%\.%_%g'` fi if test "x$qt_ok" = "xyes" @@ -143,6 +148,7 @@ AC_SUBST(QT_ROOT) AC_SUBST(QT_INCLUDES) AC_SUBST(QT_LIBS) AC_SUBST(QT_MT_LIBS) +AC_SUBST(QT_VERS) AC_LANG_RESTORE diff --git a/salome_adm/unix/config_files/check_qwt.m4 b/salome_adm/unix/config_files/check_qwt.m4 index 4e541d70d..c50835666 100644 --- a/salome_adm/unix/config_files/check_qwt.m4 +++ b/salome_adm/unix/config_files/check_qwt.m4 @@ -22,19 +22,33 @@ AC_ARG_WITH(qwt_inc, ]) if test -z $QWTHOME; then + AC_MSG_RESULT(QWTHOME not defined) exits_ok=no - AC_CHECK_FILE("/usr/local/lib/libqwt.so",exits_ok=yes,exits_ok=no) + if test "x$exits_ok" = "xno"; then + for d in /usr/local /usr ; do + AC_CHECK_FILE(${d}/lib/libqwt.so,exits_ok=yes,exits_ok=no) + if test "x$exits_ok" = "xyes"; then + QWTHOME=$d + AC_MSG_RESULT(libqwt.so detected in $d/lib) + fi + done + fi + if test "x$exits_ok" = "xno"; then + for d in `echo $LD_LIBRARY_PATH | sed -e "s/:/ /g"` ; do + if test -f $d/libqwt.so ; then + AC_MSG_RESULT(libqwt.so detected in $d) + QWTHOME=$d + QWTHOME=`echo ${QWTHOME} | sed -e "s,[[^/]]*$,,;s,/$,,;s,^$,.,"` + exits_ok=yes + break + fi + done + fi if test "x$exits_ok" = "xyes"; then - QWTHOME="/usr/local/lib" - if test -z $QWT_INCLUDES; then - QWT_INCLUDES="/usr/local/include/qwt" - fi - else - QWTHOME="/usr/lib" if test -z $QWT_INCLUDES; then - QWT_INCLUDES="/usr/include/qwt" + QWT_INCLUDES=$QWTHOME"/include/qwt" fi - fi + fi else if test -z $QWT_INCLUDES; then QWT_INCLUDES="$QWTHOME/include" diff --git a/salome_adm/unix/config_files/check_sip.m4 b/salome_adm/unix/config_files/check_sip.m4 index 84c2beaf7..3fe220f56 100644 --- a/salome_adm/unix/config_files/check_sip.m4 +++ b/salome_adm/unix/config_files/check_sip.m4 @@ -2,6 +2,7 @@ dnl Copyright (C) 2003 CEA/DEN, EDF R&D AC_DEFUN([CHECK_SIP],[ AC_REQUIRE([CHECK_PYTHON])dnl +AC_REQUIRE([CHECK_QT])dnl sip_ok=yes @@ -13,75 +14,134 @@ AC_ARG_WITH(sip, AC_PATH_PROG(SIP, sip) ]) -if test "x$SIP" = "x" -then +if test "x$SIP" = "x" ; then sip_ok=no AC_MSG_RESULT(sip not in PATH variable) else - version=`sip -V` + version=`$SIP -V` + AC_MSG_RESULT(sip version is $version) case "$version" in 3.2*) - SIP_VERS=old ;; + SIP_VERS=v3_old ;; 3.3*) - SIP_VERS=old ;; + SIP_VERS=v3_old ;; 3.4*) - SIP_VERS=new ;; + SIP_VERS=v3_old ;; 3.5*) - SIP_VERS=new ;; + SIP_VERS=v3_old ;; 3.6*) - SIP_VERS=new ;; + SIP_VERS=v3_old ;; 3.7*) - SIP_VERS=new ;; + SIP_VERS=v3_old ;; 3.8*) - SIP_VERS=new ;; + SIP_VERS=v3_old ;; 3.9*) - SIP_VERS=new ;; + SIP_VERS=v3_old ;; 3.10*) - SIP_VERS=new2 ;; + SIP_VERS=v3_new ;; + 4.*) + SIP_VERS=v4 ;; *) AC_MSG_RESULT(sip version $version not supported) - SIP_VERS=no ;; + SIP_VERS=unsupported ;; esac - sip_ok=no - if test "x$SIP_VERS" = "xold" - then - dnl old install : includes and libs are in python install or in SIPDIR - AC_MSG_RESULT(old install detected) - sip_ok=yes - SIP_ROOT="$SIPDIR" - SIP_INCLUDES="${PYTHON_INCLUDES} -I${SIPDIR}" - SIP_LIBS="-L${PYTHON_PREFIX}/lib/python${PYTHON_VERSION}/site-packages -L${SIPDIR} -lsip" + sip_ok=no + dnl Search sip.h file + if test "x$SIPDIR" != "x" ; then + dnl look for sip.h in ${SIPDIR} + AC_CHECK_FILE(${SIPDIR}/sip.h,sip_ok=yes,sip_ok=no) + if test "x$sip_ok" == "xyes" ; then + SIP_INCLUDES="-I${SIPDIR}" + fi + if test "x$sip_ok" == "xno" ; then + dnl look for sip.h in ${SIPDIR}/include/python${PYTHON_VERSION} + if test -d ${SIPDIR}/include/python${PYTHON_VERSION} ; then + AC_CHECK_FILE(${SIPDIR}/include/python${PYTHON_VERSION}/sip.h,sip_ok=yes,sip_ok=no) + if test "x$sip_ok" == "xyes" ; then + SIP_INCLUDES="-I${SIPDIR}/include/python${PYTHON_VERSION}" + fi + fi + fi fi - - if test "x$SIP_VERS" = "xnew" - then - sip_ok=yes - if test -d ${SIPDIR}/include/python${PYTHON_VERSION} ; then - AC_MSG_RESULT(new install with include dir detected) - dnl new install with include dir : includes and libs are in python install or in SIPDIR/include - SIP_ROOT="$SIPDIR" - SIP_INCLUDES="${PYTHON_INCLUDES} -I${SIPDIR}/include/python${PYTHON_VERSION}" - SIP_LIBS="-L${SIPDIR}/lib/python${PYTHON_VERSION}/site-packages -lsip" - else - dnl new install without include dir : includes and libs are in SIPDIR - AC_MSG_RESULT(new install without include dir detected) - sip_ok=yes - SIP_ROOT="$SIPDIR" - SIP_INCLUDES="-I${SIPDIR}" - SIP_LIBS="-L${SIPDIR} -lsip" - fi + if test "x$sip_ok" == "xno" ; then + dnl look for sip.h in ${PYTHON_PREFIX}/include/python${PYTHON_VERSION} + if test -d ${PYTHON_PREFIX}/include/python${PYTHON_VERSION} ; then + AC_CHECK_FILE(${PYTHON_PREFIX}/include/python${PYTHON_VERSION}/sip.h,sip_ok=yes,sip_ok=no) + if test "x$sip_ok" == "xyes" ; then + SIP_INCLUDES="${PYTHON_INCLUDES}" + fi + fi + fi + if test "x$sip_ok" == "xno" ; then + dnl look for sip.h in /usr/include/python${PYTHON_VERSION} + if test -d /usr/include/python${PYTHON_VERSION} ; then + AC_CHECK_FILE(/usr/include/python${PYTHON_VERSION}/sip.h,sip_ok=yes,sip_ok=no) + if test "x$sip_ok" == "xyes" ; then + SIP_INCLUDES="/usr/include/python${PYTHON_VERSION}" + fi + fi fi + + dnl Search (lib)sip.so file + sip_lib_ok=no + if test "x$SIPDIR" != "x" ; then + dnl look for (lib)sip.so in ${SIPDIR} + AC_CHECK_FILE(${SIPDIR}/libsip.so,sip_lib_ok=yes,sip_lib_ok=no) + if test "x$sip_lib_ok" == "xyes" ; then + SIP_LIBS="-L${SIPDIR} -lsip" + else + AC_CHECK_FILE(${SIPDIR}/sip.so,sip_lib_ok=yes,sip_lib_ok=no) + if test "x$sip_lib_ok" == "xyes" ; then + SIP_LIBS="-L${SIPDIR}" + fi + fi - if test "x$SIP_VERS" = "xnew2" - then - dnl new2 install : includes and libs are in python install - AC_MSG_RESULT(new2 install detected) - sip_ok=yes - AC_CHECK_FILE($PYTHON_PREFIX/include/python$PYTHON_VERSION/sip.h,sip_ok=$sip_ok,sip_ok=no) - SIP_INCLUDES="${PYTHON_INCLUDES}" - AC_CHECK_FILE($PYTHON_PREFIX/lib/python$PYTHON_VERSION/site-packages/libsip.so,sip_ok=$sip_ok,sip_ok=no) - SIP_LIBS="-L${PYTHON_PREFIX}/lib/python${PYTHON_VERSION}/site-packages -lsip" + if test "x$sip_lib_ok" == "xno" ; then + dnl look for (lib)sip.so in ${SIPDIR}/lib/python${PYTHON_VERSION}/site-packages + if test -d ${SIPDIR}/lib/python${PYTHON_VERSION}/site-packages ; then + AC_CHECK_FILE(${SIPDIR}/lib/python${PYTHON_VERSION}/site-packages/libsip.so,sip_lib_ok=yes,sip_lib_ok=no) + if test "x$sip_lib_ok" == "xyes" ; then + SIP_LIBS="-L${SIPDIR}/lib/python${PYTHON_VERSION}/site-packages -lsip" + else + AC_CHECK_FILE(${SIPDIR}/lib/python${PYTHON_VERSION}/site-packages/sip.so,sip_lib_ok=yes,sip_lib_ok=no) + if test "x$sip_lib_ok" == "xyes" ; then + SIP_LIBS="-L${SIPDIR}/lib/python${PYTHON_VERSION}/site-packages" + fi + fi + fi + fi + fi + if test "x$sip_lib_ok" == "xno" ; then + dnl look for (lib)sip.so in ${PYTHON_PREFIX}/lib/python${PYTHON_VERSION}/site-packages + if test -d ${PYTHON_PREFIX}/lib/python${PYTHON_VERSION}/site-packages ; then + AC_CHECK_FILE(${PYTHON_PREFIX}/lib/python${PYTHON_VERSION}/site-packages/libsip.so,sip_lib_ok=yes,sip_lib_ok=no) + if test "x$sip_lib_ok" == "xyes" ; then + SIP_LIBS="-L${PYTHON_PREFIX}/lib/python${PYTHON_VERSION}/site-packages -lsip" + else + AC_CHECK_FILE(${PYTHON_PREFIX}/lib/python${PYTHON_VERSION}/site-packages/sip.so,sip_lib_ok=yes,sip_lib_ok=no) + if test "x$sip_lib_ok" == "xyes" ; then + SIP_LIBS="-L${PYTHON_PREFIX}/lib/python${PYTHON_VERSION}/site-packages" + fi + fi + fi + fi + if test "x$sip_lib_ok" == "xno" ; then + dnl look for (lib)sip.so in /usr/lib/python${PYTHON_VERSION}/site-packages + if test -d /usr/lib/python${PYTHON_VERSION}/site-packages ; then + AC_CHECK_FILE(/usr/lib/python${PYTHON_VERSION}/site-packages/libsip.so,sip_lib_ok=yes,sip_lib_ok=no) + if test "x$sip_lib_ok" == "xyes" ; then + SIP_LIBS="-L$/usr/lib/python${PYTHON_VERSION}/site-packages -lsip" + else + AC_CHECK_FILE(/usr/lib/python${PYTHON_VERSION}/site-packages/sip.so,sip_lib_ok=yes,sip_lib_ok=no) + if test "x$sip_lib_ok" == "xyes" ; then + SIP_LIBS="-L/usr/lib/python${PYTHON_VERSION}/site-packages" + fi + fi + fi + fi + if test "x$sip_lib_ok" == "xno" ; then + sip_ok=no fi fi diff --git a/salome_adm/unix/config_files/check_vtk.m4 b/salome_adm/unix/config_files/check_vtk.m4 index 4b4b1454f..066aeb1ca 100644 --- a/salome_adm/unix/config_files/check_vtk.m4 +++ b/salome_adm/unix/config_files/check_vtk.m4 @@ -62,7 +62,14 @@ TRY_LINK_LIBS="-lvtkCommon $OGL_LIBS $LXLIB -lX11 -lXt" if test -z $VTKHOME then AC_MSG_WARN(undefined VTKHOME variable which specify where vtk was compiled) -else + if test -f /usr/include/vtk/vtkPlane.h ; then + AC_MSG_RESULT(trying /usr) + VTKHOME="/usr" + fi +fi + +if test ! -z $VTKHOME +then LOCAL_INCLUDES="-I$VTKHOME/include/vtk $LOCAL_INCLUDES" LOCAL_LIBS="-L$VTKHOME/lib/vtk $LOCAL_LIBS" TRY_LINK_LIBS="-L$VTKHOME/lib/vtk $TRY_LINK_LIBS" diff --git a/salome_adm/unix/make_commence.in b/salome_adm/unix/make_commence.in index 620cfd9ff..134ae236b 100644 --- a/salome_adm/unix/make_commence.in +++ b/salome_adm/unix/make_commence.in @@ -77,6 +77,7 @@ QT_INCLUDES = @QT_INCLUDES@ QT_MT_INCLUDES = @QT_INCLUDES@ -DQT_THREAD_SUPPORT QT_LIBS = @QT_LIBS@ QT_MT_LIBS = @QT_MT_LIBS@ +QT_VERS = @QT_VERS@ MOC = @MOC@ UIC = @UIC@ @@ -192,6 +193,7 @@ CXXFLAGS+= $(CORBA_CXXFLAGS) # add corba libs when link salome application ! #LDFLAGS+= $(CORBA_LIBS) LIBS+=$(CORBA_LIBS) +LIBSFORBIN+=$(CORBA_LIBS) DOXYGEN = @DOXYGEN@ diff --git a/salome_adm/unix/make_conclude.in b/salome_adm/unix/make_conclude.in index 2b8f95495..e77dc8c44 100644 --- a/salome_adm/unix/make_conclude.in +++ b/salome_adm/unix/make_conclude.in @@ -58,7 +58,7 @@ $(LIB_BUILD): $(top_builddir)/lib/salome/%.la: %.la ln -sf $(patsubst %.la, %.so, $(CURDIR)/.libs/$<).0 \ $(patsubst %.la, %.so, $@).0 || true - if test "X$(LIB_SWIG)" != X; then \ + if ! test -z $(LIB_SWIG) ; then \ ln -sf $(patsubst %.la,%.so, $(CURDIR)/.libs/$<) $(top_builddir)/lib/salome/_$(LIB_SWIG) || true;\ fi; @@ -95,7 +95,7 @@ $(BIN:%=$(top_builddir)/bin/salome/%) $(TEST_PROGS:%=$(top_builddir)/bin/salome/ ln -sf $(CURDIR)/$< $@ $(BIN) $(TEST_PROGS): %: %.lo $(BIN_OBJ) - $(CXX) $(CPPFLAGS) $(CXXFLAGS) -o $@ $^ $(BIN_LIB) $(LDFLAGSFORBIN) $(LIBSFORBIN) + $(CXX) $(CXXFLAGS) -o $@ $^ $(BIN_LIB) $(LDFLAGS) $(LIBS) # copy python scripts in $(top_builddir)/bin/salome # @@ -147,20 +147,27 @@ $(DEST_HEADERS): $(inc_builddir)/%: % cp -f $< $@ # build resources file (icons and messages) : .qm file from .po file -resources: $(PO_FILES:%.po=$(top_builddir)/share/salome/resources/%.qm) +resources: resources-po resources-cp + +resources-po: $(PO_FILES:%.po=$(top_builddir)/share/salome/resources/%.qm) + +resources-cp: $(RESOURCES_FILES:%=$(top_builddir)/share/salome/resources/%) + +$(RESOURCES_FILES:%=$(top_builddir)/share/salome/resources/%): $(top_builddir)/share/salome/resources/% : % + cp -f $< $@ # Make installation directories if they don't exist. $(libdir) $(includedir) $(bindir) $(datadir) $(idldir) $(sharedpydir): $(INSTALL) -d $@ && chmod 755 $@ # Install the library, the public header files, and programs. -install: $(LIB) $(BIN) $(TEST_PROGS) $(libdir) $(includedir) $(bindir) $(datadir) $(idldir) install-python install-sharedpyqt install-qm +install: $(LIB) $(BIN) $(TEST_PROGS) $(libdir) $(includedir) $(bindir) $(datadir) $(idldir) install-python install-sharedpyqt install-qm install-res @for f in X $(LIB); do \ if test $$f != X; then \ ($(LT_INSTALL_LIB) $$f $(libdir)/. || exit 1); \ fi; \ done - @if test "X$(LIB_SWIG)" != X; then \ + @if ! test -z $(LIB_SWIG) ; then \ (cd $(libdir); ln -sf $(patsubst %.so, %cmodule.so, $(LIB_SWIG)) _$(LIB_SWIG) || true); \ fi; @for f in X $(BIN); do \ @@ -213,6 +220,15 @@ install-qm: resources fi; \ done +# generic rule to install resources files (png, ini ...): +install-res: resources + $(INSTALL) -d $(datadir)/resources + @for f in X $(RESOURCES_FILES:%=$(top_builddir)/share/salome/resources/%); do \ + if test $$f != X; then \ + ($(INSTALL_DATA) $$f $(datadir)/resources/. || exit 1); \ + fi; \ + done + # Removes those things that `make install' (would have) installed. uninstall: @if test "X$(LIB)" != X; then \ @@ -353,11 +369,7 @@ distclean: clean $(SWIG) $(SWIG_FLAGS) -o $@ $< $(top_builddir)/share/salome/resources/%.qm: %.po - if test -e ${KERNEL_ROOT_DIR}/bin/salome/msg2qm ; then \ - ${KERNEL_ROOT_DIR}/bin/salome/msg2qm $< $@ ; \ - else \ - $(top_builddir)/bin/salome/msg2qm $< $@ ; \ - fi + $(MSG2QM_ROOT)/msg2qm $< $@ ; \ #------------------------------------------------------------------------------ # The following section of this makefile contains dependencies between the diff --git a/src/CASCatch/CASCatch_SignalsHandler.cxx b/src/CASCatch/CASCatch_SignalsHandler.cxx index d18c1af6b..fd8cb5a0e 100644 --- a/src/CASCatch/CASCatch_SignalsHandler.cxx +++ b/src/CASCatch/CASCatch_SignalsHandler.cxx @@ -20,14 +20,10 @@ #include "CASCatch_SignalsHandler.h" -#include #include -using namespace std; + CASCatch_SignalsHandler::CASCatch_SignalsHandler(bool theFloatingSignal) { OSD::SetSignal(theFloatingSignal); - // To allow application kill when used in xterm, one must use default behavior - // with SIGHUP signal - Utils_SignalsHandler::SetSigHandler(SIGHUP,SIG_DFL); } diff --git a/src/Container/Component_i.cxx b/src/Container/Component_i.cxx index ff343a2cc..86763cb89 100644 --- a/src/Container/Component_i.cxx +++ b/src/Container/Component_i.cxx @@ -26,6 +26,7 @@ // Module : SALOME // $Header$ +//#define private protected // for pd_refCount trace #include "SALOME_Component_i.hxx" #include "SALOME_Container_i.hxx" #include "RegistryConnexion.hxx" @@ -34,16 +35,44 @@ #include #include #include "utilities.h" + +#include +#include +#include + using namespace std; extern bool _Sleeping ; static Engines_Component_i * theEngines_Component ; +bool Engines_Component_i::_isMultiStudy = true; +bool Engines_Component_i::_isMultiInstance = false; + +//============================================================================= +/*! + * Default constructor, not for use + */ +//============================================================================= + Engines_Component_i::Engines_Component_i() { -// MESSAGE("Component constructor"); + //ASSERT(0); + INFOS("Default Constructor..."); } +//============================================================================= +/*! + * Standard Constructor for generic Component, used in derived class + * Connection to Registry and Notification + * \param orb Object Request broker given by Container + * \parap poa Portable Object Adapter from Container (normally root_poa) + * \param contId container CORBA id inside the server + * \param instanceName unique instance name for this object (see Container_i) + * \param interfaceName component class name + * \param notif use of notification + */ +//============================================================================= + Engines_Component_i::Engines_Component_i(CORBA::ORB_ptr orb, PortableServer::POA_ptr poa, PortableServer::ObjectId * contId, @@ -53,63 +82,142 @@ Engines_Component_i::Engines_Component_i(CORBA::ORB_ptr orb, _instanceName(instanceName), _interfaceName(interfaceName), _myConnexionToRegistry(0), - _ThreadId(0) , _ThreadCpuUsed(0) , _Executed(false) , _graphName("") , _nodeName("") { + _ThreadId(0) , + _ThreadCpuUsed(0) , + _Executed(false) , + _graphName("") , + _nodeName(""), + _studyId(-1) +{ MESSAGE("Component constructor with instanceName "<< _instanceName); + //SCRUTE(pd_refCount); _orb = CORBA::ORB::_duplicate(orb); _poa = PortableServer::POA::_duplicate(poa); _contId = contId ; CORBA::Object_var o = _poa->id_to_reference(*contId); // container ior... const CORBA::String_var ior = _orb->object_to_string(o); - _myConnexionToRegistry = new RegistryConnexion(0, 0, ior, "theSession", _instanceName.c_str()); + _myConnexionToRegistry = new RegistryConnexion(0, 0, ior,"theSession", + _instanceName.c_str()); _notifSupplier = new NOTIFICATION_Supplier(instanceName, notif); + //SCRUTE(pd_refCount); } -// Constructeur pour composant parallele: ne pas faire appel au registry!! +//============================================================================= +/*! + * Standard constructor for parallel component + * Connection Notification (no connection to Registry !) + * \param orb Object Request broker given by Container + * \parap poa Portable Object Adapter from Container (normally root_poa) + * \param contId container CORBA id inside the server + * \param instanceName unique instance name for this object (see Container_i) + * \param interfaceName component class name + * \param flag not used... + * \param notif use of notification + */ +//============================================================================= + Engines_Component_i::Engines_Component_i(CORBA::ORB_ptr orb, PortableServer::POA_ptr poa, PortableServer::ObjectId * contId, const char *instanceName, const char *interfaceName, int flag, - bool notif ) - : _instanceName(instanceName), - _interfaceName(interfaceName), - _myConnexionToRegistry(0), - _ThreadId(0) , _ThreadCpuUsed(0) , _Executed(false) , _graphName("") , _nodeName("") { -// MESSAGE("Component constructor with instanceName "<< _instanceName); + bool notif ) : + _instanceName(instanceName), + _interfaceName(interfaceName), + _myConnexionToRegistry(0), + _ThreadId(0) , + _ThreadCpuUsed(0) , + _Executed(false) , + _graphName("") , + _nodeName(""), + _studyId(-1) +{ _orb = CORBA::ORB::_duplicate(orb); _poa = PortableServer::POA::_duplicate(poa); _contId = contId ; - // CORBA::Object_var myself = this->_this(); //appel a _this = increment reference _notifSupplier = new NOTIFICATION_Supplier(instanceName, notif); } +//============================================================================= +/*! + * Destructor: call Container for decrement of instances count. + * When instances count falls to 0, the container tries to remove the + * component library (dlclose) + */ +//============================================================================= + Engines_Component_i::~Engines_Component_i() { MESSAGE("Component destructor"); -// delete _myConnexionToRegistry; -// _myConnexionToRegistry = 0 ; + Engines_Container_i::decInstanceCnt(_interfaceName); } -char* Engines_Component_i::instanceName() { +//============================================================================= +/*! + * CORBA method: return name of the instance, unique in this Container + */ +//============================================================================= + +char* Engines_Component_i::instanceName() +{ return CORBA::string_dup(_instanceName.c_str()) ; } -char* Engines_Component_i::interfaceName() { - return CORBA::string_dup(_interfaceName.c_str()) ; +//============================================================================= +/*! + * CORBA method: return name of the component class + */ +//============================================================================= + +char* Engines_Component_i::interfaceName() +{ + return CORBA::string_dup(_interfaceName.c_str()) ; } +//============================================================================= +/*! + * CORBA method: Get study Id + * \return -1: not initialised (Internal Error) + * 0: multistudy component instance + * >0: study id associated to this instance + */ +//============================================================================= + +CORBA::Long Engines_Component_i::getStudyId() +{ + return _studyId; +} + +//============================================================================= +/*! + * CORBA method: Test if instance is alive and responds + */ +//============================================================================= + void Engines_Component_i::ping() { MESSAGE("Engines_Component_i::ping() pid "<< getpid() << " threadid " << pthread_self()); } +//============================================================================= +/*! + * CORBA method: Deactivate this instance. CORBA object is deactivated (do not + * respond any more to CORBA calls), the connection to Regsitry is removed + * (Registry informed of deactivation), internal server reference counter on + * the derived servant class is decremented, to allow destruction of the class + * (delete) by POA, when there are no more references. + * -- TO BE USED BY CONTAINER ONLY (Container housekeeping) -- + */ +//============================================================================= + void Engines_Component_i::destroy() { MESSAGE("Engines_Component_i::destroy()"); + //SCRUTE(pd_refCount); delete _notifSupplier; _notifSupplier = 0; @@ -119,10 +227,19 @@ void Engines_Component_i::destroy() _poa->deactivate_object(*_id) ; CORBA::release(_poa) ; delete(_id) ; + //SCRUTE(pd_refCount); _thisObj->_remove_ref(); + //SCRUTE(pd_refCount); MESSAGE("Engines_Component_i::destroyed") ; } +//============================================================================= +/*! + * CORBA method: return CORBA reference of the Container + * + */ +//============================================================================= + Engines::Container_ptr Engines_Component_i::GetContainerRef() { MESSAGE("Engines_Component_i::GetContainerRef"); @@ -130,11 +247,16 @@ Engines::Container_ptr Engines_Component_i::GetContainerRef() return Engines::Container::_narrow(o); } -PortableServer::ObjectId * Engines_Component_i::getId() -{ -// MESSAGE("PortableServer::ObjectId * Engines_Component_i::getId()"); - return _id ; -} +//============================================================================= +/*! + * CORBA method: + * Gives a sequence of (key=string,value=any) to the component. + * Base class component stores the sequence in a map. + * The map is cleared before. + * This map is for use by derived classes. + * \param dico sequence of (key=string,value=any) + */ +//============================================================================= void Engines_Component_i::setProperties(const Engines::FieldsDict& dico) { @@ -146,6 +268,14 @@ void Engines_Component_i::setProperties(const Engines::FieldsDict& dico) } } +//============================================================================= +/*! + * CORBA method: + * returns a previously stored map (key=string,value=any) as a sequence. + * (see setProperties) + */ +//============================================================================= + Engines::FieldsDict* Engines_Component_i::getProperties() { Engines::FieldsDict_var copie = new Engines::FieldsDict; @@ -161,24 +291,239 @@ Engines::FieldsDict* Engines_Component_i::getProperties() return copie._retn(); } +//============================================================================= +/*! + * CORBA method: used by Supervision to give names to this instance + */ +//============================================================================= + +void Engines_Component_i::Names( const char * graphName , + const char * nodeName ) +{ + _graphName = graphName ; + _nodeName = nodeName ; + // MESSAGE("Engines_Component_i::Names( '" << _graphName << "' , '" + // << _nodeName << "' )"); +} + +//============================================================================= +/*! + * CORBA method: used in Supervision + */ +//============================================================================= + +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 +// << dec << " _ThreadId " << _ThreadId << " this " << hex << this +// << dec ) ; + + bool RetVal = false ; + if ( _ThreadId > 0 && pthread_self() != _ThreadId ) + { + RetVal = Killer( _ThreadId , 0 ) ; + _ThreadId = (pthread_t ) -1 ; + } + return RetVal ; +} + +//============================================================================= +/*! + * CORBA method: used in Supervision + */ +//============================================================================= + +bool Engines_Component_i::Stop_impl() +{ + 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 + << dec << " _ThreadId " << _ThreadId ); + + + bool RetVal = false ; + if ( _ThreadId > 0 && pthread_self() != _ThreadId ) + { + RetVal = Killer( _ThreadId , 0 ) ; + _ThreadId = (pthread_t ) -1 ; + } + return RetVal ; +} + +//============================================================================= +/*! + * CORBA method: used in Supervision + */ +//============================================================================= + +bool Engines_Component_i::Suspend_impl() +{ + 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 + << dec << " _ThreadId " << _ThreadId ); + + bool RetVal = false ; + if ( _ThreadId > 0 && pthread_self() != _ThreadId ) + { + if ( _Sleeping ) + { + return false ; + } + else + { + RetVal = Killer( _ThreadId ,SIGINT ) ; + } + } + return RetVal ; +} + +//============================================================================= +/*! + * CORBA method: used in Supervision + */ +//============================================================================= + +bool Engines_Component_i::Resume_impl() +{ + 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 + << dec << " _ThreadId " << _ThreadId ); + bool RetVal = false ; + if ( _ThreadId > 0 && pthread_self() != _ThreadId ) + { + if ( _Sleeping ) + { + _Sleeping = false ; + RetVal = true ; + } + else + { + RetVal = false ; + } + } + return RetVal ; +} + +//============================================================================= +/*! + * CORBA method: + */ +//============================================================================= + +CORBA::Long Engines_Component_i::CpuUsed_impl() +{ + long cpu = 0 ; + if ( _ThreadId || _Executed ) + { + if ( _ThreadId > 0 ) + { + if ( pthread_self() != _ThreadId ) + { + if ( _Sleeping ) + { + } + else + { + // Get Cpu in the appropriate thread with that object !... + theEngines_Component = this ; + Killer( _ThreadId ,SIGUSR1 ) ; + } + cpu = _ThreadCpuUsed ; + } + else + { + _ThreadCpuUsed = CpuUsed() ; + cpu = _ThreadCpuUsed ; + // cout << pthread_self() << " Engines_Component_i::CpuUsed_impl " + // << _serviceName << " " << cpu << endl ; + } + } + else + { + cpu = _ThreadCpuUsed ; + // cout << pthread_self() << " Engines_Component_i::CpuUsed_impl " + // << _serviceName << " " << cpu<< endl ; + } + } + else + { + // cout<< pthread_self()<<"Engines_Component_i::CpuUsed_impl _ThreadId " + // <<_ThreadId <<" "<<_serviceName<<" _StartUsed "<<_StartUsed<0 otherwise (== study id) + * \return true if the set of study Id is OK + * must be set once by Container, and cannot be changed after. + */ +//============================================================================= + +CORBA::Boolean Engines_Component_i::setStudyId(CORBA::Long studyId) +{ + ASSERT( studyId >= 0); + CORBA::Boolean ret = false; + if (_studyId < 0) + { + _studyId = studyId; + ret = true; + } + else + if ( _studyId == studyId) ret = true; + return ret; +} + +//============================================================================= +/*! + * C++ method: return CORBA instance id, the id is set in derived class + * constructor, when instance is activated. + */ +//============================================================================= + +PortableServer::ObjectId * Engines_Component_i::getId() +{ +// MESSAGE("PortableServer::ObjectId * Engines_Component_i::getId()"); + return _id ; +} + +//============================================================================= +/*! + * C++ method: used by derived classes for supervision + */ +//============================================================================= + void Engines_Component_i::beginService(const char *serviceName) { - MESSAGE(pthread_self() << "Send BeginService notification for " << serviceName << endl - << "Component instance : " << _instanceName << endl << endl); + MESSAGE(pthread_self() << "Send BeginService notification for " <>= value; - // --- todo: replace __GNUC__ test by an autoconf macro AC_CHECK_FUNC... + // ---todo: replace __GNUC__ test by an autoconf macro AC_CHECK_FUNC. #if defined __GNUC__ int ret = setenv(cle.c_str(), value, overwrite); #else @@ -202,7 +547,8 @@ void Engines_Component_i::beginService(const char *serviceName) std::string s(cle); s+='='; s+=value; - //char* cast because 1st arg of linux putenv function is not a const char* !!! + // char* cast because 1st arg of linux putenv function + // is not a const char* ! int ret=putenv((char *)s.c_str()); //End of CCRT porting #endif @@ -211,194 +557,156 @@ void Engines_Component_i::beginService(const char *serviceName) } } +//============================================================================= +/*! + * C++ method: used by derived classes for supervision + */ +//============================================================================= + void Engines_Component_i::endService(const char *serviceName) { _ThreadCpuUsed = CpuUsed_impl() ; - MESSAGE(pthread_self() << " Send EndService notification for " << serviceName << endl - << " Component instance : " << _instanceName << " StartUsed " << _StartUsed << " _ThreadCpuUsed " - << _ThreadCpuUsed << endl << endl); + MESSAGE(pthread_self() << " Send EndService notification for " << serviceName + << endl << " Component instance : " << _instanceName << " StartUsed " + << _StartUsed << " _ThreadCpuUsed "<< _ThreadCpuUsed << endl < 0 && pthread_self() != _ThreadId ) { - RetVal = Killer( _ThreadId , 0 ) ; - _ThreadId = (pthread_t ) -1 ; - } - return RetVal ; -} +//============================================================================= +/*! + * C++ method: + */ +//============================================================================= -bool Engines_Component_i::Stop_impl() { - 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 - << dec << " _ThreadId " << _ThreadId ); - bool RetVal = false ; - if ( _ThreadId > 0 && pthread_self() != _ThreadId ) { - RetVal = Killer( _ThreadId , 0 ) ; - _ThreadId = (pthread_t ) -1 ; - } - return RetVal ; -} - -bool Engines_Component_i::Suspend_impl() { - 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 - << dec << " _ThreadId " << _ThreadId ); - bool RetVal = false ; - if ( _ThreadId > 0 && pthread_self() != _ThreadId ) { - if ( _Sleeping ) { - return false ; - } - else { - RetVal = Killer( _ThreadId ,SIGINT ) ; - } - } - return RetVal ; +void SetCpuUsed() +{ + theEngines_Component->SetCurCpu() ; } -bool Engines_Component_i::Resume_impl() { - 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 - << dec << " _ThreadId " << _ThreadId ); - bool RetVal = false ; - if ( _ThreadId > 0 && pthread_self() != _ThreadId ) { - if ( _Sleeping ) { - _Sleeping = false ; - RetVal = true ; - } - else { - RetVal = false ; - } - } - return RetVal ; - -} +//============================================================================= +/*! + * C++ method: + */ +//============================================================================= -void SetCpuUsed() { - theEngines_Component->SetCurCpu() ; -} -void Engines_Component_i::SetCurCpu() { +void Engines_Component_i::SetCurCpu() +{ _ThreadCpuUsed = CpuUsed() ; -// MESSAGE(pthread_self() << " Engines_Component_i::SetCurCpu() _ThreadCpuUsed " << _ThreadCpuUsed) ; + // MESSAGE(pthread_self() << + // " Engines_Component_i::SetCurCpu() _ThreadCpuUsed " << _ThreadCpuUsed) ; } -#include -#include -#include +//============================================================================= +/*! + * C++ method: + */ +//============================================================================= -long Engines_Component_i::CpuUsed() { +long Engines_Component_i::CpuUsed() +{ long cpu = 0 ; struct rusage usage ; - if ( _ThreadId || _Executed ) { - if ( getrusage( RUSAGE_SELF , &usage ) == -1 ) { - perror("Engines_Component_i::CpuUsed") ; - return 0 ; - } - cpu = usage.ru_utime.tv_sec - _StartUsed ; -// cout << pthread_self() << " Engines_Component_i::CpuUsed " << " " << _serviceName -// << usage.ru_utime.tv_sec << " - " << _StartUsed << " = " << cpu << endl ; - } - else { -// cout << pthread_self() << "Engines_Component_i::CpuUsed _ThreadId " << _ThreadId << " " << _serviceName -// << " _StartUsed " << _StartUsed << endl ; - } - return cpu ; -} - -CORBA::Long Engines_Component_i::CpuUsed_impl() { - long cpu = 0 ; - if ( _ThreadId || _Executed ) { - if ( _ThreadId > 0 ) { - if ( pthread_self() != _ThreadId ) { - if ( _Sleeping ) { - } - else { -// Get Cpu in the appropriate thread with that object !... - theEngines_Component = this ; - Killer( _ThreadId ,SIGUSR1 ) ; - } - cpu = _ThreadCpuUsed ; - } - else { - _ThreadCpuUsed = CpuUsed() ; - cpu = _ThreadCpuUsed ; -// cout << pthread_self() << " Engines_Component_i::CpuUsed_impl " << _serviceName << " " << cpu -// << endl ; - } + if ( _ThreadId || _Executed ) + { + if ( getrusage( RUSAGE_SELF , &usage ) == -1 ) + { + perror("Engines_Component_i::CpuUsed") ; + return 0 ; + } + cpu = usage.ru_utime.tv_sec - _StartUsed ; + // cout << pthread_self() << " Engines_Component_i::CpuUsed " << " " + // << _serviceName << usage.ru_utime.tv_sec << " - " << _StartUsed + // << " = " << cpu << endl ; } - else { - cpu = _ThreadCpuUsed ; -// cout << pthread_self() << " Engines_Component_i::CpuUsed_impl " << _serviceName << " " << cpu -// << endl ; + else + { + // cout << pthread_self() << "Engines_Component_i::CpuUsed _ThreadId " + // << _ThreadId << " " << _serviceName<< " _StartUsed " + // << _StartUsed << endl ; } - } - else { -// cout << pthread_self() << "Engines_Component_i::CpuUsed_impl _ThreadId " << _ThreadId << " " -// << _serviceName << " _StartUsed " << _StartUsed << endl ; - } return cpu ; } -// Send message to event channel +//============================================================================= +/*! + * C++ method: Send message to event channel + */ +//============================================================================= -void Engines_Component_i::sendMessage(const char *event_type, const char *message) { +void Engines_Component_i::sendMessage(const char *event_type, + const char *message) +{ _notifSupplier->Send(graphName(), nodeName(), event_type, message); } +//============================================================================= +/*! + * C++ method: + */ +//============================================================================= + string Engines_Component_i::GetDynLibraryName(const char *componentName) { string ret="lib"; @@ -407,11 +715,38 @@ string Engines_Component_i::GetDynLibraryName(const char *componentName) return ret; } -string Engines_Component_i::BuildComponentNameForNS(const char *ComponentName, const char *ContainerName, const char *hostname) +//============================================================================= +/*! + * C++ method: + */ +//============================================================================= + +string Engines_Component_i::BuildComponentNameForNS(const char *ComponentName, + const char *ContainerName, + const char *hostname) { - string ret=Engines_Container_i::BuildContainerNameForNS(ContainerName,hostname); + string ret = + Engines_Container_i::BuildContainerNameForNS(ContainerName,hostname); ret+="/"; ret+=ComponentName; return ret; } - +//============================================================================= +/*! + * C++ method: DumpPython default implementation + */ +//============================================================================= + +Engines::TMPFile* Engines_Component_i::DumpPython(CORBA::Object_ptr theStudy, + CORBA::Boolean isPublished, + CORBA::Boolean& isValidScript) +{ + char* aScript = "def RebuildData(theStudy): pass"; + char* aBuffer = new char[strlen(aScript)+1]; + strcpy(aBuffer, aScript); + CORBA::Octet* anOctetBuf = (CORBA::Octet*)aBuffer; + int aBufferSize = strlen(aBuffer)+1; + Engines::TMPFile_var aStreamFile = new Engines::TMPFile(aBufferSize, aBufferSize, anOctetBuf, 1); + isValidScript = true; + return aStreamFile._retn(); +} diff --git a/src/Container/Container_i.cxx b/src/Container/Container_i.cxx index b65bf13bd..59671af74 100644 --- a/src/Container/Container_i.cxx +++ b/src/Container/Container_i.cxx @@ -26,16 +26,19 @@ // Module : SALOME // $Header$ +//#define private public #include #include CORBA_SERVER_HEADER(SALOME_Component) #include "SALOME_Container_i.hxx" +#include "SALOME_Component_i.hxx" #include "SALOME_NamingService.hxx" -//#include "Utils_SINGLETON.hxx" #include "OpUtil.hxx" #include #include #include #include +#include +#include "Container_init_python.hxx" #include "utilities.h" using namespace std; @@ -54,12 +57,28 @@ extern "C" {void ActSigIntHandler() ; } extern "C" {void SigIntHandler(int, siginfo_t *, void *) ; } const char *Engines_Container_i::_defaultContainerName="FactoryServer"; +map Engines_Container_i::_cntInstances_map; +map Engines_Container_i::_library_map; +map Engines_Container_i::_toRemove_map; +omni_mutex Engines_Container_i::_numInstanceMutex ; + +//============================================================================= +/*! + * Default constructor, not for use + */ +//============================================================================= Engines_Container_i::Engines_Container_i () : - _numInstance(0) + _numInstance(0) { } +//============================================================================= +/*! + * Construtor to use + */ +//============================================================================= + Engines_Container_i::Engines_Container_i (CORBA::ORB_ptr orb, PortableServer::POA_ptr poa, char *containerName , @@ -80,71 +99,141 @@ Engines_Container_i::Engines_Container_i (CORBA::ORB_ptr orb, _argc = argc ; _argv = argv ; int i = strlen( _argv[ 0 ] ) - 1 ; - while ( i >= 0 ) { - if ( _argv[ 0 ][ i ] == '/' ) { - _argv[ 0 ][ i+1 ] = '\0' ; - break ; + while ( i >= 0 ) + { + if ( _argv[ 0 ][ i ] == '/' ) + { + _argv[ 0 ][ i+1 ] = '\0' ; + break ; + } + i -= 1 ; } - i -= 1 ; - } string hostname = GetHostname(); MESSAGE(hostname << " " << getpid() << " Engines_Container_i starting argc " << _argc << " Thread " << pthread_self() ) ; i = 0 ; - while ( _argv[ i ] ) { - MESSAGE(" argv" << i << " " << _argv[ i ]) ; - i++ ; - } - if ( argc != 4 ) { - MESSAGE("SALOME_Container usage : SALOME_Container ServerName -ORBInitRef NameService=corbaname::hostname:tcpipPortNumber") ; -// exit(0) ; - } + while ( _argv[ i ] ) + { + MESSAGE(" argv" << i << " " << _argv[ i ]) ; + i++ ; + } - SCRUTE(hostname); + if ( argc < 2 ) + { + INFOS("SALOME_Container usage : SALOME_Container ServerName"); + ASSERT(0) ; + } + SCRUTE(argv[1]); + _isSupervContainer = false; + if (strcmp(argv[1],"SuperVisionContainer") == 0) _isSupervContainer = true; _containerName = BuildContainerNameForNS(containerName,hostname.c_str()); - + _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 - // 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();//SINGLETON_::Instance() ; - //ASSERT(SINGLETON_::IsAlreadyExisting()) ; - _NS->init_orb( CORBA::ORB::_duplicate(_orb) ) ; - CORBA::Object_var obj=_poa->id_to_reference(*_id); - Engines::Container_var pCont - = Engines::Container::_narrow(obj); - SCRUTE(_containerName); - _NS->Register(pCont, _containerName.c_str()); - } + if(activAndRegist) + { + _id = _poa->activate_object(this); + _NS = new SALOME_NamingService(); + _NS->init_orb( CORBA::ORB::_duplicate(_orb) ) ; + CORBA::Object_var obj=_poa->id_to_reference(*_id); + Engines::Container_var pCont + = Engines::Container::_narrow(obj); + SCRUTE(_containerName); + _NS->Register(pCont, _containerName.c_str()); + + // 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) + { + Py_ACQUIRE_NEW_THREAD; + PyRun_SimpleString("import SALOME_Container\n"); + PyRun_SimpleString((char*)myCommand.c_str()); + Py_RELEASE_NEW_THREAD; + } + } } +//============================================================================= +/*! + * Destructor + */ +//============================================================================= + Engines_Container_i::~Engines_Container_i() { MESSAGE("Container_i::~Container_i()"); delete _id; } +//============================================================================= +/*! + * CORBA attribute: Container name (see constructor) + */ +//============================================================================= + char* Engines_Container_i::name() { return CORBA::string_dup(_containerName.c_str()) ; } -char* Engines_Container_i::machineName() +//============================================================================= +/*! + * CORBA method: Get the hostName of the Container (without domain extensions) + */ +//============================================================================= + +char* Engines_Container_i::getHostName() { string s = GetHostname(); - MESSAGE("Engines_Container_i::machineName " << s); - return CORBA::string_dup(s.c_str()) ; + MESSAGE("Engines_Container_i::getHostName " << s); + return CORBA::string_dup(s.c_str()) ; +} + +//============================================================================= +/*! + * CORBA method: Get the PID (process identification) of the Container + */ +//============================================================================= + +CORBA::Long Engines_Container_i::getPID() +{ + return (CORBA::Long)getpid(); } +//============================================================================= +/*! + * CORBA method: check if servant is still alive + */ +//============================================================================= + void Engines_Container_i::ping() { MESSAGE("Engines_Container_i::ping() pid "<< getpid()); } -// shutdown corba server +//============================================================================= +/*! + * 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() { MESSAGE("Engines_Container_i::Shutdown()"); @@ -155,138 +244,553 @@ void Engines_Container_i::Shutdown() _orb->shutdown(0); } -//! Kill current container -bool Engines_Container_i::Kill_impl() { - MESSAGE("Engines_Container_i::Kill() pid "<< getpid() << " containerName " - << _containerName.c_str() << " machineName " - << GetHostname().c_str()); - exit( 0 ) ; -} -Engines::Component_ptr Engines_Container_i::load_impl( const char* nameToRegister, - const char* componentName ) { +//============================================================================= +/*! + * 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 +Engines_Container_i::load_component_Library(const char* componentName) +{ - _numInstanceMutex.lock() ; // lock on the instance number - BEGIN_OF( "Container_i::load_impl " << componentName ) ; - _numInstance++ ; - char _aNumI[12]; - sprintf( _aNumI , "%d" , _numInstance ) ; + string aCompName = componentName; - string _impl_name = componentName; - string _nameToRegister = nameToRegister; - string instanceName = _nameToRegister + "_inst_" + _aNumI ; - //SCRUTE(instanceName); + // --- try dlopen C++ component - //string absolute_impl_name = _library_path + "lib" + _impl_name + ".so"; - string absolute_impl_name( _impl_name ) ; - SCRUTE(absolute_impl_name); + string impl_name = string ("lib") + aCompName + string("Engine.so"); + SCRUTE(impl_name); + + _numInstanceMutex.lock(); // lock to be alone + // (see decInstanceCnt, finalize_removal)) + if (_toRemove_map[impl_name]) _toRemove_map.erase(impl_name); + if (_library_map[impl_name]) + { + MESSAGE("Library " << impl_name << " already loaded"); + _numInstanceMutex.unlock(); + return true; + } + void* handle; - handle = dlopen( absolute_impl_name.c_str() , RTLD_LAZY ) ; - if ( !handle ) { - INFOS("Can't load shared library : " << absolute_impl_name); - INFOS("error dlopen: " << dlerror()); - _numInstanceMutex.unlock() ; - return Engines::Component::_nil() ; - } + handle = dlopen( impl_name.c_str() , RTLD_LAZY ) ; + if ( handle ) + { + _library_map[impl_name] = handle; + _numInstanceMutex.unlock(); + return true; + } + else + { + INFOS("Can't load shared library : " << impl_name); + INFOS("error dlopen: " << dlerror()); + } + _numInstanceMutex.unlock(); + + // --- try import Python component + + INFOS("try import Python component "<0) otherwise + * \return a loaded component + */ +//============================================================================= - char *error ; - if ( (error = dlerror() ) != NULL) { - INFOS("Can't resolve symbol: " + factory_name); - SCRUTE(error); - _numInstanceMutex.unlock() ; +Engines::Component_ptr +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() ; } - string component_registerName = _containerName + "/" + _nameToRegister; Engines::Component_var iobject = Engines::Component::_nil() ; - try { - CORBA::Object_var obj = _NS->Resolve( component_registerName.c_str() ) ; - if ( CORBA::is_nil( obj ) ) { -// Instanciate required CORBA object - PortableServer::ObjectId * id ; - id = (Component_factory) ( _orb, _poa, _id, instanceName.c_str() , - _nameToRegister.c_str() ) ; - // get reference from id - obj = _poa->id_to_reference(*id); + + string aCompName = genericRegisterName; + if (_library_map[aCompName]) // Python component + { + 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, + "create_component_instance", + "ssl", + aCompName.c_str(), + instanceName.c_str(), + studyId); + string iors = PyString_AsString(result); + SCRUTE(iors); + Py_RELEASE_NEW_THREAD; + + CORBA::Object_var obj = _orb->string_to_object(iors.c_str()); iobject = Engines::Component::_narrow( obj ) ; + return iobject._retn(); + } + + //--- try C++ -// _numInstanceMutex.lock() ; // lock on the add on handle_map (necessary ?) - // register the engine under the name containerName.dir/nameToRegister.object - _NS->Register( iobject , component_registerName.c_str() ) ; - MESSAGE( "Container_i::load_impl " << component_registerName.c_str() << " bound" ) ; + string impl_name = string ("lib") + genericRegisterName +string("Engine.so"); + void* handle = _library_map[impl_name]; + if ( !handle ) + { + INFOS("shared library " << impl_name <<"must be loaded before instance"); + return Engines::Component::_nil() ; } - else { // JR : No ReBind !!! - MESSAGE( "Container_i::load_impl " << component_registerName.c_str() << " already bound" ) ; - iobject = Engines::Component::_narrow( obj ) ; + else + { + iobject = createInstance(genericRegisterName, + handle, + studyId); + return iobject._retn(); } - } - catch (...) { - INFOS( "Container_i::load_impl catched" ) ; - } +} + +//============================================================================= +/*! + * 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 + */ +//============================================================================= -//Jr _numInstanceMutex.lock() ; // lock on the add on handle_map (necessary ?) - handle_map[instanceName] = handle; - END_OF("Container_i::load_impl"); - _numInstanceMutex.unlock() ; - return Engines::Component::_duplicate(iobject); +Engines::Component_ptr +Engines_Container_i::find_component_instance( const char* registeredName, + 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) + { + 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 + */ +//============================================================================= + +Engines::Component_ptr +Engines_Container_i::load_impl( const char* genericRegisterName, + const char* componentName ) +{ + string impl_name = string ("lib") + genericRegisterName +string("Engine.so"); + Engines::Component_var iobject = Engines::Component::_nil() ; + if (load_component_Library(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 + */ +//============================================================================= void Engines_Container_i::remove_impl(Engines::Component_ptr component_i) { ASSERT(! CORBA::is_nil(component_i)); string instanceName = component_i->instanceName() ; MESSAGE("unload component " << instanceName); + _listInstances_map.erase(instanceName); component_i->destroy() ; - MESSAGE("test key handle_map"); - _numInstanceMutex.lock() ; // lock on the remove on handle_map - if (handle_map[instanceName]) // if key does not exist, created & initialized null + _NS->Destroy_Name(instanceName.c_str()); +} + +//============================================================================= +/*! + * 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) + map::iterator ith; + for (ith = _toRemove_map.begin(); ith != _toRemove_map.end(); ith++) { - remove_map[instanceName] = handle_map[instanceName] ; + 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); + } } - else MESSAGE("pas d'entree handle_map"); - handle_map.erase(instanceName) ; - _numInstanceMutex.unlock() ; - MESSAGE("contenu handle_map"); - map::iterator im ; - for (im = handle_map.begin() ; im != handle_map.end() ; im ++) + _toRemove_map.clear(); + _numInstanceMutex.unlock(); +} + +//============================================================================= +/*! + * 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()); + INFOS("==============================================================="); + INFOS("= REMOVE calls to Kill_impl in C++ container ="); + INFOS("==============================================================="); + //exit( 0 ) ; + ASSERT(0); +} + +//============================================================================= +/*! + * 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 +Engines_Container_i::find_or_create_instance(string genericRegisterName, + string componentLibraryName) +{ + string aGenRegisterName = genericRegisterName; + string impl_name = componentLibraryName; + void* handle = _library_map[impl_name]; + if ( !handle ) + { + INFOS("shared library " << impl_name <<"must be loaded before instance"); + return Engines::Component::_nil() ; + } + else { - MESSAGE("reste " << (*im).first); + // --- find a registered instance in naming service, or create + + 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 + { + // 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"); + } + } + } + catch (...) + { + INFOS( "Container_i::load_impl catched" ) ; + } + return iobject._retn(); } } -void Engines_Container_i::finalize_removal() +//============================================================================= +/*! + * 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 +Engines_Container_i::createInstance(string genericRegisterName, + void *handle, + int studyId) { - MESSAGE("finalize unload : dlclose"); - map::iterator im ; - _numInstanceMutex.lock() ; // lock on the explore remove_map & dlclose - for (im = remove_map.begin() ; im != remove_map.end() ; im ++) + // --- find the factory + + string aGenRegisterName = genericRegisterName; + string factory_name = aGenRegisterName + string("Engine_factory"); + SCRUTE(factory_name) ; + + typedef PortableServer::ObjectId * (*FACTORY_FUNCTION) + (CORBA::ORB_ptr, + PortableServer::POA_ptr, + PortableServer::ObjectId *, + const char *, + const char *) ; + + FACTORY_FUNCTION Component_factory + = (FACTORY_FUNCTION) dlsym(handle, factory_name.c_str()); + + char *error ; + if ( (error = dlerror() ) != NULL) { - void * handle = (*im).second ; - dlclose(handle) ; - MESSAGE("dlclose " << (*im).first); + INFOS("Can't resolve symbol: " + factory_name); + SCRUTE(error); + return Engines::Component::_nil() ; } - remove_map.clear() ; - _numInstanceMutex.unlock() ; - MESSAGE("remove_map.clear()"); + + // --- create instance + + 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() ) ; + + // --- 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); + _listInstances_map[instanceName] = iobject; + _cntInstances_map[aGenRegisterName] += 1; + SCRUTE(aGenRegisterName); + SCRUTE(_cntInstances_map[aGenRegisterName]); + //SCRUTE(servant->pd_refCount); + ASSERT(servant->setStudyId(studyId)); + + // --- register the engine under the name + // containerName(.dir)/instanceName(.object) + + _NS->Register( iobject , component_registerName.c_str() ) ; + MESSAGE( component_registerName.c_str() << " bound" ) ; + } + catch (...) + { + INFOS( "Container_i::createInstance exception catched" ) ; + } + return iobject._retn(); +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +void Engines_Container_i::decInstanceCnt(string genericRegisterName) +{ + string aGenRegisterName =genericRegisterName; + MESSAGE("Engines_Container_i::decInstanceCnt " << aGenRegisterName); + ASSERT(_cntInstances_map[aGenRegisterName] > 0); + _numInstanceMutex.lock(); // lock to be alone + // (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; + } + _numInstanceMutex.unlock(); +} + +//============================================================================= +/*! + * Retrieves only with container naming convention if it is a python container + */ +//============================================================================= + +bool Engines_Container_i::isPythonContainer(const char* ContainerName) +{ + bool ret=false; + int len=strlen(ContainerName); + if(len>=2) + if(strcmp(ContainerName+len-2,"Py")==0) + ret=true; + return ret; } -void ActSigIntHandler() { +//============================================================================= +/*! + * Returns string = container path + name, to use in Naming service + */ +//============================================================================= + +string Engines_Container_i::BuildContainerNameForNS(const char *ContainerName, + const char *hostname) +{ + string ret="/Containers/"; + ret += hostname; + ret+="/"; + if (strlen(ContainerName)== 0) + ret+=_defaultContainerName; + else + ret += ContainerName; + return ret; +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +void ActSigIntHandler() +{ struct sigaction SigIntAct ; SigIntAct.sa_sigaction = &SigIntHandler ; SigIntAct.sa_flags = SA_SIGINFO ; -// 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 if ( sigaction( SIGINT , &SigIntAct, NULL ) ) { perror("SALOME_Container main ") ; exit(0) ; @@ -301,7 +805,8 @@ void ActSigIntHandler() { void SetCpuUsed() ; void SigIntHandler(int what , siginfo_t * siginfo , - void * toto ) { + void * toto ) +{ MESSAGE(pthread_self() << "SigIntHandler what " << what << endl << " si_signo " << siginfo->si_signo << endl << " si_code " << siginfo->si_code << endl @@ -330,120 +835,107 @@ void SigIntHandler(int what , siginfo_t * siginfo , } } -// Get the PID of the Container - -long Engines_Container_i::getPID() { - return (long)getpid(); -} - -// Get the hostName of the Container - -char* Engines_Container_i::getHostName() { - return((char*)(GetHostname().c_str())); -} - -// Retrieves only with container naming convention if it is a python container -bool Engines_Container_i::isPythonContainer(const char* ContainerName) -{ - bool ret=false; - int len=strlen(ContainerName); - if(len>=2) - if(strcmp(ContainerName+len-2,"Py")==0) - ret=true; - return ret; -} - -string Engines_Container_i::BuildContainerNameForNS(const char *ContainerName, const char *hostname) -{ - string ret="/Containers/"; - ret += hostname; - ret+="/"; - if (strlen(ContainerName)== 0) - ret+=_defaultContainerName; - else - ret += ContainerName; - return ret; -} - - -/* - * Create one instance of componentName component and register it - * as nameToRegister in naming service +//============================================================================= +/*! + * CORBA method: Create one instance of componentName component + * and register it as genericRegisterName in naming service */ -Engines::Component_ptr Engines_Container_i::instance( const char* nameToRegister, - const char* componentName ) { +//============================================================================= - _numInstanceMutex.lock() ; // lock on the instance number - BEGIN_OF( "Container_i::instance " << componentName ) ; +// Engines::Component_ptr Engines_Container_i::instance( const char* genericRegisterName, +// const char* componentName ) +// { +// _numInstanceMutex.lock() ; // lock on the instance number +// BEGIN_OF( "Container_i::instance " << componentName ) ; - string _nameToRegister = nameToRegister; - string component_registerName = _containerName + "/" + _nameToRegister; +// string _genericRegisterName = genericRegisterName; +// string component_registerName = _containerName + "/" + _genericRegisterName; - Engines::Component_var iobject = Engines::Component::_nil() ; +// Engines::Component_var iobject = Engines::Component::_nil() ; - try { - CORBA::Object_var obj = _NS->Resolve( component_registerName.c_str() ) ; - if (! CORBA::is_nil( obj ) ) { - MESSAGE( "Container_i::instance " << component_registerName.c_str() << " already registered" ) ; - iobject = Engines::Component::_narrow( obj ) ; - } - else{ - string _compo_name = componentName; - string _impl_name = "lib" + _compo_name + "Engine.so"; - SCRUTE(_impl_name); - - void* handle; - handle = dlopen( _impl_name.c_str() , RTLD_LAZY ) ; +// try +// { +// CORBA::Object_var obj = _NS->Resolve( component_registerName.c_str() ) ; +// if (! CORBA::is_nil( obj ) ) +// { +// MESSAGE( "Container_i::instance " << component_registerName.c_str() << " already registered" ) ; +// iobject = Engines::Component::_narrow( obj ) ; +// } +// else +// { +// string _compo_name = componentName; +// string _impl_name = "lib" + _compo_name + "Engine.so"; +// SCRUTE(_impl_name); - if ( handle ) { - string factory_name = _compo_name + "Engine_factory"; - SCRUTE(factory_name) ; - - typedef PortableServer::ObjectId * (*FACTORY_FUNCTION) - (CORBA::ORB_ptr, - PortableServer::POA_ptr, - PortableServer::ObjectId *, - const char *, - const char *) ; - FACTORY_FUNCTION Component_factory = (FACTORY_FUNCTION) dlsym(handle, factory_name.c_str()); - - char *error ; - if ( (error = dlerror() ) == NULL) { - // Instanciate required CORBA object - _numInstance++ ; - char _aNumI[12]; - sprintf( _aNumI , "%d" , _numInstance ) ; - string instanceName = _compo_name + "_inst_" + _aNumI ; - SCRUTE(instanceName); - - PortableServer::ObjectId * id ; - id = (Component_factory) ( _orb, _poa, _id, instanceName.c_str() , - _nameToRegister.c_str() ) ; - // get reference from id - obj = _poa->id_to_reference(*id); - iobject = Engines::Component::_narrow( obj ) ; - - // register the engine under the name containerName.dir/nameToRegister.object - _NS->Register( iobject , component_registerName.c_str() ) ; - MESSAGE( "Container_i::instance " << component_registerName.c_str() << " registered" ) ; - handle_map[instanceName] = handle; - } - else{ - INFOS("Can't resolve symbol: " + factory_name); - SCRUTE(error); - } - } - else{ - INFOS("Can't load shared library : " << _impl_name); - INFOS("error dlopen: " << dlerror()); - } - } - } - catch (...) { - INFOS( "Container_i::instance exception caught" ) ; - } - END_OF("Container_i::instance"); - _numInstanceMutex.unlock() ; - return Engines::Component::_duplicate(iobject); -} - +// void* handle; +// handle = dlopen( _impl_name.c_str() , RTLD_LAZY ) ; + +// if ( handle ) +// { +// string factory_name = _compo_name + "Engine_factory"; +// SCRUTE(factory_name) ; + +// typedef PortableServer::ObjectId * (*FACTORY_FUNCTION) +// (CORBA::ORB_ptr, +// PortableServer::POA_ptr, +// PortableServer::ObjectId *, +// const char *, +// const char *) ; +// FACTORY_FUNCTION Component_factory = (FACTORY_FUNCTION) dlsym(handle, factory_name.c_str()); + +// char *error ; +// if ( (error = dlerror() ) == NULL) +// { +// // Instanciate required CORBA object +// _numInstance++ ; +// char _aNumI[12]; +// sprintf( _aNumI , "%d" , _numInstance ) ; +// string instanceName = _compo_name + "_inst_" + _aNumI ; +// SCRUTE(instanceName); + +// PortableServer::ObjectId * id ; +// id = (Component_factory) ( _orb, _poa, _id, instanceName.c_str() , +// _genericRegisterName.c_str() ) ; +// // get reference from id +// obj = _poa->id_to_reference(*id); +// iobject = Engines::Component::_narrow( obj ) ; + +// // register the engine under the name containerName.dir/genericRegisterName.object +// _NS->Register( iobject , component_registerName.c_str() ) ; +// MESSAGE( "Container_i::instance " << component_registerName.c_str() << " registered" ) ; +// _handle_map[instanceName] = handle; +// } +// else +// { +// INFOS("Can't resolve symbol: " + factory_name); +// SCRUTE(error); +// } +// } +// else +// { +// INFOS("Can't load shared library : " << _impl_name); +// INFOS("error dlopen: " << dlerror()); +// } +// } +// } +// catch (...) +// { +// INFOS( "Container_i::instance exception caught" ) ; +// } +// END_OF("Container_i::instance"); +// _numInstanceMutex.unlock() ; +// return Engines::Component::_duplicate(iobject); +// } + +//============================================================================= +/*! + * CORBA attribute: Machine Name (hostname without domain extensions) + */ +//============================================================================= + +// char* Engines_Container_i::machineName() +// { +// string s = GetHostname(); +// MESSAGE("Engines_Container_i::machineName " << s); +// return CORBA::string_dup(s.c_str()) ; +// } diff --git a/src/Container/Makefile.in b/src/Container/Makefile.in index 1ed861ed0..5ccebde83 100644 --- a/src/Container/Makefile.in +++ b/src/Container/Makefile.in @@ -34,22 +34,29 @@ VPATH=.:@srcdir@:@top_srcdir@/idl @COMMENCE@ -EXPORT_PYSCRIPTS = SALOME_ComponentPy.py SALOME_ContainerPy.py +EXPORT_PYSCRIPTS = SALOME_ComponentPy.py \ + SALOME_ContainerPy.py \ + SALOME_Container.py EXPORT_HEADERS = \ SALOME_Component_i.hxx \ SALOME_Container_i.hxx \ - SALOME_ContainerManager.hxx + SALOME_ContainerManager.hxx \ + Container_init_python.hxx # Libraries targets LIB = libSalomeContainer.la -LIB_SRC = Component_i.cxx Container_i.cxx SALOME_ContainerManager.cxx +LIB_SRC = Component_i.cxx \ + Container_i.cxx \ + SALOME_ContainerManager.cxx \ + Container_init_python.cxx + LIB_SERVER_IDL = SALOME_Registry.idl SALOME_Component.idl SALOME_ContainerManager.idl LIB_CLIENT_IDL = # Executables targets -BIN = SALOME_Container +BIN = SALOME_Container SALOME_ContainerManagerServer BIN_SRC = SALOME_Container_SignalsHandler.cxx BIN_SERVER_IDL = SALOME_Component.idl SALOME_ContainerManager.idl diff --git a/src/Container/SALOME_ComponentPy.py b/src/Container/SALOME_ComponentPy.py index 10a47c978..000775318 100755 --- a/src/Container/SALOME_ComponentPy.py +++ b/src/Container/SALOME_ComponentPy.py @@ -218,4 +218,9 @@ class SALOME_ComponentPy_i (Engines__POA.Component): return 0 #------------------------------------------------------------------------- + + def DumpPython(self, theStudy, isPublished): + aBuffer = "def RebuildData(theStudy): pass" + return (aBuffer, 1) + #------------------------------------------------------------------------- diff --git a/src/Container/SALOME_Component_i.hxx b/src/Container/SALOME_Component_i.hxx index 620ca1499..205eabd75 100644 --- a/src/Container/SALOME_Component_i.hxx +++ b/src/Container/SALOME_Component_i.hxx @@ -91,15 +91,26 @@ public: void SetCurCpu() ; long CpuUsed() ; CORBA::Long CpuUsed_impl() ; + CORBA::Long getStudyId(); + virtual Engines::TMPFile* DumpPython(CORBA::Object_ptr theStudy, CORBA::Boolean isPublished, CORBA::Boolean& isValidScript); + + bool setStudyId(CORBA::Long studyId); + static bool isMultiStudy(); + static bool isMultiInstance(); static std::string GetDynLibraryName(const char *componentName); - static std::string BuildComponentNameForNS(const char *ComponentName, const char *ContainerName, const char *hostname); + static std::string BuildComponentNameForNS(const char *ComponentName, + const char *ContainerName, + const char *hostname); protected: + static bool _isMultiStudy; + static bool _isMultiInstance; std::string _instanceName ; std::string _interfaceName ; std::string _serviceName ; std::string _graphName ; std::string _nodeName ; + int _studyId; // -1: not initialised; 0: multiStudy; >0: study CORBA::ORB_ptr _orb; PortableServer::POA_ptr _poa; PortableServer::ObjectId * _id; diff --git a/src/Container/SALOME_Container.cxx b/src/Container/SALOME_Container.cxx index dfd501e9f..f6bb9b0fe 100644 --- a/src/Container/SALOME_Container.cxx +++ b/src/Container/SALOME_Container.cxx @@ -37,6 +37,7 @@ #include "SALOME_Container_i.hxx" #include "utilities.h" #include "SALOMETraceCollector.hxx" +#include "OpUtil.hxx" #ifdef CHECKTIME #include @@ -46,30 +47,40 @@ #include #endif -#include +#include "Container_init_python.hxx" using namespace std; extern "C" void HandleServerSideSignals(CORBA::ORB_ptr theORB); -static PyMethodDef MethodPyVoidMethod[] = {{ NULL, NULL }}; - int main(int argc, char* argv[]) { #ifdef HAVE_MPI2 MPI_Init(&argc,&argv); #endif // Initialise the ORB. - //ORB_INIT &init = *SINGLETON_::Instance() ; CORBA::ORB_var orb = CORBA::ORB_init( argc , argv ) ; SALOMETraceCollector *myThreadTrace = SALOMETraceCollector::instance(orb); INFOS_COMPILATION; BEGIN_OF(argv[0]); - - Py_Initialize() ; - PySys_SetArgv( argc , argv ) ; - Py_InitModule( "InitPyRunMethod" , MethodPyVoidMethod ) ; - + + ASSERT(argc > 1); + SCRUTE(argv[1]); + bool isSupervContainer = false; + if (strcmp(argv[1],"SuperVisionContainer") == 0) isSupervContainer = true; + + if (!isSupervContainer) + { + int _argc = 1; + char* _argv[] = {""}; + KERNEL_PYTHON::init_python(argc,argv); + } + else + { + Py_Initialize() ; + PySys_SetArgv( argc , argv ) ; + } + try{ // Obtain a reference to the root POA. // obtain the root poa manager @@ -112,8 +123,8 @@ int main(int argc, char* argv[]) theObj = orb->resolve_initial_references("NameService"); if (!CORBA::is_nil(theObj)) inc = CosNaming::NamingContext::_narrow(theObj); - }catch(CORBA::COMM_FAILURE&){ - MESSAGE( "Container: CORBA::COMM_FAILURE: Unable to contact the Naming Service" ); + }catch(CORBA::SystemException&){ + MESSAGE( "Container: CORBA::SystemException: Unable to contact the Naming Service" ); } if(!CORBA::is_nil(inc)){ MESSAGE( "Container: Naming Service was found" ); diff --git a/src/Container/SALOME_ContainerManager.cxx b/src/Container/SALOME_ContainerManager.cxx index d5fad0ae9..77cebf354 100644 --- a/src/Container/SALOME_ContainerManager.cxx +++ b/src/Container/SALOME_ContainerManager.cxx @@ -15,8 +15,16 @@ SALOME_ContainerManager::SALOME_ContainerManager(CORBA::ORB_ptr orb) { _NS=new SALOME_NamingService(orb); PortableServer::POA_var root_poa=PortableServer::POA::_the_root_poa(); - PortableServer::ObjectId_var id=root_poa->activate_object(this); - CORBA::Object_var obj=root_poa->id_to_reference(id); + PortableServer::POAManager_var pman = root_poa->the_POAManager(); + PortableServer::POA_var my_poa; + CORBA::PolicyList policies; + policies.length(1); + PortableServer::ThreadPolicy_var threadPol=root_poa->create_thread_policy(PortableServer::SINGLE_THREAD_MODEL); + policies[0]=PortableServer::ThreadPolicy::_duplicate(threadPol); + my_poa=root_poa->create_POA("SThreadPOA",pman,policies); + threadPol->destroy(); + PortableServer::ObjectId_var id=my_poa->activate_object(this); + CORBA::Object_var obj=my_poa->id_to_reference(id); Engines::ContainerManager_var refContMan = Engines::ContainerManager::_narrow(obj); _NS->Register(refContMan,_ContainerManagerNameInNS); } diff --git a/src/Container/SALOME_Container_i.hxx b/src/Container/SALOME_Container_i.hxx index 1f0eb93cc..06e1f1aa8 100644 --- a/src/Container/SALOME_Container_i.hxx +++ b/src/Container/SALOME_Container_i.hxx @@ -56,33 +56,64 @@ public: bool isServantAloneInProcess = true); virtual ~Engines_Container_i(); + // --- CORBA methods - //! Load component in current container - Engines::Component_ptr load_impl(const char* nameToRegister, - const char* componentName); + bool load_component_Library(const char* componentName); + + Engines::Component_ptr + create_component_instance( const char* componentName, + CORBA::Long studyId); // 0 for multiStudy + + Engines::Component_ptr + find_component_instance( const char* registeredName, + CORBA::Long studyId); // 0 for multiStudy + + Engines::Component_ptr + load_impl(const char* nameToRegister, + const char* componentName); - Engines::Component_ptr instance(const char* nameToRegister, - const char* componentName); - //! Unload component from current container void remove_impl(Engines::Component_ptr component_i); void finalize_removal(); + void Shutdown(); + char* getHostName(); + CORBA::Long getPID(); char* name(); - char* machineName(); void ping(); - void Shutdown(); - //! Kill current container + bool Kill_impl() ; - char* getHostName(); - CORBA::Long getPID(); + //char* machineName(); + //Engines::Component_ptr instance(const char* nameToRegister, + // const char* componentName); + + // --- local C++ methods + + Engines::Component_ptr + find_or_create_instance( std::string genericRegisterName, + std::string componentLibraryName); + + Engines::Component_ptr + createInstance(std::string genericRegisterName, + void *handle, + int studyId); + static bool isPythonContainer(const char* ContainerName); + static std::string BuildContainerNameForNS(const char *ContainerName, + const char *hostname); + static void decInstanceCnt(std::string genericRegisterName); - static std::string BuildContainerNameForNS(const char *ContainerName, const char *hostname); - static const char *_defaultContainerName; protected: + static const char *_defaultContainerName; + static std::map _cntInstances_map; + static std::map _library_map; // library names, loaded + static std::map _toRemove_map;// library names to remove + static omni_mutex _numInstanceMutex ; // lib and instance protection + + bool _isSupervContainer; + SALOME_NamingService *_NS ; std::string _library_path; std::string _containerName; @@ -90,16 +121,14 @@ protected: PortableServer::POA_var _poa; PortableServer::ObjectId * _id ; int _numInstance ; - std::map handle_map ; - std::map remove_map ; - omni_mutex _numInstanceMutex ; // if several threads on the same object + std::map _listInstances_map; //private: - int _argc ; + int _argc ; char** _argv ; - long _pid; - bool _isServantAloneInProcess; + long _pid; + bool _isServantAloneInProcess; }; #endif diff --git a/src/DataTypeCatalog/Makefile.in b/src/DataTypeCatalog/Makefile.in index 7ba1a085f..f5bd3bc35 100644 --- a/src/DataTypeCatalog/Makefile.in +++ b/src/DataTypeCatalog/Makefile.in @@ -54,7 +54,6 @@ BIN_SERVER_IDL = SALOME_DataTypeCatalog.idl CPPFLAGS+= $(QT_MT_INCLUDES) CXXFLAGS+= -LDFLAGS+= $(QT_MT_LIBS) $(OGL_LIBS) -lSalomeNS -lOpUtil -lSALOMELocalTrace -LDFLAGSFORBIN= $(LDFLAGS) -lSALOMETraceCollector +LDFLAGS+= $(QT_MT_LIBS) $(OGL_LIBS) -lSalomeNS -lOpUtil -lSALOMELocalTrace -lSALOMETraceCollector @CONCLUDE@ diff --git a/src/DataTypeCatalog/SALOME_DataTypeCatalog_Server.cxx b/src/DataTypeCatalog/SALOME_DataTypeCatalog_Server.cxx index d79829163..ff2151361 100644 --- a/src/DataTypeCatalog/SALOME_DataTypeCatalog_Server.cxx +++ b/src/DataTypeCatalog/SALOME_DataTypeCatalog_Server.cxx @@ -83,9 +83,9 @@ int main(int argc,char **argv) theObj = orb->resolve_initial_references("NameService"); if (!CORBA::is_nil(theObj)) inc = CosNaming::NamingContext::_narrow(theObj);} - catch( CORBA::COMM_FAILURE& ) + catch( CORBA::SystemException& ) { - MESSAGE( "Data Type Catalog: CORBA::COMM_FAILURE: Unable to contact the Naming Service" ); + MESSAGE( "Data Type Catalog: CORBA::SystemException: Unable to contact the Naming Service" ); } if(!CORBA::is_nil(inc)) { diff --git a/src/LifeCycleCORBA/Launchers.cxx b/src/LifeCycleCORBA/Launchers.cxx index f3622465d..3957e8f77 100644 --- a/src/LifeCycleCORBA/Launchers.cxx +++ b/src/LifeCycleCORBA/Launchers.cxx @@ -1,4 +1,7 @@ #include +#include "utilities.h" + +using namespace std; static int Launchers_IsLoaded = 0; static PyObject * Launchers_module = 0; @@ -30,8 +33,14 @@ void releaseMainThread(PyThreadState *tstate){ } void Launchers_assertInitialized() { + MESSAGE("==========================================================="); + MESSAGE("Launchers_assertInitialized"); + MESSAGE("==========================================================="); PyThreadState *_save; if( !Py_IsInitialized() ) { + MESSAGE("==========================================================="); + MESSAGE("Py_Initialize()"); + MESSAGE("==========================================================="); Py_Initialize(); PyEval_InitThreads(); PyEval_SaveThread(); diff --git a/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx b/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx index af5848155..1af1f64e6 100644 --- a/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx +++ b/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx @@ -44,69 +44,75 @@ #include "SALOME_NamingService.hxx" using namespace std; +//============================================================================= +/*! + * Constructor + */ +//============================================================================= + SALOME_LifeCycleCORBA::SALOME_LifeCycleCORBA(SALOME_NamingService *ns) { _NS = ns; //add try catch - _NS->Change_Directory("/"); // mpv 250105: current directory may be not root (in SALOMEDS for an example) - CORBA::Object_var obj=_NS->Resolve(SALOME_ContainerManager::_ContainerManagerNameInNS); + _NS->Change_Directory("/"); // mpv 250105: current directory may be not root + // (in SALOMEDS for an example) + // not enough: set a current directory in naming service is not thread safe + // if naming service instance is shared among several threads... + // ==> allways use absolute path and dot rely on current directory! + + CORBA::Object_var obj = + _NS->Resolve(SALOME_ContainerManager::_ContainerManagerNameInNS); ASSERT( !CORBA::is_nil(obj)); _ContManager=Engines::ContainerManager::_narrow(obj); } +//============================================================================= +/*! + * Destructor + */ +//============================================================================= + SALOME_LifeCycleCORBA::~SALOME_LifeCycleCORBA() { } -string SALOME_LifeCycleCORBA::ContainerName( - const char * aComputerContainer , - string * theComputer , - string * theContainer ) { - char * ContainerName = new char [ strlen( aComputerContainer ) + 1 ] ; - strcpy( ContainerName , aComputerContainer ) ; - string theComputerContainer("/Containers/"); - char * slash = strchr( ContainerName , '/' ) ; - if ( !slash ) { - *theComputer = GetHostname() ; - theComputerContainer += *theComputer ; - theComputerContainer += "/" ; - *theContainer = ContainerName ; - theComputerContainer += *theContainer ; - } - else { - slash[ 0 ] = '\0' ; - slash += 1 ; - *theContainer = slash ; - if ( !strcmp( ContainerName , "localhost" ) ) { - *theComputer = GetHostname() ; - } - else { - *theComputer = ContainerName ; - } - theComputerContainer += *theComputer ; - theComputerContainer += "/" ; - theComputerContainer += *theContainer ; - } - delete [] ContainerName; - return theComputerContainer ; -} +//============================================================================= +/*! Public - + * Look for a fully qualified container name in Naming Service + * \param containerName name of the container to find. + * if containerName begins with "/Containers/" it's used as it is. + * We assume string = "/Containers/machine/aContainerName" + * else + * we assume string = "aContainerName" or "machine/aContainerName". + * string "/Containers/machine/aContainerName" is rebuilt. + * if machine = "localhost", machine replaced by GetHostname() + * \return Container CORBA reference or _nil if not found in Naming Service + */ +//============================================================================= -bool SALOME_LifeCycleCORBA::isKnownComponentClass(const char *componentName) +Engines::Container_ptr +SALOME_LifeCycleCORBA::FindContainer(const char *containerName) { - + ASSERT(_NS != NULL); + string cont ; + if ( strncmp( containerName , "/Containers/" , 12 ) ) + { // Compatibility ... + string theComputer ; + string theContainer ; + cont = ContainerName( containerName , &theComputer , &theContainer ) ; + } + else + { + cont = containerName ; + } try { - CORBA::Object_var obj = _NS->Resolve("/Kernel/ModulCatalog"); - SALOME_ModuleCatalog::ModuleCatalog_var Catalog = - SALOME_ModuleCatalog::ModuleCatalog::_narrow(obj) ; - SALOME_ModuleCatalog::Acomponent_ptr compoInfo = - Catalog->GetComponent(componentName); - if (CORBA::is_nil (compoInfo)) + SCRUTE( cont ); + CORBA::Object_var obj = _NS->Resolve( cont.c_str() ); + if( !CORBA::is_nil( obj ) ) { - INFOS("Catalog Error : Component not found in the catalog"); - return false; + return Engines::Container::_narrow( obj ) ; } - else return true; } catch (ServiceUnreachable&) { @@ -116,61 +122,98 @@ bool SALOME_LifeCycleCORBA::isKnownComponentClass(const char *componentName) { INFOS("Caught unknown exception."); } - return false; + return Engines::Container::_nil(); } -string SALOME_LifeCycleCORBA::ComputerPath( - const char * theComputer ) { - CORBA::String_var path; - CORBA::Object_var obj = _NS->Resolve("/Kernel/ModulCatalog"); - SALOME_ModuleCatalog::ModuleCatalog_var Catalog = - SALOME_ModuleCatalog::ModuleCatalog::_narrow(obj) ; - try { - path = Catalog->GetPathPrefix( theComputer ); - } - catch (SALOME_ModuleCatalog::NotFound&) { - INFOS("GetPathPrefix(" << theComputer << ") not found!"); - path = "" ; - } - SCRUTE( path ) ; - return CORBA::string_dup( path ) ; +//============================================================================= +/*! Public - + * Find and aready existing and registered component instance. + * \param params machine parameters like type or name... + * \param componentName the name of component class + * \param studyId default = 0 : multistudy instance + * \param instanceName default = "" : to retrieve a specific instance + * \return a CORBA reference of the component instance, or _nil if not found + */ +//============================================================================= + +Engines::Component_ptr +SALOME_LifeCycleCORBA::FindComponent(const Engines::MachineParameters& params, + const char *componentName, + int studyId, + const char *instanceName) +{ + ASSERT(0); } -Engines::Container_ptr SALOME_LifeCycleCORBA::FindContainer(const char *containerName) +//============================================================================= +/*! Public - + * Load a component instance on a container defined by machine parameters + * \param params machine parameters like type or name... + * \param componentName the name of component class + * \param studyId default = 0 : multistudy instance + * \return a CORBA reference of the component instance, or _nil if problem + */ +//============================================================================= + +Engines::Component_ptr +SALOME_LifeCycleCORBA::LoadComponent(const Engines::MachineParameters& params, + const char *componentName, + int studyId) { - ASSERT(_NS != NULL); - string cont ; - if ( strncmp( containerName , "/Containers/" , 12 ) ) { // Compatibility ... - string theComputer ; - string theContainer ; - cont = ContainerName( containerName , &theComputer , &theContainer ) ; - } - else { - cont = containerName ; - } - try { + ASSERT(0); +} - SCRUTE( cont ); +//============================================================================= +/*! Public - + * Find and aready existing and registered component instance or load a new + * component instance on a container defined by machine parameters + * \param params machine parameters like type or name... + * \param componentName the name of component class + * \param studyId default = 0 : multistudy instance + * \return a CORBA reference of the component instance, or _nil if problem + */ +//============================================================================= - CORBA::Object_var obj = _NS->Resolve( cont.c_str() ); - if( !CORBA::is_nil( obj ) ) { - return Engines::Container::_narrow( obj ) ; - } - } - catch (ServiceUnreachable&) { - INFOS("Caught exception: Naming Service Unreachable"); - } - catch (...) { - INFOS("Caught unknown exception."); - } - return Engines::Container::_nil(); +Engines::Component_ptr +SALOME_LifeCycleCORBA:: +FindOrLoad_Component(const Engines::MachineParameters& params, + const char *componentName, + int studyId) +{ + if (! isKnownComponentClass(componentName)) + return Engines::Component::_nil(); + + Engines::MachineList_var listOfMachine = + _ContManager->GetFittingResources(params,componentName); + Engines::Component_ptr ret= + FindComponent(params.container_name,componentName,listOfMachine); + if(CORBA::is_nil(ret)) + return LoadComponent(params.container_name,componentName,listOfMachine); + else + return ret; } -Engines::Component_ptr SALOME_LifeCycleCORBA::FindOrLoad_Component - (const char *containerName, - const char *componentName) +//============================================================================= +/*! Public - + * Find and aready existing and registered component instance or load a new + * component instance on a container defined by name + * \param containerName the name of container, under one of the forms + * - 1 localhost/aContainer + * - 2 aContainer + * - 3 /machine/aContainer + * (not the same rules as FindContainer() method base on protected method + * ContainerName() -- MUST BE CORRECTED --) + * \param componentName the name of component class + * \return a CORBA reference of the component instance, or _nil if problem + */ +//============================================================================= + +Engines::Component_ptr +SALOME_LifeCycleCORBA::FindOrLoad_Component(const char *containerName, + const char *componentName) { - if (! isKnownComponentClass(componentName)) return Engines::Component::_nil(); + if (!isKnownComponentClass(componentName)) return Engines::Component::_nil(); + char *stContainer=strdup(containerName); string st2Container(stContainer); int rg=st2Container.find("/"); @@ -179,50 +222,87 @@ Engines::Component_ptr SALOME_LifeCycleCORBA::FindOrLoad_Component stContainer[rg]='\0'; if(strcmp(stContainer,"localhost")==0) { - Engines::Component_ptr ret=FindOrLoad_Component(stContainer+rg+1,componentName); + Engines::Component_ptr ret=FindOrLoad_Component(stContainer+rg+1, + componentName); free(stContainer); return ret; } + else ASSERT(0); // no return in that case... + } + if(rg<0) + { + //containerName doesn't contain "/" => Local container + free(stContainer); + Engines::MachineList_var listOfMachine=new Engines::MachineList; + listOfMachine->length(1); + listOfMachine[0]=CORBA::string_dup(GetHostname().c_str()); + Engines::Component_ptr ret = FindComponent(containerName, + componentName, + listOfMachine.in()); + if(CORBA::is_nil(ret)) + return LoadComponent(containerName,componentName,listOfMachine); + else + return ret; + } + else + { + //containerName contains "/" => Remote container + stContainer[rg]='\0'; + Engines::MachineParameters_var params=new Engines::MachineParameters; + params->container_name=CORBA::string_dup(stContainer+rg+1); + params->hostname=CORBA::string_dup(stContainer); + params->OS=CORBA::string_dup("LINUX"); + free(stContainer); + return FindOrLoad_Component(params,componentName); } - if(rg<0) { - //containerName doesn't contain "/" => Local container - free(stContainer); - Engines::MachineList_var listOfMachine=new Engines::MachineList; - listOfMachine->length(1); - listOfMachine[0]=CORBA::string_dup(GetHostname().c_str()); - Engines::Component_ptr ret=FindComponent(containerName,componentName,listOfMachine.in()); - if(CORBA::is_nil(ret)) - return LoadComponent(containerName,componentName,listOfMachine); - else - return ret; - } - else { - //containerName contains "/" => Remote container - stContainer[rg]='\0'; - Engines::MachineParameters_var params=new Engines::MachineParameters; - params->container_name=CORBA::string_dup(stContainer+rg+1); - params->hostname=CORBA::string_dup(stContainer); - params->OS=CORBA::string_dup("LINUX"); - free(stContainer); - return FindOrLoad_Component(params,componentName); - } } -Engines::Component_ptr SALOME_LifeCycleCORBA::FindOrLoad_Component(const Engines::MachineParameters& params, - const char *componentName) +//============================================================================= +/*! Public - + * Check if the component class is known in module catalog + * \param componentName the name of component class + * \return true if found, false otherwise + */ +//============================================================================= + +bool SALOME_LifeCycleCORBA::isKnownComponentClass(const char *componentName) { - if (! isKnownComponentClass(componentName)) return Engines::Component::_nil(); - Engines::MachineList_var listOfMachine=_ContManager->GetFittingResources(params,componentName); - Engines::Component_ptr ret=FindComponent(params.container_name,componentName,listOfMachine); - if(CORBA::is_nil(ret)) - return LoadComponent(params.container_name,componentName,listOfMachine); - else - return ret; + + try + { + CORBA::Object_var obj = _NS->Resolve("/Kernel/ModulCatalog"); + SALOME_ModuleCatalog::ModuleCatalog_var Catalog = + SALOME_ModuleCatalog::ModuleCatalog::_narrow(obj) ; + SALOME_ModuleCatalog::Acomponent_ptr compoInfo = + Catalog->GetComponent(componentName); + if (CORBA::is_nil (compoInfo)) + { + INFOS("Catalog Error : Component not found in the catalog"); + return false; + } + else return true; + } + catch (ServiceUnreachable&) + { + INFOS("Caught exception: Naming Service Unreachable"); + } + catch (...) + { + INFOS("Caught unknown exception."); + } + return false; } -Engines::Component_ptr SALOME_LifeCycleCORBA::FindComponent(const char *containerName, - const char *componentName, - const Engines::MachineList& listOfMachines) +//============================================================================= +/*! Protected - + * + */ +//============================================================================= + +Engines::Component_ptr +SALOME_LifeCycleCORBA::FindComponent(const char *containerName, + const char *componentName, + const Engines::MachineList& listOfMachines) { if (! isKnownComponentClass(componentName)) return Engines::Component::_nil(); if(containerName[0]!='\0') @@ -233,8 +313,12 @@ Engines::Component_ptr SALOME_LifeCycleCORBA::FindComponent(const char *containe for(unsigned int i=0;iResolve(componentNameForNS.c_str()); + string componentNameForNS = + Engines_Component_i::BuildComponentNameForNS(componentName, + containerName, + currentMachine); + SCRUTE(componentNameForNS); + CORBA::Object_var obj=_NS->ResolveFirst(componentNameForNS.c_str()); if(!CORBA::is_nil(obj)) { machinesOK[lghtOfmachinesOK++]=CORBA::string_dup(currentMachine); @@ -244,8 +328,12 @@ Engines::Component_ptr SALOME_LifeCycleCORBA::FindComponent(const char *containe { machinesOK->length(lghtOfmachinesOK); CORBA::String_var bestMachine=_ContManager->FindBest(machinesOK); - string componentNameForNS=Engines_Component_i::BuildComponentNameForNS(componentName,containerName,bestMachine); - CORBA::Object_var obj=_NS->Resolve(componentNameForNS.c_str()); + string componentNameForNS = + Engines_Component_i::BuildComponentNameForNS(componentName, + containerName, + bestMachine); + SCRUTE(componentNameForNS); + CORBA::Object_var obj=_NS->ResolveFirst(componentNameForNS.c_str()); return Engines::Component::_narrow(obj); } else @@ -253,44 +341,70 @@ Engines::Component_ptr SALOME_LifeCycleCORBA::FindComponent(const char *containe } else { - //user specified no container name so trying to find a component in the best machine among listOfMachines + //user specified no container name so trying to find a component in + //the best machine among listOfMachines CORBA::String_var bestMachine=_ContManager->FindBest(listOfMachines); - //Normally look at all containers launched on bestMachine to see if componentName is already launched on one of them. To do.. - string componentNameForNS=Engines_Component_i::BuildComponentNameForNS(componentName,containerName,bestMachine); - CORBA::Object_var obj = _NS->Resolve(componentNameForNS.c_str()); + //Normally look at all containers launched on bestMachine to see if + //componentName is already launched on one of them. To do.. + string componentNameForNS = + Engines_Component_i::BuildComponentNameForNS(componentName, + containerName, + bestMachine); + SCRUTE(componentNameForNS); + CORBA::Object_var obj = _NS->ResolveFirst(componentNameForNS.c_str()); return Engines::Component::_narrow(obj); } } -Engines::Component_ptr SALOME_LifeCycleCORBA::LoadComponent(const char *containerName, const char *componentName, const Engines::MachineList& listOfMachines) +//============================================================================= +/*! Protected - + * + */ +//============================================================================= + +Engines::Component_ptr +SALOME_LifeCycleCORBA::LoadComponent(const char *containerName, + const char *componentName, + const Engines::MachineList& listOfMachines) { - Engines::Container_var cont=_ContManager->FindOrStartContainer(containerName,listOfMachines); - string implementation=Engines_Component_i::GetDynLibraryName(componentName); - return cont->load_impl(componentName, implementation.c_str()); + Engines::Container_var cont=_ContManager->FindOrStartContainer(containerName, + listOfMachines); + //string implementation=Engines_Component_i::GetDynLibraryName(componentName); + //return cont->load_impl(componentName, implementation.c_str()); + return cont->load_impl(componentName,""); } -Engines::Container_ptr SALOME_LifeCycleCORBA::FindOrStartContainer( - const string aComputerContainer , - const string theComputer , - const string theContainer ) { +//============================================================================= +/*! Protected - + * + */ +//============================================================================= + +Engines::Container_ptr +SALOME_LifeCycleCORBA::FindOrStartContainer(const string aComputerContainer , + const string theComputer , + const string theContainer ) +{ SCRUTE( aComputerContainer ) ; SCRUTE( theComputer ) ; SCRUTE( theContainer ) ; - Engines::Container_var aContainer = FindContainer( aComputerContainer.c_str() ) ; + Engines::Container_var aContainer = FindContainer(aComputerContainer.c_str()); - if ( !CORBA::is_nil( aContainer ) ) { - return aContainer ; - } + if ( !CORBA::is_nil( aContainer ) ) + { + return aContainer ; + } Engines::Container_var aFactoryServer ; bool pyCont = false ; int len = theContainer.length() ; - if ( !strcmp( &theContainer.c_str()[len-2] , "Py" ) ) { - pyCont = true ; - } + if ( !strcmp( &theContainer.c_str()[len-2] , "Py" ) ) + { + pyCont = true ; + } string addr=_NS->getIORaddr(); string CMD="SALOME_Container"; @@ -309,16 +423,94 @@ Engines::Container_ptr SALOME_LifeCycleCORBA::FindOrStartContainer( * Wait until the container is registered in Naming Service */ int count = 5 ; - while ( CORBA::is_nil( aFactoryServer ) && count ) { + while ( CORBA::is_nil( aFactoryServer ) && count ) + { sleep( 1 ) ; count-- ; if ( count != 10 ) - MESSAGE( count << ". Waiting for FactoryServer on " << theComputer) - aFactoryServer = FindContainer( aComputerContainer.c_str() ) ; - } - if ( !CORBA::is_nil( aFactoryServer ) ) { - return aFactoryServer; - } + MESSAGE( count << ". Waiting for FactoryServer on " << theComputer) + aFactoryServer = FindContainer( aComputerContainer.c_str() ) ; + } + if ( !CORBA::is_nil( aFactoryServer ) ) + { + return aFactoryServer; + } MESSAGE("SALOME_LifeCycleCORBA::StartOrFindContainer rsh failed") ; return Engines::Container::_nil(); } + +//============================================================================= +/*! Protected - + * \param aComputerContainer container name under one of the forms: + * - 1 aContainer + * - 2 machine/aContainer + * \param theComputer return computer name: + * - 1 machine = GetHostname() + * - 2 machine (localhost replaced by GetHostName()) + * \param theContainer return container name: + * - 1 aContainer + * - 2 aContainer + * \return /Containers/machine/aContainer + */ +//============================================================================= + +string SALOME_LifeCycleCORBA::ContainerName(const char *aComputerContainer , + string * theComputer , + string * theContainer ) +{ + char * ContainerName = new char [ strlen( aComputerContainer ) + 1 ] ; + strcpy( ContainerName , aComputerContainer ) ; + string theComputerContainer("/Containers/"); + char *slash = strchr( ContainerName , '/' ) ; // first occurence of '/' + if ( !slash ) // no '/', only the name, without path + { + *theComputer = GetHostname() ; + theComputerContainer += *theComputer ; + theComputerContainer += "/" ; + *theContainer = ContainerName ; + theComputerContainer += *theContainer ; + } + else + { + ASSERT( slash != aComputerContainer); // "/something..." not OK + slash[ 0 ] = '\0' ; + slash += 1 ; + *theContainer = slash ; + if ( !strcmp( ContainerName , "localhost" ) ) + { + *theComputer = GetHostname() ; + } + else + { + *theComputer = ContainerName ; + } + theComputerContainer += *theComputer ; + theComputerContainer += "/" ; + theComputerContainer += *theContainer ; + } + delete [] ContainerName; + return theComputerContainer ; +} + +//============================================================================= +/*! Protected - + * + */ +//============================================================================= + +string SALOME_LifeCycleCORBA::ComputerPath(const char * theComputer ) +{ + CORBA::String_var path; + CORBA::Object_var obj = _NS->Resolve("/Kernel/ModulCatalog"); + SALOME_ModuleCatalog::ModuleCatalog_var Catalog = + SALOME_ModuleCatalog::ModuleCatalog::_narrow(obj) ; + try { + path = Catalog->GetPathPrefix( theComputer ); + } + catch (SALOME_ModuleCatalog::NotFound&) { + INFOS("GetPathPrefix(" << theComputer << ") not found!"); + path = "" ; + } + SCRUTE( path ) ; + return CORBA::string_dup( path ) ; +} diff --git a/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.hxx b/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.hxx index ca91a238f..fc4e9d479 100644 --- a/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.hxx +++ b/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.hxx @@ -44,32 +44,63 @@ class SALOME_LifeCycleCORBA public: SALOME_LifeCycleCORBA(SALOME_NamingService *ns); virtual ~SALOME_LifeCycleCORBA(); - Engines::Container_ptr FindContainer(const char *containerName); // for supervision - Engines::Component_ptr FindOrLoad_Component(const Engines::MachineParameters& params, - const char *componentName); - Engines::Component_ptr FindOrLoad_Component(const char *containerName, - const char *componentName); + + Engines::Container_ptr + FindContainer(const char *containerName); // for supervision + + Engines::Component_ptr + FindComponent(const Engines::MachineParameters& params, + const char *componentName, + int studyId=0, + const char *instanceName=""); + + Engines::Component_ptr + LoadComponent(const Engines::MachineParameters& params, + const char *componentName, + int studyId=0); + + Engines::Component_ptr + FindOrLoad_Component(const Engines::MachineParameters& params, + const char *componentName, + int studyId=0); + + Engines::Component_ptr + FindOrLoad_Component(const char *containerName, + const char *componentName); // for compatibility + bool isKnownComponentClass(const char *componentName); + protected: - //! Establish if a component called "componentName" in a container called "containerName" exists among the list of resources - //! in "listOfMachines". This method uses Naming Service to find the component. - Engines::Component_ptr FindComponent(const char *containerName, - const char *componentName, - const Engines::MachineList& listOfMachines); - Engines::Component_ptr LoadComponent(const char *containerName, const char *componentName, const Engines::MachineList& listOfMachines); + /*! Establish if a component called "componentName" in a container called + * "containerName" + * exists among the list of resources in "listOfMachines". + * This method uses Naming Service to find the component. + */ + Engines::Component_ptr + FindComponent(const char *containerName, + const char *componentName, + const Engines::MachineList& listOfMachines); + Engines::Component_ptr + LoadComponent(const char *containerName, + const char *componentName, + const Engines::MachineList& listOfMachines); + SALOME_NamingService *_NS; Engines::ContainerManager_var _ContManager; //private: + std::string ContainerName( const char * aComputerContainer , std::string * theComputer , std::string * theContainer ) ; std::string ComputerPath( const char * theComputer ) ; - Engines::Container_ptr FindOrStartContainer(const std::string aComputerContainer , - const std::string theComputer , - const std::string theContainer ) ; + + Engines::Container_ptr + FindOrStartContainer(const std::string aComputerContainer , + const std::string theComputer , + const std::string theContainer ) ; } ; #endif diff --git a/src/LifeCycleCORBA/TestLifeCycleCORBA.cxx b/src/LifeCycleCORBA/TestLifeCycleCORBA.cxx index 49e3b28b0..312cbd211 100644 --- a/src/LifeCycleCORBA/TestLifeCycleCORBA.cxx +++ b/src/LifeCycleCORBA/TestLifeCycleCORBA.cxx @@ -111,7 +111,7 @@ int main (int argc, char * argv[]) cout << m4->instanceName() << endl; } - catch(CORBA::COMM_FAILURE& ex) + catch(CORBA::SystemException& ex) { INFOS("Caught system exception COMM_FAILURE -- unable to contact the object."); } diff --git a/src/Logger/SALOME_Logger_Server.cxx b/src/Logger/SALOME_Logger_Server.cxx index f4b6fd53b..708a93f51 100644 --- a/src/Logger/SALOME_Logger_Server.cxx +++ b/src/Logger/SALOME_Logger_Server.cxx @@ -12,9 +12,9 @@ #include "SALOME_Logger_Server.hxx" #include #include -#include -using namespace std; - +#ifndef __WIN32__ +# include +#endif omni_mutex Logger::myLock; ///////////////////////////////////////////////////////////////////// @@ -29,7 +29,7 @@ Logger::Logger() Logger::Logger(const char *filename) { // m_outputFile.open( filename, ios::out | ios::trunc , filebuf::openprot); - m_outputFile.open( filename, ios::out | ios::trunc); + m_outputFile.open( filename, std::ios::out | std::ios::trunc); if (m_outputFile.is_open()) m_putIntoFile = true; else @@ -46,9 +46,9 @@ void Logger::putMessage(const char* message) { myLock.lock(); if (m_putIntoFile) - m_outputFile << message << flush; + m_outputFile << message << std::flush; else - cout << message; + std::cout << message; myLock.unlock(); } @@ -61,13 +61,13 @@ int main(int argc, char **argv) { if (argc > 2) { - cout << "usage: SALOME_Logger_Server [output_file]" << endl; + std::cout << "usage: SALOME_Logger_Server [output_file]" << std::endl; exit(1); } try { //Initialize the ORB - const long TIMESleep = 500000000; + const long TIMESleep = 250000000; const int NumberOfTries = 40; int i; timespec ts_req = {0, TIMESleep}; @@ -82,42 +82,43 @@ int main(int argc, char **argv) CORBA::ORB_var orb = CORBA::ORB_init(argc, argv) ; - for (int i = 1; i <= NumberOfTries; i++){ - if (i != 1) nanosleep(&ts_req, &ts_rem); - try { - obj = orb->resolve_initial_references("RootPOA") ; - if(!CORBA::is_nil(obj)) - poa = PortableServer::POA::_narrow(obj) ; - pman = poa->the_POAManager(); - // NB. You can activate the POA before or after - // activating objects in that POA. - - // This activates the object in the root POA (by default), and - // returns a reference to it. - //NB. You can't use SALOME_NamingService class because it uses MESSAGE macro - //Otherwise, you will get segmentation fault. - //Get initial naming context - if(!CORBA::is_nil(orb)) - theObj = orb->resolve_initial_references("NameService"); - //Narrow to NamingContext - if (!CORBA::is_nil(theObj)) - inc = CosNaming::NamingContext::_narrow(theObj); - } catch(CORBA::COMM_FAILURE&) { - //cout<<"Logger Server: CORBA::COMM_FAILURE: Unable to contact the Naming Service"<resolve_initial_references("RootPOA") ; + if(!CORBA::is_nil(obj)) + poa = PortableServer::POA::_narrow(obj) ; + pman = poa->the_POAManager(); + // NB. You can activate the POA before or after + // activating objects in that POA. + + // This activates the object in the root POA (by default), and + // returns a reference to it. + //NB. You can't use SALOME_NamingService class because it uses MESSAGE macro + //Otherwise, you will get segmentation fault. + //Get initial naming context + if(!CORBA::is_nil(orb)) + theObj = orb->resolve_initial_references("NameService"); + //Narrow to NamingContext + if (!CORBA::is_nil(theObj)) + inc = CosNaming::NamingContext::_narrow(theObj); + } catch(CORBA::COMM_FAILURE&) { + //cout<<"Logger Server: CORBA::COMM_FAILURE: Unable to contact the Naming Service"<_this(); CosNaming::Name name; @@ -128,29 +129,29 @@ int main(int argc, char **argv) pman->activate(); orb->run() ; orb->destroy() ; - } - catch(CORBA::COMM_FAILURE& ex) - { - cerr << "Caught system exception COMM_FAILURE -- unable to contact the " - << "object." << endl; + } + catch(CORBA::COMM_FAILURE& ex) + { + std::cerr << "Caught system exception COMM_FAILURE -- unable to contact the " + << "object." << std::endl; } catch(CORBA::SystemException&) { - cerr << "Caught CORBA::SystemException." << endl; + std::cerr << "Caught CORBA::SystemException." << std::endl; } catch(CORBA::Exception&) { - cerr << "Caught CORBA::Exception." << endl; + std::cerr << "Caught CORBA::Exception." << std::endl; } catch(omniORB::fatalException& fe) { - cerr << "Caught omniORB::fatalException:" << endl; - cerr << " file: " << fe.file() << endl; - cerr << " line: " << fe.line() << endl; - cerr << " mesg: " << fe.errmsg() << endl; + std::cerr << "Caught omniORB::fatalException:" << std::endl; + std::cerr << " file: " << fe.file() << std::endl; + std::cerr << " line: " << fe.line() << std::endl; + std::cerr << " mesg: " << fe.errmsg() << std::endl; } catch(...) { - cerr << "Caught unknown exception." << endl; + std::cerr << "Caught unknown exception." << std::endl; } } diff --git a/src/Logger/SALOME_Trace.cxx b/src/Logger/SALOME_Trace.cxx index 1a33333eb..705f066bd 100644 --- a/src/Logger/SALOME_Trace.cxx +++ b/src/Logger/SALOME_Trace.cxx @@ -62,7 +62,7 @@ int SALOME_Trace::Initialize(CORBA::ORB_ptr theOrb) { if (!CORBA::is_nil(theObj)) inc = CosNaming::NamingContext::_narrow(theObj); if (!CORBA::is_nil(inc)) break; - } catch( CORBA::COMM_FAILURE& ) { + } catch( CORBA::SystemException& ) { } catch (...) { } } diff --git a/src/Logger/SALOME_Trace.py b/src/Logger/SALOME_Trace.py index fd507c7c7..2b88171d6 100644 --- a/src/Logger/SALOME_Trace.py +++ b/src/Logger/SALOME_Trace.py @@ -41,7 +41,7 @@ class SALOME_Trace : except CosNaming.NamingContext.NotFound, e : if steps == 1: print "Caught exception: Naming Service can't found Logger" - except CORBA.COMM_FAILURE, e: + except (CORBA.TRANSIENT,CORBA.OBJECT_NOT_EXIST,CORBA.COMM_FAILURE): if steps == 1: print "Caught CORBA::SystemException CommFailure" except CORBA.SystemException, e: if steps == 1: print "Caught CORBA::SystemException." diff --git a/src/MEDWrapper/Base/MED_Common.hxx b/src/MEDWrapper/Base/MED_Common.hxx index c2ae42522..279489642 100644 --- a/src/MEDWrapper/Base/MED_Common.hxx +++ b/src/MEDWrapper/Base/MED_Common.hxx @@ -42,6 +42,8 @@ extern "C"{ #include +#include "SALOMEconfig.h" + namespace MED{ enum EVersion {eVUnknown = -1, eV2_1, eV2_2}; @@ -76,12 +78,12 @@ namespace MED{ operator const T& () const { - return *get(); + return *(this->get()); } operator T& () { - return *get(); + return *(this->get()); } }; @@ -141,15 +143,19 @@ namespace MED{ typename TSupperClass::TValue& operator[](size_t theId) { - return myContainer[GetID(theId)]; + return myContainer[this->GetID(theId)]; } }; typedef enum {eFAUX, eVRAI} EBooleen ; typedef double TFloat; +#if defined(SUN4SOL2) || defined(PCLINUX) || defined(OSF1_32) || defined(IRIX64_32) || defined(RS6000) || defined(HP9000) typedef int TInt; - +#endif +#if defined(IRIX64) || defined(OSF1) + typedef long TInt; +#endif typedef hid_t TIdt; typedef herr_t TErr; diff --git a/src/MEDWrapper/Base/MED_Wrapper.hxx b/src/MEDWrapper/Base/MED_Wrapper.hxx index fccf3406f..de1b43175 100644 --- a/src/MEDWrapper/Base/MED_Wrapper.hxx +++ b/src/MEDWrapper/Base/MED_Wrapper.hxx @@ -271,6 +271,7 @@ namespace MED{ EGeometrieElement theTGeom, EConnectivite theTConn, const TIntVector& theConnectivities, + const TIntVector& theIndexes, const TIntVector& theFamilyNums, const TIntVector& theElemNums, const TStringVector& theElemNames = TStringVector()) @@ -345,6 +346,8 @@ namespace MED{ EGeometrieElement theTGeom, EConnectivite theTConn, const TIntVector& theConnectivities, + const TIntVector& theFaces, + const TIntVector& theIndexes, const TIntVector& theFamilyNums, const TIntVector& theElemNums, const TStringVector& theElemNames = TStringVector()) diff --git a/src/MEDWrapper/Base/Makefile.in b/src/MEDWrapper/Base/Makefile.in index ae80425cb..dbb3f7164 100644 --- a/src/MEDWrapper/Base/Makefile.in +++ b/src/MEDWrapper/Base/Makefile.in @@ -54,7 +54,7 @@ LIB_SRC = \ BIN = BIN_SRC = -CPPFLAGS+= $(BOOST_CPPFLAGS) $(HDF5_INCLUDES) +CPPFLAGS+= $(BOOST_CPPFLAGS) $(HDF5_INCLUDES) -D@MACHINE@ LDFLAGS+= diff --git a/src/MEDWrapper/V2_1/MED_V2_1_Wrapper.cxx b/src/MEDWrapper/V2_1/MED_V2_1_Wrapper.cxx index 9dc64affc..04afa18fc 100644 --- a/src/MEDWrapper/V2_1/MED_V2_1_Wrapper.cxx +++ b/src/MEDWrapper/V2_1/MED_V2_1_Wrapper.cxx @@ -135,7 +135,7 @@ namespace MED{ TErr aRet = MEDmaaInfo(myFile->Id(), theMeshId, &theInfo.myName[0], - &theInfo.myDim); + (med_2_1::med_int *)&theInfo.myDim); if(theErr) *theErr = aRet; else if(aRet < 0) @@ -243,13 +243,13 @@ namespace MED{ &aMeshInfo.myName[0], theFamId, &theInfo.myName[0], - &theInfo.myId, - &theInfo.myAttrId[0], - &theInfo.myAttrVal[0], + (med_2_1::med_int *)&theInfo.myId, + (med_2_1::med_int *)&theInfo.myAttrId[0], + (med_2_1::med_int *)&theInfo.myAttrVal[0], &theInfo.myAttrDesc[0], - &theInfo.myNbAttr, + (med_2_1::med_int *)&theInfo.myNbAttr, &theInfo.myGroupNames[0], - &theInfo.myNbGroup); + (med_2_1::med_int *)&theInfo.myNbGroup); if(theErr) *theErr = aRet; @@ -278,8 +278,8 @@ namespace MED{ &aMeshInfo.myName[0], &anInfo.myName[0], anInfo.myId, - &anInfo.myAttrId[0], - &anInfo.myAttrVal[0], + (med_2_1::med_int *)&anInfo.myAttrId[0], + (med_2_1::med_int *)&anInfo.myAttrVal[0], &anInfo.myAttrDesc[0], anInfo.myNbAttr, &anInfo.myGroupNames[0], @@ -341,9 +341,9 @@ namespace MED{ MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo; - med_repere& aRepere = static_cast(theInfo.mySystem); - med_booleen& anIsElemNames = static_cast(theInfo.myIsElemNames); - med_booleen& anIsElemNum = static_cast(theInfo.myIsElemNum); + med_repere& aRepere = (med_repere&)(theInfo.mySystem); + med_booleen& anIsElemNames = (med_booleen&)(theInfo.myIsElemNames); + med_booleen& anIsElemNum = (med_booleen&)(theInfo.myIsElemNum); TErr aRet = MEDnoeudsLire(myFile->Id(), &aMeshInfo.myName[0], @@ -355,9 +355,9 @@ namespace MED{ &theInfo.myCoordUnits[0], &theInfo.myElemNames[0], &anIsElemNames, - &theInfo.myElemNum[0], + (med_2_1::med_int *)&theInfo.myElemNum[0], &anIsElemNum, - &theInfo.myFamNum[0], + (med_2_1::med_int *)&theInfo.myFamNum[0], theInfo.myNbElem); ADDMSG(MYDEBUG," myDim="<(theInfo); MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo; - med_repere& aRepere = static_cast(theInfo.mySystem); - med_booleen& anIsElemNames = static_cast(theInfo.myIsElemNames); - med_booleen& anIsElemNum = static_cast(theInfo.myIsElemNum); + med_repere& aRepere = (med_repere&)(theInfo.mySystem); + med_booleen& anIsElemNames = (med_booleen&)(theInfo.myIsElemNames); + med_booleen& anIsElemNum = (med_booleen&)(theInfo.myIsElemNum); TErr aRet = MEDnoeudsEcr(myFile->Id(), &aMeshInfo.myName[0], @@ -395,9 +395,9 @@ namespace MED{ &anInfo.myCoordUnits[0], &anInfo.myElemNames[0], anIsElemNames, - &anInfo.myElemNum[0], + (med_2_1::med_int *)&anInfo.myElemNum[0], anIsElemNum, - &anInfo.myFamNum[0], + (med_2_1::med_int *)&anInfo.myFamNum[0], anInfo.myNbElem, MED_REMP); if(theErr) @@ -489,22 +489,22 @@ namespace MED{ MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo; TInt aNbElem = theInfo.myElemNum.size(); - med_booleen& anIsElemNames = static_cast(theInfo.myIsElemNames); - med_booleen& anIsElemNum = static_cast(theInfo.myIsElemNum); - med_entite_maillage& anEntity = static_cast(theInfo.myTEntity); - med_geometrie_element& aGeom = static_cast(theInfo.myTGeom); - med_connectivite& aConn = static_cast(theInfo.myTConn); + med_booleen& anIsElemNames = (med_booleen&)(theInfo.myIsElemNames); + med_booleen& anIsElemNum = (med_booleen&)(theInfo.myIsElemNum); + med_entite_maillage& anEntity = (med_entite_maillage&)(theInfo.myTEntity); + med_geometrie_element& aGeom = (med_geometrie_element&)(theInfo.myTGeom); + med_connectivite& aConn = (med_connectivite&)(theInfo.myTConn); TErr aRet = MEDelementsLire(myFile->Id(), &aMeshInfo.myName[0], aMeshInfo.myDim, - &theInfo.myConn[0], + (med_2_1::med_int *)&theInfo.myConn[0], MED_FULL_INTERLACE, &theInfo.myElemNames[0], &anIsElemNames, - &theInfo.myElemNum[0], + (med_2_1::med_int *)&theInfo.myElemNum[0], &anIsElemNum, - &theInfo.myFamNum[0], + (med_2_1::med_int *)&theInfo.myFamNum[0], aNbElem, anEntity, aGeom, @@ -529,22 +529,22 @@ namespace MED{ MED::TCellInfo& anInfo = const_cast(theInfo); MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo; - med_booleen& anIsElemNames = static_cast(theInfo.myIsElemNames); - med_booleen& anIsElemNum = static_cast(theInfo.myIsElemNum); - med_entite_maillage& anEntity = static_cast(theInfo.myTEntity); - med_geometrie_element& aGeom = static_cast(theInfo.myTGeom); - med_connectivite& aConn = static_cast(theInfo.myTConn); + med_booleen& anIsElemNames = (med_booleen&)(theInfo.myIsElemNames); + med_booleen& anIsElemNum = (med_booleen&)(theInfo.myIsElemNum); + med_entite_maillage& anEntity = (med_entite_maillage&)(theInfo.myTEntity); + med_geometrie_element& aGeom = (med_geometrie_element&)(theInfo.myTGeom); + med_connectivite& aConn = (med_connectivite&)(theInfo.myTConn); TErr aRet = MEDelementsEcr(myFile->Id(), &aMeshInfo.myName[0], aMeshInfo.myDim, - &anInfo.myConn[0], + (med_2_1::med_int *)&anInfo.myConn[0], MED_FULL_INTERLACE, &anInfo.myElemNames[0], anIsElemNames, - &anInfo.myElemNum[0], + (med_2_1::med_int *)&anInfo.myElemNum[0], anIsElemNum, - &anInfo.myFamNum[0], + (med_2_1::med_int *)&anInfo.myFamNum[0], anInfo.myNbElem, anEntity, aGeom, @@ -601,7 +601,7 @@ namespace MED{ if(theErr && *theErr < 0) return; - med_type_champ& aType = static_cast(theInfo.myType); + med_type_champ& aType = (med_type_champ&)(theInfo.myType); TErr aRet = MEDchampInfo(myFile->Id(), theFieldId, @@ -628,7 +628,7 @@ namespace MED{ MED::TFieldInfo& anInfo = const_cast(theInfo); - med_type_champ& aType = static_cast(theInfo.myType); + med_type_champ& aType = (med_type_champ&)(theInfo.myType); TErr aRet = MEDchampCr(myFile->Id(), &anInfo.myName[0], @@ -685,11 +685,11 @@ namespace MED{ MED::TFieldInfo& anInfo = const_cast(theInfo); TEntityInfo::const_iterator anIter = theEntityInfo.begin(); for(; anIter != theEntityInfo.end(); anIter++){ - const med_entite_maillage& anEntity = static_cast(anIter->first); + const med_entite_maillage& anEntity = (const med_entite_maillage&)(anIter->first); const TGeom& aTGeom = anIter->second; TGeom::const_iterator anGeomIter = aTGeom.begin(); for(; anGeomIter != aTGeom.end(); anGeomIter++){ - const med_geometrie_element& aGeom = static_cast(anGeomIter->first); + const med_geometrie_element& aGeom = (const med_geometrie_element&)(anGeomIter->first); aNbTimeStamps = MEDnPasdetemps(myFile->Id(),&anInfo.myName[0],anEntity,aGeom); if(aNbTimeStamps){ theEntity = EEntiteMaillage(anEntity); @@ -722,10 +722,10 @@ namespace MED{ MED::TFieldInfo& aFieldInfo = *theInfo.myFieldInfo; MED::TMeshInfo& aMeshInfo = *aFieldInfo.myMeshInfo; - med_entite_maillage& anEntity = static_cast(theInfo.myEntity); + med_entite_maillage& anEntity = (med_entite_maillage&)(theInfo.myEntity); TGeom::iterator anIter = aTGeom.begin(); - med_geometrie_element& aGeom = static_cast(anIter->first); + med_geometrie_element& aGeom = (med_geometrie_element&)(anIter->first); TErr aRet = MEDpasdetempsInfo(myFile->Id(), &aFieldInfo.myName[0], @@ -733,11 +733,11 @@ namespace MED{ aGeom, theTimeStampId, &aMeshInfo.myName[0], - &theInfo.myNbGauss, - &theInfo.myNumDt, + (med_2_1::med_int *)&theInfo.myNbGauss, + (med_2_1::med_int *)&theInfo.myNumDt, &theInfo.myUnitDt[0], &theInfo.myDt, - &theInfo.myNumOrd); + (med_2_1::med_int *)&theInfo.myNumOrd); if(theErr) *theErr = aRet; @@ -764,11 +764,11 @@ namespace MED{ MED::TFieldInfo& aFieldInfo = *aTimeStampInfo.myFieldInfo; MED::TMeshInfo& aMeshInfo = *aFieldInfo.myMeshInfo; - med_entite_maillage& anEntity = static_cast(aTimeStampInfo.myEntity); + med_entite_maillage& anEntity = (med_entite_maillage&)(aTimeStampInfo.myEntity); TGeom& aTGeom = aTimeStampInfo.myGeom; TGeom::iterator anIter = aTGeom.begin(); for(; anIter != aTGeom.end(); anIter++){ - med_geometrie_element& aGeom = static_cast(anIter->first); + med_geometrie_element& aGeom = (med_geometrie_element&)(anIter->first); TInt aNbVal = MEDnVal(anId, &aFieldInfo.myName[0], anEntity, @@ -866,10 +866,10 @@ namespace MED{ MED::TMeshInfo& aMeshInfo = *aFieldInfo.myMeshInfo; MED::TMeshValue& aMeshValue = aVal.myMeshValue; - med_entite_maillage& anEntity = static_cast(aTimeStampInfo.myEntity); + med_entite_maillage& anEntity = (med_entite_maillage&)(aTimeStampInfo.myEntity); TMeshValue::iterator anIter = aMeshValue.begin(); for(; anIter != aMeshValue.end(); anIter++){ - med_geometrie_element& aGeom = static_cast(anIter->first); + med_geometrie_element& aGeom = (med_geometrie_element&)(anIter->first); TValue& aValue = aVal.myMeshValue[EGeometrieElement(aGeom)]; med_int iEnd = aValue.size(); med_int aNbVal = iEnd / aFieldInfo.myNbComp; diff --git a/src/MEDWrapper/V2_1/MEDdatasetNumEcrire.cxx b/src/MEDWrapper/V2_1/MEDdatasetNumEcrire.cxx index 85fb2a7b2..846ea206a 100644 --- a/src/MEDWrapper/V2_1/MEDdatasetNumEcrire.cxx +++ b/src/MEDWrapper/V2_1/MEDdatasetNumEcrire.cxx @@ -18,6 +18,7 @@ #include "med.hxx" #include "med_outils.hxx" +#include /* * - Nom de la fonction : _MEDdatasetNumEcrire diff --git a/src/MEDWrapper/V2_1/MEDdatasetNumLire.cxx b/src/MEDWrapper/V2_1/MEDdatasetNumLire.cxx index 8195e36a7..8eef19f6c 100644 --- a/src/MEDWrapper/V2_1/MEDdatasetNumLire.cxx +++ b/src/MEDWrapper/V2_1/MEDdatasetNumLire.cxx @@ -18,6 +18,7 @@ #include "med.hxx" #include "med_outils.hxx" +#include /* * - Nom de la fonction : _MEDdatasetNumLire diff --git a/src/MEDWrapper/V2_1/Makefile.in b/src/MEDWrapper/V2_1/Makefile.in index 3344a7b1e..778b27267 100644 --- a/src/MEDWrapper/V2_1/Makefile.in +++ b/src/MEDWrapper/V2_1/Makefile.in @@ -161,7 +161,7 @@ EXPORT_HEADERS = \ BIN = mdump_V2_1 test1_V2_1 BIN_SRC = -CPPFLAGS+= $(BOOST_CPPFLAGS) $(HDF5_INCLUDES) -DPCLINUX +CPPFLAGS+= -D@MACHINE@ $(BOOST_CPPFLAGS) $(HDF5_INCLUDES) LDFLAGS+= $(HDF5_LIBS) -lMEDWrapperBase diff --git a/src/MEDWrapper/V2_2/MED_V2_2_Wrapper.cxx b/src/MEDWrapper/V2_2/MED_V2_2_Wrapper.cxx index e744c183f..179bfa45c 100644 --- a/src/MEDWrapper/V2_2/MED_V2_2_Wrapper.cxx +++ b/src/MEDWrapper/V2_2/MED_V2_2_Wrapper.cxx @@ -133,12 +133,12 @@ namespace MED{ if(theErr && !*theErr) return; - med_maillage& aType = static_cast(theInfo.myType); + med_maillage& aType = (med_maillage&)(theInfo.myType); TErr aRet = MEDmaaInfo(myFile->Id(), theMeshId, &theInfo.myName[0], - &theInfo.myDim, + (med_int *)&theInfo.myDim, &aType, &theInfo.myDesc[0]); if(theErr) @@ -159,7 +159,7 @@ namespace MED{ MED::TMeshInfo& anInfo = const_cast(theInfo); - med_maillage& aType = static_cast(theInfo.myType); + med_maillage& aType = (med_maillage&)(theInfo.myType); TErr aRet = MEDmaaCr(myFile->Id(), &anInfo.myName[0], @@ -255,13 +255,13 @@ namespace MED{ &aMeshInfo.myName[0], theFamId, &theInfo.myName[0], - &theInfo.myId, - &theInfo.myAttrId[0], - &theInfo.myAttrVal[0], + (med_int *)&theInfo.myId, + (med_int *)&theInfo.myAttrId[0], + (med_int *)&theInfo.myAttrVal[0], &theInfo.myAttrDesc[0], - &theInfo.myNbAttr, + (med_int *)&theInfo.myNbAttr, &theInfo.myGroupNames[0], - &theInfo.myNbGroup); + (med_int *)&theInfo.myNbGroup); if(theErr) *theErr = aRet; @@ -296,8 +296,8 @@ namespace MED{ &aMeshInfo.myName[0], &anInfo.myName[0], anInfo.myId, - &anInfo.myAttrId[0], - &anInfo.myAttrVal[0], + (med_int*)&anInfo.myAttrId[0], + (med_int*)&anInfo.myAttrVal[0], &anInfo.myAttrDesc[0], anInfo.myNbAttr, &anInfo.myGroupNames[0], @@ -336,8 +336,8 @@ namespace MED{ MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo; - med_entite_maillage& anEntity = static_cast(theTEntity); - med_geometrie_element& aGeom = static_cast(theTGeom); + med_entite_maillage& anEntity = (med_entite_maillage&)(theTEntity); + med_geometrie_element& aGeom = (med_geometrie_element&)(theTGeom); TErr aRet = MEDnomLire(myFile->Id(), &aMeshInfo.myName[0], @@ -367,12 +367,12 @@ namespace MED{ MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo; - med_entite_maillage& anEntity = static_cast(theTEntity); - med_geometrie_element& aGeom = static_cast(theTGeom); + med_entite_maillage& anEntity = (med_entite_maillage&)(theTEntity); + med_geometrie_element& aGeom = (med_geometrie_element&)(theTGeom); TErr aRet = MEDnumLire(myFile->Id(), &aMeshInfo.myName[0], - &theInfo.myElemNum[0], + (med_int*)&theInfo.myElemNum[0], nb, anEntity, aGeom); @@ -398,12 +398,12 @@ namespace MED{ MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo; - med_entite_maillage& anEntity = static_cast(theTEntity); - med_geometrie_element& aGeom = static_cast(theTGeom); + med_entite_maillage& anEntity = (med_entite_maillage&)(theTEntity); + med_geometrie_element& aGeom = (med_geometrie_element&)(theTGeom); TErr aRet = MEDfamLire(myFile->Id(), &aMeshInfo.myName[0], - &theInfo.myFamNum[0], + (med_int*)&theInfo.myFamNum[0], nb, anEntity, aGeom); @@ -436,9 +436,9 @@ namespace MED{ MED::TElemInfo& anInfo = const_cast(theInfo); MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo; - med_booleen& anIsElemNames = static_cast(theInfo.myIsElemNames); - med_entite_maillage& anEntity = static_cast(theTEntity); - med_geometrie_element& aGeom = static_cast(theTGeom); + med_booleen& anIsElemNames = (med_booleen&)(theInfo.myIsElemNames); + med_entite_maillage& anEntity = (med_entite_maillage&)(theTEntity); + med_geometrie_element& aGeom = (med_geometrie_element&)(theTGeom); TErr aRet = 0; if (anIsElemNames){ @@ -477,15 +477,15 @@ namespace MED{ MED::TElemInfo& anInfo = const_cast(theInfo); MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo; - med_booleen& anIsElemNum = static_cast(theInfo.myIsElemNum); - med_entite_maillage& anEntity = static_cast(theTEntity); - med_geometrie_element& aGeom = static_cast(theTGeom); + med_booleen& anIsElemNum = (med_booleen&)(theInfo.myIsElemNum); + med_entite_maillage& anEntity = (med_entite_maillage&)(theTEntity); + med_geometrie_element& aGeom = (med_geometrie_element&)(theTGeom); TErr aRet = 0; if (anIsElemNum){ aRet = MEDnumEcr(myFile->Id(), &aMeshInfo.myName[0], - &anInfo.myElemNum[0], + (med_int*)&anInfo.myElemNum[0], anInfo.myElemNum.size(), anEntity, aGeom); @@ -518,12 +518,12 @@ namespace MED{ MED::TElemInfo& anInfo = const_cast(theInfo); MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo; - med_entite_maillage& anEntity = static_cast(theTEntity); - med_geometrie_element& aGeom = static_cast(theTGeom); + med_entite_maillage& anEntity = (med_entite_maillage&)(theTEntity); + med_geometrie_element& aGeom = (med_geometrie_element&)(theTGeom); TErr aRet = MEDfamEcr(myFile->Id(), &aMeshInfo.myName[0], - &anInfo.myFamNum[0], + (med_int *)&anInfo.myFamNum[0], anInfo.myFamNum.size(), anEntity, aGeom); @@ -564,9 +564,9 @@ namespace MED{ MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo; - med_repere& aRepere = static_cast(theInfo.mySystem); - med_booleen& anIsElemNames = static_cast(theInfo.myIsElemNames); - med_booleen& anIsElemNum = static_cast(theInfo.myIsElemNum); + med_repere& aRepere = (med_repere&)(theInfo.mySystem); + med_booleen& anIsElemNames = (med_booleen&)(theInfo.myIsElemNames); + med_booleen& anIsElemNum = (med_booleen&)(theInfo.myIsElemNum); TErr aRet = MEDnoeudsLire(myFile->Id(), &aMeshInfo.myName[0], @@ -578,9 +578,9 @@ namespace MED{ &theInfo.myCoordUnits[0], &theInfo.myElemNames[0], &anIsElemNames, - &theInfo.myElemNum[0], + (med_int *)&theInfo.myElemNum[0], &anIsElemNum, - &theInfo.myFamNum[0], + (med_int *)&theInfo.myFamNum[0], theInfo.myNbElem); if(theErr) *theErr = aRet; @@ -601,9 +601,9 @@ namespace MED{ MED::TNodeInfo& anInfo = const_cast(theInfo); MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo; - med_repere& aRepere = static_cast(theInfo.mySystem); - med_booleen& anIsElemNames = static_cast(theInfo.myIsElemNames); - med_booleen& anIsElemNum = static_cast(theInfo.myIsElemNum); + med_repere& aRepere = (med_repere&)(theInfo.mySystem); + med_booleen& anIsElemNames = (med_booleen&)(theInfo.myIsElemNames); + med_booleen& anIsElemNum = (med_booleen&)(theInfo.myIsElemNum); TErr aRet = MEDnoeudsEcr(myFile->Id(), &aMeshInfo.myName[0], @@ -615,9 +615,9 @@ namespace MED{ &anInfo.myCoordUnits[0], &anInfo.myElemNames[0], anIsElemNames, - &anInfo.myElemNum[0], + (med_int *)&anInfo.myElemNum[0], anIsElemNum, - &anInfo.myFamNum[0], + (med_int *)&anInfo.myFamNum[0], anInfo.myNbElem); if(theErr) *theErr = aRet; @@ -647,16 +647,16 @@ namespace MED{ MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo; TInt aNbElem = theInfo.myElemNum.size(); - med_entite_maillage& anEntity = static_cast(theInfo.myTEntity); - med_connectivite& aConn = static_cast(theInfo.myTConn); + med_entite_maillage& anEntity = (med_entite_maillage&)(theInfo.myTEntity); + med_connectivite& aConn = (med_connectivite&)(theInfo.myTConn); TErr aRet = 0; aRet = MEDpolygoneConnLire(myFile->Id(), &aMeshInfo.myName[0], - &theInfo.myIndex[0], + (med_int *)&theInfo.myIndex[0], aNbElem+1, - &theInfo.myConn[0], + (med_int *)&theInfo.myConn[0], anEntity, aConn); @@ -697,14 +697,14 @@ namespace MED{ MED::TPolygoneInfo& anInfo = const_cast(theInfo); MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo; - med_entite_maillage& anEntity = static_cast(theInfo.myTEntity); - med_connectivite& aConn = static_cast(theInfo.myTConn); + med_entite_maillage& anEntity = (med_entite_maillage&)(theInfo.myTEntity); + med_connectivite& aConn = (med_connectivite&)(theInfo.myTConn); TErr aRet = MEDpolygoneConnEcr(myFile->Id(), &aMeshInfo.myName[0], - &anInfo.myIndex[0], + (med_int *)&anInfo.myIndex[0], anInfo.myNbElem+1, - &anInfo.myConn[0], + (med_int *)&anInfo.myConn[0], anEntity, aConn); @@ -748,8 +748,8 @@ namespace MED{ MED::TMeshInfo& aMeshInfo = const_cast(theMeshInfo); - med_entite_maillage& anEntity = static_cast(theTEntity); - med_connectivite& aConn = static_cast(theTConn); + med_entite_maillage& anEntity = (med_entite_maillage&)(theTEntity); + med_connectivite& aConn = (med_connectivite&)(theTConn); med_int taille = 0; @@ -778,17 +778,17 @@ namespace MED{ MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo; TInt aNbElem = theInfo.myElemNum.size(); - med_connectivite& aConn = static_cast(theInfo.myTConn); + med_connectivite& aConn = (med_connectivite&)(theInfo.myTConn); TErr aRet = 0; aRet = MEDpolyedreConnLire(myFile->Id(), &aMeshInfo.myName[0], - &theInfo.myIndex[0], + (med_int *)&theInfo.myIndex[0], aNbElem+1, - &theInfo.myFacesIndex[0], + (med_int *)&theInfo.myFacesIndex[0], theInfo.myNbFacesIndex, - &theInfo.myConn[0], + (med_int *)&theInfo.myConn[0], aConn); if(theErr) @@ -827,18 +827,18 @@ namespace MED{ MED::TPolyedreInfo& anInfo = const_cast(theInfo); MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo; - med_booleen& anIsElemNames = static_cast(theInfo.myIsElemNames); - med_booleen& anIsElemNum = static_cast(theInfo.myIsElemNum); - med_entite_maillage& anEntity = static_cast(theInfo.myTEntity); - med_connectivite& aConn = static_cast(theInfo.myTConn); + med_booleen& anIsElemNames = (med_booleen&)(theInfo.myIsElemNames); + med_booleen& anIsElemNum = (med_booleen&)(theInfo.myIsElemNum); + med_entite_maillage& anEntity = (med_entite_maillage&)(theInfo.myTEntity); + med_connectivite& aConn = (med_connectivite&)(theInfo.myTConn); TErr aRet = MEDpolyedreConnEcr(myFile->Id(), &aMeshInfo.myName[0], - &anInfo.myIndex[0], + (med_int *)&anInfo.myIndex[0], anInfo.myNbElem+1, - &anInfo.myFacesIndex[0], + (med_int *)&anInfo.myFacesIndex[0], anInfo.myNbFacesIndex, - &anInfo.myConn[0], + (med_int *)&anInfo.myConn[0], aConn); if(theErr) @@ -862,7 +862,7 @@ namespace MED{ if (anIsElemNum){ aRet = MEDnumEcr(myFile->Id(), &aMeshInfo.myName[0], - &anInfo.myElemNum[0], + (med_int *)&anInfo.myElemNum[0], anInfo.myElemNum.size(), anEntity, MED_POLYEDRE); @@ -875,7 +875,7 @@ namespace MED{ aRet = MEDfamEcr(myFile->Id(), &aMeshInfo.myName[0], - &anInfo.myFamNum[0], + (med_int *)&anInfo.myFamNum[0], anInfo.myFamNum.size(), anEntity, MED_POLYEDRE); @@ -906,13 +906,13 @@ namespace MED{ if(theErr && !*theErr) EXCEPTION(runtime_error,"GetPolyedreInfo - (...)"); MED::TMeshInfo& aMeshInfo = const_cast(theMeshInfo); - med_connectivite& aConn = static_cast(theTConn); + med_connectivite& aConn = (med_connectivite&)(theTConn); TErr aRet = MEDpolyedreInfo(myFile->Id(), &aMeshInfo.myName[0], aConn, - &nf, - &nc); + (med_int *)&nf, + (med_int *)&nc); if(theErr) *theErr = aRet; @@ -992,22 +992,22 @@ namespace MED{ MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo; TInt aNbElem = theInfo.myElemNum.size(); - med_booleen& anIsElemNames = static_cast(theInfo.myIsElemNames); - med_booleen& anIsElemNum = static_cast(theInfo.myIsElemNum); - med_entite_maillage& anEntity = static_cast(theInfo.myTEntity); - med_geometrie_element& aGeom = static_cast(theInfo.myTGeom); - med_connectivite& aConn = static_cast(theInfo.myTConn); + med_booleen& anIsElemNames = (med_booleen&)(theInfo.myIsElemNames); + med_booleen& anIsElemNum = (med_booleen&)(theInfo.myIsElemNum); + med_entite_maillage& anEntity = (med_entite_maillage&)(theInfo.myTEntity); + med_geometrie_element& aGeom = (med_geometrie_element&)(theInfo.myTGeom); + med_connectivite& aConn = (med_connectivite&)(theInfo.myTConn); TErr aRet = MEDelementsLire(myFile->Id(), &aMeshInfo.myName[0], aMeshInfo.myDim, - &theInfo.myConn[0], + (med_int *)&theInfo.myConn[0], MED_FULL_INTERLACE, &theInfo.myElemNames[0], &anIsElemNames, - &theInfo.myElemNum[0], + (med_int *)&theInfo.myElemNum[0], &anIsElemNum, - &theInfo.myFamNum[0], + (med_int *)&theInfo.myFamNum[0], aNbElem, anEntity, aGeom, @@ -1031,22 +1031,22 @@ namespace MED{ MED::TCellInfo& anInfo = const_cast(theInfo); MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo; - med_booleen& anIsElemNames = static_cast(theInfo.myIsElemNames); - med_booleen& anIsElemNum = static_cast(theInfo.myIsElemNum); - med_entite_maillage& anEntity = static_cast(theInfo.myTEntity); - med_geometrie_element& aGeom = static_cast(theInfo.myTGeom); - med_connectivite& aConn = static_cast(theInfo.myTConn); + med_booleen& anIsElemNames = (med_booleen&)(theInfo.myIsElemNames); + med_booleen& anIsElemNum = (med_booleen&)(theInfo.myIsElemNum); + med_entite_maillage& anEntity = (med_entite_maillage&)(theInfo.myTEntity); + med_geometrie_element& aGeom = (med_geometrie_element&)(theInfo.myTGeom); + med_connectivite& aConn = (med_connectivite&)(theInfo.myTConn); TErr aRet = MEDelementsEcr(myFile->Id(), &aMeshInfo.myName[0], aMeshInfo.myDim, - &anInfo.myConn[0], + (med_int *)&anInfo.myConn[0], MED_FULL_INTERLACE, &anInfo.myElemNames[0], anIsElemNames, - &anInfo.myElemNum[0], + (med_int *)&anInfo.myElemNum[0], anIsElemNum, - &anInfo.myFamNum[0], + (med_int *)&anInfo.myFamNum[0], anInfo.myNbElem, anEntity, aGeom, @@ -1098,7 +1098,7 @@ namespace MED{ if(theErr && !*theErr) return; - med_type_champ& aType = static_cast(theInfo.myType); + med_type_champ& aType = (med_type_champ&)(theInfo.myType); TErr aRet = MEDchampInfo(myFile->Id(), theFieldId, @@ -1125,7 +1125,7 @@ namespace MED{ MED::TFieldInfo& anInfo = const_cast(theInfo); - med_type_champ& aType = static_cast(theInfo.myType); + med_type_champ& aType = (med_type_champ&)(theInfo.myType); TErr aRet = MEDchampCr(myFile->Id(), &anInfo.myName[0], @@ -1173,11 +1173,11 @@ namespace MED{ MED::TFieldInfo& anInfo = const_cast(theInfo); TEntityInfo::const_iterator anIter = theEntityInfo.begin(); for(; anIter != theEntityInfo.end(); anIter++){ - const med_entite_maillage& anEntity = static_cast(anIter->first); + const med_entite_maillage& anEntity = (const med_entite_maillage&)(anIter->first); const TGeom& aTGeom = anIter->second; TGeom::const_iterator anGeomIter = aTGeom.begin(); for(; anGeomIter != aTGeom.end(); anGeomIter++){ - const med_geometrie_element& aGeom = static_cast(anGeomIter->first); + const med_geometrie_element& aGeom = (const med_geometrie_element&)(anGeomIter->first); TInt aTmp = MEDnPasdetemps(myFile->Id(),&anInfo.myName[0],anEntity,aGeom); aNbTimeStamps = max(aTmp,aNbTimeStamps); if (aNbTimeStamps<1) @@ -1215,26 +1215,26 @@ namespace MED{ MED::TFieldInfo& aFieldInfo = *theInfo.myFieldInfo; MED::TMeshInfo& aMeshInfo = *aFieldInfo.myMeshInfo; - med_entite_maillage& anEntity = static_cast(theInfo.myEntity); + med_entite_maillage& anEntity = (med_entite_maillage&)(theInfo.myEntity); TGeom::iterator anIter = aTGeom.begin(); - med_geometrie_element& aGeom = static_cast(anIter->first); + med_geometrie_element& aGeom = (med_geometrie_element&)(anIter->first); - med_booleen& anIsLocal = static_cast(aFieldInfo.myIsLocal); + med_booleen& anIsLocal = (med_booleen&)(aFieldInfo.myIsLocal); TErr aRet = MEDpasdetempsInfo(myFile->Id(), &aFieldInfo.myName[0], anEntity, aGeom, theTimeStampId, - &theInfo.myNbGauss, - &theInfo.myNumDt, - &theInfo.myNumOrd, + (med_int *)&theInfo.myNbGauss, + (med_int *)&theInfo.myNumDt, + (med_int *)&theInfo.myNumOrd, &theInfo.myUnitDt[0], &theInfo.myDt, &aMeshInfo.myName[0], &anIsLocal, - &aFieldInfo.myNbRef); + (med_int *)&aFieldInfo.myNbRef); if(theErr) *theErr = aRet; else if(aRet < 0) @@ -1260,12 +1260,12 @@ namespace MED{ MED::TFieldInfo& aFieldInfo = *aTimeStampInfo.myFieldInfo; MED::TMeshInfo& aMeshInfo = *aFieldInfo.myMeshInfo; - med_entite_maillage& anEntity = static_cast(aTimeStampInfo.myEntity); - med_mode_profil& aPflMode = static_cast(theVal.myPflMode); + med_entite_maillage& anEntity = (med_entite_maillage&)(aTimeStampInfo.myEntity); + med_mode_profil& aPflMode = (med_mode_profil&)(theVal.myPflMode); TGeom& aTGeom = aTimeStampInfo.myGeom; TGeom::iterator anIter = aTGeom.begin(); for(; anIter != aTGeom.end(); anIter++){ - med_geometrie_element& aGeom = static_cast(anIter->first); + med_geometrie_element& aGeom = (med_geometrie_element&)(anIter->first); TInt aNbVal = MEDnVal(anId, &aFieldInfo.myName[0], anEntity, @@ -1369,11 +1369,11 @@ namespace MED{ MED::TMeshInfo& aMeshInfo = *aFieldInfo.myMeshInfo; MED::TMeshValue& aMeshValue = aVal.myMeshValue; - med_entite_maillage& anEntity = static_cast(aTimeStampInfo.myEntity); - med_mode_profil& aPflMode = static_cast(theVal.myPflMode); + med_entite_maillage& anEntity = (med_entite_maillage&)(aTimeStampInfo.myEntity); + med_mode_profil& aPflMode = (med_mode_profil&)(theVal.myPflMode); TMeshValue::iterator anIter = aMeshValue.begin(); for(; anIter != aMeshValue.end(); anIter++){ - med_geometrie_element& aGeom = static_cast(anIter->first); + med_geometrie_element& aGeom = (med_geometrie_element&)(anIter->first); TValue& aValue = aVal.myMeshValue[EGeometrieElement(aGeom)]; med_int iEnd = aValue.size(); med_int aNbVal = iEnd / aFieldInfo.myNbComp; diff --git a/src/MPILifeCycleCORBA/SALOME_MPILifeCycleCORBA.cxx b/src/MPILifeCycleCORBA/SALOME_MPILifeCycleCORBA.cxx index 9d342ca32..5dfe13fcb 100644 --- a/src/MPILifeCycleCORBA/SALOME_MPILifeCycleCORBA.cxx +++ b/src/MPILifeCycleCORBA/SALOME_MPILifeCycleCORBA.cxx @@ -337,7 +337,7 @@ Engines::Component_var SALOME_MPILifeCycleCORBA::FindOrLoad_MPIComponent { string instanceName = compo->instanceName(); } - catch (CORBA::COMM_FAILURE&) + catch (CORBA::SystemException&) { INFOS("Caught CORBA::SystemException CommFailure. Engine " << path << "does not respond" ); diff --git a/src/Makefile.in b/src/Makefile.in index c64ecb109..4f4a247e7 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -32,29 +32,13 @@ VPATH=.:@srcdir@ @COMMENCE@ -ifeq (@WITHIHM@,yes) -SUBDIRS = MSG2QM SALOMELocalTrace SALOMETraceCollector Logger Utils CASCatch PatchQt \ - GenericObj MEDWrapper NamingService Registry \ +SUBDIRS = SALOMELocalTrace SALOMETraceCollector Logger Utils \ + CASCatch GenericObj MEDWrapper NamingService Registry \ ModuleCatalog DataTypeCatalog RessourcesCatalog \ ResourcesManager Notification NOTIFICATION_SWIG \ - Container TestContainer LifeCycleCORBA HDFPersist Prs \ - VTKFilter OBJECT \ - TOOLSDS SALOMEDS Event \ - SALOMEGUI TOOLSGUI Plot2d VTKViewer OCCViewer \ - SUPERVGraph \ - Session SALOME_SWIG SALOME_SWIG_WITHOUTIHM SALOME_PY \ - RegistryDisplay ModuleGenerator SALOME_PYQT Loader Communication -endif - -ifeq (@WITHIHM@,no) -SUBDIRS = MSG2QM SALOMELocalTrace SALOMETraceCollector Logger Utils CASCatch \ - GenericObj NamingService Registry \ - ModuleCatalog DataTypeCatalog RessourcesCatalog \ - ResourcesManager Notification NOTIFICATION_SWIG \ - Container TestContainer LifeCycleCORBA HDFPersist Prs \ - TOOLSDS SALOMEDS Event \ - SALOME_SWIG_WITHOUTIHM ModuleGenerator Loader Communication -endif + Container TestContainer LifeCycleCORBA HDFPersist \ + SALOMEDSClient TOOLSDS SALOMEDSImpl SALOMEDS KERNEL_PY \ + ModuleGenerator Communication ifeq (@mpi_ok@,yes) SUBDIRS+= MPIContainer MPILifeCycleCORBA TestMPIContainer diff --git a/src/ModuleCatalog/Makefile.in b/src/ModuleCatalog/Makefile.in index bc4a90bab..794765fb2 100644 --- a/src/ModuleCatalog/Makefile.in +++ b/src/ModuleCatalog/Makefile.in @@ -51,18 +51,16 @@ LIB_SRC = \ SALOME_ModuleCatalog_impl.cxx \ SALOME_ModuleCatalog_Acomponent_impl.cxx -CXXFLAGS+=@CXXTMPDPTHFLAGS@ +CXXFLAGS+=-ftemplate-depth-32 # Executables targets # trouble we have client and serveur and build don't known about this with rule # in fact client is a test ! So it may go away BIN ! BIN = SALOME_ModuleCatalog_Server SALOME_ModuleCatalog_Client BIN_SRC = -LIB_CLIENT_IDL = SALOME_ModuleCatalog.idl BIN_SERVER_IDL = SALOME_ModuleCatalog.idl CPPFLAGS+= $(QT_MT_INCLUDES) -LDFLAGS+= $(QT_MT_LIBS) -lSalomeNS -lOpUtil -lSALOMELocalTrace +LDFLAGS+= $(QT_MT_LIBS) -lSalomeNS -lSALOMELocalTrace -lSALOMETraceCollector -lOpUtil -LDFLAGSFORBIN= $(LDFLAGS) -lSALOMETraceCollector @CONCLUDE@ diff --git a/src/ModuleCatalog/SALOME_ModuleCatalog_Server.cxx b/src/ModuleCatalog/SALOME_ModuleCatalog_Server.cxx index ad8cdd43d..f2176aa12 100644 --- a/src/ModuleCatalog/SALOME_ModuleCatalog_Server.cxx +++ b/src/ModuleCatalog/SALOME_ModuleCatalog_Server.cxx @@ -85,9 +85,9 @@ int main(int argc,char **argv) if(!CORBA::is_nil(orb)) theObj = orb->resolve_initial_references("NameService"); } - catch( CORBA::COMM_FAILURE& ) + catch( CORBA::SystemException& ) { - INFOS( "Module Catalog Server: CORBA::COMM_FAILURE: Unable to contact the Naming Service" ); + INFOS( "Module Catalog Server: CORBA::SystemException: Unable to contact the Naming Service" ); } if (!CORBA::is_nil(theObj)) { diff --git a/src/NamingService/NamingService_WaitForServerReadiness.cxx b/src/NamingService/NamingService_WaitForServerReadiness.cxx index 7cb1a6bce..6108b2dc3 100644 --- a/src/NamingService/NamingService_WaitForServerReadiness.cxx +++ b/src/NamingService/NamingService_WaitForServerReadiness.cxx @@ -66,7 +66,7 @@ void NamingService_WaitForServerReadiness(SALOME_NamingService* NS, { if (serverName.length() == 0) { - string curdir = NS->Current_Directory(); // to wait for naming service + string dummyadr = NS->getIORaddr(); // to wait for naming service found = 1; break; // naming service found } diff --git a/src/NamingService/SALOME_NamingService.cxx b/src/NamingService/SALOME_NamingService.cxx index e939d5341..f39bb93e1 100644 --- a/src/NamingService/SALOME_NamingService.cxx +++ b/src/NamingService/SALOME_NamingService.cxx @@ -80,7 +80,8 @@ SALOME_NamingService::~SALOME_NamingService() void SALOME_NamingService::init_orb(CORBA::ORB_ptr orb) { - // MESSAGE("SALOME_NamingService initialisation"); + MESSAGE("SALOME_NamingService initialisation"); + Utils_Locker lock(&_myMutex); _orb = orb ; _initialize_root_context(); } @@ -100,7 +101,8 @@ void SALOME_NamingService::Register(CORBA::Object_ptr ObjRef, const char* Path) throw(ServiceUnreachable) { - // MESSAGE("BEGIN OF Register: "<< Path); + MESSAGE("BEGIN OF Register: "<< Path); + Utils_Locker lock(&_myMutex); int dimension_Path = strlen(Path) + 1; char** resultat_resolve_Path = new char* [dimension_Path]; @@ -151,9 +153,9 @@ void SALOME_NamingService::Register(CORBA::Object_ptr ObjRef, { INFOS("!!!Register() : CosNaming::NamingContext::CannotProceed"); } - catch(CORBA::COMM_FAILURE&) + catch(CORBA::SystemException&) { - INFOS("!!!Register() : CORBA::COMM_FAILURE : unable to contact" + INFOS("!!!Register() : CORBA::SystemException : unable to contact" << " the naming service"); throw ServiceUnreachable(); } @@ -218,9 +220,9 @@ void SALOME_NamingService::Register(CORBA::Object_ptr ObjRef, { INFOS("!!!Register() : CosNaming::NamingContext::InvalidName"); } - catch(CORBA::COMM_FAILURE&) + catch(CORBA::SystemException&) { - INFOS("!!!Register() :CORBA::COMM_FAILURE : unable to contact" + INFOS("!!!Register() :CORBA::SystemException : unable to contact" << " the naming service"); throw ServiceUnreachable(); } @@ -270,9 +272,9 @@ void SALOME_NamingService::Register(CORBA::Object_ptr ObjRef, INFOS("!!!Register() : CosNaming::NamingContext::AlreadyBound, object will be rebind"); _current_context->rebind(_context_name, ObjRef); } - catch(CORBA::COMM_FAILURE&) + catch(CORBA::SystemException&) { - INFOS("!!!Register() :CORBA::COMM_FAILURE : unable to contact" + INFOS("!!!Register() :CORBA::SystemException : unable to contact" << " the naming service"); throw ServiceUnreachable(); } @@ -298,7 +300,8 @@ void SALOME_NamingService::Register(CORBA::Object_ptr ObjRef, CORBA::Object_ptr SALOME_NamingService::Resolve(const char* Path) throw(ServiceUnreachable) { - //MESSAGE("BEGIN OF Resolve: " << Path); + MESSAGE("BEGIN OF Resolve: " << Path); + Utils_Locker lock(&_myMutex); int dimension_Path = strlen(Path) + 1; char** resultat_resolve_Path = new char* [dimension_Path]; @@ -352,9 +355,9 @@ CORBA::Object_ptr SALOME_NamingService::Resolve(const char* Path) { INFOS("!!!Resolve() : CosNaming::NamingContext::InvalidName"); } - catch(CORBA::COMM_FAILURE&) + catch(CORBA::SystemException&) { - INFOS("!!!Resolve() :CORBA::COMM_FAILURE : unable to contact" + INFOS("!!!Resolve() :CORBA::SystemException : unable to contact" << "the naming service"); throw ServiceUnreachable(); } @@ -368,6 +371,53 @@ CORBA::Object_ptr SALOME_NamingService::Resolve(const char* Path) return _obj; } +//---------------------------------------------------------------------- +/*! Function : ResolveFirst + * Purpose : method to get an ObjRef with a symbolic name + * \param Path const char* argument like "/path/name" + * search the fist reference like "/path(.dir)/name*(.kind)" + * If the NamingService is out, the exception ServiceUnreachable is thrown + * \return the object reference + */ +//---------------------------------------------------------------------- + +CORBA::Object_ptr SALOME_NamingService::ResolveFirst(const char* Path) + throw(ServiceUnreachable) +{ + MESSAGE("ResolveFirst"); + Utils_Locker lock(&_myMutex); + SCRUTE(Path); + string thePath =Path; + string basePath ="/"; + string name = thePath; + string::size_type idx = thePath.rfind('/'); + if (idx != string::npos) // at least one '/' found + { + basePath = thePath.substr(0,idx); + name = thePath.substr(idx+1); + SCRUTE(basePath); + } + SCRUTE(name); + CORBA::Object_ptr obj = CORBA::Object::_nil(); + bool isOk = Change_Directory(basePath.c_str()); + if (isOk) + { + vector listElem = list_directory(); + vector::iterator its = listElem.begin(); + while (its != listElem.end()) + { + MESSAGE(*its); + if ((*its).find(name) == 0) + { + //string instance = basePath + "/" + *its; + return Resolve((*its).c_str()); + } + its++; + } + } + return obj; +} + //---------------------------------------------------------------------- /*! Function : Find * Purpose : method to research a name from the current directory @@ -384,15 +434,16 @@ CORBA::Object_ptr SALOME_NamingService::Resolve(const char* Path) int SALOME_NamingService::Find(const char* name) throw(ServiceUnreachable) { - // MESSAGE("BEGIN OF Find " << name); + MESSAGE("BEGIN OF Find " << name); + Utils_Locker lock(&_myMutex); CORBA::Long occurence_number = 0 ; try { _Find(name,occurence_number); } - catch(CORBA::COMM_FAILURE&) + catch(CORBA::SystemException&) { - INFOS("!!!Find() : CORBA::COMM_FAILURE : unable to contact" + INFOS("!!!Find() : CORBA::SystemException : unable to contact" << " the naming service"); throw ServiceUnreachable(); } @@ -411,7 +462,8 @@ int SALOME_NamingService::Find(const char* name) bool SALOME_NamingService::Create_Directory(const char* Path) throw(ServiceUnreachable) { - //MESSAGE("BEGIN OF Create_Directory"); + MESSAGE("BEGIN OF Create_Directory"); + Utils_Locker lock(&_myMutex); int dimension_Path = strlen(Path) + 1; char** resultat_resolve_Path= new char* [dimension_Path];; CORBA::Boolean _return_code = true ; @@ -495,10 +547,10 @@ bool SALOME_NamingService::Create_Directory(const char* Path) _return_code = false; INFOS("!!!Create_Directory():CosNaming::NamingContext::InvalidName"); } - catch(CORBA::COMM_FAILURE&) + catch(CORBA::SystemException&) { _return_code = false; - INFOS("!!!Register() :CORBA::COMM_FAILURE : unable to contact" + INFOS("!!!Register() :CORBA::SystemException : unable to contact" << " the naming service"); throw ServiceUnreachable(); } @@ -525,7 +577,8 @@ bool SALOME_NamingService::Create_Directory(const char* Path) bool SALOME_NamingService::Change_Directory(const char* Path) throw(ServiceUnreachable) { - //MESSAGE("BEGIN OF Change_Directory " << Path); + MESSAGE("BEGIN OF Change_Directory " << Path); + Utils_Locker lock(&_myMutex); int dimension_Path = strlen(Path) + 1; char** resultat_resolve_Path = new char* [dimension_Path]; CORBA::Boolean _return_code = true ; @@ -588,10 +641,10 @@ bool SALOME_NamingService::Change_Directory(const char* Path) _return_code = false; INFOS( "!!!Change_Directory() : CosNaming::NamingContext::InvalidName" ) } - catch(CORBA::COMM_FAILURE&) + catch(CORBA::SystemException&) { _return_code = false; - INFOS( "!!!Change_Directory() :CORBA::COMM_FAILURE : unable to contact" + INFOS( "!!!Change_Directory() :CORBA::SystemException : unable to contact" << "the naming service") throw ServiceUnreachable(); } @@ -617,7 +670,8 @@ bool SALOME_NamingService::Change_Directory(const char* Path) char* SALOME_NamingService::Current_Directory() throw(ServiceUnreachable) { - //MESSAGE("BEGIN OF Current_Directory"); + MESSAGE("BEGIN OF Current_Directory"); + Utils_Locker lock(&_myMutex); CosNaming::NamingContext_var _ref_context = _current_context; @@ -633,9 +687,9 @@ char* SALOME_NamingService::Current_Directory() { _current_directory(result_path,i,_ref_context,_continue ); } - catch(CORBA::COMM_FAILURE&) + catch(CORBA::SystemException&) { - INFOS("!!!Current_Directory(): CORBA::COMM_FAILURE : unable to contact" + INFOS("!!!Current_Directory(): CORBA::SystemException : unable to contact" << " the naming service" ) throw ServiceUnreachable(); } @@ -672,6 +726,7 @@ void SALOME_NamingService::list() throw(ServiceUnreachable) { MESSAGE("Begin of list"); + Utils_Locker lock(&_myMutex); CosNaming::BindingList_var _binding_list; CosNaming::BindingIterator_var _binding_iterator; unsigned long nb=0 ; // for using only the BindingIterator to access the bindings @@ -748,6 +803,8 @@ vector SALOME_NamingService::list_directory() vector SALOME_NamingService::list_directory_recurs() throw(ServiceUnreachable) { + MESSAGE("list_directory_recurs"); + Utils_Locker lock(&_myMutex); vector _list ; char *currentDir=Current_Directory(); _list_directory_recurs(_list,0,currentDir); @@ -768,6 +825,7 @@ void SALOME_NamingService::Destroy_Name(const char* Path) throw(ServiceUnreachable) { MESSAGE("BEGIN OF Destroy_Name"); + Utils_Locker lock(&_myMutex); int dimension_Path = strlen(Path) + 1; char** resultat_resolve_Path = new char* [dimension_Path]; @@ -817,9 +875,9 @@ void SALOME_NamingService::Destroy_Name(const char* Path) { INFOS( "!!!Destroy_Name(): CosNaming::NamingContext::CannotProceed" ) } - catch(CORBA::COMM_FAILURE&) + catch(CORBA::SystemException&) { - INFOS( "!!!Destroy_Name() : CORBA::COMM_FAILURE : unable to contact" + INFOS( "!!!Destroy_Name() : CORBA::SystemException : unable to contact" << " the naming service") throw ServiceUnreachable(); } @@ -861,9 +919,9 @@ void SALOME_NamingService::Destroy_Name(const char* Path) { INFOS( "!!!Destroy_Name() : CosNaming::NamingContext::InvalidName") } - catch(CORBA::COMM_FAILURE&) + catch(CORBA::SystemException&) { - INFOS( "!!!Destroy_Name() :CORBA::COMM_FAILURE : unable to contact" + INFOS( "!!!Destroy_Name() :CORBA::SystemException : unable to contact" << " the naming service") throw ServiceUnreachable(); } @@ -889,6 +947,7 @@ void SALOME_NamingService::Destroy_Directory(const char* Path) throw(ServiceUnreachable) { MESSAGE("BEGIN OF Destroy_Directory"); + Utils_Locker lock(&_myMutex); int dimension_Path = strlen(Path) + 1; char** resultat_resolve_Path = new char* [dimension_Path]; @@ -940,9 +999,9 @@ void SALOME_NamingService::Destroy_Directory(const char* Path) { INFOS("!!!Destroy_Directory(): CosNaming::NamingContext::CannotProceed" ) } - catch(CORBA::COMM_FAILURE&) + catch(CORBA::SystemException&) { - INFOS( "!!!Destroy_Directory() : CORBA::COMM_FAILURE : unable to contact" + INFOS( "!!!Destroy_Directory() : CORBA::SystemException : unable to contact" << " the naming service" ) throw ServiceUnreachable(); } @@ -984,9 +1043,9 @@ void SALOME_NamingService::Destroy_Directory(const char* Path) { INFOS( "!!!Destroy_Directory(): CosNaming::NamingContext::CannotProceed" ) } - catch(CORBA::COMM_FAILURE&) + catch(CORBA::SystemException&) { - INFOS( "!!!Destroy_Directory() : CORBA::COMM_FAILURE : unable to contact" + INFOS( "!!!Destroy_Directory() : CORBA::SystemException : unable to contact" << " the naming service" ) throw ServiceUnreachable(); } @@ -1003,9 +1062,9 @@ void SALOME_NamingService::Destroy_Directory(const char* Path) INFOS( "!!!Destroy_Directory() : CosNaming::NamingContext::NoEmpty " << Path << " is not empty" ) } - catch(CORBA::COMM_FAILURE&) + catch(CORBA::SystemException&) { - INFOS( "!!!Destroy_Directory() :CORBA::COMM_FAILURE : " + INFOS( "!!!Destroy_Directory() :CORBA::SystemException : " << "unable to contact the naming service") throw ServiceUnreachable(); } @@ -1039,9 +1098,9 @@ void SALOME_NamingService::Destroy_Directory(const char* Path) { INFOS( "!!!Destroy_Directory() : CosNaming::NamingContext::InvalidName") } - catch(CORBA::COMM_FAILURE&) + catch(CORBA::SystemException&) { - INFOS( "!!!Destroy_Directory() :CORBA::COMM_FAILURE : unable to contact" + INFOS( "!!!Destroy_Directory() :CORBA::SystemException : unable to contact" << " the naming service") throw ServiceUnreachable(); } @@ -1070,9 +1129,9 @@ void SALOME_NamingService::_initialize_root_context() ASSERT(!CORBA::is_nil(_root_context)); } - catch(CORBA::COMM_FAILURE&) + catch(CORBA::SystemException&) { - INFOS("CORBA::COMM_FAILURE: unable to contact the naming service"); + INFOS("CORBA::SystemException: unable to contact the naming service"); throw ServiceUnreachable(); } catch(...) @@ -1284,7 +1343,7 @@ SALOME_NamingService::_current_directory(char** result_path, CosNaming::NamingContext_var _temp_context = _current_context; _current_context->list(nb, _binding_list, _binding_iterator) ; - + if ( !_binding_iterator->_is_nil() ) { while ((_binding_iterator->next_one(_binding)) && _continue) { CosNaming::Name _bindingName = _binding->binding_name; if (_binding->binding_type == CosNaming::ncontext) @@ -1324,6 +1383,7 @@ SALOME_NamingService::_current_directory(char** result_path, } } _binding_iterator->destroy(); + } // We go to the last directory where an occurence was found _current_context = _ref_context ; } @@ -1383,6 +1443,7 @@ void SALOME_NamingService::_list_directory_recurs(vector& myList, const //---------------------------------------------------------------------- -char * SALOME_NamingService::getIORaddr(){ +char * SALOME_NamingService::getIORaddr() +{ return _orb->object_to_string(_root_context); } diff --git a/src/NamingService/SALOME_NamingService.hxx b/src/NamingService/SALOME_NamingService.hxx index db9c39e17..1f3205498 100644 --- a/src/NamingService/SALOME_NamingService.hxx +++ b/src/NamingService/SALOME_NamingService.hxx @@ -33,6 +33,7 @@ #include #include #include +#include "Utils_Mutex.hxx" //class ServiceUnreachable; #include "ServiceUnreachable.hxx" @@ -60,6 +61,10 @@ public: CORBA::Object_ptr Resolve(const char* Path) throw( ServiceUnreachable); + //! method to get an ObjRef, given a symbolic name without instance suffix "/Path/Name*.kind" + CORBA::Object_ptr ResolveFirst(const char* Path) + throw( ServiceUnreachable); + //! method to research a name from the naming service's current directory int Find(const char* name) throw(ServiceUnreachable); @@ -101,6 +106,7 @@ public: char * getIORaddr(); protected: + Utils_Mutex _myMutex; CORBA::ORB_ptr _orb; CosNaming::NamingContext_var _root_context, _current_context; diff --git a/src/NamingService/SALOME_NamingServicePy.py b/src/NamingService/SALOME_NamingServicePy.py index 2bc3c553c..ab7f2050d 100644 --- a/src/NamingService/SALOME_NamingServicePy.py +++ b/src/NamingService/SALOME_NamingServicePy.py @@ -64,7 +64,7 @@ class SALOME_NamingServicePy_i: MESSAGE(" Name service not found") else: ok = 1 - except CORBA.COMM_FAILURE, ex: + except (CORBA.TRANSIENT,CORBA.OBJECT_NOT_EXIST,CORBA.COMM_FAILURE): MESSAGE(" Name service not found") time.sleep(0.25) steps = steps - 1 @@ -100,8 +100,8 @@ class SALOME_NamingServicePy_i: MESSAGE ( "Register : CosNaming.NamingContext.InvalidName" ) except CosNaming.NamingContext.CannotProceed, ex: MESSAGE ( "Register : CosNaming.NamingContext.CannotProceed" ) - except CORBA.COMM_FAILURE, ex: - MESSAGE ( "Register : CORBA.COMM_FAILURE" ) + except (CORBA.TRANSIENT,CORBA.OBJECT_NOT_EXIST,CORBA.COMM_FAILURE): + MESSAGE ( "Register : CORBA.TRANSIENT,CORBA.OBJECT_NOT_EXIST,CORBA.COMM_FAILURE" ) if _not_exist: # at least one context of the complete path is not created, we had @@ -132,8 +132,8 @@ class SALOME_NamingServicePy_i: except CosNaming.NamingContext.AlreadyBound, ex: MESSAGE ( "Register : CosNaming.NamingContext.AlreadyBound, object will be rebind" ) self._current_context.rebind(_context_name,ObjRef) - except CORBA.COMM_FAILURE, ex: - MESSAGE ( "Register : CORBA.COMM_FAILURE" ) + except (CORBA.TRANSIENT,CORBA.OBJECT_NOT_EXIST,CORBA.COMM_FAILURE): + MESSAGE ( "Register : CORBA.TRANSIENT,CORBA.OBJECT_NOT_EXIST,CORBA.COMM_FAILURE" ) #------------------------------------------------------------------------- @@ -161,8 +161,8 @@ class SALOME_NamingServicePy_i: except CosNaming.NamingContext.CannotProceed, ex: MESSAGE ( "Resolve : CosNaming.NamingContext.CannotProceed" ) self._obj = None - except CORBA.COMM_FAILURE, ex: - MESSAGE ( "Resolve : CORBA.COMM_FAILURE" ) + except (CORBA.TRANSIENT,CORBA.OBJECT_NOT_EXIST,CORBA.COMM_FAILURE): + MESSAGE ( "Resolve : CORBA.TRANSIENT,CORBA.OBJECT_NOT_EXIST,CORBA.COMM_FAILURE" ) self._obj = None return self._obj @@ -191,8 +191,8 @@ class SALOME_NamingServicePy_i: MESSAGE ( "Create_Directory : CosNaming.NamingContext.InvalidName" ) except CosNaming.NamingContext.CannotProceed, ex: MESSAGE ( "Create_Directory : CosNaming.NamingContext.CannotProceed" ) - except CORBA.COMM_FAILURE, ex: - MESSAGE ( "Create_Directory : CORBA.COMM_FAILURE" ) + except (CORBA.TRANSIENT,CORBA.OBJECT_NOT_EXIST,CORBA.COMM_FAILURE): + MESSAGE ( "Create_Directory : CORBA.TRANSIENT,CORBA.OBJECT_NOT_EXIST,CORBA.COMM_FAILURE" ) diff --git a/src/Notification/NOTIFICATION.cxx b/src/Notification/NOTIFICATION.cxx index bbbb92294..e55d0abc7 100644 --- a/src/Notification/NOTIFICATION.cxx +++ b/src/Notification/NOTIFICATION.cxx @@ -50,7 +50,7 @@ CosNA_EventChannel_ptr NOTIFICATION_channel() { } catch(CORBA::ORB::InvalidName& ex) { MESSAGE("NOTIFICATION Error : service required is invalid [does not exist]"); return(channel); - } catch (CORBA::COMM_FAILURE& ex) { + } catch (CORBA::SystemException& ex) { MESSAGE("NOTIFICATION Error : caught system exception COMM_FAILURE"); return(channel); } catch (...) { @@ -70,7 +70,7 @@ CosNA_EventChannel_ptr NOTIFICATION_channel() { }; } catch(CORBA::ORB::InvalidName& ex) { MESSAGE("NOTIFICATION Error : invalid name"); - } catch (CORBA::COMM_FAILURE& ex) { + } catch (CORBA::SystemException& ex) { MESSAGE("NOTIFICATION Error : caught system exception COMM_FAILURE while resolving event channel name"); } catch (...) { MESSAGE("NOTIFICATION Error : caught exception while resolving event channel name"); diff --git a/src/Registry/SALOME_Registry_Server.cxx b/src/Registry/SALOME_Registry_Server.cxx index d47523a93..0756e2b70 100644 --- a/src/Registry/SALOME_Registry_Server.cxx +++ b/src/Registry/SALOME_Registry_Server.cxx @@ -118,9 +118,9 @@ int main( int argc , char **argv ) if (!CORBA::is_nil(theObj)) inc = CosNaming::NamingContext::_narrow(theObj); } - catch( CORBA::COMM_FAILURE& ) + catch( CORBA::SystemException& ) { - MESSAGE( "Registry Server: CORBA::COMM_FAILURE: Unable to contact the Naming Service" ); + MESSAGE( "Registry Server: CORBA::SystemException: Unable to contact the Naming Service" ); } if(!CORBA::is_nil(inc)) { diff --git a/src/ResourcesManager/SALOME_ResourcesManager.cxx b/src/ResourcesManager/SALOME_ResourcesManager.cxx index f84a35867..da3c89977 100644 --- a/src/ResourcesManager/SALOME_ResourcesManager.cxx +++ b/src/ResourcesManager/SALOME_ResourcesManager.cxx @@ -11,6 +11,7 @@ #include #include #include +#include #include #include diff --git a/src/RessourcesCatalog/Makefile.in b/src/RessourcesCatalog/Makefile.in index 17f8c42af..b43546776 100644 --- a/src/RessourcesCatalog/Makefile.in +++ b/src/RessourcesCatalog/Makefile.in @@ -54,8 +54,7 @@ BIN_SERVER_IDL = SALOME_RessourcesCatalog.idl CPPFLAGS+= $(QT_MT_INCLUDES) CXXFLAGS+= -LDFLAGS+= $(QT_MT_LIBS) $(OGL_LIBS) -lSalomeNS -lOpUtil -lSALOMELocalTrace -LDFLAGSFORBIN= $(LDFLAGS) -lSALOMETraceCollector +LDFLAGS+= $(QT_MT_LIBS) $(OGL_LIBS) -lSalomeNS -lOpUtil -lSALOMELocalTrace -lSALOMETraceCollector @CONCLUDE@ diff --git a/src/RessourcesCatalog/SALOME_RessourcesCatalog_Server.cxx b/src/RessourcesCatalog/SALOME_RessourcesCatalog_Server.cxx index b52c63b67..fdb7de8d6 100644 --- a/src/RessourcesCatalog/SALOME_RessourcesCatalog_Server.cxx +++ b/src/RessourcesCatalog/SALOME_RessourcesCatalog_Server.cxx @@ -26,7 +26,7 @@ // Module : SALOME // $Header$ -#include +#include #include "SALOME_NamingService.hxx" #include "SALOME_RessourcesCatalog_impl.hxx" #include "utilities.h" @@ -85,9 +85,9 @@ int main(int argc,char **argv) if (!CORBA::is_nil(theObj)) inc = CosNaming::NamingContext::_narrow(theObj); } - catch( CORBA::COMM_FAILURE& ) + catch( CORBA::SystemException& ) { - INFOS( "Ressources Catalog: CORBA::COMM_FAILURE: Unable to contact the Naming Service" ); + INFOS( "Ressources Catalog: CORBA::SystemException: Unable to contact the Naming Service" ); } if(!CORBA::is_nil(inc)) { diff --git a/src/SALOMELocalTrace/utilities.h b/src/SALOMELocalTrace/utilities.h index 40238630f..d29e35a5b 100644 --- a/src/SALOMELocalTrace/utilities.h +++ b/src/SALOMELocalTrace/utilities.h @@ -52,17 +52,17 @@ #define MESS_INIT(deb) std::ostringstream os; os<insert(NORMAL_MESS, os.str().c_str()); -#define MESS_ABORT endl; LocalTraceBufferPool::instance()->insert(ABORT_MESS, os.str().c_str()); +#define MESS_END std::endl; LocalTraceBufferPool::instance()->insert(NORMAL_MESS, os.str().c_str()); +#define MESS_ABORT std::endl; LocalTraceBufferPool::instance()->insert(ABORT_MESS, os.str().c_str()); // --- Some macros are always defined (without _DEBUG_): for use with release version #define INFOS(msg) {MESS_BEGIN("- Trace ") << msg << MESS_END} #define PYSCRIPT(msg) {MESS_INIT("---PYSCRIPT--- ") << msg << MESS_END} #define INTERRUPTION(msg) {MESS_BEGIN("- INTERRUPTION: ")<< msg << MESS_ABORT} -#define IMMEDIATE_ABORT(code) {cout <FindAttribute( anAttr, "AttributeFlags" ) ) + { + _PTR(AttributeFlags) aFlags( anAttr ); + bool ret = aFlags->Get( theFlag ); + return ret; + } + + return false; +} + +//======================================================================= +// name : SetFlag +// Purpose : Set/Unset specified flaf from "AttributeFlags" attribute +//======================================================================= +bool SALOMEDS_Tool::SetFlag( const int theFlag, + _PTR(Study) theStudy, + const std::string& theEntry, + const bool theValue ) +{ + _PTR(SObject) anObj (theStudy->FindObjectID(theEntry.c_str())); + + if ( anObj ) + { + _PTR(GenericAttribute) aGAttr; + if ( anObj->FindAttribute( aGAttr, "AttributeFlags" ) ) + { + _PTR(AttributeFlags) anAttr ( aGAttr ); + anAttr->Set( theFlag, theValue ); + } + else if ( theValue ) + { + _PTR(StudyBuilder) aBuilder ( theStudy->NewBuilder() ); + _PTR(AttributeFlags) anAttr = aBuilder->FindOrCreateAttribute( anObj, "AttributeFlags" ); + anAttr->Set( theFlag, theValue ); + } + return true; + } + + return false; +} + +//======================================================================= +// name : getAllChildren +// Purpose : Get all entries of children of object. +// If theObj is null all entries of objects of study are returned +//======================================================================= +void SALOMEDS_Tool::GetAllChildren( _PTR(Study) theStudy, + _PTR(SObject) theObj, + std::list& theList ) +{ + if ( !theObj ) + { + _PTR(SComponentIterator) anIter (theStudy->NewComponentIterator()); + for ( ; anIter->More(); anIter->Next() ) + { + _PTR(SObject) anObj ( anIter->Value() ); + if ( anObj ) + { + theList.push_back( anObj->GetID() ); + GetAllChildren( theStudy, anObj, theList ); + } + } + } + else + { + _PTR(ChildIterator) anIter ( theStudy->NewChildIterator( theObj ) ); + for ( ; anIter->More(); anIter->Next() ) + { + _PTR(SObject) anObj ( anIter->Value() ); + _PTR(SObject) aRef; + if ( !anObj->ReferencedObject( aRef ) ) + { + theList.push_back( anObj->GetID() ); + GetAllChildren( theStudy, anObj, theList ); + } + } + } +} diff --git a/src/TOOLSDS/SALOMEDS_Tool.hxx b/src/TOOLSDS/SALOMEDS_Tool.hxx index e3d1d3993..b3f898902 100644 --- a/src/TOOLSDS/SALOMEDS_Tool.hxx +++ b/src/TOOLSDS/SALOMEDS_Tool.hxx @@ -13,6 +13,8 @@ #include #include +#include "SALOMEDSClient.hxx" + // IDL headers #include "SALOMEconfig.h" #include CORBA_SERVER_HEADER(SALOMEDS) @@ -67,6 +69,23 @@ public: SALOMEDS::SObject_var theObj, std::list& theList ); + + // Retrieves specified flaf from "AttributeFlags" attribute + static bool GetFlag( const int theFlag, + _PTR(Study) theStudy, + _PTR(SObject) theObj ); + + // Sets/Unsets specified flaf from "AttributeFlags" attribute + static bool SetFlag( const int theFlag, + _PTR(Study) theStudy, + const std::string& theEntry, + const bool theValue ); + + // Get all entries of children of object. If theObj is null all entries of objects of study are returned + static void GetAllChildren( _PTR(Study) theStudy, + _PTR(SObject) theObj, + std::list& theList ); + }; #endif diff --git a/src/TestContainer/Makefile.in b/src/TestContainer/Makefile.in index c5b22b104..8ee409d99 100644 --- a/src/TestContainer/Makefile.in +++ b/src/TestContainer/Makefile.in @@ -45,8 +45,7 @@ LIB_CLIENT_IDL = SALOME_Component.idl SALOME_TestComponent.idl BIN = TestContainer TestLogger BIN_SRC = -LDFLAGS+= -lSalomeNotification -lSalomeNS -lSalomeContainer -lRegistry -lOpUtil -lSALOMELocalTrace -lSalomeResourcesManager -LDFLAGSFORBIN= $(LDFLAGS) -lSALOMETraceCollector +LDFLAGS+= -lSalomeNotification -lSalomeNS -lSalomeContainer -lRegistry -lOpUtil -lSALOMELocalTrace @CONCLUDE@ diff --git a/src/TestContainer/SALOME_TestComponent_i.cxx b/src/TestContainer/SALOME_TestComponent_i.cxx index 413fd2fa0..64772b14e 100644 --- a/src/TestContainer/SALOME_TestComponent_i.cxx +++ b/src/TestContainer/SALOME_TestComponent_i.cxx @@ -26,6 +26,7 @@ // Module : SALOME // $Header$ +#define private protected #include "utilities.h" #include "SALOME_TestComponent_i.hxx" #include @@ -40,10 +41,10 @@ Engines_TestComponent_i::Engines_TestComponent_i(CORBA::ORB_ptr orb, const char *interfaceName) : Engines_Component_i(orb, poa, contId, instanceName, interfaceName) { - MESSAGE("activate object") + MESSAGE("activate object"); _thisObj = this ; _id = _poa->activate_object(_thisObj); - //SCRUTE(this) + SCRUTE(pd_refCount); } Engines_TestComponent_i::Engines_TestComponent_i() @@ -52,12 +53,14 @@ Engines_TestComponent_i::Engines_TestComponent_i() Engines_TestComponent_i::~Engines_TestComponent_i() { + MESSAGE("~Engines_TestComponent_i()"); } char* Engines_TestComponent_i::Coucou(CORBA::Long L) { char s[100]; sprintf(s, "TestComponent_i : L = %ld", (long) L); + SCRUTE(pd_refCount); return CORBA::string_dup(s); } diff --git a/src/TestContainer/TestComponentPy.py b/src/TestContainer/TestComponentPy.py index b6c248463..2dacf6dbb 100755 --- a/src/TestContainer/TestComponentPy.py +++ b/src/TestContainer/TestComponentPy.py @@ -34,7 +34,6 @@ import string from omniORB import CORBA import CosNaming import Engines -from Utils_Identity import getShortHostName #initialise the ORB @@ -49,7 +48,8 @@ if rootContext is None: sys.exit(1) #resolve the name /Containers.dir/FactoryServerPy.object -machineName= getShortHostName() +myMachine=string.split(os.getenv( "HOSTNAME" ),'.') +machineName= myMachine[0] containerName = "FactoryServerPy" name = [CosNaming.NameComponent("Containers","dir"), CosNaming.NameComponent(machineName,"dir"), diff --git a/src/TestContainer/TestContainer.cxx b/src/TestContainer/TestContainer.cxx index e8492fb6e..89137f358 100644 --- a/src/TestContainer/TestContainer.cxx +++ b/src/TestContainer/TestContainer.cxx @@ -34,6 +34,7 @@ #include CORBA_CLIENT_HEADER(SALOME_TestComponent) #include "SALOME_NamingService.hxx" +#include "NamingService_WaitForServerReadiness.hxx" #include "OpUtil.hxx" #include "Utils_ORB_INIT.hxx" #include "Utils_SINGLETON.hxx" @@ -59,10 +60,25 @@ static ostream& operator<<(ostream& os, const CORBA::Exception& e) return os; } +Engines::TestComponent_ptr create_instance(Engines::Container_ptr iGenFact, + string componenttName) +{ + bool isLib = + iGenFact->load_component_Library(componenttName.c_str()); + // iGenFact->load_component_Library("SalomeTestComponent"); + ASSERT(isLib); + CORBA::Object_var obj = + // iGenFact->create_component_instance("SalomeTestComponent", + iGenFact->create_component_instance(componenttName.c_str(), + 0); + Engines::TestComponent_var anInstance = Engines::TestComponent::_narrow(obj); + MESSAGE("create anInstance"); + SCRUTE(anInstance->instanceName()); + return anInstance._retn(); +} int main (int argc, char * argv[]) { - // Initializing omniORB ORB_INIT &init = *SINGLETON_::Instance() ; CORBA::ORB_var &orb = init( argc , argv ) ; @@ -70,115 +86,30 @@ int main (int argc, char * argv[]) try { - - - - // use IOR to find container - //if (argc != 2) { return 1; } - //CORBA::Object_var obj = orb->string_to_object(argv[1]); - //Engines::Container_var iGenFact = Engines::Container::_narrow(obj); - - // Obtain a reference to the root POA - // - long TIMESleep = 250000000; - int NumberOfTries = 40; - int a; - timespec ts_req; - ts_req.tv_nsec=TIMESleep; - ts_req.tv_sec=0; - timespec ts_rem; - ts_rem.tv_nsec=0; - ts_rem.tv_sec=0; - CosNaming::NamingContext_var inc; - PortableServer::POA_var poa; - CORBA::Object_var theObj; - CORBA::Object_var obj; - CORBA::Object_var object; - SALOME_NamingService &naming = *SINGLETON_::Instance() ; - int TEST_CONTAINER=0; - const char * Env = getenv("USE_LOGGER"); - int EnvL =0; - if ((Env!=NULL) && (strlen(Env))) - EnvL=1; - CosNaming::Name name; - name.length(1); - name[0].id=CORBA::string_dup("Logger"); - PortableServer::POAManager_var manager; - for (int i = 1; i<=NumberOfTries; i++) - { - if (i!=1) - a=nanosleep(&ts_req,&ts_rem); - try - { - obj = orb->resolve_initial_references("RootPOA"); - if(!CORBA::is_nil(obj)) - poa = PortableServer::POA::_narrow(obj); - if(!CORBA::is_nil(poa)) - manager = poa->the_POAManager(); - if(!CORBA::is_nil(orb)) - theObj = orb->resolve_initial_references("NameService"); - if (!CORBA::is_nil(theObj)) - inc = CosNaming::NamingContext::_narrow(theObj); - } - catch( CORBA::COMM_FAILURE& ) - { - INFOS( "Test Container: CORBA::COMM_FAILURE: Unable to contact the Naming Service" ) - } - if(!CORBA::is_nil(inc)) - { - MESSAGE( "Test Container: Naming Service was found" ) - if(EnvL==1) - { - for(int j=1; j<=NumberOfTries; j++) - { - if (j!=1) - a=nanosleep(&ts_req, &ts_rem); - try - { - object = inc->resolve(name); - } - catch(CosNaming::NamingContext::NotFound) - { - INFOS( "Test Container: Logger Server wasn't found" ); - } - catch(...) - { - INFOS( "Test Container: Unknown exception" ); - } - if (!CORBA::is_nil(object)) - { - MESSAGE( "Test Container: Loger Server was found" ); - TEST_CONTAINER=1; - break; - } - } - } - } - if ((TEST_CONTAINER==1)||((EnvL==0)&&(!CORBA::is_nil(inc)))) - break; - } - - // Use Name Service to find container SALOME_NamingService _NS(orb) ; string containerName = "/Containers/" ; string hostName = GetHostname(); containerName += hostName + "/FactoryServer"; + NamingService_WaitForServerReadiness(&_NS,containerName); - obj = _NS.Resolve(containerName.c_str()) ; + CORBA::Object_var obj = _NS.Resolve(containerName.c_str()) ; Engines::Container_var iGenFact = Engines::Container::_narrow(obj); - Engines::TestComponent_var m1; + int nbInstances = 5; + + vector instances(nbInstances); - for (int iter = 0; iter < 3 ; iter++) + MESSAGE("------------------------------- create instances "); + for (int iter = 0; iter < nbInstances ; iter++) { - MESSAGE("----------------------------------------------------" << iter); - string dirn = getenv("KERNEL_ROOT_DIR"); - dirn += "/lib/salome/libSalomeTestComponentEngine.so"; - obj = iGenFact->load_impl("SalomeTestComponent",dirn.c_str()); - m1 = Engines::TestComponent::_narrow(obj); - MESSAGE("recup m1"); - SCRUTE(m1->instanceName()); + instances[iter] = create_instance(iGenFact,"SalomeTestComponent"); + } + MESSAGE("------------------------------ set env instances "); + for (int iter = 0; iter < nbInstances ; iter++) + { + Engines::TestComponent_var anInstance = instances[iter]; + SCRUTE(anInstance->instanceName()); Engines::FieldsDict_var dico = new Engines::FieldsDict; dico->length(3); dico[0].key=CORBA::string_dup("key_0"); @@ -186,14 +117,18 @@ int main (int argc, char * argv[]) dico[1].key=CORBA::string_dup("key_1"); dico[1].value <<=(CORBA::UShort)72; dico[2].key=CORBA::string_dup("key_2"); - dico[2].value <<="value_2"; - m1->setProperties(dico); - - MESSAGE("Coucou " << m1->Coucou(1L)); - - m1->Setenv(); + dico[2].value <<=(CORBA::ULong)iter; + anInstance->setProperties(dico); + MESSAGE("Coucou " << anInstance->Coucou(iter)); + anInstance->Setenv(); + } - Engines::FieldsDict_var dico2 = m1->getProperties(); + MESSAGE("---------------------------------- get instances "); + for (int iter = 0; iter < nbInstances ; iter++) + { + Engines::TestComponent_var anInstance = instances[iter]; + SCRUTE(anInstance->instanceName()); + Engines::FieldsDict_var dico2 = anInstance->getProperties(); for (CORBA::ULong i=0; ilength(); i++) { MESSAGE("dico2["<instanceName()); + iGenFact->remove_impl(anInstance) ; //iGenFact->finalize_removal() ; // unpredictable results ... - sleep(5); - } + } + MESSAGE("------------------------------- PYTHON "); + { +// bool isLib = +// iGenFact->load_component_Library("SALOME_TestComponentPy"); +// ASSERT(isLib); +// CORBA::Object_var obj = +// iGenFact->create_component_instance("SALOME_TestComponentPy", +// 0); +// Engines::TestComponent_var anInstance = +// Engines::TestComponent::_narrow(obj); +// MESSAGE("create anInstance"); +// SCRUTE(anInstance->instanceName()); + MESSAGE("------------------------------- create instances "); + for (int iter = 0; iter < nbInstances ; iter++) + { + instances[iter] = create_instance(iGenFact,"SALOME_TestComponentPy"); + } + + MESSAGE("---------------------------------- get instances "); + for (int iter = 0; iter < nbInstances ; iter++) + { + Engines::TestComponent_var anInstance = instances[iter]; + SCRUTE(anInstance->instanceName()); + MESSAGE("Coucou " << anInstance->Coucou(iter)); + } + } + // Clean-up. iGenFact->finalize_removal() ; - orb->destroy(); + orb->shutdown(0); } catch(CORBA::COMM_FAILURE& ex) { INFOS("Caught system exception COMM_FAILURE -- unable to contact the object.") diff --git a/src/Utils/Makefile.in b/src/Utils/Makefile.in index f7f5d5a65..c862428f3 100644 --- a/src/Utils/Makefile.in +++ b/src/Utils/Makefile.in @@ -46,7 +46,8 @@ EXPORT_HEADERS= \ Utils_SINGLETON.hxx \ Utils_DESTRUCTEUR_GENERIQUE.hxx \ Utils_ExceptHandlers.hxx \ - Utils_SignalsHandler.h + Utils_SignalsHandler.h \ + Utils_Mutex.hxx EXPORT_PYSCRIPTS = Utils_Identity.py SALOME_utilities.py # Libraries targets @@ -58,7 +59,8 @@ LIB_SRC = OpUtil.cxx Utils_Timer.cxx duplicate.cxx \ Utils_Identity.cxx Utils_ORB_INIT.cxx \ Utils_DESTRUCTEUR_GENERIQUE.cxx \ Utils_ExceptHandlers.cxx \ - Utils_SignalsHandler.cxx + Utils_SignalsHandler.cxx \ + Utils_Mutex.cxx LIB_SERVER_IDL = SALOME_Exception.idl diff --git a/src/Utils/OpUtil.cxx b/src/Utils/OpUtil.cxx index 00ed5a66d..28f95b660 100644 --- a/src/Utils/OpUtil.cxx +++ b/src/Utils/OpUtil.cxx @@ -26,19 +26,23 @@ #include "utilities.h" #include "OpUtil.hxx" -#include #include #include -using namespace std; -int gethostname(char *name, size_t len); +#ifndef WNT +#include +#else +#include +#endif +using namespace std; +//int gethostname(char *name, size_t len); -string GetHostname() +std::string GetHostname() { - int ls = 100, r = 0; + int ls = 100, r = 1; char *s; - while (ls < 10000) { + while (ls < 10000 && r) { ls *= 2; s = new char[ls]; r = gethostname(s, ls-1); diff --git a/src/Utils/Utils_CorbaException.hxx b/src/Utils/Utils_CorbaException.hxx index 5d6d5bf51..c05e8e50a 100644 --- a/src/Utils/Utils_CorbaException.hxx +++ b/src/Utils/Utils_CorbaException.hxx @@ -45,7 +45,7 @@ throw SALOME::SALOME_Exception(ExDescription); \ } -#include +#include //Dump the CORBA exception type. inline std::ostream& operator<<(std::ostream& os, const CORBA::Exception& e) diff --git a/src/Utils/Utils_DESTRUCTEUR_GENERIQUE.cxx b/src/Utils/Utils_DESTRUCTEUR_GENERIQUE.cxx index 62ce955ef..b600d8ac1 100644 --- a/src/Utils/Utils_DESTRUCTEUR_GENERIQUE.cxx +++ b/src/Utils/Utils_DESTRUCTEUR_GENERIQUE.cxx @@ -36,8 +36,6 @@ extern "C" # include "Utils_DESTRUCTEUR_GENERIQUE.hxx" # include "utilities.h" -using namespace std; - void Nettoyage(); #ifdef _DEBUG_ @@ -46,7 +44,9 @@ static int MYDEBUG = 0; static int MYDEBUG = 0; #endif -static list *Destructeurs=0 ; +using namespace std; + +std::list *DESTRUCTEUR_GENERIQUE_::Destructeurs=0 ; /*! \class ATEXIT_ * @@ -72,15 +72,16 @@ public : * * La liste chaînée Destructeurs est détruite dans la fonction Nettoyage. */ - //CCRT ATEXIT_( void ) + //CCRT ATEXIT_( void ) ATEXIT_( bool Make_ATEXIT ) { //CCRT if ( Make_ATEXIT && !ATEXIT_Done ) { //CCRT - ASSERT (Destructeurs==0); + ASSERT (DESTRUCTEUR_GENERIQUE_::Destructeurs==0); if(MYDEBUG) MESSAGE("Construction ATEXIT"); // message necessaire pour utiliser logger dans Nettoyage (cf.BUG KERNEL4561) - Destructeurs = new list ; // Destructeurs alloué dynamiquement (cf. ci-dessous) , + DESTRUCTEUR_GENERIQUE_::Destructeurs = + new std::list ; // Destructeurs alloué dynamiquement (cf. ci-dessous) , // il est utilisé puis détruit par la fonction Nettoyage int cr = atexit( Nettoyage ); // exécute Nettoyage lors de exit, après la destruction des données statiques ! ASSERT(cr==0) ; @@ -111,30 +112,30 @@ static ATEXIT_ nettoyage = ATEXIT_( false ); /* singleton statique */ void Nettoyage( void ) { if(MYDEBUG) BEGIN_OF("Nettoyage( void )") ; - ASSERT(Destructeurs) ; - if(MYDEBUG) SCRUTE( Destructeurs->size() ) ; - if( Destructeurs->size() ) + ASSERT(DESTRUCTEUR_GENERIQUE_::Destructeurs) ; + if(MYDEBUG) SCRUTE( DESTRUCTEUR_GENERIQUE_::Destructeurs->size() ) ; + if( DESTRUCTEUR_GENERIQUE_::Destructeurs->size() ) { - list::iterator it = Destructeurs->end() ; + std::list::iterator it = DESTRUCTEUR_GENERIQUE_::Destructeurs->end() ; do { if(MYDEBUG) MESSAGE( "DESTRUCTION d'un SINGLETON"); it-- ; DESTRUCTEUR_GENERIQUE_* ptr = *it ; - //Destructeurs->remove( *it ) ; + //DESTRUCTEUR_GENERIQUE_::Destructeurs->remove( *it ) ; (*ptr)() ; delete ptr ; - }while( it!= Destructeurs->begin() ) ; + }while( it!= DESTRUCTEUR_GENERIQUE_::Destructeurs->begin() ) ; - Destructeurs->clear() ; - if(MYDEBUG) SCRUTE( Destructeurs->size() ) ; - ASSERT( Destructeurs->size()==0 ) ; - ASSERT( Destructeurs->empty() ) ; + DESTRUCTEUR_GENERIQUE_::Destructeurs->clear() ; + if(MYDEBUG) SCRUTE( DESTRUCTEUR_GENERIQUE_::Destructeurs->size() ) ; + ASSERT( DESTRUCTEUR_GENERIQUE_::Destructeurs->size()==0 ) ; + ASSERT( DESTRUCTEUR_GENERIQUE_::Destructeurs->empty() ) ; } - delete Destructeurs; - Destructeurs=0; + delete DESTRUCTEUR_GENERIQUE_::Destructeurs; + DESTRUCTEUR_GENERIQUE_::Destructeurs=0; if(MYDEBUG) END_OF("Nettoyage( void )") ; return ; } diff --git a/src/Utils/Utils_DESTRUCTEUR_GENERIQUE.hxx b/src/Utils/Utils_DESTRUCTEUR_GENERIQUE.hxx index 6cf3432c1..02491fb29 100644 --- a/src/Utils/Utils_DESTRUCTEUR_GENERIQUE.hxx +++ b/src/Utils/Utils_DESTRUCTEUR_GENERIQUE.hxx @@ -29,6 +29,7 @@ # if !defined( __DESTRUCTEUR_GENERIQUE__H__ ) # define __DESTRUCTEUR_GENERIQUE__H__ +# include # include # include "utilities.h" @@ -56,6 +57,8 @@ class DESTRUCTEUR_GENERIQUE_ { public : + static std::list *Destructeurs; + virtual ~DESTRUCTEUR_GENERIQUE_() {}//!< virtual destructor static const int Ajout( DESTRUCTEUR_GENERIQUE_ &objet );//!< adds a destruction object to the list of destructions virtual void operator()( void )=0 ;//!< performs the destruction @@ -105,13 +108,13 @@ public : typedef PortableServer::ServantBase TServant; if(_PtrObjet){ if(TServant* aServant = dynamic_cast(_PtrObjet)){ - MESSAGE("deleting ServantBase's _PtrObjet"); + //MESSAGE("deleting ServantBase's _PtrObjet"); PortableServer::POA_var aPOA = aServant->_default_POA(); PortableServer::ObjectId_var anObjectId = aPOA->servant_to_id(aServant); aPOA->deactivate_object(anObjectId.in()); aServant->_remove_ref(); }else{ - MESSAGE("deleting _PtrObjet"); + //MESSAGE("deleting _PtrObjet"); TYPE* aPtr = static_cast(_PtrObjet); delete aPtr; } diff --git a/src/Utils/Utils_ExceptHandlers.hxx b/src/Utils/Utils_ExceptHandlers.hxx index 7996ae922..572243e26 100644 --- a/src/Utils/Utils_ExceptHandlers.hxx +++ b/src/Utils/Utils_ExceptHandlers.hxx @@ -36,18 +36,30 @@ typedef void (*PVF)(); class Unexpect { //save / retrieve unexpected exceptions treatment PVF old; public : +#ifndef WNT Unexpect( PVF f ) { old = std::set_unexpected(f); } ~Unexpect() { std::set_unexpected(old); } +#else + Unexpect( PVF f ) + { old = ::set_unexpected(f); } + ~Unexpect() { ::set_unexpected(old); } +#endif }; class Terminate {//save / retrieve terminate function PVF old; public : +#ifndef WNT Terminate( PVF f ) { old = std::set_terminate(f); } ~Terminate() { std::set_terminate(old); } +#else + Terminate( PVF f ) + { old = ::set_terminate(f); } + ~Terminate() { ::set_terminate(old); } +#endif }; #define UNEXPECT_CATCH(FuncName, ExceptionConstructor) \ diff --git a/src/Utils/Utils_Identity.cxx b/src/Utils/Utils_Identity.cxx index 570839bfa..f6ae3019f 100644 --- a/src/Utils/Utils_Identity.cxx +++ b/src/Utils/Utils_Identity.cxx @@ -27,19 +27,25 @@ // $Header$ # include -# include -# include -# include -# include # include "utilities.h" # include "Utils_Identity.hxx" -using namespace std; + extern "C" { # include + +#ifndef WNT /* unix functionality */ # include +#endif } +#ifndef WNT /* unix functionality */ + +# include +# include +# include +# include + const char* duplicate( const char *const str ) ; const struct utsname get_uname( void ) @@ -67,6 +73,59 @@ const char* const get_pwname( void ) return papa->pw_name ; } +#else /* Windows functionality */ + +#include +#include +#include + +const char* duplicate( const char *const str ) ; + +const char* get_uname( void ) +{ + char* hostName = new char[256]; + DWORD nSize = 256; + ASSERT(GetComputerName(hostName, &nSize)); + return hostName; +} + +const char* get_adip( void ) +{ + return get_uname(); +} + +const char* const get_pwname( void ) +{ + DWORD dwSize = 256 + 1; + char* retVal = new char[256]; + ASSERT(GetUserName ( retVal, &dwSize )); + return retVal; +} + +PSID getuid() { + PSID retVal = NULL; + HANDLE hProcessToken = INVALID_HANDLE_VALUE; + PTOKEN_OWNER pTKowner = NULL; + LPVOID buffer = NULL; + DWORD dwsize = 0; + + if ( !OpenProcessToken ( GetCurrentProcess (), TOKEN_QUERY, &hProcessToken )) return 0; + if (!GetTokenInformation(hProcessToken, TokenOwner, buffer, dwsize, &dwsize)) return 0; + pTKowner = (PTOKEN_OWNER)buffer; + if ( pTKowner != NULL ) { + retVal = pTKowner->Owner; + } + if ( hProcessToken != INVALID_HANDLE_VALUE ) CloseHandle ( hProcessToken ); + + return retVal; +} + +#define getcwd _getcwd +#define getpid _getpid + +#endif /* WNT */ + + Identity::Identity( const char *name ): _name(duplicate(name)),\ _hostid(get_uname()),\ _adip(get_adip()),\ @@ -103,15 +162,29 @@ const char* const Identity::name (void) const { return _name ; } -const pid_t &Identity::pid(void) const +#ifndef WNT + const pid_t& Identity::pid(void) const +#else + const DWORD& Identity::pid(void) const +#endif { return _pid ; } -const struct utsname &Identity::hostid(void) const + +#ifndef WNT + const struct utsname &Identity::hostid(void) const +#else + const char* const hostid(void) const +#endif { - return _hostid ; + return _hostid ; } -const uid_t &Identity::uid(void) const + +#ifndef WNT + const uid_t& Identity::uid(void) const +#else + const PSID& Identity::uid(void) const +#endif { return _uid ; } @@ -138,7 +211,11 @@ const char* const Identity::adip (void) const const char* Identity::host_char( void ) const { - return _hostid.nodename; +#ifndef WNT + return _hostid.nodename; +#else + return _hostid; +#endif } const char* Identity::start_char(void) const @@ -146,18 +223,22 @@ const char* Identity::start_char(void) const return ctime(&_start) ; } -ostream & operator<< ( ostream& os , const Identity& monid ) +std::ostream & operator<< ( std::ostream& os , const Identity& monid ) { ASSERT(monid._name!=NULL) ; - os << "Identity :" << endl ; - os << '\t' << "Component name : " << monid._name << endl ; - os << '\t' << "Numero de PID : " << monid._pid << endl; - os << '\t' << "Uid utilisateur : " << monid._uid << endl; - os << '\t' << "nom utilisateur : " << monid._pwname << endl; - os << '\t' << "Nom de machine : " << (monid._hostid).nodename << endl; - os << '\t' << "Adresse IP : " << monid._adip << endl; + os << "Identity :" << std::endl ; + os << '\t' << "Component name : " << monid._name << std::endl ; + 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 + os << '\t' << "Nom de machine : " << monid._hostid.nodename << std::endl; +#else + os << '\t' << "Nom de machine : " << monid._hostid << std::endl; +#endif + os << '\t' << "Adresse IP : " << monid._adip << std::endl; os << '\t' << "Heure de lancement : " << monid._cstart ; //ctime(&monid._start) ; - os << '\t' << "Dans le repertoire : " << monid._dir << endl; + os << '\t' << "Dans le repertoire : " << monid._dir << std::endl; return os ; } diff --git a/src/Utils/Utils_Identity.hxx b/src/Utils/Utils_Identity.hxx index 78d4ab8e2..9f4ca4704 100644 --- a/src/Utils/Utils_Identity.hxx +++ b/src/Utils/Utils_Identity.hxx @@ -32,9 +32,13 @@ extern "C" { # include -# include # include +#ifndef WNT +# include # include +#else +# include +#endif } class Identity @@ -42,31 +46,43 @@ class Identity protected : const char* const _name ; - const struct utsname _hostid; const char* const _adip; // Internet address + +#ifndef WNT + const struct utsname _hostid; + const pid_t _pid ; const uid_t _uid ; - const char* const _pwname ; +#else + const char* const _hostid; + const DWORD _pid ; + const PSID _uid ; +#endif + const char* const _pwname ; const char* const _dir ; - const pid_t _pid ; const time_t _start; const char* const _cstart ; - private : Identity( void ); Identity( const Identity &monid ); - public : Identity(const char *name); ~Identity(); friend std::ostream & operator<< ( std::ostream& os , const Identity& monid ); +#ifndef WNT + const pid_t& pid(void) const; + const struct utsname& hostid(void) const; + const uid_t& uid(void) const; +#else + const DWORD& pid(void) const; + const char* const hostid(void) const; + const PSID& uid(void) const; +#endif + const char* const name( void ) const; - const pid_t& pid(void) const; - const struct utsname& hostid(void) const; const char* const adip(void) const; - const uid_t& uid(void) const; const char* const pwname(void) const; const time_t& start(void) const; const char* const rep (void) const; diff --git a/src/Utils/Utils_ORB_INIT.cxx b/src/Utils/Utils_ORB_INIT.cxx index 5ac639246..bc5a7c37c 100644 --- a/src/Utils/Utils_ORB_INIT.cxx +++ b/src/Utils/Utils_ORB_INIT.cxx @@ -28,22 +28,22 @@ # include "Utils_ORB_INIT.hxx" # include "utilities.h" -using namespace std; + +# include "SALOMEconfig.h" ORB_INIT::ORB_INIT( void ): _orb( CORBA::ORB::_nil() ) { - ; } ORB_INIT::~ORB_INIT() { - if ( ! CORBA::is_nil( _orb ) ) - { - MESSAGE("appel _orb->destroy()") ; - _orb->destroy() ; - MESSAGE("retour _orb->destroy()") ; - } + if ( ! CORBA::is_nil( _orb ) ) + { + //MESSAGE("appel _orb->destroy()") ; + _orb->destroy() ; + //MESSAGE("retour _orb->destroy()") ; + } } diff --git a/src/Utils/Utils_SALOME_Exception.cxx b/src/Utils/Utils_SALOME_Exception.cxx index 6db802be8..dcb4ed95c 100644 --- a/src/Utils/Utils_SALOME_Exception.cxx +++ b/src/Utils/Utils_SALOME_Exception.cxx @@ -29,7 +29,6 @@ #include #include "Utils_SALOME_Exception.hxx" #include "utilities.h" -using namespace std; extern "C" { #include @@ -89,8 +88,9 @@ SALOME_Exception::~SALOME_Exception() throw () { if ( _text ) { - delete [] _text ; - _text = 0 ; + delete [] ((char*)_text); + char** pRef = (char**)&_text; + *pRef = 0; } ASSERT(_text==NULL) ; } @@ -103,7 +103,7 @@ SALOME_Exception::SALOME_Exception( const SALOME_Exception &ex ): _text(duplicat } -ostream & operator<<( ostream &os , const SALOME_Exception &ex ) +std::ostream & operator<<( std::ostream &os , const SALOME_Exception &ex ) { os << ex._text ; return os ; diff --git a/src/Utils/Utils_SINGLETON.hxx b/src/Utils/Utils_SINGLETON.hxx index 79d484389..4447b3de7 100644 --- a/src/Utils/Utils_SINGLETON.hxx +++ b/src/Utils/Utils_SINGLETON.hxx @@ -147,11 +147,11 @@ template int SINGLETON_::Destruction( void ) std::list::iterator k ; - for( k=DESTRUCTEUR_GENERIQUE_::Destructeurs.begin() ; k!=DESTRUCTEUR_GENERIQUE_::Destructeurs.end();k++) + for( k=DESTRUCTEUR_GENERIQUE_::Destructeurs->begin() ; k!=DESTRUCTEUR_GENERIQUE_::Destructeurs->end();k++) { if ( *k == PtrSingleton->_Instance ) { - DESTRUCTEUR_GENERIQUE_::Destructeurs.erase( k ) ; + DESTRUCTEUR_GENERIQUE_::Destructeurs->erase( k ) ; break ; } } diff --git a/src/Utils/Utils_SignalsHandler.cxx b/src/Utils/Utils_SignalsHandler.cxx index e0940bfda..c96747334 100644 --- a/src/Utils/Utils_SignalsHandler.cxx +++ b/src/Utils/Utils_SignalsHandler.cxx @@ -24,7 +24,6 @@ #include #include "Utils_SignalsHandler.h" -using namespace std; //============================================================================ @@ -78,12 +77,15 @@ static void RestoreSigHandler(TSigHandler theSigHandler, //======================================================================= Utils_SignalsHandler::Utils_SignalsHandler() { - StoreSignalHandler(mySigHandlerCont,SIGHUP); // end of leader process - StoreSignalHandler(mySigHandlerCont,SIGFPE); // floating point exception - - StoreSignalHandler(mySigHandlerCont,SIGINT); // interrupt + // asv 28.02.05 : some signals are not defined on Windows.. why? I don't know.. +#ifndef WNT + StoreSignalHandler(mySigHandlerCont,SIGHUP); // floating point exception StoreSignalHandler(mySigHandlerCont,SIGQUIT); // quit StoreSignalHandler(mySigHandlerCont,SIGBUS); // bus error + StoreSignalHandler(mySigHandlerCont,SIGSTKFLT); // stack fault. +#endif + StoreSignalHandler(mySigHandlerCont,SIGFPE); // floating point exception + StoreSignalHandler(mySigHandlerCont,SIGINT); // interrupt StoreSignalHandler(mySigHandlerCont,SIGILL); // illegal instruction StoreSignalHandler(mySigHandlerCont,SIGTERM); // termination StoreSignalHandler(mySigHandlerCont,SIGSEGV); // segmentation diff --git a/src/Utils/Utils_Timer.cxx b/src/Utils/Utils_Timer.cxx index 67153429e..65325f103 100644 --- a/src/Utils/Utils_Timer.cxx +++ b/src/Utils/Utils_Timer.cxx @@ -25,23 +25,35 @@ // Module : SALOME # include "Utils_Timer.hxx" + # include #include "utilities.h" -using namespace std; +#ifndef WNT static struct timezone *tz=(struct timezone*) malloc(sizeof(struct timezone)); +#else +//timezone *tz=_timezone; +#endif #ifndef CLK_TCK # define CLK_TCK CLOCKS_PER_SEC #endif Utils_Timer::Utils_Timer() { +#ifndef WNT RefToInitialTMS = new tms; RefToCurrentTMS = new tms; RefToInitialTimeB = new timeval; RefToCurrentTimeB = new timeval; +#else + RefToInitialTMS = new FILETIME; + RefToCurrentTMS = new FILETIME; + + RefToInitialTimeB = new time_t; + RefToCurrentTimeB = new time_t; +#endif Cumul_user = Cumul_sys = 0.; Stopped = 1; @@ -58,22 +70,37 @@ Utils_Timer::~Utils_Timer() { void Utils_Timer::Start() { if (Stopped) { Stopped = 0; +#ifndef WNT times(RefToInitialTMS); gettimeofday(RefToInitialTimeB,tz); +#else + SYSTEMTIME st; + GetSystemTime(&st); + SystemTimeToFileTime(&st, RefToInitialTMS); + time(RefToCurrentTimeB); +#endif } } void Utils_Timer::Stop() { if (!Stopped) { +#ifndef WNT times(RefToCurrentTMS); int diffr_user = RefToCurrentTMS->tms_utime - RefToInitialTMS->tms_utime; int diffr_sys = RefToCurrentTMS->tms_stime - RefToInitialTMS->tms_stime; gettimeofday(RefToCurrentTimeB,tz); - + Cumul_user += (double) diffr_user / CLK_TCK ; Cumul_sys += (double) diffr_sys / CLK_TCK ; - - Stopped = 1; +#else + SYSTEMTIME st; + GetSystemTime(&st); + SystemTimeToFileTime(&st, RefToCurrentTMS); + Cumul_user += (int)(((ULARGE_INTEGER*)(RefToCurrentTMS))->QuadPart - ((ULARGE_INTEGER*)(RefToInitialTMS))->QuadPart) / 10000000; + Cumul_sys = Cumul_user; + time(RefToCurrentTimeB); +#endif + Stopped = 1; } } @@ -91,6 +118,10 @@ void Utils_Timer::Reset() { } void Utils_Timer::ShowAbsolute(){ +#ifndef WNT unsigned long Absolute_user = (unsigned long) ((timeval*)RefToCurrentTimeB)->tv_sec ; +#else + unsigned long Absolute_user = *RefToCurrentTimeB; +#endif MESSAGE("Absolute time: " << Absolute_user << " seconds "); } diff --git a/src/Utils/Utils_Timer.hxx b/src/Utils/Utils_Timer.hxx index 06e10671b..603323e4d 100644 --- a/src/Utils/Utils_Timer.hxx +++ b/src/Utils/Utils_Timer.hxx @@ -27,9 +27,16 @@ #include #include +#ifndef WNT # include # include # include +#else +# include +# include +# include +#define _POSIX_ +#endif class Utils_Timer { public: @@ -44,6 +51,11 @@ class Utils_Timer { double Cumul_user; double Cumul_sys; bool Stopped; +#ifndef WNT tms *RefToCurrentTMS, *RefToInitialTMS; timeval *RefToCurrentTimeB, *RefToInitialTimeB; +#else + FILETIME *RefToCurrentTMS, *RefToInitialTMS; + time_t *RefToCurrentTimeB, *RefToInitialTimeB; +#endif }; diff --git a/src/Utils/duplicate.cxx b/src/Utils/duplicate.cxx index fa6cff737..b1e449ce4 100644 --- a/src/Utils/duplicate.cxx +++ b/src/Utils/duplicate.cxx @@ -31,10 +31,11 @@ * It is strongly (and only) used in the Registry environment * (RegistryService, RegistryConnexion, Identity, ...) */ - -#include -#include - +extern "C" +{ +#include +#include +} #include "utilities.h" using namespace std; -- 2.39.2