-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
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= \
$(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:
@MODULE@
-install: install-bin install-include install-make install-end
+install: install-bin install-include install-make install-plugin install-end
-THIS IS SALOME - KERNEL VERSION: 2.2.0
+THIS IS SALOME - KERNEL VERSION: 3.0.0
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()
-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"):
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):
# -----------------------------------------------------------------------------
-### 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
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()
except:
pass
-args["port"] = my_port
+args[port_nam] = my_port
# -----------------------------------------------------------------------------
### 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
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",
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()
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()
# --------------------------------------------------------------------------
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
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
\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} &
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} "
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):
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")
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 + "; "
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
# -----------------------------------------------------------------------------
#
-# 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:
+ 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
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=[]
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
'(','--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=[]
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
def startGUI():
"""Salome Session Graphic User Interface activation"""
import SALOME
+ import SALOME_Session_idl
session=clt.waitNS("/Kernel/Session",SALOME.Session)
session.GetInterface()
print "startSalome ", args
- if args['gui']:
- myServer=SessionLoader(args)
- myServer.run()
+ #if args['gui']:
+ # myServer=SessionLoader(args)
+ # myServer.run()
#
# Initialisation ORB et Naming Service
#
# 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']:
#
# 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
#
#
# 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
#
# 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']:
#
# Lancement Container Python local,
- # attente de la disponibilité du Container Python local
+ # attente de la disponibilite du Container Python local
# dans le Naming Service
#
#
# Lancement Container Supervision local,
- # attente de la disponibilité du Container Supervision local
+ # attente de la disponibilite du Container Supervision local
# dans le Naming Service
#
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
#
#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')
<launchoptions>
<gui>yes</gui>
<logger>no</logger>
- <!-- <file>atrace.log</file> -->
<xterm>no</xterm>
<portkill>yes</portkill>
<killall>no</killall>
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
echo ---------------------------------------------
echo
-openpbs_ok=no
+dnl openpbs_ok=no
CHECK_OPENPBS
dnl openpbs_ok is set to yes by CHECK_OPENPBS
echo ---------------------------------------------
echo
-lsf_ok=no
+dnl lsf_ok=no
CHECK_LSF
dnl lsf_ok is set to yes by CHECK_LSF
../../../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 \
SALOME_RessourcesCatalog.idl \
SALOMEDS.idl \
SALOMEDS_Attributes.idl \
- SALOME_Session.idl \
SALOME_Component.idl \
SALOME_ContainerManager.idl \
SALOME_TestComponent.idl \
#define _SALOMEDS_IDL_
#include "SALOME_Exception.idl"
+#include "SALOME_GenericObj.idl"
/*!
This package contains the interfaces used for creation, managment
interface AttributeStudyProperties;
interface UseCaseIterator;
interface UseCaseBuilder;
- interface Callback;
/*! List of attributes of %SObjects
*/
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);
+
};
//==========================================================================
Defines the instance to the %SComponent.
*/
void DefineComponentInstance (in SComponent aComponent,in Object ComponentIOR) raises(LockProtection);
+
/*! \brief Deletion of a %SComponent
Removes a %SComponent.
*/
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
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);
+
+
};
*/
//==========================================================================
- interface SObject
+ interface SObject : SALOME::GenericObj
{
/*! Name of the %SObject
*/
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);
};
%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
*/
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);
};
The search is started from the first %SComponent in the list.
*/
//==========================================================================
- interface SComponentIterator
+ interface SComponentIterator : SALOME::GenericObj
{
/*!
Activates the %SComponentIterator.
levels.
*/
//==========================================================================
- interface ChildIterator
+ interface ChildIterator : SALOME::GenericObj
{
/*!
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.
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.
UseCaseIterator GetUseCaseIterator(in SObject theObject);
};
//==========================================================================
- //==========================================================================
-/*! \brief The callback interface
-
- The %StudyBuilder can be created with the method <VAR>NewBuilder</VAR>. While invocation of this method a new object of the class <VAR>Callback</VAR> 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 <VAR>Append</VAR> of the %UseCaseBuilder.
-*/
- void OnAddSObject(in SObject theObject);
-/*!
- Invokes the corresponding method <VAR>Remove</VAR> 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
//
// 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<octet> TMPFile;
+
+ /*!
General Key Value Structure to set or get properties, for component
-*/
+ */
struct KeyValuePair
{
string key;
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);
+
} ;
} ;
/*!
Type to describe properties of wanted resource.
*/
-struct MachineParameters {
+struct MachineParameters
+{
string container_name;
string hostname;
string OS;
*/
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();
} ;
<component-username>Salome</component-username>
<component-type>Other</component-type>
<component-author>NRI</component-author>
- <component-version>2.2.0</component-version>
+ <component-version>3.0.0</component-version>
<component-comment>GUI Neutral Context</component-comment>
<component-multistudy>1</component-multistudy>
<component-username>SalomeTestComponent</component-username>
<component-type>Other</component-type>
<component-author>NRI</component-author>
- <component-version>2.1.0</component-version>
+ <component-version>3.0.0</component-version>
<component-comment>GUI Neutral Context</component-comment>
<component-multistudy>1</component-multistudy>
<constraint>'linux' ~ OS</constraint>
<component-username>SALOME_TestComponentPy</component-username>
<component-type>Other</component-type>
<component-author>NRI</component-author>
- <component-version>2.1.0</component-version>
+ <component-version>3.0.0</component-version>
<component-comment>GUI Neutral Context</component-comment>
<component-multistudy>1</component-multistudy>
<constraint>'linux' ~ OS</constraint>
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
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=
AC_SUBST(DEPCXXFLAGS)
AC_SUBST(C_DEPEND_FLAG)
AC_SUBST(CXX_DEPEND_FLAG)
+ AC_SUBST(MACHINE)
])
])
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)
AC_SUBST(CAS_DATAEXCHANGE)
AC_SUBST(CAS_LDFLAGS)
AC_SUBST(CAS_LDPATH)
+AC_SUBST(CAS_STDPLUGIN)
OWN_CONFIG_H=no
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)
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
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
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"
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)
])
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
fi
WITHOPENPBS=$openpbs_ok
+ if test x$WITHOPENPBS = x ; then
+ WITHOPENPBS=no
+ fi
AC_SUBST(WITHOPENPBS)
])
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 ],
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
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"
AC_SUBST(QT_INCLUDES)
AC_SUBST(QT_LIBS)
AC_SUBST(QT_MT_LIBS)
+AC_SUBST(QT_VERS)
AC_LANG_RESTORE
])
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"
AC_DEFUN([CHECK_SIP],[
AC_REQUIRE([CHECK_PYTHON])dnl
+AC_REQUIRE([CHECK_QT])dnl
sip_ok=yes
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
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"
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@
# add corba libs when link salome application !
#LDFLAGS+= $(CORBA_LIBS)
LIBS+=$(CORBA_LIBS)
+LIBSFORBIN+=$(CORBA_LIBS)
DOXYGEN = @DOXYGEN@
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;
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
#
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 \
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 \
$(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
#include "CASCatch_SignalsHandler.h"
-#include <signal.h>
#include <OSD.hxx>
-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);
}
// Module : SALOME
// $Header$
+//#define private protected // for pd_refCount trace
#include "SALOME_Component_i.hxx"
#include "SALOME_Container_i.hxx"
#include "RegistryConnexion.hxx"
#include <dlfcn.h>
#include <cstdlib>
#include "utilities.h"
+
+#include <sys/time.h>
+#include <sys/resource.h>
+#include <unistd.h>
+
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,
_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;
_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");
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)
{
}
}
+//=============================================================================
+/*!
+ * 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;
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<<endl;
+ }
+ return cpu ;
+}
+
+//=============================================================================
+/*!
+ * C++ method: set study Id
+ * \param studyId 0 if instance is not associated to a study,
+ * >0 otherwise (== study id)
+ * \return true if the set of study Id is OK
+ * must be set once by Container, 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 " <<serviceName
+ << endl << "Component instance : " << _instanceName << endl << endl);
_ThreadId = pthread_self() ;
_StartUsed = 0 ;
_StartUsed = CpuUsed_impl() ;
_ThreadCpuUsed = 0 ;
_Executed = true ;
_serviceName = serviceName ;
- if ( pthread_setcanceltype( PTHREAD_CANCEL_ASYNCHRONOUS , NULL ) ) {
- perror("pthread_setcanceltype ") ;
- exit(0) ;
- }
- if ( pthread_setcancelstate( PTHREAD_CANCEL_ENABLE , NULL ) ) {
- perror("pthread_setcancelstate ") ;
- exit(0) ;
- }
+ if ( pthread_setcanceltype( PTHREAD_CANCEL_ASYNCHRONOUS , NULL ) )
+ {
+ perror("pthread_setcanceltype ") ;
+ exit(0) ;
+ }
+ if ( pthread_setcancelstate( PTHREAD_CANCEL_ENABLE , NULL ) )
+ {
+ perror("pthread_setcancelstate ") ;
+ exit(0) ;
+ }
// MESSAGE(pthread_self() << " Return from BeginService for " << serviceName
// << " ThreadId " << _ThreadId << " StartUsed " << _StartUsed
// << " _graphName " << _graphName << " _nodeName " << _nodeName );
{
const char* value;
(*it).second >>= 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
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
}
}
+//=============================================================================
+/*!
+ * 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 <<endl);
_ThreadId = 0 ;
}
-void Engines_Component_i::Names( const char * graphName ,
- const char * nodeName ) {
- _graphName = graphName ;
- _nodeName = nodeName ;
-// MESSAGE("Engines_Component_i::Names( '" << _graphName << "' , '"
-// << _nodeName << "' )");
-}
+//=============================================================================
+/*!
+ * C++ method: -- CHECK IF USED --
+ */
+//=============================================================================
-char* Engines_Component_i::graphName() {
+char* Engines_Component_i::graphName()
+{
return CORBA::string_dup( _graphName.c_str() ) ;
}
-char* Engines_Component_i::nodeName() {
+//=============================================================================
+/*!
+ * C++ method: -- CHECK IF USED --
+ */
+//=============================================================================
+
+char* Engines_Component_i::nodeName()
+{
return CORBA::string_dup( _nodeName.c_str() ) ;
}
-bool Engines_Component_i::Killer( pthread_t ThreadId , int signum ) {
- if ( ThreadId ) {
- if ( signum == 0 ) {
- if ( pthread_cancel( ThreadId ) ) {
- perror("Killer pthread_cancel error") ;
- return false ;
- }
- else {
- MESSAGE(pthread_self() << "Killer : ThreadId " << ThreadId << " pthread_canceled") ;
- }
- }
- else {
- if ( pthread_kill( ThreadId , signum ) == -1 ) {
- perror("Killer pthread_kill error") ;
- return false ;
- }
- else {
- MESSAGE(pthread_self() << "Killer : ThreadId " << ThreadId << " pthread_killed("
- << signum << ")") ;
- }
+//=============================================================================
+/*!
+ * C++ method: used in Supervision (see kill_impl)
+ */
+//=============================================================================
+
+bool Engines_Component_i::Killer( pthread_t ThreadId , int signum )
+{
+ if ( ThreadId )
+ {
+ if ( signum == 0 )
+ {
+ if ( pthread_cancel( ThreadId ) )
+ {
+ perror("Killer pthread_cancel error") ;
+ return false ;
+ }
+ else
+ {
+ MESSAGE(pthread_self() << "Killer : ThreadId " << ThreadId
+ << " pthread_canceled") ;
+ }
+ }
+ else
+ {
+ if ( pthread_kill( ThreadId , signum ) == -1 )
+ {
+ perror("Killer pthread_kill error") ;
+ return false ;
+ }
+ else
+ {
+ MESSAGE(pthread_self() << "Killer : ThreadId " << ThreadId
+ << " pthread_killed(" << signum << ")") ;
+ }
+ }
}
- }
return true ;
}
-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 ;
-}
+//=============================================================================
+/*!
+ * 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 <sys/time.h>
-#include <sys/resource.h>
-#include <unistd.h>
+//=============================================================================
+/*!
+ * 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";
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();
+}
// Module : SALOME
// $Header$
+//#define private public
#include <SALOMEconfig.h>
#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 <string.h>
#include <stdio.h>
#include <dlfcn.h>
#include <unistd.h>
+#include <Python.h>
+#include "Container_init_python.hxx"
#include "utilities.h"
using namespace std;
extern "C" {void SigIntHandler(int, siginfo_t *, void *) ; }
const char *Engines_Container_i::_defaultContainerName="FactoryServer";
+map<std::string, int> Engines_Container_i::_cntInstances_map;
+map<std::string, void *> Engines_Container_i::_library_map;
+map<std::string, void *> 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 ,
_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_<SALOME_NamingService>::Instance() ;
- //ASSERT(SINGLETON_<SALOME_NamingService>::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()");
_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 "<<componentName);
+ if (_isSupervContainer)
+ {
+ INFOS('Supervision Container does not support Python Component Engines');
+ return false;
+ }
+ if (_library_map[aCompName])
+ {
+ return true; // Python Component, already imported
+ }
+ else
+ {
+ 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,
+ "import_component",
+ "s",componentName);
+ int ret= PyInt_AsLong(result);
+ SCRUTE(ret);
+ Py_RELEASE_NEW_THREAD;
- string factory_name = _nameToRegister + string("Engine_factory");
- // SCRUTE(factory_name) ;
+ if (ret) // import possible: Python component
+ {
+ _library_map[aCompName] = (void *)pyCont; // any non O value OK
+ MESSAGE("import Python: "<<aCompName<<" OK");
+ return true;
+ }
+ }
+ return false;
+}
- 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());
+//=============================================================================
+/*!
+ * CORBA method: Creates a new servant instance of a component.
+ * The servant registers itself to naming service and Registry.
+ * \param genericRegisterName Name of the component instance to register
+ * in Registry & Name Service (without _inst_n suffix)
+ * \param studyId 0 for multiStudy instance,
+ * study Id (>0) otherwise
+ * \return a loaded component
+ */
+//=============================================================================
- 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<string,Engines::Component_var>::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<string, void *>::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<string, void *>::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<Engines_Component_i*>
+ (_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<string, void *>::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<Engines_Component_i*>(_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) ;
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
}
}
-// 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()) ;
+// }
@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
return 0
#-------------------------------------------------------------------------
+
+ def DumpPython(self, theStudy, isPublished):
+ aBuffer = "def RebuildData(theStudy): pass"
+ return (aBuffer, 1)
+ #-------------------------------------------------------------------------
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;
#include "SALOME_Container_i.hxx"
#include "utilities.h"
#include "SALOMETraceCollector.hxx"
+#include "OpUtil.hxx"
#ifdef CHECKTIME
#include <Utils_Timer.hxx>
#include <mpi.h>
#endif
-#include <Python.h>
+#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_<ORB_INIT>::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
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" );
{
_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);
}
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<std::string, int> _cntInstances_map;
+ static std::map<std::string, void *> _library_map; // library names, loaded
+ static std::map<std::string, void *> _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;
PortableServer::POA_var _poa;
PortableServer::ObjectId * _id ;
int _numInstance ;
- std::map<std::string, void *> handle_map ;
- std::map<std::string, void *> remove_map ;
- omni_mutex _numInstanceMutex ; // if several threads on the same object
+ std::map<std::string,Engines::Component_var> _listInstances_map;
//private:
- int _argc ;
+ int _argc ;
char** _argv ;
- long _pid;
- bool _isServantAloneInProcess;
+ long _pid;
+ bool _isServantAloneInProcess;
};
#endif
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@
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))
{
#include <Launchers.hxx>
+#include "utilities.h"
+
+using namespace std;
static int Launchers_IsLoaded = 0;
static PyObject * Launchers_module = 0;
}
void Launchers_assertInitialized() {
+ MESSAGE("===========================================================");
+ MESSAGE("Launchers_assertInitialized");
+ MESSAGE("===========================================================");
PyThreadState *_save;
if( !Py_IsInitialized() ) {
+ MESSAGE("===========================================================");
+ MESSAGE("Py_Initialize()");
+ MESSAGE("===========================================================");
Py_Initialize();
PyEval_InitThreads();
PyEval_SaveThread();
#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&)
{
{
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("/");
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')
for(unsigned int i=0;i<listOfMachines.length();i++)
{
const char *currentMachine=listOfMachines[i];
- string componentNameForNS=Engines_Component_i::BuildComponentNameForNS(componentName,containerName,currentMachine);
- CORBA::Object_var obj = _NS->Resolve(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);
{
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
}
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";
* 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 ) ;
+}
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
cout << m4->instanceName() << endl;
}
- catch(CORBA::COMM_FAILURE& ex)
+ catch(CORBA::SystemException& ex)
{
INFOS("Caught system exception COMM_FAILURE -- unable to contact the object.");
}
#include "SALOME_Logger_Server.hxx"
#include <SALOMEconfig.h>
#include <sys/types.h>
-#include <unistd.h>
-using namespace std;
-
+#ifndef __WIN32__
+# include <unistd.h>
+#endif
omni_mutex Logger::myLock;
/////////////////////////////////////////////////////////////////////
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
{
myLock.lock();
if (m_putIntoFile)
- m_outputFile << message << flush;
+ m_outputFile << message << std::flush;
else
- cout << message;
+ std::cout << message;
myLock.unlock();
}
{
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};
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"<<endl;
- }
- catch(...) {
- //cout<<"Logger Server: Unknown exception dealed with Naming Service" <<endl;
- }
- if (!CORBA::is_nil(inc)) {
-// cout<<"Logger Server: Naming Service was found"<<endl;
- break;
- }
+ for (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"<<endl;
+ } catch(...) {
+ //cout<<"Logger Server: Unknown exception dealed with Naming Service" <<endl;
+ }
+
+ if (!CORBA::is_nil(inc)) {
+ // cout<<"Logger Server: Naming Service was found"<<endl;
+ break;
+ }
}
if (argc == 1)
- myLogger = new Logger();
+ myLogger = new Logger();
else
- myLogger = new Logger(argv[1]);
-
+ myLogger = new Logger(argv[1]);
myLoggerRef = myLogger->_this();
CosNaming::Name name;
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;
}
}
if (!CORBA::is_nil(theObj))
inc = CosNaming::NamingContext::_narrow(theObj);
if (!CORBA::is_nil(inc)) break;
- } catch( CORBA::COMM_FAILURE& ) {
+ } catch( CORBA::SystemException& ) {
} catch (...) {
}
}
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."
#include <boost/shared_ptr.hpp>
+#include "SALOMEconfig.h"
+
namespace MED{
enum EVersion {eVUnknown = -1, eV2_1, eV2_2};
operator const T& () const
{
- return *get();
+ return *(this->get());
}
operator T& ()
{
- return *get();
+ return *(this->get());
}
};
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;
EGeometrieElement theTGeom,
EConnectivite theTConn,
const TIntVector& theConnectivities,
+ const TIntVector& theIndexes,
const TIntVector& theFamilyNums,
const TIntVector& theElemNums,
const TStringVector& theElemNames = TStringVector())
EGeometrieElement theTGeom,
EConnectivite theTConn,
const TIntVector& theConnectivities,
+ const TIntVector& theFaces,
+ const TIntVector& theIndexes,
const TIntVector& theFamilyNums,
const TIntVector& theElemNums,
const TStringVector& theElemNames = TStringVector())
BIN =
BIN_SRC =
-CPPFLAGS+= $(BOOST_CPPFLAGS) $(HDF5_INCLUDES)
+CPPFLAGS+= $(BOOST_CPPFLAGS) $(HDF5_INCLUDES) -D@MACHINE@
LDFLAGS+=
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)
&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;
&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],
MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
- med_repere& aRepere = static_cast<med_repere>(theInfo.mySystem);
- med_booleen& anIsElemNames = static_cast<med_booleen>(theInfo.myIsElemNames);
- med_booleen& anIsElemNum = static_cast<med_booleen>(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],
&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="<<aMeshInfo.myDim<<" myNbElem="<<theInfo.myNbElem<<" ... ");
MED::TNodeInfo& anInfo = const_cast<MED::TNodeInfo&>(theInfo);
MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
- med_repere& aRepere = static_cast<med_repere>(theInfo.mySystem);
- med_booleen& anIsElemNames = static_cast<med_booleen>(theInfo.myIsElemNames);
- med_booleen& anIsElemNum = static_cast<med_booleen>(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],
&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)
MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
TInt aNbElem = theInfo.myElemNum.size();
- med_booleen& anIsElemNames = static_cast<med_booleen>(theInfo.myIsElemNames);
- med_booleen& anIsElemNum = static_cast<med_booleen>(theInfo.myIsElemNum);
- med_entite_maillage& anEntity = static_cast<med_entite_maillage>(theInfo.myTEntity);
- med_geometrie_element& aGeom = static_cast<med_geometrie_element>(theInfo.myTGeom);
- med_connectivite& aConn = static_cast<med_connectivite>(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,
MED::TCellInfo& anInfo = const_cast<MED::TCellInfo&>(theInfo);
MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
- med_booleen& anIsElemNames = static_cast<med_booleen>(theInfo.myIsElemNames);
- med_booleen& anIsElemNum = static_cast<med_booleen>(theInfo.myIsElemNum);
- med_entite_maillage& anEntity = static_cast<med_entite_maillage>(theInfo.myTEntity);
- med_geometrie_element& aGeom = static_cast<med_geometrie_element>(theInfo.myTGeom);
- med_connectivite& aConn = static_cast<med_connectivite>(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,
if(theErr && *theErr < 0)
return;
- med_type_champ& aType = static_cast<med_type_champ>(theInfo.myType);
+ med_type_champ& aType = (med_type_champ&)(theInfo.myType);
TErr aRet = MEDchampInfo(myFile->Id(),
theFieldId,
MED::TFieldInfo& anInfo = const_cast<MED::TFieldInfo&>(theInfo);
- med_type_champ& aType = static_cast<med_type_champ>(theInfo.myType);
+ med_type_champ& aType = (med_type_champ&)(theInfo.myType);
TErr aRet = MEDchampCr(myFile->Id(),
&anInfo.myName[0],
MED::TFieldInfo& anInfo = const_cast<MED::TFieldInfo&>(theInfo);
TEntityInfo::const_iterator anIter = theEntityInfo.begin();
for(; anIter != theEntityInfo.end(); anIter++){
- const med_entite_maillage& anEntity = static_cast<const med_entite_maillage>(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<const med_geometrie_element>(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);
MED::TFieldInfo& aFieldInfo = *theInfo.myFieldInfo;
MED::TMeshInfo& aMeshInfo = *aFieldInfo.myMeshInfo;
- med_entite_maillage& anEntity = static_cast<med_entite_maillage>(theInfo.myEntity);
+ med_entite_maillage& anEntity = (med_entite_maillage&)(theInfo.myEntity);
TGeom::iterator anIter = aTGeom.begin();
- med_geometrie_element& aGeom = static_cast<med_geometrie_element>(anIter->first);
+ med_geometrie_element& aGeom = (med_geometrie_element&)(anIter->first);
TErr aRet = MEDpasdetempsInfo(myFile->Id(),
&aFieldInfo.myName[0],
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;
MED::TFieldInfo& aFieldInfo = *aTimeStampInfo.myFieldInfo;
MED::TMeshInfo& aMeshInfo = *aFieldInfo.myMeshInfo;
- med_entite_maillage& anEntity = static_cast<med_entite_maillage>(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<med_geometrie_element>(anIter->first);
+ med_geometrie_element& aGeom = (med_geometrie_element&)(anIter->first);
TInt aNbVal = MEDnVal(anId,
&aFieldInfo.myName[0],
anEntity,
MED::TMeshInfo& aMeshInfo = *aFieldInfo.myMeshInfo;
MED::TMeshValue& aMeshValue = aVal.myMeshValue;
- med_entite_maillage& anEntity = static_cast<med_entite_maillage>(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<med_geometrie_element>(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;
#include "med.hxx"
#include "med_outils.hxx"
+#include <stdlib.h>
/*
* - Nom de la fonction : _MEDdatasetNumEcrire
#include "med.hxx"
#include "med_outils.hxx"
+#include <stdlib.h>
/*
* - Nom de la fonction : _MEDdatasetNumLire
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
if(theErr && !*theErr)
return;
- med_maillage& aType = static_cast<med_maillage>(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)
MED::TMeshInfo& anInfo = const_cast<MED::TMeshInfo&>(theInfo);
- med_maillage& aType = static_cast<med_maillage>(theInfo.myType);
+ med_maillage& aType = (med_maillage&)(theInfo.myType);
TErr aRet = MEDmaaCr(myFile->Id(),
&anInfo.myName[0],
&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;
&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],
MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
- med_entite_maillage& anEntity = static_cast<med_entite_maillage>(theTEntity);
- med_geometrie_element& aGeom = static_cast<med_geometrie_element>(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],
MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
- med_entite_maillage& anEntity = static_cast<med_entite_maillage>(theTEntity);
- med_geometrie_element& aGeom = static_cast<med_geometrie_element>(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);
MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
- med_entite_maillage& anEntity = static_cast<med_entite_maillage>(theTEntity);
- med_geometrie_element& aGeom = static_cast<med_geometrie_element>(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);
MED::TElemInfo& anInfo = const_cast<MED::TElemInfo&>(theInfo);
MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
- med_booleen& anIsElemNames = static_cast<med_booleen>(theInfo.myIsElemNames);
- med_entite_maillage& anEntity = static_cast<med_entite_maillage>(theTEntity);
- med_geometrie_element& aGeom = static_cast<med_geometrie_element>(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){
MED::TElemInfo& anInfo = const_cast<MED::TElemInfo&>(theInfo);
MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
- med_booleen& anIsElemNum = static_cast<med_booleen>(theInfo.myIsElemNum);
- med_entite_maillage& anEntity = static_cast<med_entite_maillage>(theTEntity);
- med_geometrie_element& aGeom = static_cast<med_geometrie_element>(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);
MED::TElemInfo& anInfo = const_cast<MED::TElemInfo&>(theInfo);
MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
- med_entite_maillage& anEntity = static_cast<med_entite_maillage>(theTEntity);
- med_geometrie_element& aGeom = static_cast<med_geometrie_element>(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);
MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
- med_repere& aRepere = static_cast<med_repere>(theInfo.mySystem);
- med_booleen& anIsElemNames = static_cast<med_booleen>(theInfo.myIsElemNames);
- med_booleen& anIsElemNum = static_cast<med_booleen>(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],
&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;
MED::TNodeInfo& anInfo = const_cast<MED::TNodeInfo&>(theInfo);
MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
- med_repere& aRepere = static_cast<med_repere>(theInfo.mySystem);
- med_booleen& anIsElemNames = static_cast<med_booleen>(theInfo.myIsElemNames);
- med_booleen& anIsElemNum = static_cast<med_booleen>(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],
&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;
MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
TInt aNbElem = theInfo.myElemNum.size();
- med_entite_maillage& anEntity = static_cast<med_entite_maillage>(theInfo.myTEntity);
- med_connectivite& aConn = static_cast<med_connectivite>(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);
MED::TPolygoneInfo& anInfo = const_cast<MED::TPolygoneInfo&>(theInfo);
MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
- med_entite_maillage& anEntity = static_cast<med_entite_maillage>(theInfo.myTEntity);
- med_connectivite& aConn = static_cast<med_connectivite>(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);
MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
- med_entite_maillage& anEntity = static_cast<med_entite_maillage>(theTEntity);
- med_connectivite& aConn = static_cast<med_connectivite>(theTConn);
+ med_entite_maillage& anEntity = (med_entite_maillage&)(theTEntity);
+ med_connectivite& aConn = (med_connectivite&)(theTConn);
med_int taille = 0;
MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
TInt aNbElem = theInfo.myElemNum.size();
- med_connectivite& aConn = static_cast<med_connectivite>(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)
MED::TPolyedreInfo& anInfo = const_cast<MED::TPolyedreInfo&>(theInfo);
MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
- med_booleen& anIsElemNames = static_cast<med_booleen>(theInfo.myIsElemNames);
- med_booleen& anIsElemNum = static_cast<med_booleen>(theInfo.myIsElemNum);
- med_entite_maillage& anEntity = static_cast<med_entite_maillage>(theInfo.myTEntity);
- med_connectivite& aConn = static_cast<med_connectivite>(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)
if (anIsElemNum){
aRet = MEDnumEcr(myFile->Id(),
&aMeshInfo.myName[0],
- &anInfo.myElemNum[0],
+ (med_int *)&anInfo.myElemNum[0],
anInfo.myElemNum.size(),
anEntity,
MED_POLYEDRE);
aRet = MEDfamEcr(myFile->Id(),
&aMeshInfo.myName[0],
- &anInfo.myFamNum[0],
+ (med_int *)&anInfo.myFamNum[0],
anInfo.myFamNum.size(),
anEntity,
MED_POLYEDRE);
if(theErr && !*theErr) EXCEPTION(runtime_error,"GetPolyedreInfo - (...)");
MED::TMeshInfo& aMeshInfo = const_cast<MED::TMeshInfo&>(theMeshInfo);
- med_connectivite& aConn = static_cast<med_connectivite>(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;
MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo;
TInt aNbElem = theInfo.myElemNum.size();
- med_booleen& anIsElemNames = static_cast<med_booleen>(theInfo.myIsElemNames);
- med_booleen& anIsElemNum = static_cast<med_booleen>(theInfo.myIsElemNum);
- med_entite_maillage& anEntity = static_cast<med_entite_maillage>(theInfo.myTEntity);
- med_geometrie_element& aGeom = static_cast<med_geometrie_element>(theInfo.myTGeom);
- med_connectivite& aConn = static_cast<med_connectivite>(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,
MED::TCellInfo& anInfo = const_cast<MED::TCellInfo&>(theInfo);
MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo;
- med_booleen& anIsElemNames = static_cast<med_booleen>(theInfo.myIsElemNames);
- med_booleen& anIsElemNum = static_cast<med_booleen>(theInfo.myIsElemNum);
- med_entite_maillage& anEntity = static_cast<med_entite_maillage>(theInfo.myTEntity);
- med_geometrie_element& aGeom = static_cast<med_geometrie_element>(theInfo.myTGeom);
- med_connectivite& aConn = static_cast<med_connectivite>(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,
if(theErr && !*theErr)
return;
- med_type_champ& aType = static_cast<med_type_champ>(theInfo.myType);
+ med_type_champ& aType = (med_type_champ&)(theInfo.myType);
TErr aRet = MEDchampInfo(myFile->Id(),
theFieldId,
MED::TFieldInfo& anInfo = const_cast<MED::TFieldInfo&>(theInfo);
- med_type_champ& aType = static_cast<med_type_champ>(theInfo.myType);
+ med_type_champ& aType = (med_type_champ&)(theInfo.myType);
TErr aRet = MEDchampCr(myFile->Id(),
&anInfo.myName[0],
MED::TFieldInfo& anInfo = const_cast<MED::TFieldInfo&>(theInfo);
TEntityInfo::const_iterator anIter = theEntityInfo.begin();
for(; anIter != theEntityInfo.end(); anIter++){
- const med_entite_maillage& anEntity = static_cast<const med_entite_maillage>(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<const med_geometrie_element>(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)
MED::TFieldInfo& aFieldInfo = *theInfo.myFieldInfo;
MED::TMeshInfo& aMeshInfo = *aFieldInfo.myMeshInfo;
- med_entite_maillage& anEntity = static_cast<med_entite_maillage>(theInfo.myEntity);
+ med_entite_maillage& anEntity = (med_entite_maillage&)(theInfo.myEntity);
TGeom::iterator anIter = aTGeom.begin();
- med_geometrie_element& aGeom = static_cast<med_geometrie_element>(anIter->first);
+ med_geometrie_element& aGeom = (med_geometrie_element&)(anIter->first);
- med_booleen& anIsLocal = static_cast<med_booleen>(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)
MED::TFieldInfo& aFieldInfo = *aTimeStampInfo.myFieldInfo;
MED::TMeshInfo& aMeshInfo = *aFieldInfo.myMeshInfo;
- med_entite_maillage& anEntity = static_cast<med_entite_maillage>(aTimeStampInfo.myEntity);
- med_mode_profil& aPflMode = static_cast<med_mode_profil>(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<med_geometrie_element>(anIter->first);
+ med_geometrie_element& aGeom = (med_geometrie_element&)(anIter->first);
TInt aNbVal = MEDnVal(anId,
&aFieldInfo.myName[0],
anEntity,
MED::TMeshInfo& aMeshInfo = *aFieldInfo.myMeshInfo;
MED::TMeshValue& aMeshValue = aVal.myMeshValue;
- med_entite_maillage& anEntity = static_cast<med_entite_maillage>(aTimeStampInfo.myEntity);
- med_mode_profil& aPflMode = static_cast<med_mode_profil>(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<med_geometrie_element>(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;
{
string instanceName = compo->instanceName();
}
- catch (CORBA::COMM_FAILURE&)
+ catch (CORBA::SystemException&)
{
INFOS("Caught CORBA::SystemException CommFailure. Engine "
<< path << "does not respond" );
@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
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@
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))
{
{
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
}
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();
}
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];
{
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();
}
{
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();
}
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();
}
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];
{
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();
}
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<string> listElem = list_directory();
+ vector<string>::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
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();
}
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 ;
_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();
}
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 ;
_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();
}
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;
{
_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();
}
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
vector<string> SALOME_NamingService::list_directory_recurs()
throw(ServiceUnreachable)
{
+ MESSAGE("list_directory_recurs");
+ Utils_Locker lock(&_myMutex);
vector<string> _list ;
char *currentDir=Current_Directory();
_list_directory_recurs(_list,0,currentDir);
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];
{
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();
}
{
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();
}
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];
{
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();
}
{
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();
}
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();
}
{
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();
}
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(...)
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)
}
}
_binding_iterator->destroy();
+ }
// We go to the last directory where an occurence was found
_current_context = _ref_context ;
}
//----------------------------------------------------------------------
-char * SALOME_NamingService::getIORaddr(){
+char * SALOME_NamingService::getIORaddr()
+{
return _orb->object_to_string(_root_context);
}
#include <CORBA.h>
#include <vector>
#include <string>
+#include "Utils_Mutex.hxx"
//class ServiceUnreachable;
#include "ServiceUnreachable.hxx"
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);
char * getIORaddr();
protected:
+ Utils_Mutex _myMutex;
CORBA::ORB_ptr _orb;
CosNaming::NamingContext_var _root_context, _current_context;
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
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
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" )
#-------------------------------------------------------------------------
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
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" )
} 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 (...) {
};
} 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");
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))
{
#include <iostream>
#include <string.h>
#include <map>
+#include <list>
#include <sys/types.h>
#include <sys/stat.h>
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@
// Module : SALOME
// $Header$
-#include <iostream.h>
+#include <iostream>
#include "SALOME_NamingService.hxx"
#include "SALOME_RessourcesCatalog_impl.hxx"
#include "utilities.h"
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))
{
#define MESS_INIT(deb) std::ostringstream os; os<<deb
#define MESS_BEGIN(deb) MESS_INIT(deb)<<__FILE__ <<" ["<<__LINE__<<"] : "
-#define MESS_END endl; LocalTraceBufferPool::instance()->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 <<std::flush; \
- cerr << "- ABORT " << __FILE__ << " [" <<__LINE__<< "] : " << flush; \
- cerr << "ABORT return code= "<< code << endl; \
+#define IMMEDIATE_ABORT(code) {std::cout <<std::flush; \
+ std::cerr << "- ABORT " << __FILE__ << " [" <<__LINE__<< "] : " << flush; \
+ std::cerr << "ABORT return code= "<< code << std::endl; \
std::exit(code);}
/* --- To print date and time of compilation of current source --- */
if (!CORBA::is_nil(theObj))
inc = CosNaming::NamingContext::_narrow(theObj);
}
- catch( CORBA::COMM_FAILURE& )
+ catch( CORBA::SystemException& )
{
cout << "TraceCollector_WaitForServerReadiness: "
- << "CORBA::COMM_FAILURE: "
+ << "CORBA::SystemException: "
<< "Unable to contact the Naming Service" << endl;
}
catch(...)
# Executables targets
BIN =
BIN_SRC =
-LIB_SERVER_IDL = SALOMEDS.idl SALOMEDS_Attributes.idl SALOME_Exception.idl
+LIB_SERVER_IDL = SALOMEDS.idl SALOMEDS_Attributes.idl SALOME_Exception.idl SALOME_GenericObj.idl
BIN_SERVER_IDL = SALOMEDS.idl SALOMEDS_Attributes.idl
BIN_CLIENT_IDL =
-CPPFLAGS+=$(OCC_INCLUDES) $(HDF5_INCLUDES)
-CXXFLAGS+=$(OCC_CXXFLAGS)
+CPPFLAGS+=$(OCC_INCLUDES) $(HDF5_INCLUDES) $(BOOST_CPPFLAGS)
+CXXFLAGS+=$(OCC_CXXFLAGS) $(BOOST_CPPFLAGS)
LDFLAGS+= -lOpUtil $(CAS_LDPATH) -lTKernel
@CONCLUDE@
TCollection_AsciiString aSubDir(aRND);
if(aSubDir.Length() <= 1) aSubDir = TCollection_AsciiString("123409876");
- MESSAGE("#### RND " << aRND);
-
aTmpDir += aSubDir; //Get RND sub directory
#ifdef WIN32
+//=======================================================================
+// name : GetFlag
+// Purpose : Retrieve specified flaf from "AttributeFlags" attribute
+//=======================================================================
+bool SALOMEDS_Tool::GetFlag( const int theFlag,
+ _PTR(Study) theStudy,
+ _PTR(SObject) theObj )
+{
+ _PTR(GenericAttribute) anAttr;
+ if ( theObj && theObj->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<std::string>& 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 );
+ }
+ }
+ }
+}
#include <string>
#include <list>
+#include "SALOMEDSClient.hxx"
+
// IDL headers
#include "SALOMEconfig.h"
#include CORBA_SERVER_HEADER(SALOMEDS)
SALOMEDS::SObject_var theObj,
std::list<SALOMEDS::SObject_var>& 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<std::string>& theList );
+
};
#endif
BIN = TestContainer TestLogger
BIN_SRC =
-LDFLAGS+= -lSalomeNotification -lSalomeNS -lSalomeContainer -lRegistry -lOpUtil -lSALOMELocalTrace -lSalomeResourcesManager
-LDFLAGSFORBIN= $(LDFLAGS) -lSALOMETraceCollector
+LDFLAGS+= -lSalomeNotification -lSalomeNS -lSalomeContainer -lRegistry -lOpUtil -lSALOMELocalTrace
@CONCLUDE@
// Module : SALOME
// $Header$
+#define private protected
#include "utilities.h"
#include "SALOME_TestComponent_i.hxx"
#include <stdio.h>
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()
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);
}
from omniORB import CORBA
import CosNaming
import Engines
-from Utils_Identity import getShortHostName
#initialise the ORB
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"),
#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"
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_<ORB_INIT>::Instance() ;
CORBA::ORB_var &orb = init( argc , 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_<SALOME_NamingService>::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<Engines::TestComponent_var> 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");
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; i<dico2->length(); i++)
{
MESSAGE("dico2["<<i<<"].key="<<dico2[i].key);
MESSAGE("dico2["<<i<<"].value="<<value);
}
}
+ }
- iGenFact->remove_impl(m1) ;
+ MESSAGE("------------------------------- remove instances ");
+ for (int iter = 0; iter < nbInstances ; iter++)
+ {
+ Engines::TestComponent_var anInstance = instances[iter];
+ SCRUTE(anInstance->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.")
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
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
#include "utilities.h"
#include "OpUtil.hxx"
-#include <unistd.h>
#include <errno.h>
#include <string.h>
-using namespace std;
-int gethostname(char *name, size_t len);
+#ifndef WNT
+#include <unistd.h>
+#else
+#include <winsock2.h>
+#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);
throw SALOME::SALOME_Exception(ExDescription); \
}
-#include <ostream.h>
+#include <ostream>
//Dump the CORBA exception type.
inline std::ostream& operator<<(std::ostream& os, const CORBA::Exception& e)
# include "Utils_DESTRUCTEUR_GENERIQUE.hxx"
# include "utilities.h"
-using namespace std;
-
void Nettoyage();
#ifdef _DEBUG_
static int MYDEBUG = 0;
#endif
-static list<DESTRUCTEUR_GENERIQUE_*> *Destructeurs=0 ;
+using namespace std;
+
+std::list<DESTRUCTEUR_GENERIQUE_*> *DESTRUCTEUR_GENERIQUE_::Destructeurs=0 ;
/*! \class ATEXIT_
*
*
* 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<DESTRUCTEUR_GENERIQUE_*> ; // Destructeurs alloué dynamiquement (cf. ci-dessous) ,
+ DESTRUCTEUR_GENERIQUE_::Destructeurs =
+ new std::list<DESTRUCTEUR_GENERIQUE_*> ; // 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) ;
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<DESTRUCTEUR_GENERIQUE_*>::iterator it = Destructeurs->end() ;
+ std::list<DESTRUCTEUR_GENERIQUE_*>::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 ;
}
# if !defined( __DESTRUCTEUR_GENERIQUE__H__ )
# define __DESTRUCTEUR_GENERIQUE__H__
+# include <list>
# include <CORBA.h>
# include "utilities.h"
class DESTRUCTEUR_GENERIQUE_
{
public :
+ static std::list<DESTRUCTEUR_GENERIQUE_*> *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
typedef PortableServer::ServantBase TServant;
if(_PtrObjet){
if(TServant* aServant = dynamic_cast<TServant*>(_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<TYPE*>(_PtrObjet);
delete aPtr;
}
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) \
// $Header$
# include <iostream>
-# include <arpa/inet.h>
-# include <netinet/in.h>
-# include <sys/types.h>
-# include <netdb.h>
# include "utilities.h"
# include "Utils_Identity.hxx"
-using namespace std;
+
extern "C"
{
# include <string.h>
+
+#ifndef WNT /* unix functionality */
# include <pwd.h>
+#endif
}
+#ifndef WNT /* unix functionality */
+
+# include <arpa/inet.h>
+# include <netinet/in.h>
+# include <sys/types.h>
+# include <netdb.h>
+
const char* duplicate( const char *const str ) ;
const struct utsname get_uname( void )
return papa->pw_name ;
}
+#else /* Windows functionality */
+
+#include <windows.h>
+#include <direct.h>
+#include <process.h>
+
+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()),\
{
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 ;
}
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
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 ;
}
extern "C"
{
# include <stdlib.h>
-# include <unistd.h>
# include <time.h>
+#ifndef WNT
+# include <unistd.h>
# include <sys/utsname.h>
+#else
+# include <windows.h>
+#endif
}
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;
# 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()") ;
+ }
}
#include <iostream>
#include "Utils_SALOME_Exception.hxx"
#include "utilities.h"
-using namespace std;
extern "C"
{
#include <math.h>
{
if ( _text )
{
- delete [] _text ;
- _text = 0 ;
+ delete [] ((char*)_text);
+ char** pRef = (char**)&_text;
+ *pRef = 0;
}
ASSERT(_text==NULL) ;
}
}
-ostream & operator<<( ostream &os , const SALOME_Exception &ex )
+std::ostream & operator<<( std::ostream &os , const SALOME_Exception &ex )
{
os << ex._text ;
return os ;
std::list<DESTRUCTEUR_GENERIQUE_ *>::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 ;
}
}
#include <signal.h>
#include "Utils_SignalsHandler.h"
-using namespace std;
//============================================================================
//=======================================================================
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
// Module : SALOME
# include "Utils_Timer.hxx"
+
# include <iostream>
#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;
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;
}
}
}
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 ");
}
#include <stdlib.h>
#include <time.h>
+#ifndef WNT
# include <sys/times.h>
# include <sys/time.h>
# include <unistd.h>
+#else
+# include <windows.h>
+# include <time.h>
+# include <sys/timeb.h>
+#define _POSIX_
+#endif
class Utils_Timer {
public:
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
};
* It is strongly (and only) used in the Registry environment
* (RegistryService, RegistryConnexion, Identity, ...)
*/
-
-#include <cstdlib>
-#include <cstring>
-
+extern "C"
+{
+#include <stdlib.h>
+#include <string.h>
+}
#include "utilities.h"
using namespace std;