]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
after merge with V4_1_0_maintainance
authorsecher <secher>
Mon, 8 Sep 2008 14:28:39 +0000 (14:28 +0000)
committersecher <secher>
Mon, 8 Sep 2008 14:28:39 +0000 (14:28 +0000)
95 files changed:
Makefile.am
bin/Makefile.am
bin/NSparam.py
bin/addToKillList.py
bin/envSalome.py
bin/killSalome.py
bin/killSalomeWithPort.py
bin/launchConfigureParser.py
bin/nameserver.py
bin/orbmodule.py
bin/runNS.py
bin/runSalome.py
bin/salome_session.py
bin/salome_utilities.py [new file with mode: 0644]
bin/setenv.py
idl/Makefile.am
salome_adm/unix/Makefile.am
salome_adm/unix/SALOMEconfig.ref.in
salome_adm/unix/config_files/check_cas.m4
src/Basics/BasicsGenericDestructor.cxx
src/Batch/Batch_Date.cxx
src/Batch/Batch_Versatile.cxx
src/Communication_SWIG/libSALOME_Comm.i
src/Container/Component_i.cxx
src/Container/Container_i.cxx
src/Container/Container_init_python.hxx
src/Container/SALOME_ComponentPy.py
src/Container/SALOME_Container.cxx
src/Container/SALOME_Container.py
src/Container/SALOME_ContainerManager.cxx
src/Container/SALOME_Container_SignalsHandler.cxx
src/Container/SALOME_FileRef_i.cxx
src/Container/Salome_file_i.cxx
src/DF/testDF.cxx
src/DSC/DSC_Python/calcium.i
src/DSC/DSC_User/Datastream/Calcium/CalciumCxxInterface.hxx
src/DSC/DSC_User/Datastream/Calcium/CalciumGenericProvidesPort.hxx
src/DSC/DSC_User/Datastream/Calcium/CalciumInterface.hxx
src/DSC/DSC_User/Datastream/Calcium/CalciumPortTraits.hxx
src/DSC/DSC_User/Datastream/Calcium/Copy2CorbaSpace.hxx
src/DSC/DSC_User/Datastream/Calcium/Makefile.am
src/DSC/DSC_User/Datastream/Palm/test_DataIdContainer.cxx
src/DSC/DSC_User/Datastream/fake.cc
src/HDFPersist/HDFfile.cc
src/HDFPersist/HDFfile.hxx
src/HDFPersist/HDFgroup.cc
src/HDFPersist/HDFgroup.hxx
src/HDFPersist/HDFnObjects.c
src/HDFPersist/HDFobject.hxx
src/HDFPersist/HDFobjectIdentify.c
src/HDFPersist/hdfi.h
src/Launcher/SALOME_LauncherServer.cxx
src/LifeCycleCORBA/SALOME_FileTransferCORBA.cxx
src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx
src/LifeCycleCORBA/Test/LifeCycleCORBATest.cxx
src/Logger/SALOME_Trace.hxx
src/ModuleCatalog/SALOME_ModuleCatalog_impl.cxx
src/NamingService/SALOME_NamingService.cxx
src/NamingService/SALOME_NamingServicePy.py
src/NamingService/Test/NamingServiceTest.cxx
src/Registry/RegistryService.cxx
src/Registry/RegistryService.hxx
src/Registry/SALOME_Registry_Server.cxx
src/SALOMEDS/SALOMEDS.cxx
src/SALOMEDS/SALOMEDS_AttributeUserID.cxx
src/SALOMEDS/SALOMEDS_GenericAttribute.cxx
src/SALOMEDS/SALOMEDS_GenericAttribute_i.cxx
src/SALOMEDS/SALOMEDS_SObject.cxx
src/SALOMEDS/SALOMEDS_SObject_i.cxx
src/SALOMEDS/SALOMEDS_Study.cxx
src/SALOMEDS/SALOMEDS_StudyManager.cxx
src/SALOMEDS/SALOMEDS_StudyManager_i.cxx
src/SALOMEDS/SALOMEDS_StudyManager_i.hxx
src/SALOMEDS/SALOMEDS_Study_i.cxx
src/SALOMEDS/Test/SALOMEDSTest.cxx
src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.cxx
src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfString.cxx
src/SALOMELocalTrace/FileTraceCollector.cxx
src/SALOMELocalTrace/LocalTraceBufferPool.cxx
src/SALOMELocalTrace/LocalTraceBufferPool.hxx
src/SALOMELocalTrace/LocalTraceCollector.cxx
src/SALOMELocalTrace/Test/SALOMELocalTraceTest.cxx
src/SALOMELocalTrace/utilities.h
src/SALOMETraceCollector/SALOMETraceCollector.cxx
src/SALOMETraceCollector/Test/SALOMETraceCollectorTest.cxx
src/SALOMETraceCollector/TraceCollector_WaitForServerReadiness.cxx
src/SALOMETraceCollector/TraceCollector_WaitForServerReadiness.hxx
src/TestContainer/SALOME_TestComponent_i.cxx
src/TestContainer/TestContainer.cxx
src/Utils/Test/UtilsTest.cxx
src/Utils/Utils_DESTRUCTEUR_GENERIQUE.cxx
src/Utils/Utils_DESTRUCTEUR_GENERIQUE.hxx
src/Utils/Utils_Identity.cxx
src/Utils/Utils_SALOME_Exception.hxx
src/Utils/Utils_Timer.cxx

index d3b87e52de439a72cd361f2ce281b1fe00591c43..a49a0cc2139f2773ade3f788ff463ab99439f6c3 100644 (file)
@@ -33,10 +33,10 @@ ACLOCAL_AMFLAGS = -I salome_adm/unix/config_files
 if WITHONLYLAUNCHER
   SUBDIRS = src resources
 else
-  SUBDIRS = $(IDLDIR) salome_adm src doc bin resources
+  SUBDIRS = salome_adm $(IDLDIR) src doc bin resources
 endif
 
-DIST_SUBDIRS=   idl salome_adm src doc bin resources
+DIST_SUBDIRS= salome_adm idl src doc bin resources
 
 DISTCLEANFILES = a.out
 
index b8086e529de0034c078a01d909ea4d44a24e7058..077743e33a951e53e8dab7cc4c4dac0ff93978f2 100644 (file)
@@ -32,40 +32,44 @@ include $(top_srcdir)/salome_adm/unix/make_common_starter.am
 #
 
 # These files are data, module or lib files
-dist_salomescript_DATA= \
-       VERSION \
-       orbmodule.py \
-       salomeConsole.py \
-       salome_session.py
+dist_salomescript_DATA =       \
+       config_appli.xml        \
+       salome.launch           \
+       VERSION
 
 # These files are executable scripts
-dist_salomescript_SCRIPTS=\
-       envSalome.py \
-       runIDLparser \
-       runSalome.py \
-       killSalome.py \
-       killSalomeWithPort.py \
-       runSalome \
-       runSalome.csh \
-       runNS.sh \
-       createAppli.sh \
-       appli_install.sh \
-       appli_clean.sh \
-       appli_gen.py \
-       virtual_salome.py \
-       config_appli.xml \
-       launchConfigureParser.py \
-       showNS.py \
-       addToKillList.py \
-       NSparam.py \
-       setenv.py \
-       launchSalome.py \
-       nameserver.py \
-        server.py \
-       waitNS.sh \
-       waitNS.py \
-       waitContainers.py \
-       shutdownSalome.py
+dist_salomescript_SCRIPTS =            \
+       addToKillList.py                \
+       appli_clean.sh                  \
+       appli_gen.py                    \
+       appli_install.sh                \
+       createAppli.sh                  \
+       envSalome.py                    \
+       killSalome.py                   \
+       killSalomeWithPort.py           \
+       launchConfigureParser.py        \
+       launchSalome.py                 \
+       nameserver.py                   \
+       NSparam.py                      \
+       orbmodule.py                    \
+       runIDLparser                    \
+       runNS.py                        \
+       runNS.sh                        \
+       runSalome                       \
+       runSalome.csh                   \
+       runSalome.ksh                   \
+       runSalome.py                    \
+       salomeConsole.py                \
+       salome_session.py               \
+       salome_utilities.py             \
+       server.py                       \
+       setenv.py                       \
+       showNS.py                       \
+       shutdownSalome.py               \
+       virtual_salome.py               \
+       waitContainers.py               \
+       waitNS.py                       \
+       waitNS.sh
 
 EXTRA_DIST = appliskel
 
@@ -74,21 +78,17 @@ dist-hook:
 
 DISTCLEANFILES = $(top_builddir)/bin/salome/Makefile.am
 
-clean-local:
-       rm -rf $(top_builddir)/bin/salome/appliskel
-       cd $(top_builddir)/bin/salome; \
-       rm -f $(dist_salomescript_DATA) $(dist_salomescript_SCRIPTS)
-
 # This is an ugly target to avoid exploring the appliskel subdirectory.
 install-exec-local:
        $(INSTALL) -d $(DESTDIR)$(salomescriptdir)
        $(RM) -rf $(DESTDIR)$(salomescriptdir)/appliskel 1> /dev/null 2>&1
        cp -r $(srcdir)/appliskel $(DESTDIR)$(salomescriptdir)
+       chmod a+x -R $(DESTDIR)$(salomescriptdir)/appliskel
        find $(DESTDIR)$(salomescriptdir) -name CVS -prune -exec rm -rf {} \;
 
 uninstall-local:
        if test -d $(DESTDIR)$(salomescriptdir)/appliskel; then \
          find $(DESTDIR)$(salomescriptdir)/appliskel -exec chmod +w {} ';' ; \
-    rm -rf $(DESTDIR)$(salomescriptdir)/appliskel; \
-  fi;
+         rm -rf $(DESTDIR)$(salomescriptdir)/appliskel; \
+       fi;
 
index 652e6da662a62c2c6795b85aaf51ba7657197b1a..2f93c9e54a010c07f4904887e5b2db4aea24eddc 100755 (executable)
@@ -20,7 +20,6 @@
 # 
 
 import sys,os
-import string
 
 def getNSparams(info=""):
     """
@@ -32,25 +31,8 @@ def getNSparams(info=""):
     elif info==port print host
     else    print 2 strings on stdout on one line: host port
     """
-    my_port=""
-    my_host=""
-    if os.environ.has_key("OMNIORB_CONFIG"):
-        file = open(os.environ["OMNIORB_CONFIG"], "r")
-        s = file.readline()
-        while len(s):
-            l = string.split(s, ":")
-            if string.split(l[0], " ")[0] == "ORBInitRef" or \
-               string.split(l[0], " ")[0] == "InitRef" :
-                my_port = l[len(l)-1]
-                if my_port[-1] == '\n':
-                    my_port = my_port[:-1]
-                    pass
-                my_host = l[len(l)-2]
-                break;
-                pass
-            s = file.readline()
-            pass
-        pass
+    from salome_utilities import getORBcfgInfo
+    my_version, my_host, my_port = getORBcfgInfo()
     if info=='host':
         # keep print, stdout used in shell
         print my_host
@@ -80,9 +62,10 @@ if __name__ == "__main__":
             getNSparams('port')
             pass
         else:
-            getNSparams('')
+            getNSparams()
             pass
         pass
     else:
-        getNSparams('')
+        getNSparams()
         pass
+    pass
index 537dfaf3d8cfb9c1af36ff67772606ed2e6cc1a4..548a8958d18d99d91b8d72f41c287a0a5fd646cf 100755 (executable)
@@ -25,78 +25,87 @@ from launchConfigureParser import verbose
 ########## adds to the kill list of SALOME one more process ##########
 
 def findFileDict():
-    if os.environ.has_key('NSPORT'):
-        my_port = os.environ['NSPORT']
-        pass
-    else:
-        my_port = 2809
-        try:
-            file = open(os.environ["OMNIORB_CONFIG"], "r")
-            s = file.read()
-            while len(s):
-                l = string.split(s, ":")
-                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()
-                pass
-            pass
-        except:
-            pass
-        pass
-    if verbose(): print "myport = ", my_port
-    return my_port
+    """
+    Detect current SALOME session's port number.
+    Returns port number.
+    """
+    from salome_utilities import getPortNumber
+    port = getPortNumber()
+    if verbose(): print "myport = ", port
+    return port
     
-def addToKillList(command_pid, command):
-    my_port = findFileDict()
+def addToKillList(command_pid, command, port=None):
+    """
+    Add the process to the SALOME processes dictionary file.
+    Parameters:
+    - command_pid : command PID
+    - command     : command (string or list of strings)
+    - [port]      : SALOME port number; if this parameter is None (default),
+    it is detected automatically
+    """
+    # retrieve current processes dictionary
     from killSalomeWithPort import getPiDict
-    filedict=getPiDict(my_port)
+    if port is None: port=findFileDict()
+    filedict=getPiDict(port)
     try:
         fpid=open(filedict, 'r')
         process_ids=pickle.load(fpid)
         fpid.close()
     except:
-        process_ids=[{}]
+        process_ids=[]
         pass
-        
-    already_in=0
+    # check if PID is already in dictionary
+    already_in=False
     for process_id in process_ids:
-        if verbose(): print process_id
         for pid, cmd in process_id.items():
-            #print "see process %s : %s"% (pid, cmd[0])
-            if pid == command_pid:
-                already_in=1
-                pass
+            if int(pid) == int(command_pid):
+                already_in=True
+                break
             pass
+        if already_in: break
         pass
-
-    command=(command.split(" "))[0]
-    if already_in == 0:
+    # add process to the dictionary
+    if not already_in:
+        import types
+        if type(command) == types.ListType: command=" ".join([str(c) for c in command])
+        command=command.split()[0]
         try:
-            process_ids.append({command_pid: [command]})
-            fpid=open(filedict,'w')
+            if verbose(): print "addToKillList: %s : %s" % ( str(command_pid), command )
+            process_ids.append({int(command_pid): [command]})
+            dir = os.path.dirname(filedict)
+            if not os.path.exists(dir): os.makedirs(dir, 0777)
+            fpid = open(filedict,'w')
             pickle.dump(process_ids, fpid)
             fpid.close()
         except:
-            print "addToKillList: can not add command %s to the kill list"% filedict
+            if verbose(): print "addToKillList: can not add command %s : %s to the kill list" % ( str(command_pid), command )
             pass
         pass
     pass
 
-def killList():
-    my_port = findFileDict()
+def killList(port=None):
+    """
+    Kill all the processes listed in the SALOME processes dictionary file.
+    - [port]      : SALOME port number; if this parameter is None (default),
+    it is detected automatically
+    """
+    # retrieve processes dictionary
     from killSalomeWithPort import getPiDict
-    filedict=getPiDict(my_port)
+    if port is None: port=findFileDict()
+    # new-style dot-prefixed pidict file
+    filedict=getPiDict(port, hidden=True)
+    # provide compatibility with old-style pidict file (not dot-prefixed)
+    if not os.path.exists(filedict): filedict = getPiDict(port, hidden=False)
     try:
         fpid=open(filedict, 'r')
         process_ids=pickle.load(fpid)
         fpid.close()
     except:
-        process_ids=[{}]
+        process_ids=[]
         pass
-
+    # kill processes
     for process_id in process_ids:
-        print process_id
+        #print process_id
         for pid, cmd in process_id.items():
             print "stop process %s : %s"% (pid, cmd[0])
             try:
@@ -106,11 +115,11 @@ def killList():
                 pass
             pass
         pass
+    # remove processes dictionary file
     os.remove(filedict)
     pass
-  
-
 
 if __name__ == "__main__":
     if verbose(): print sys.argv
     addToKillList(sys.argv[1], sys.argv[2])
+    pass
index 1d0d61cb6a8a489dc2c39953aecdb3fd106e6627..ed153d41bfb382216b4c620d3245a6960678f0d6 100755 (executable)
@@ -39,6 +39,6 @@ sys.argv = argv[1:]
     
 #args, modules_list, modules_root_dir = setenv.get_config()
 #runSalome.set_env(args, modules_list, modules_root_dir)
-setenv.main();
+setenv.main(True);
 
 os.execvp(argv[0],argv)
index 2f1388182f522ed10621b47b36a38173a3d5359e..1c76890a96cc6cd71eaf08bbf2e9b89a9da0df7f 100755 (executable)
 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 # 
 
-import os, string, sys, re
+import os, sys, re, signal
 
 from killSalomeWithPort import killMyPort, getPiDict
 
 def killAllPorts():
+    """
+    Kill all SALOME sessions belonging to the user.
+    """
     user = os.getenv('USER')
-    filedict = "^%s$"%(getPiDict('(\d*)',full=False))
-    fnamere = re.compile(filedict)
-    for file in os.listdir(os.getenv("HOME")):
-        mo = re.match(fnamere,file)
-        if mo and len(mo.groups()):
-            killMyPort(mo.groups()[0])
+    # new-style dot-prefixed pidict file
+    fpidict   = getPiDict('(\d*)',hidden=True)
+    dirpidict = os.path.dirname(fpidict)
+    fpidict   = os.path.basename(fpidict)
+    fnamere   = re.compile("^%s$" % fpidict)
+    try:
+        for f in os.listdir(dirpidict):
+            mo = fnamere.match(f)
+            try:
+                killMyPort(mo.group(1))
+            except:
+                pass
+            pass
         pass
-
-    if not sys.platform == 'win32':
-        cmd = "pid=`ps -fea | grep '"+os.getenv('USER')+"' | grep 'ghs3d' | grep 'f /tmp/GHS3D_' | grep -v 'grep' | awk '{print $2}'` ; echo $pid > /tmp/logs/"+os.getenv('USER')+"/_"+"Pid_ghs3d.log"
-        a = os.system(cmd)
-        try:
-            fpidomniNames=open('/tmp/logs/'+os.getenv('USER')+"/_"+"Pid_ghs3d.log")
-            prc = fpidomniNames.read()
-            fpidomniNames.close()
-            if prc != None :
-                for field in prc.split(" ") :
-                    field = field.strip()
-                    if field != None and len(field) != 0:
-                        os.system('kill -9 '+field)
-        except:
+    except:
+        pass
+    # provide compatibility with old-style pidict file (not dot-prefixed)
+    fpidict   = getPiDict('(\d*)',hidden=False)
+    dirpidict = os.path.dirname(fpidict)
+    fpidict   = os.path.basename(fpidict)
+    fnamere   = re.compile("^%s$" % fpidict)
+    try:
+        for f in os.listdir(dirpidict):
+            mo = fnamere.match(f)
+            try:
+                killMyPort(mo.group(1))
+            except:
+                pass
+            pass
+        pass
+    except:
+        pass
+    # kill other processes
+    if sys.platform != 'win32':
+        import commands
+        cmd = "ps -fea | grep '%s' | grep 'ghs3d' | grep 'f /tmp/GHS3D_' | grep -v 'grep' | awk '{print $2}'" % user
+        prc = commands.getoutput(cmd)
+        for field in prc.split():
+            try:
+                os.kill(int(field), signal.SIGKILL)
+            except:
+                pass
             pass
         pass
+    pass
 
 if __name__ == "__main__":
     killAllPorts()
+    pass
     
index 79c1682792d42d757f063f757cf8d56a5cab6cd8..2308505a0e2ead3e7392b0293755269b1881cc2f 100755 (executable)
 import os, sys, pickle, signal, commands
 from launchConfigureParser import verbose
 
-def getPiDict(port,appname='salome',full=True):
-    from Utils_Identity import getShortHostName
-
-    # get hostname by special function in all cases to
-    # have always same result in lower case at win32
-    host = getShortHostName()
-    if not host:
-        host = os.getenv("HOSTNAME")
-    if not host:
-        host = os.getenv("HOST")
-
-    filedict = []
-    filedict.append( os.getenv('USER') )          # user name
-    filedict.append( host )                       # host name
-    filedict.append( str(port) )                  # port number
-    filedict.append( appname.upper() )            # application name
-    filedict.append( 'pidict' )                   # constant part
+def getPiDict(port,appname='salome',full=True,hidden=True):
+    """
+    Get file with list of SALOME processes.
+    This file is located in the user's home directory
+    and named .<user>_<host>_<port>_SALOME_pidict
+    where
+    <user> is user name
+    <host> is host name
+    <port> is port number
 
-    filedict = '_'.join(filedict)
+    Parameters:
+    - port    : port number
+    - appname : application name (default is 'SALOME')
+    - full    : if True, full path to the file is returned, otherwise only file name is returned
+    - hidden  : if True, file name is prefixed with . (dot) symbol; this internal parameter is used
+    to support compatibility with older versions of SALOME
+    """
+    from salome_utilities import generateFileName, getTmpDir
+    dir = ""
     if full:
-        filedict = os.getenv("HOME") + '/' + filedict
-    return filedict
+        # full path to the pidict file is requested
+        if hidden:
+            # new-style dot-prefixed pidict files
+            # are in the system-dependant temporary diretory
+            dir = getTmpDir()
+        else:
+            # old-style non-dot-prefixed pidict files
+            # are in the user's home directory
+            dir = os.getenv("HOME")
+            pass
+        pass
+    return generateFileName(dir,
+                            suffix="pidict",
+                            hidden=hidden,
+                            with_username=True,
+                            with_hostname=True,
+                            with_port=port,
+                            with_app=appname.upper())
 
 def appliCleanOmniOrbConfig(port):
     """
-    remove omniorb config files related to the port in SALOME application:
+    Remove omniorb config files related to the port in SALOME application:
     - ${HOME}/${APPLI}/.omniORB_${HOSTNAME}_${NSPORT}.cfg
     - ${HOME}/${APPLI}/.omniORB_last.cfg
     the last is removed only if the link points to the first file.
     """
-    from Utils_Identity import getShortHostName
-    appli=os.environ.get("APPLI")
+    from salome_utilities import generateFileName
+    home  = os.getenv("HOME")
+    appli = os.getenv("APPLI")
     if appli is None:
         #Run outside application context
         pass
     else:
-        home = os.environ['HOME']
-        home='%s/%s'%(home,appli)
-        hostname=getShortHostName()
-        omniorb_config = '%s/.omniORB_%s_%s.cfg'%(home,hostname, str(port))
-        last_running_config = '%s/.omniORB_last.cfg'%(home)
+        dir = os.path.join(home, appli)
+        omniorb_config      = generateFileName(dir, prefix="omniORB",
+                                               extension="cfg",
+                                               hidden=True,
+                                               with_hostname=True,
+                                               with_port=port)
+        last_running_config = generateFileName(dir, prefix="omniORB",
+                                               suffix="last",
+                                               extension="cfg",
+                                               hidden=True)
         if os.access(last_running_config,os.F_OK):
             pointedPath = os.readlink(last_running_config)
             if pointedPath[0] != '/':
@@ -75,77 +97,100 @@ def appliCleanOmniOrbConfig(port):
             os.remove(omniorb_config)
             pass
         pass
+    pass
 
 ########## kills all salome processes with the given port ##########
 
 def killMyPort(port):
-    filedict=getPiDict(port)
-    found = 0
+    """
+    Kill SALOME session running on the specified port.
+    Parameters:
+    - port - port number
+    """
+    # new-style dot-prefixed pidict file
+    filedict = getPiDict(port, hidden=True)
+    # provide compatibility with old-style pidict file (not dot-prefixed)
+    if not os.path.exists(filedict): filedict = getPiDict(port, hidden=False)
+    #
     try:
-        fpid=open(filedict, 'r')
-        found = 1
-    except:
-        print "file %s giving SALOME process id is not readable"% filedict
-        pass
-        
-    if found:
+        fpid = open(filedict, 'r')
+        #
+        from salome_utilities import generateFileName
+        fpidomniNames = generateFileName(os.path.join('/tmp/logs', os.getenv('USER')),
+                                         prefix="",
+                                         suffix="Pid_omniNames",
+                                         extension="log",
+                                         with_port=port)
         if not sys.platform == 'win32':        
-            cmd = 'pid=`ps -eo pid,command | egrep "[0-9] omniNames -start '+str(port)+'"` ; echo $pid > /tmp/logs/'+os.getenv('USER')+"/_"+port+'_Pid_omniNames.log'
+            cmd = 'pid=`ps -eo pid,command | egrep "[0-9] omniNames -start %s"` ; echo $pid > %s' % ( str(port), fpidomniNames )
             a = os.system(cmd)
+            pass
         try:
-            fpidomniNames=open('/tmp/logs/'+os.getenv('USER')+"/_"+port+'_Pid_omniNames.log')
-            prc = fpidomniNames.read()
-            fpidomniNames.close()
-            if prc != None :
-                for field in prc.split(" ") :
-                    if field == "omniNames" :
-                        if pidfield != "egrep" :
-                            if sys.platform == "win32":
-                                import win32pm
-                                print 'stop process '+pidfield+' : omniNames'
-                                win32pm.killpid(int(pidfield),0)
-                            else:
-                                if verbose(): print 'stop process '+pidfield+' : omniNames'
-                                os.system('kill -9 '+pidfield)
-                    pidfield = field
+            fpidomniNamesFile = open(fpidomniNames)
+            lines = fpidomniNamesFile.readlines()
+            fpidomniNamesFile.close()
+            os.remove(fpidomniNames)
+            for l in lines:
+                try:
+                    pidfield = l.split()[0] # pid should be at the first position
+                    if sys.platform == "win32":
+                        import win32pm
+                        if verbose(): print 'stop process '+pidfield+' : omniNames'
+                        win32pm.killpid(int(pidfield),0)
+                    else:
+                        if verbose(): print 'stop process '+pidfield+' : omniNames'
+                        os.kill(int(pidfield),signal.SIGKILL)
+                        pass
+                    pass
+                except:
+                    pass
+                pass
+            pass
         except:
             pass
-        
+        #
         try:
             process_ids=pickle.load(fpid)
             fpid.close()
             for process_id in process_ids:
-
                 for pid, cmd in process_id.items():
                     if verbose(): print "stop process %s : %s"% (pid, cmd[0])
                     try:
                         if sys.platform == "win32":
-                          import win32pm
-                          win32pm.killpid(int(pid),0)
+                            import win32pm
+                            win32pm.killpid(int(pid),0)
                         else:
-                           os.kill(int(pid),signal.SIGKILL)
+                            os.kill(int(pid),signal.SIGKILL)
+                            pass
+                        pass
                     except:
                         if verbose(): print "  ------------------ process %s : %s not found"% (pid, cmd[0])
                         pass
-                pass
+                    pass # for pid, cmd ...
+                pass # for process_id ...
+            pass # try...
         except:
             pass
-        
+        #
         os.remove(filedict)
         cmd='ps -eo pid,command | egrep "[0-9] omniNames -start '+str(port)+'" | sed -e "s%[^0-9]*\([0-9]*\) .*%\\1%g"'
         pid = commands.getoutput(cmd)
         a = ""
-        while pid != "" and len(a.split(" ")) < 2:
-            a = commands.getoutput("pid=`ps -eo pid,command | egrep \"[0-9] omniNames -start "+str(port)+"\" | sed -e \"s%[^0-9]*\([0-9]*\) .*%\\1%g\"`; kill -9 $pid")
-            pid = commands.getoutput("ps -eo pid,command | egrep \"[0-9] omniNames -start "+str(port)+"\" | sed -e \"s%[^0-9]*\([0-9]*\) .*%\\1%g\"")
-            print pid
-            
+        while pid and len(a.split()) < 2:
+            a = commands.getoutput("kill -9 " + pid)
+            pid = commands.getoutput(cmd)
+            #print pid
+            pass
         pass
-
+    except:
+        print "Cannot find or open SALOME PIDs file for port", port
+        pass
+    #
     appliCleanOmniOrbConfig(port)
     pass
             
-
 if __name__ == "__main__":
     for port in sys.argv[1:]:
         killMyPort(port)
+        pass
+    pass
index 399c40ef73a7bcd0595db57cfb4012a0fbdb9f25..74b3cd0a10a88cf2a92f69df2e81df362537dd0c 100755 (executable)
@@ -701,9 +701,16 @@ def get_env(theAdditionalOptions=[], appname="SalomeApp"):
             dirs += re.split(';', os.getenv(config_var))
         else:
             dirs += re.split('[;|:]', os.getenv(config_var))
-            
+
+    gui_available = True
     if os.getenv("GUI_ROOT_DIR") and os.path.isdir( os.getenv("GUI_ROOT_DIR") + "/share/salome/resources/gui" ):
         dirs += [os.getenv("GUI_ROOT_DIR") + "/share/salome/resources/gui"]
+       pass
+    else:
+       gui_available = False
+       if os.getenv("KERNEL_ROOT_DIR") and os.path.isdir( os.getenv("KERNEL_ROOT_DIR") + "/bin/salome/appliskel" ):
+           dirs += [os.getenv("KERNEL_ROOT_DIR") + "/bin/salome/appliskel"]
+       pass
     os.environ[config_var] = separator.join(dirs)
 
     dirs.reverse() # reverse order, like in "path" variable - FILO-style processing
@@ -800,6 +807,10 @@ def get_env(theAdditionalOptions=[], appname="SalomeApp"):
         args[gui_nam] = cmd_opts.gui
     if cmd_opts.batch is not None:
         args[batch_nam] = True
+
+    if not gui_available:
+       args[gui_nam] = False
+       
     if args[gui_nam]:
         args["session_gui"] = True
         if cmd_opts.desktop is not None:
index dd03c51a39754a4c38ef680622d51b0db76f3e4f..99ec4c3b2f06d19a401fe0ea15d7d2875b00cee4 100755 (executable)
@@ -4,6 +4,7 @@ import sys, os, re, socket
 #import commands
 from server import *
 from Utils_Identity import getShortHostName
+from launchConfigureParser import verbose
 
 # -----------------------------------------------------------------------------
 
@@ -45,12 +46,12 @@ class NamingServer(Server):
         #os.system("touch " + upath + "/dummy")
         for fname in os.listdir(upath):
           try:
-            os.remove(upath + "/" + fname)
+            if not fname.startswith("."): os.remove(upath + "/" + fname)
           except:
             pass
         #os.system("rm -f " + upath + "/omninames* " + upath + "/dummy " + upath + "/*.log")
 
-        print "Name Service... ",
+        if verbose(): print "Name Service... ",
         #hname=os.environ["HOST"] #commands.getoutput("hostname")
         if sys.platform == "win32":
           hname=getShortHostName();
@@ -60,7 +61,7 @@ class NamingServer(Server):
 
         f=open(os.environ["OMNIORB_CONFIG"])
         ss=re.findall("NameService=corbaname::" + hname + ":\d+", f.read())
-        print "ss = ", ss,
+        if verbose(): print "ss = ", ss,
         f.close()
         sl=ss[0]
         ll = sl.split(':')
@@ -74,15 +75,15 @@ class NamingServer(Server):
         #print "port=", aPort
         if sys.platform == "win32":
           #print "start omniNames -start " + aPort + " -logdir " + upath
-          self.CMD=['omniNames -start ' , aPort , ' -logdir ' , '\"' + upath + '\"']
+          self.CMD=['omniNames -start ' , aPort , ' -logdir ' , '\"' + upath + '\"', ' -errlog', upath+'/omniNameErrors.log']
           #os.system("start omniNames -start " + aPort + " -logdir " + upath)
         else:
           #self.CMD=['omniNames -start ' , aPort , ' -logdir ' , upath , ' &']
-          self.CMD=['omniNames','-start' , aPort, '-logdir' , upath ]
+          self.CMD=['omniNames','-start' , aPort, '-logdir' , upath, '-errlog', upath+'/omniNameErrors.log']
           #os.system("omniNames -start " + aPort + " -logdir " + upath + " &")
 
-        print "... ok"
-        print "to list contexts and objects bound into the context with the specified name : showNS "
+        if verbose(): print "... ok"
+        if verbose(): print "to list contexts and objects bound into the context with the specified name : showNS "
 
 
    def initArgs(self):
index 9f3c66324b7852108f47dfa85faaa4af3d2877e5..ffb211fab8ce48cf703d84a91b7e995f7ee60736 100755 (executable)
@@ -20,6 +20,7 @@ import sys,os,time
 import string
 from nameserver import *
 from omniORB import CORBA
+from launchConfigureParser import verbose
 
 # Import the stubs for the Naming service
 import CosNaming
@@ -47,7 +48,7 @@ class client:
           return
       except (CORBA.TRANSIENT,CORBA.OBJECT_NOT_EXIST,CORBA.COMM_FAILURE):
           self.rootContext = None
-          print "Launch Naming Service++",
+          if verbose(): print "Launch Naming Service++",
           
       # On lance le Naming Server (doit etre dans le PATH)
       NamingServer(args).run()
index 44476036965a6c885b9f56b0eb61bc4399b908dc..601c7b00d3dabb7ef1474d4a65981f0c9e90db2e 100755 (executable)
@@ -39,7 +39,7 @@ def startOmni():
   #os.system("touch " + upath + "/dummy")
   for fname in os.listdir(upath):
     try:
-      os.remove(upath + "/" + fname)
+      if not fname.startswith("."): os.remove(upath + "/" + fname)
     except:
       pass
   #os.system("rm -f " + upath + "/omninames* " + upath + "/dummy " + upath + "/*.log")
index dc256253e35f154b40fd1781d2d6efcafb1cecbe..aae7d0dfa37d7fd53d50faa2a74db8f8b3401110 100755 (executable)
@@ -19,7 +19,7 @@
 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 # 
 
-import sys, os, string, glob, time, pickle
+import sys, os, string, glob, time, pickle, re
 import orbmodule
 import setenv
 from server import *
@@ -204,10 +204,22 @@ class LoggerServer(Server):
     def __init__(self,args):
         self.args=args
         self.initArgs()
-        if sys.platform == "win32":
-            self.CMD=['SALOME_Logger_Server', os.environ["HOME"] + "/logger.log"];
-        else:
-            self.CMD=['SALOME_Logger_Server', 'logger.log']
+        from salome_utilities import generateFileName
+        if sys.platform == "win32": dirpath = os.environ["HOME"]
+        else:                       dirpath = "/tmp"
+        logfile = generateFileName( dirpath,
+                                    prefix="logger",
+                                    extension="log",
+                                    with_username=True,
+                                    with_hostname=True,
+                                    with_port=True)
+        print "==========================================================="
+        print "Logger server: put log to the file:"
+        print logfile
+        print "==========================================================="
+        self.CMD=['SALOME_Logger_Server', logfile]
+        pass
+    pass # end of LoggerServer class
 
 # ---
 
@@ -418,10 +430,8 @@ def startSalome(args, modules_list, modules_root_dir):
     # Notify Server launch
     #
 
-    if verbose(): print "Notify Server to launch"
-
     if sys.platform != "win32":
-      print "Notify Server to launch"
+      if verbose(): print "Notify Server to launch"
     
       myServer=NotifyServer(args,modules_root_dir)
       myServer.run()
@@ -623,22 +633,14 @@ def useSalome(args, modules_list, modules_root_dir):
         
     #print process_id
 
+    from addToKillList import addToKillList
     from killSalomeWithPort import getPiDict
-    filedict = getPiDict(args['port'])
 
-    process_ids = []
-    try:
-        fpid=open(filedict, 'r')
-        process_ids=pickle.load(fpid)
-        fpid.close()
-    except:
+    filedict = getPiDict(args['port'])
+    for pid, cmd in process_id.items():
+        addToKillList(pid, cmd, args['port'])
         pass
-    
-    fpid=open(filedict, 'w')
-    process_ids.append(process_id)
-    pickle.dump(process_ids,fpid)
-    fpid.close()
-    
+
     if verbose(): print """
     Saving of the dictionary of Salome processes in %s
     To kill SALOME processes from a console (kill all sessions from all ports):
@@ -714,89 +716,92 @@ def registerEnv(args, modules_list, modules_root_dir):
 
 def searchFreePort(args, save_config=1):
     print "Searching for a free port for naming service:",
+    #
+    if sys.platform == "win32":
+        tmp_file = os.getenv('TEMP');
+    else:
+        tmp_file = '/tmp'
+    tmp_file = os.path.join(tmp_file, '.netstat_%s'%os.getpid())
+    #
+    ###status = os.system("netstat -ltn | grep -E :%s > /dev/null 2>&1"%(NSPORT))
+    os.system( "netstat -a -n > %s" % tmp_file );
+    f = open( tmp_file, 'r' );
+    ports = f.readlines();
+    f.close();
+    os.remove( tmp_file );
+    #
+    def portIsUsed(port, data):
+        regObj = re.compile( "tcp.*:([0-9]+).*:.*listen", re.IGNORECASE );
+        for item in data:
+            try:
+                p = int(regObj.match(item).group(1))
+                if p == port: return True
+                pass
+            except:
+                pass
+            pass
+        return False
+    #
     NSPORT=2810
-    limit=NSPORT
-    limit=limit+10
+    limit=NSPORT+100
+    #
     while 1:
-        import os
-        import re
-        from os import getpid
-        from os import system
-
-        if sys.platform == "win32":
-            tmp_file = os.getenv('TEMP');
-        else:
-            tmp_file = '/tmp/'
-        tmp_file += 'hostname_%s'%(getpid())
-
-#       status = os.system("netstat -ltn | grep -E :%s > /dev/null 2>&1"%(NSPORT))
-
-        system( "netstat -a -n > %s" % tmp_file );
-
-        f = open( tmp_file, 'r' );
-        lines = f.readlines();
-        f.close();
-
-        pattern = "tcp.*:([0-9]+).*:.*listen";
-        regObj = re.compile( pattern, re.IGNORECASE );
-
-        status = 1;
-        for item in lines:
-            m = regObj.search( item )
-            if m:
-                try:
-                    p = int( m.group(1) )
-                    if p == NSPORT: 
-                        status = 0;
-                        break;
-                except:
-                    pass
-            pass
-
-        if status == 1:
+        if not portIsUsed(NSPORT, ports):
             print "%s - OK"%(NSPORT)
             #
-            system('hostname > %s'%(tmp_file))
-            f = open(tmp_file)
-            myhost = f.read()
-            myhost = myhost[:-1]
-            f.close()
-
-            os.remove( tmp_file );
-
+            from salome_utilities import generateFileName, getHostName
+            hostname = getHostName()
             #
-            home = os.environ['HOME']
-            appli=os.environ.get("APPLI")
-            if appli is not None:
-                home='%s/%s'%(home,appli)
-                pass
+            home  = os.getenv("HOME")
+            appli = os.getenv("APPLI")
+            if appli is not None: home = os.path.join(home, appli)
             #
-            os.environ['OMNIORB_CONFIG'] = '%s/.omniORB_%s_%s.cfg'%(home, myhost, NSPORT)
-            initref = "NameService=corbaname::%s:%s"%(myhost, NSPORT)
-            os.environ['NSPORT'] = "%s"%(NSPORT)
-            os.environ['NSHOST'] = "%s"%(myhost)
-            f = open(os.environ['OMNIORB_CONFIG'], "w")
+            omniorb_config = generateFileName(home, prefix="omniORB",
+                                              extension="cfg",
+                                              hidden=True,
+                                              with_hostname=True,
+                                              with_port=NSPORT)
+            orbdata = []
+            initref = "NameService=corbaname::%s:%s"%(hostname, NSPORT)
             import CORBA
             if CORBA.ORB_ID == "omniORB4":
-                initref += "\ngiopMaxMsgSize = 2097152000  # 2 GBytes";
-                initref += "\ntraceLevel = 0 # critical errors only";
-                f.write("InitRef = %s\n"%(initref))
+                orbdata.append("InitRef = %s"%(initref))
+                orbdata.append("giopMaxMsgSize = 2097152000  # 2 GBytes")
+                orbdata.append("traceLevel = 0 # critical errors only")
             else:
-                initref += "\nORBgiopMaxMsgSize = 2097152000  # 2 GBytes";
-                initref += "\nORBtraceLevel = 0 # critical errors only";
-                f.write("ORBInitRef %s\n"%(initref))
+                orbdata.append("ORBInitRef %s"%(initref))
+                orbdata.append("ORBgiopMaxMsgSize = 2097152000  # 2 GBytes")
+                orbdata.append("ORBtraceLevel = 0 # critical errors only")
                 pass
+            orbdata.append("")
+            f = open(omniorb_config, "w")
+            f.write("\n".join(orbdata))
             f.close()
+            #
+            os.environ['OMNIORB_CONFIG'] = omniorb_config
+            os.environ['NSPORT'] = "%s"%(NSPORT)
+            os.environ['NSHOST'] = "%s"%(hostname)
             args['port'] = os.environ['NSPORT']
             #
             if save_config:
-                from os import system
-                if sys.platform == "win32":
-                    import shutil       
-                    shutil.copyfile( os.environ['OMNIORB_CONFIG'], "%s/.omniORB_last.cfg"%( home ) )
-                else:            
-                    system('ln -s -f %s %s/.omniORB_last.cfg'%(os.environ['OMNIORB_CONFIG'], home))     
-                pass
+                last_running_config = generateFileName(home, prefix="omniORB",
+                                                       suffix="last",
+                                                       extension="cfg",
+                                                       hidden=True)
+                try:
+                    if sys.platform == "win32":
+                        import shutil       
+                        shutil.copyfile(omniorb_config, last_running_config)
+                    else:
+                        try:
+                            os.remove(last_running_config)
+                        except OSError:
+                            pass
+                        os.symlink(omniorb_config, last_running_config)
+                        pass
+                    pass
+                except:
+                    pass
             break
         print "%s"%(NSPORT),
         if NSPORT == limit:
@@ -826,14 +831,16 @@ def no_main():
 def main():
     """Salome launch as a main application"""
     import sys
-    print "runSalome running on ",os.getenv('HOSTNAME')
+    from salome_utilities import getHostName
+    print "runSalome running on %s" % getHostName()
     args, modules_list, modules_root_dir = setenv.get_config()
     kill_salome(args)
     save_config = True
     if args.has_key('save_config'):
         save_config = args['save_config']
     searchFreePort(args, save_config)
-    setenv.main()
+    #setenv.main()
+    setenv.set_env(args, modules_list, modules_root_dir)
     clt = useSalome(args, modules_list, modules_root_dir)
     return clt,args
 
index 870b53bc4c1ca397f5aab53bc47266fce20170dc..64e13c9511124ea7ddc3d67e45037e671f390561 100644 (file)
@@ -39,48 +39,55 @@ def getShortHostName():
     socket.gethostname() gives short or complete Hostname, depending on
     defined aliases.
     """
-    return string.split(socket.gethostname(),'.')[0]
+    from salome_utilities import getShortHostName
+    return getShortHostName()
 
 def searchFreePort():
+    """
+    Search free port for SALOME session.
+    Returns first found free port number.
+    """
     print "Searching a free port for naming service:",
-    NSPORT=2810
-    limit=NSPORT
-    limit=limit+100
+    from salome_utilities import generateFileName, getHostName
+    hostname = getHostName()
+    NSPORT = 2810
+    limit  = NSPORT+100
     while 1:
         print "%s "%(NSPORT),
         status = os.system("netstat -ltn | grep -E :%s"%(NSPORT))
         if status:
-            home = os.environ['HOME']
-            appli=os.environ.get("APPLI")
-            if appli is None:
-                #Run outside application context
-                home=home
-            else:
-                home='%s/%s'%(home,appli)
-            hostname=getShortHostName()
-            omniorb_config = '%s/.omniORB_%s_%s.cfg'%(home,hostname, NSPORT)
-            os.environ['OMNIORB_CONFIG'] = omniorb_config
+            home  = os.getenv("HOME")
+            appli = os.getenv("APPLI")
+            if appli is not None: home = os.path.join(home, appli)
+            omniorb_config = generateFileName(home, prefix="omniORB",
+                                              extension="cfg",
+                                              hidden=True,
+                                              with_hostname=True,
+                                              with_port=NSPORT)
             f = open(omniorb_config, "w")
             f.write("ORBInitRef NameService=corbaname::%s:%s\n"%(hostname, NSPORT))
             f.close()
-            last_running_config = '%s/.omniORB_last.cfg'%(home, hostname)
+            os.environ['OMNIORB_CONFIG'] = omniorb_config
+            last_running_config = generateFileName(home, prefix="omniORB",
+                                                   suffix="last",
+                                                   extension="cfg",
+                                                   hidden=True)
             os.environ['LAST_RUNNING_CONFIG'] = last_running_config
             if os.access(last_running_config,os.F_OK):
                 os.unlink(last_running_config)
                 pass
             os.symlink(omniorb_config,last_running_config)
-            #            LAST_RUNNING_CONFIG=${HOME}/${APPLI}/.omniORB_${myhost}_last.cfg
             print "- Ok"
             break
         if NSPORT == limit:
             msg  = ""
-            msg += "I Can't find a free port to launch omniNames\n"
-            msg += "I suggest you to kill the running servers and try again.\n"
+            msg += "Can not find a free port to launch omniNames\n"
+            msg += "Kill the running servers and try again.\n"
             raise msg
-        NSPORT=NSPORT+1
+        NSPORT = NSPORT+1
         pass
-    os.environ['NSHOST']=hostname
-    os.environ['NSPORT']=str(NSPORT)
+    os.environ['NSHOST'] = hostname
+    os.environ['NSPORT'] = str(NSPORT)
     return NSPORT
 
 
diff --git a/bin/salome_utilities.py b/bin/salome_utilities.py
new file mode 100644 (file)
index 0000000..b4349cd
--- /dev/null
@@ -0,0 +1,346 @@
+# Copyright (C) 2005  OPEN CASCADE, CEA, EDF R&D, LEG
+#           PRINCIPIA R&D, EADS CCR, Lip6, BV, CEDRAT
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+# ---
+#
+# File   : salome_utilities.py
+# Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
+#
+# ---
+
+"""
+Set of utility functions used by SALOME python scripts.
+"""
+
+#
+# Exported functions
+#
+__all__ = [
+    'getORBcfgInfo',
+    'getHostFromORBcfg',
+    'getPortFromORBcfg',
+    'getUserName',
+    'getHostName',
+    'getShortHostName',
+    'getAppName',
+    'getPortNumber',
+    'getTmpDir',
+    'generateFileName',
+    ]
+
+# ---
+
+def _try_bool( arg ):
+    """
+    Check if specified parameter represents boolean value and returns its value.
+    String values like 'True', 'TRUE', 'YES', 'Yes', 'y', 'NO', 'false', 'n', etc
+    are supported.
+    If <arg> does not represent a boolean, an exception is raised.
+    """
+    import types
+    if type( arg ) == types.BooleanType  :
+        return arg
+    elif type( arg ) == types.StringType  :
+        v = str( arg ).lower()
+        if   v in [ "yes", "y", "true"  ]: return True
+        elif v in [ "no",  "n", "false" ]: return False
+        pass
+    raise Exception("Not boolean value")
+
+# ---
+
+def getORBcfgInfo():
+    """
+    Get omniORB current configuration.
+    Returns a list of three values: [ orb_version, host_name, port_number ].
+    
+    The information is retrieved from the omniORB configuration file defined
+    by the OMNIORB_CONFIG environment variable.
+    If omniORB configuration file can not be accessed, a list of three empty
+    strings is returned.
+    """
+    import os, re
+    ret = [ "", "", "" ]
+    try:
+        f = open( os.getenv( "OMNIORB_CONFIG" ) )
+        lines = f.readlines()
+        f.close()
+        regvar = re.compile( "(ORB)?InitRef.*corbaname::(.*):(\d+)\s*$" )
+        for l in lines:
+            try:
+                m = regvar.match( l )
+                if m:
+                    if m.group(1) is None:
+                        ret[0] = "4"
+                    else:
+                        ret[0] = "3"
+                        pass
+                    ret[1] = m.group(2)
+                    ret[2] = m.group(3)
+                    break
+                pass
+            except:
+                pass
+            pass
+        pass
+    except:
+        pass
+    return ret
+
+# ---
+
+def getHostFromORBcfg():
+    """
+    Get current omniORB host.
+    """
+    return getORBcfgInfo()[1]
+# ---
+
+def getPortFromORBcfg():
+    """
+    Get current omniORB port.
+    """
+    return getORBcfgInfo()[2]
+
+# ---
+
+def getUserName():
+    """
+    Get user name:
+    1. try USER environment variable
+    2. if fails, return 'unknown' as default user name
+    """
+    import os
+    return os.getenv( "USER", "unknown" ) # 'unknown' is default user name
+
+# ---
+
+def getHostName():
+    """
+    Get host name:
+    1. try socket python module gethostname() function
+    2. if fails, try HOSTNAME environment variable
+    3. if fails, try HOST environment variable
+    4. if fails, return 'unknown' as default host name
+    """
+    import os
+    try:
+        import socket
+        host = socket.gethostname()
+    except:
+        host = None
+        pass
+    if not host: host = os.getenv("HOSTNAME")
+    if not host: host = os.getenv("HOST")
+    if not host: host = "unknown"           # 'unknown' is default host name
+    return host
+
+# ---
+
+def getShortHostName():
+    """
+    Get short host name:
+    1. try socket python module gethostname() function
+    2. if fails, try HOSTNAME environment variable
+    3. if fails, try HOST environment variable
+    4. if fails, return 'unknown' as default host name
+    """
+    try:
+        return getHostName().split('.')[0]
+    except:
+        pass
+    return "unknown"           # 'unknown' is default host name
+    
+# ---
+
+def getAppName():
+    """
+    Get application name:
+    1. try APPNAME environment variable
+    2. if fails, return 'SALOME' as default application name
+    """
+    import os
+    return os.getenv( "APPNAME", "SALOME" ) # 'SALOME' is default user name
+
+# ---
+
+def getPortNumber():
+    """
+    Get current naming server port number:
+    1. try NSPORT environment variable
+    1. if fails, try to parse config file defined by OMNIORB_CONFIG environment variable
+    2. if fails, return 2809 as default port number
+    """
+    import os
+    try:
+        return int( os.getenv( "NSPORT" ) )
+    except:
+        pass
+    port = getPortFromORBcfg()
+    if port is not None: return port
+    return 2809      # '2809' is default port number
+
+# ---
+
+def getTmpDir():
+    """
+    Get directory to be used for the temporary files.
+    """
+    import os, sys
+    if sys.platform == "win32":
+        # for Windows: temporarily using home directory for tmp files;
+        # to be replaced with TEMP environment variable later...
+        dir = os.getenv("HOME")
+    else:
+        # for Linux: use /tmp/logs/{user} folder
+        dir = os.path.join( '/tmp', 'logs', getUserName() )
+        pass
+    return dir
+
+# ---
+
+def generateFileName( dir, prefix = None, suffix = None, extension = None,
+                      unique = False, separator = "_", hidden = False, **kwargs ):
+    """
+    Generate file name by sepecified parameters. If necessary, file name
+    can be generated to be unique.
+
+    Parameters:
+    - dir       : directory path
+    - prefix    : file prefix (not added by default)
+    - suffix    : file suffix (not added by default)
+    - extension : file extension (not added by default)
+    - unique    : if this parameter is True, the unique file name is generated:
+    in this case, if the file with the generated name already exists
+    in the <dir> directory, an integer suffix is added to the end of the
+    file name. This parameter is False by default.
+    - separator : separator of the words ('_' by default)
+    - hidden    : if this parameter is True, the file name is prepended by . (dot)
+    symbol. This parameter is False by default.
+
+    Other keyword parameters are:
+    - with_username : 'add user name' flag/option:
+      * boolean value can be passed to determine user name automatically
+      * string value to be used as user name
+    - with_hostname : 'add host name' flag/option:
+      * boolean value can be passed to determine host name automatically
+      * string value to be used as host name
+    - with_port     : 'add port number' flag/option:
+      * boolean value can be passed to determine port number automatically
+      * string value to be used as port number
+    - with_app      : 'add application name' flag/option:
+      * boolean value can be passed to determine application name automatically
+      * string value to be used as application name
+    All <with_...> parameters are optional.
+    """
+    supported = [ 'with_username', 'with_hostname', 'with_port', 'with_app' ]
+    from launchConfigureParser import verbose
+    filename = []
+    # separator
+    if separator is None:
+        separator = ""
+        pass
+    else:
+        separator = str( separator )
+        pass
+    # prefix (if specified)
+    if prefix is not None:
+        filename.append( str( prefix ) )
+        pass
+    # additional keywords
+    ### check unsupported parameters
+    for kw in kwargs:
+        if kw not in supported and verbose():
+            print 'Warning! salome_utilitie.py: generateFileName(): parameter %s is not supported' % kw
+            pass
+        pass
+    ### process supported keywords
+    for kw in supported:
+        if kw not in kwargs: continue
+        ### user name
+        if kw == 'with_username':
+            try:
+                # auto user name ?
+                if _try_bool( kwargs[kw] ): filename.append( getUserName() )
+                pass
+            except:
+                # user name given as parameter
+                filename.append( kwargs[kw] )
+                pass
+            pass
+        ### host name
+        elif kw == 'with_hostname':
+            try:
+                # auto host name ?
+                if _try_bool( kwargs[kw] ): filename.append( getShortHostName() )
+                pass
+            except:
+                # host name given as parameter
+                filename.append( kwargs[kw] )
+                pass
+            pass
+        ### port number
+        elif kw == 'with_port':
+            try:
+                # auto port number ?
+                if _try_bool( kwargs[kw] ): filename.append( str( getPortNumber() ) )
+                pass
+            except:
+                # port number given as parameter
+                filename.append( str( kwargs[kw] ) )
+                pass
+            pass
+        ### application name
+        elif kw == 'with_app':
+            try:
+                # auto application name ?
+                if _try_bool( kwargs[kw] ): filename.append( getAppName() )
+                pass
+            except:
+                # application name given as parameter
+                filename.append( kwargs[kw] )
+                pass
+            pass
+        pass
+    # suffix (if specified)
+    if suffix is not None:
+        filename.append( str( suffix ) )
+        pass
+    # raise an exception if file name is empty
+    if not filename:
+        raise Exception("Empty file name")
+    #
+    if extension is not None and extension.startswith("."): extension = extension[1:]
+    #
+    import os
+    name = separator.join( filename )
+    if hidden: name = "." + name                       # add dot for hidden files
+    if extension: name = name + "." + str( extension ) # add extension if defined
+    name = os.path.join( dir, name )
+    if unique:
+        # create unique file name
+        index = 0
+        while os.path.exists( name ):
+            index = index + 1
+            name = separator.join( filename ) + separator + str( index )
+            if hidden: name = "." + name                       # add dot for hidden files
+            if extension: name = name + "." + str( extension ) # add extension if defined
+            name = os.path.join( dir, name )
+            pass
+        pass
+    return name
index 86a4803baaa0683c42d6e237174cdb4884b685f1..14ae3c5bcdb3e6eb5dbe6f08eb979a7765e525e1 100755 (executable)
@@ -75,7 +75,7 @@ def get_lib_dir():
 
 # -----------------------------------------------------------------------------
 
-def get_config():
+def get_config(silent=False):
     """
     Get list of modules, paths.
     
@@ -116,12 +116,14 @@ def get_config():
     for module in modules_list :
         module_variable=module+"_ROOT_DIR"
         if not os.environ.has_key(module_variable):
-            print "*******************************************************"
-            print "*"
-            print "* Environment variable",module_variable,"must be set"
-            print "* Module", module, "will be not available"
-            print "*"
-            print "********************************************************"
+            if not silent:
+                print "*******************************************************"
+                print "*"
+                print "* Environment variable",module_variable,"must be set"
+                print "* Module", module, "will be not available"
+                print "*"
+                print "********************************************************"
+                pass
             to_remove_list.append(module)
             continue
             pass
@@ -147,7 +149,7 @@ def get_config():
 
 # -----------------------------------------------------------------------------
 
-def set_env(args, modules_list, modules_root_dir):
+def set_env(args, modules_list, modules_root_dir, silent=False):
     """Add to the PATH-variables modules specific paths"""
     
     python_version="python%d.%d" % sys.version_info[0:2]
@@ -187,9 +189,46 @@ def set_env(args, modules_list, modules_root_dir):
                                   salome_subdir,
                                   "shared_modules"),
                      "PYTHONPATH")
-            pass
-        pass
 
+            # set environment for SMESH plugins
+           if module == "SMESH" :
+               os.environ["SMESH_MeshersList"]="StdMeshers"
+               if not os.environ.has_key("SALOME_StdMeshersResources"):
+                   os.environ["SALOME_StdMeshersResources"] \
+                    = modules_root_dir["SMESH"]+"/share/"+salome_subdir+"/resources/smesh"
+                    pass
+               if args.has_key("SMESH_plugins"):
+                    for plugin in args["SMESH_plugins"]:
+                        plugin_root = ""
+                        if os.environ.has_key(plugin+"_ROOT_DIR"):
+                            plugin_root = os.environ[plugin+"_ROOT_DIR"]
+                        else:
+                            # workaround to avoid modifications of existing environment
+                            if os.environ.has_key(plugin.upper()+"_ROOT_DIR"):
+                                plugin_root = os.environ[plugin.upper()+"_ROOT_DIR"]
+                                pass
+                            pass
+                        if plugin_root != "":
+                            os.environ["SMESH_MeshersList"] \
+                            = os.environ["SMESH_MeshersList"]+":"+plugin
+                            if not os.environ.has_key("SALOME_"+plugin+"Resources"):
+                                os.environ["SALOME_"+plugin+"Resources"] \
+                                = plugin_root+"/share/"+salome_subdir+"/resources/"+plugin.lower()
+                                add_path(os.path.join(plugin_root,get_lib_dir(),python_version, "site-packages",salome_subdir), "PYTHONPATH")
+                                add_path(os.path.join(plugin_root,get_lib_dir(),salome_subdir), "PYTHONPATH")
+                                
+                                if sys.platform == "win32":
+                                    add_path(os.path.join(plugin_root,get_lib_dir(),salome_subdir), "PATH")
+                                else:
+                                    add_path(os.path.join(plugin_root,get_lib_dir(),salome_subdir), "LD_LIBRARY_PATH")
+                                    add_path(os.path.join(plugin_root,"bin",salome_subdir), "PYTHONPATH")
+                                    add_path(os.path.join(plugin_root,"bin",salome_subdir), "PATH")
+                                    pass
+                                pass
+                            pass
+                        pass
+                    pass
+                    
     if sys.platform == 'win32':
         os.environ["SALOMEPATH"]=";".join(modules_root_dir_list)
     else:
@@ -204,51 +243,6 @@ def set_env(args, modules_list, modules_root_dir):
     if args['logger']:
         os.environ["SALOME_trace"]="with_logger"
 
-    # set environment for SMESH plugins
-
-    if "SMESH" in modules_list:
-        os.environ["SMESH_MeshersList"]="StdMeshers"
-        if not os.environ.has_key("SALOME_StdMeshersResources"):
-            os.environ["SALOME_StdMeshersResources"] \
-            = modules_root_dir["SMESH"]+"/share/"+salome_subdir+"/resources/smesh"
-            pass
-        if args.has_key("SMESH_plugins"):
-            for plugin in args["SMESH_plugins"]:
-                plugin_root = ""
-                if os.environ.has_key(plugin+"_ROOT_DIR"):
-                    plugin_root = os.environ[plugin+"_ROOT_DIR"]
-                else:
-                    # workaround to avoid modifications of existing environment
-                    if os.environ.has_key(plugin.upper()+"_ROOT_DIR"):
-                        plugin_root = os.environ[plugin.upper()+"_ROOT_DIR"]
-                        pass
-                    pass
-                if plugin_root != "":
-                    os.environ["SMESH_MeshersList"] \
-                    = os.environ["SMESH_MeshersList"]+":"+plugin
-                    if not os.environ.has_key("SALOME_"+plugin+"Resources"):
-                        os.environ["SALOME_"+plugin+"Resources"] \
-                        = plugin_root+"/share/"+salome_subdir+"/resources/"+plugin.lower()
-                    add_path(os.path.join(plugin_root,get_lib_dir(),python_version,
-                                          "site-packages",salome_subdir),
-                             "PYTHONPATH")
-                    add_path(os.path.join(plugin_root,get_lib_dir(),salome_subdir),
-                             "PYTHONPATH")
-
-
-                    if sys.platform == "win32":
-                      add_path(os.path.join(plugin_root,get_lib_dir(),salome_subdir),
-                          "PATH")
-                    else:
-                      add_path(os.path.join(plugin_root,get_lib_dir(),salome_subdir),
-                               "LD_LIBRARY_PATH")
-                    add_path(os.path.join(plugin_root,"bin",salome_subdir),
-                             "PYTHONPATH")
-                    add_path(os.path.join(plugin_root,"bin",salome_subdir),
-                             "PATH")
-            pass
-        pass
-
     # set environment for SUPERV module
     os.environ["ENABLE_MACRO_NODE"]="1"
     # set resources variables if not yet set
@@ -261,7 +255,7 @@ def set_env(args, modules_list, modules_root_dir):
                    salome_subdir,"resources","kernel")
 
     if "GEOM" in modules_list:
-        if verbose(): print "GEOM OCAF Resources" 
+        if verbose() and not silent: print "GEOM OCAF Resources" 
         
        # set CSF_PluginDefaults variable only if it is not customized
         # by the user
@@ -273,16 +267,16 @@ def set_env(args, modules_list, modules_root_dir):
         os.environ["CSF_GEOMDS_ResourcesDefaults"] \
         = os.path.join(modules_root_dir["GEOM"],"share",
                        salome_subdir,"resources","geom")
-        if verbose(): print "GEOM Shape Healing Resources"
+        if verbose() and not silent: print "GEOM Shape Healing Resources"
         os.environ["CSF_ShHealingDefaults"] \
         = os.path.join(modules_root_dir["GEOM"],"share",
                        salome_subdir,"resources","geom")
 
 # -----------------------------------------------------------------------------
 
-def main():
-    args, modules_list, modules_root_dir = get_config()
-    set_env(args, modules_list, modules_root_dir)
+def main(silent=False):
+    args, modules_list, modules_root_dir = get_config(silent=silent)
+    set_env(args, modules_list, modules_root_dir, silent=silent)
     return args
 
 # -----------------------------------------------------------------------------
index 9ff37591de2d54238c88674176d55976943841c5..05bad51407f921ff97df54b1c542e4465d45ee08 100644 (file)
@@ -201,14 +201,15 @@ DSC_EnginesPaCO.h DSC_EnginesPaCO.cc : DSC_Engines.idl DSC_Engines.xml
 lib_LTLIBRARIES = libSalomeIDLKernel.la $(PAR_LIB)
 
 nodist_libSalomeIDLKernel_la_SOURCES = $(IDL_SOURCES) $(DYNIDL_SRCS)
-libSalomeIDLKernel_la_CPPFLAGS =-I$(top_builddir)/salome_adm/unix \
+libSalomeIDLKernel_la_CPPFLAGS =-I$(top_builddir)/salome_adm/unix -include SALOMEconfig.h \
                                -I$(top_builddir)/idl \
                                @CORBA_CXXFLAGS@ @CORBA_INCLUDES@
 libSalomeIDLKernel_la_LDFLAGS = -no-undefined -version-info=0:0:0
 libSalomeIDLKernel_la_LIBADD  = @CORBA_LIBS@
 
 nodist_libSalomeParallelIDLKernel_la_SOURCES = $(PAR) $(GEN_PACO)
-libSalomeParallelIDLKernel_la_CPPFLAGS =-I$(top_builddir)/idl \
+libSalomeParallelIDLKernel_la_CPPFLAGS =-I$(top_builddir)/salome_adm/unix -include SALOMEconfig.h \
+                                       -I$(top_builddir)/idl \
                                        @CORBA_CXXFLAGS@ @CORBA_INCLUDES@ \
                                        @PACO_INCLUDES@
 libSalomeParallelIDLKernel_la_LDFLAGS = -no-undefined -version-info=0:0:0
index b2d2a9a5f5dbaf40797c041ae2fef94e40616ec0..0597e7822d2fd476ba377135f1bf3eadd783c9f7 100644 (file)
@@ -34,7 +34,7 @@ DEPRECATED_FILES=\
 # rules for install and build (see make_common_starter.am)
 salomeadmux_DATA = SALOMEconfig.h.in
 salomeinclude_DATA = SALOMEconfig.h
-BUILT_SOURCES=SALOMEconfig.h SALOMEconfig.h.in
+BUILT_SOURCES=SALOMEconfig.ref SALOMEconfig.h SALOMEconfig.h.in
 
 mostlyclean-local:
        -rm -rf SALOMEconfig.h SALOMEconfig.h.in
@@ -45,9 +45,11 @@ SALOMEconfig.h.in : SALOMEconfig.ref.in
 # test if SALOMEconfig.ref has changed (contents), at build time
 SALOMEconfig.h: $(top_builddir)/salome_adm/unix/SALOMEconfig.ref
        @if ! [ -a $@ ]; then \
+         echo cp -p $< $@;   \
          cp -p $< $@;        \
        fi;                   \
-       if ! cmp $< $@; then  \
+       if ! cmp -s $< $@; then  \
+         echo cp -p $< $@;   \
          cp -p $< $@;        \
        fi;
 
index 78688bd880cdd3e9e5375612d6a99a28ace3f936..923fef3562fb65856e289d6fb4401fa6056627f4 100644 (file)
@@ -71,4 +71,8 @@
 #undef PACKAGE_VERSION
 #endif
 
+#ifdef _POSIX_C_SOURCE
+#undef _POSIX_C_SOURCE
+#endif
+
 #endif
index ab2ba319dd9586d665d06135966fe590c19ec3c9..1eade7949649c12679d585609695ac872fdb5805 100644 (file)
@@ -188,8 +188,7 @@ if test "x$occ_ok" = xyes ; then
   AC_CACHE_VAL(salome_cv_lib_occ,[
     AC_TRY_LINK(
 #include <TCollection_AsciiString.hxx>
-,   size_t size;
-    TCollection_AsciiString aStr ("toto");
+,    TCollection_AsciiString aStr ("toto");
     aStr.Capitalize();, 
     eval "salome_cv_lib_occ=yes",eval "salome_cv_lib_occ=no")
   ])
index 9c1e213009d529f5c30d8c88a7891b8d38dd6735..deca0e9c9c9a88be4d43e905efcb2290ce0b95bd 100644 (file)
@@ -172,6 +172,7 @@ void HouseKeeping( void )
 
   delete GENERIC_DESTRUCTOR::Destructors;
   GENERIC_DESTRUCTOR::Destructors = 0;
+  atExitSingletonDone = false ;
   DEVTRACE("HouseKeeping() very end ");
   return ;
 }
index a657696acf0641fb55ac7ca91e363094ef5d28e7..b228a5ddc04b91aee1ae3f4450439914f1bb2413 100644 (file)
@@ -124,7 +124,7 @@ namespace Batch {
       _sec   = p_tm->tm_sec;
 
     } else {
-      char c;
+//       char c;
 //       istringstream ist(s);
 //       ist >> _day   >> c
 //       >> _month >> c
index ad778fa147fa92b6d0d5bf492852ee6deb57d6cc..58dfacc87add9be634bf2f22616d41338d1299b2 100644 (file)
@@ -184,7 +184,7 @@ namespace Batch {
   ostream & operator << (ostream & os, const Versatile & V)
   {
     Versatile::const_iterator it;
-    char * sep = "";
+    const char * sep = "";
 
     for(it=V.begin(); it!=V.end(); it++, sep=" ") {
       string s = (*it)->affiche();
index 4ff9731e87aae1b9c9e57e6af884fe9c064dfd2e..f27bc4f3ca586aa8f7ec125d1ca5a53543350a59 100644 (file)
@@ -43,7 +43,7 @@
 
   // Ask omniORBpy to transform SUPPORT (python Corba) ptr to IOR string
 
-  PyObject* iorSupport = PyObject_CallMethod(orb, "object_to_string", "O", $input);
+  PyObject* iorSupport = PyObject_CallMethod(orb, (char*)"object_to_string", (char*)"O", $input);
  
   if (iorSupport == Py_None)
     return NULL;
@@ -52,7 +52,7 @@
   // Ask omniORB to convert IOR string to SALOME::SenderDouble_ptr
 
   int argc = 0;
-  char *xargv = "";
+  char *xargv = (char*)"";
   char **argv = &xargv;
   CORBA::ORB_var ORB = CORBA::ORB_init(argc, argv);
   CORBA::Object_var O =  ORB->string_to_object(s);
@@ -73,7 +73,7 @@
 
   // Ask omniORBpy to transform SUPPORT (python Corba) ptr to IOR string
 
-  PyObject* iorSupport = PyObject_CallMethod(orb, "object_to_string", "O", $input);
+  PyObject* iorSupport = PyObject_CallMethod(orb, (char*)"object_to_string", (char*)"O", $input);
  
   if (iorSupport == Py_None)
     return NULL;
@@ -82,7 +82,7 @@
   // Ask omniORB to convert IOR string to SALOME::SenderInt_ptr
 
   int argc = 0;
-  char *xargv = "";
+  char *xargv = (char*)"";
   char **argv = &xargv;
   CORBA::ORB_var ORB = CORBA::ORB_init(argc, argv);
   CORBA::Object_var O =  ORB->string_to_object(s);
    PyObject* orb = PyDict_GetItemString(pdict, "o");
    // Get the orb Corba C++
    int argc = 0;
-   char *xargv = "";
+   char *xargv = (char*)"";
    char **argv = &xargv;
    CORBA::ORB_var ORB = CORBA::ORB_init(argc, argv);
    std::string s =  ORB->object_to_string($1);
    PyObject * tmp = PyString_FromString(s.c_str());
-   $result = PyObject_CallMethod(orb, "string_to_object", "O", tmp);
+   $result = PyObject_CallMethod(orb, (char*)"string_to_object", (char*)"O", tmp);
 }
 
 %typemap(python,out) SALOME::SenderInt_ptr
    PyObject* orb = PyDict_GetItemString(pdict, "o");
    // Get the orb Corba C++
    int argc = 0;
-   char *xargv = "";
+   char *xargv = (char*)"";
    char **argv = &xargv;
    CORBA::ORB_var ORB = CORBA::ORB_init(argc, argv);
    std::string s =  ORB->object_to_string($1);
    PyObject * tmp = PyString_FromString(s.c_str());
-   $result = PyObject_CallMethod(orb, "string_to_object", "O", tmp);
+   $result = PyObject_CallMethod(orb, (char*)"string_to_object", (char*)"O", tmp);
 }
 
 PyObject * getValueForSenderDouble(SALOME::SenderDouble_ptr senderDouble);
@@ -140,7 +140,7 @@ PyObject * getValueForSenderDouble(SALOME::SenderDouble_ptr senderDouble)
             int err = PyList_SetItem(py_list, i, Py_BuildValue("d", (double) ret[i]));
             if(err)
               {
-                char * message = "Error in SUPPORT::getTypes";
+                const char * message = "Error in SUPPORT::getTypes";
                 PyErr_SetString(PyExc_RuntimeError, message);
                 return NULL;
               }
@@ -167,7 +167,7 @@ PyObject * getValueForSenderInt(SALOME::SenderInt_ptr senderInt)
             int err = PyList_SetItem(py_list, i, Py_BuildValue("i", (int) ret[i]));
             if(err)
               {
-                char * message = "Error in SUPPORT::getTypes";
+                const char * message = "Error in SUPPORT::getTypes";
                 PyErr_SetString(PyExc_RuntimeError, message);
                 return NULL;
               }
@@ -195,7 +195,7 @@ PyObject * getValueForMatrix(SALOME::Matrix_ptr matrix)
            int err = PyList_SetItem(tmpRow, j, Py_BuildValue("d", (double) ret[i*column+j]));
             if(err)
               {
-                char * message = "PyList_SetItem matrix sent may be invalid";
+                const char * message = "PyList_SetItem matrix sent may be invalid";
                 PyErr_SetString(PyExc_RuntimeError, message);
                 return NULL;
               }
index 867411196bac4f20c75227798e473c4533e4217b..885750da9ed96f7101f1e2158805677b304a1541 100644 (file)
@@ -295,8 +295,8 @@ void Engines_Component_i::destroy()
 
   delete _myConnexionToRegistry;
   _myConnexionToRegistry = 0 ;
-  _poa->deactivate_object(*_id) ;
-  delete(_id) ;
+  if(_id)
+    delete(_id) ;
   //SCRUTE(pd_refCount);
   _thisObj->_remove_ref();
   //SCRUTE(pd_refCount);
index 0095b0bc579c69fdc082d273322ff3eb4f4137b0..985fd4e42f7427cf4cc565e962d79766776cca91 100644 (file)
@@ -480,8 +480,8 @@ Engines_Container_i::load_component_Library(const char* componentName)
       PyObject *globals = PyModule_GetDict(mainmod);
       PyObject *pyCont = PyDict_GetItemString(globals, "pyCont");
       PyObject *result = PyObject_CallMethod(pyCont,
-                                             "import_component",
-                                             "s",componentName);
+                                             (char*)"import_component",
+                                             (char*)"s",componentName);
       int ret= PyInt_AsLong(result);
       Py_XDECREF(result);
       SCRUTE(ret);
@@ -557,8 +557,8 @@ Engines_Container_i::create_component_instance(const char*genericRegisterName,
       PyObject *globals = PyModule_GetDict(mainmod);
       PyObject *pyCont = PyDict_GetItemString(globals, "pyCont");
       PyObject *result = PyObject_CallMethod(pyCont,
-                                             "create_component_instance",
-                                             "ssl",
+                                             (char*)"create_component_instance",
+                                             (char*)"ssl",
                                              aCompName.c_str(),
                                              instanceName.c_str(),
                                              studyId);
@@ -655,7 +655,7 @@ Engines_Container_i::create_component_instance(const char*genericRegisterName,
     }
   else
     {
-      int count=10;
+      int count=20;
       CORBA::Object_var obj = CORBA::Object::_nil() ;
       while ( CORBA::is_nil(obj) && count )
         {
@@ -678,6 +678,7 @@ Engines_Container_i::create_component_instance(const char*genericRegisterName,
         {
           MESSAGE("SALOME_Container::create_component_instance successful");
           iobject=Engines::Component::_narrow(obj);
+          _listInstances_map[instanceName] = iobject;
           return iobject._retn();
         }
     }
@@ -1075,8 +1076,12 @@ Engines_Container_i::createInstance(string genericRegisterName,
       SCRUTE(aGenRegisterName);
       SCRUTE(_cntInstances_map[aGenRegisterName]);
       //SCRUTE(servant->pd_refCount);
+#if defined(_DEBUG_) || defined(_DEBUG)
       bool ret_studyId = servant->setStudyId(studyId);
       ASSERT(ret_studyId);
+#else
+      servant->setStudyId(studyId);
+#endif
 
       // --- register the engine under the name
       //     containerName(.dir)/instanceName(.object)
index dcdaed6e10f60f5237bd5f9a0645a81242c0b1f7..d81ac5760aadb50a3e8111872361d048d0346af9 100644 (file)
@@ -30,6 +30,7 @@
 #define _CONTAINER_INIT_PYTHON_HXX_
 
 #include <SALOME_Container.hxx>
+#include <SALOMEconfig.h>
 
 #include <pthread.h>  // must be before Python.h !
 #include <Python.h>
@@ -50,7 +51,7 @@
 #define Py_ACQUIRE_NEW_THREAD \
   PyEval_AcquireLock(); \
   PyThreadState *myTstate = PyThreadState_New(KERNEL_PYTHON::_interp); \
-  PyThreadState *myoldTstate = PyThreadState_Swap(myTstate);
+  PyThreadState_Swap(myTstate);
 
 #define Py_RELEASE_NEW_THREAD \
   PyEval_ReleaseThread(myTstate); \
index 5d071b8e422c38e44b653047edade3c9f2911ef1..77f89ac4720ade0f60f808f8c7db8609d9057c90 100755 (executable)
@@ -147,8 +147,9 @@ class SALOME_ComponentPy_i (Engines__POA.Component):
 
     def destroy(self):
         MESSAGE(  "SALOME_ComponentPy_i::destroy" )
-        id = self._poa.servant_to_id(self)
-        self._poa.deactivate_object(id)
+        #id = self._poa.servant_to_id(self)
+        #self._poa.deactivate_object(id)
+        return
         
     #-------------------------------------------------------------------------
 
index 39812040d6c27d0297bb27fe1406cee523776bbb..61401e7f086a802f091fbc19c611b7f7a963c2e5 100644 (file)
@@ -142,8 +142,8 @@ int main(int argc, char* argv[])
 
   if (!isSupervContainer)
     {
-      int _argc = 1;
-      char* _argv[] = {""};
+      // int _argc = 1;
+      // char* _argv[] = {""};
       KERNEL_PYTHON::init_python(argc,argv);
     }
   else
@@ -152,7 +152,7 @@ int main(int argc, char* argv[])
       PySys_SetArgv( argc , argv ) ;
     }
     
-  char *containerName = "";
+  char *containerName = (char *)"";
   if(argc > 1)
     {
       containerName = argv[1] ;
@@ -173,8 +173,7 @@ int main(int argc, char* argv[])
       system(aCommand.str().c_str());
 #endif
       
-      Engines_Container_i * myContainer 
-       = new Engines_Container_i(orb, root_poa, containerName , argc , argv );
+      new Engines_Container_i(orb, root_poa, containerName , argc , argv );
       
       pman->activate();
       
@@ -189,7 +188,7 @@ int main(int argc, char* argv[])
 
       if (!isSupervContainer)
       {
-        PyGILState_STATE gstate = PyGILState_Ensure();
+        PyGILState_Ensure();
         //Delete python container that destroy orb from python (pyCont._orb.destroy())
         Py_Finalize();
       }
index 17915095442258ac4a9895206cacc724ef5997fa..405d1f963f7a7ca2bab7814701b0a9093a11b456 100644 (file)
@@ -64,8 +64,8 @@ class SALOME_Container_i:
 
     #-------------------------------------------------------------------------
 
-    def __del__(self ):
-      self._orb.destroy()
+    #def __del__(self ):
+    #  self._orb.destroy()
 
     def import_component(self, componentName):
         MESSAGE( "SALOME_Container_i::import_component" )
index 20f46f6d7c48d28afa4a86b5cbc005c1c55600a1..8d887aed84650f7b280c680bf163590811284e8f 100644 (file)
@@ -280,10 +280,19 @@ StartContainer(const Engines::MachineParameters& params,
   CORBA::Object_var obj = _NS->Resolve(containerNameInNS.c_str());
   if ( !CORBA::is_nil(obj) )
     {
-      // unregister the registered container if it exists
-      _NS->Destroy_Name(containerNameInNS.c_str());
-      // unregister component instances ???
-      //Engines::Container_var cont=Engines::Container::_narrow(obj);
+      // shutdown the registered container if it exists
+      Engines::Container_var cont=Engines::Container::_narrow(obj);
+      if(!CORBA::is_nil(cont))
+        {
+          try
+            {
+              cont->Shutdown();
+            }
+          catch(CORBA::Exception&)
+            {
+              INFOS("CORBA::Exception ignored.");
+            }
+        }
     }
 
   //redirect stdout and stderr in a file
@@ -367,9 +376,7 @@ StartContainer(const Engines::MachineParameters& params,
           SALOME_ModuleCatalog::Acomponent_var compoInfo = Catalog->GetComponent(compoi);
           if (CORBA::is_nil (compoInfo))
             {
-              INFOS("ContainerManager Error: Component not found in the catalog" );
-              INFOS( compoi );
-              return Engines::Container::_nil();
+              continue;
             }
           SALOME_ModuleCatalog::ImplType impl=compoInfo->implementation_type();
           container_exe=compoInfo->implementation_name();
index cb1117ed73aa56984565733ffca450658aa4e8a6..6f4d1b6a81b50684acae46ee080ca429780a7229 100644 (file)
 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 
 
+#include <SALOMEconfig.h>
 #include <stdexcept>
 #include <omniORB4/CORBA.h>
+
 #include "utilities.h"
 
 // CCRT porting
index 7dfa311b9e857ecbc1e184741a694717db15e24c..3fda8667f7e5227ed773390090423e128520ada3 100644 (file)
@@ -53,8 +53,12 @@ fileRef_i::fileRef_i(Engines::Container_ptr container,
   _container =  Engines::Container::_duplicate(container);
   _origFileName = origFileName;
   _machine = GetHostname();
+#if defined(_DEBUG_) || defined(_DEBUG)
   int OK = addRef(_machine.c_str(), _origFileName.c_str());
   SCRUTE(OK);
+#else
+  addRef(_machine.c_str(), _origFileName.c_str());
+#endif
 }
 
 
index d2cbb1d6e9d7fba0dffc9bc383f7238c6a6d999e..89aae57db797364bff24e3a3bdfb55ddeea01b7c 100644 (file)
@@ -838,8 +838,12 @@ Salome_file_i::getDistributedFile(std::string file_name)
       aBlock = _fileDistributedSource[file_name]->getBlock(fileId);
       toFollow = aBlock->length();
       CORBA::Octet *buf = aBlock->get_buffer();
+#if defined(_DEBUG_) || defined(_DEBUG)
       int nbWri = fwrite(buf, sizeof(CORBA::Octet), toFollow, fp);
       ASSERT(nbWri == toFollow);
+#else
+      fwrite(buf, sizeof(CORBA::Octet), toFollow, fp);
+#endif
       delete aBlock;
     }
     fclose(fp);
index 69dd8920cb378a4c0982ec61d99b78ccb1a93a0c..ee457316f1a0e5c18efa54cf8d70b566228187ae 100644 (file)
@@ -186,9 +186,9 @@ int main (int argc, char * argv[])
   cout << "Test started " << endl;
   
   DF_Application* appli = new DF_Application;
+  /*  
   DF_Document* doc1 = appli->NewDocument("doc_1");
   
-  /*  
   DF_Label root1 = doc1->Main();
   DF_Label child = root1.FindChild(3, true); //0:1:3
   
index dddf3aa063f20c47c9af8dfa00d8c709573e1a5e..90d135d8d0dc4a9de21ef3002fd8b1b32bdd709b 100644 (file)
@@ -38,6 +38,7 @@ struct omniORBpyAPI {
 };
 
   omniORBpyAPI* api;
+  PyObject* dsc ;
 
 
 %}
@@ -60,6 +61,9 @@ struct omniORBpyAPI {
   PyObject* pyapi = PyObject_GetAttrString(omnipy, (char*)"API");
   api = (omniORBpyAPI*)PyCObject_AsVoidPtr(pyapi);
   Py_DECREF(pyapi);
+
+  PyObject* engines = PyImport_ImportModule("Engines");
+  dsc = PyObject_GetAttrString(engines, "DSC");
 %}
 
 %include <exception.i>
@@ -78,6 +82,9 @@ struct omniORBpyAPI {
 
 #ifdef WITH_NUMPY
 /* With Numpy */
+#ifdef HAVE_ISINF
+#undef HAVE_ISINF
+#endif
 #include <numpy/arrayobject.h>
 
 typedef PyArrayObject ArrayObject;
@@ -92,7 +99,7 @@ typedef PyArrayObject ArrayObject;
 
 /* Given a PyObject, return a string describing its type.
  */
-char* pytype_string(PyObject* py_obj) {
+const char* pytype_string(PyObject* py_obj) {
   if (py_obj == NULL          ) return "C NULL value";
   if (PyCallable_Check(py_obj)) return "callable"    ;
   if (PyString_Check(  py_obj)) return "string"      ;
@@ -148,8 +155,8 @@ enum NPY_TYPECHAR { NPY_BOOLLTR = '?',
 
 /* Given a Numeric typecode, return a string describing the type.
  */
-char* typecode_string(int typecode) {
-  char* type_names[] = {"bool","byte","unsigned byte","short",
+const char* typecode_string(int typecode) {
+  const char* type_names[] = {"bool","byte","unsigned byte","short",
         "unsigned short","int","unsigned int","long","unsigned long",
         "longlong","unsigned longlong",
         "float","double","long double","complex float","complex double","complex long double",
@@ -176,16 +183,16 @@ PyArrayObject* obj_to_array_no_conversion(PyObject* input, int typecode) {
         ary = (PyArrayObject*) input;
     }
     else if is_array(input) {
-      char* desired_type = typecode_string(typecode);
-      char* actual_type = typecode_string(array_type(input));
+      const char* desired_type = typecode_string(typecode);
+      const char* actual_type = typecode_string(array_type(input));
       PyErr_Format(PyExc_TypeError,
        "Array of type '%s' required.  Array of type '%s' given",
        desired_type, actual_type);
       ary = NULL;
     }
     else {
-      char * desired_type = typecode_string(typecode);
-      char * actual_type = pytype_string(input);
+      const char * desired_type = typecode_string(typecode);
+      const char * actual_type = pytype_string(input);
       PyErr_Format(PyExc_TypeError,
        "Array of type '%s' required.  A %s was given",
        desired_type, actual_type);
@@ -418,10 +425,10 @@ struct stringArray
 %define TYPEMAP_IN3(type,typecode)
 %typemap(in) type* IN_ARRAY3
              (ArrayObject* array=NULL, int is_new_object) {
-  int size[1] = {-1};
   if ((SWIG_ConvertPtr($input, (void **) &$1, $1_descriptor,0)) == -1)
   {
 %#ifdef WITH_NUMPY
+    int size[1] = {-1};
     array = obj_to_array_contiguous_allow_conversion($input, typecode, &is_new_object);
     if (!array || !require_dimensions(array,1) || !require_size(array,size,1)) SWIG_fail;
     $1 = (type*) array->data;
@@ -448,10 +455,10 @@ TYPEMAP_IN3(double,  PyArray_DOUBLE)
 /*  Specific typemap for complex */
 %typemap(in) float*  ecpval
              (ArrayObject* array=NULL, int is_new_object) {
-  int size[1] = {-1};
   if ((SWIG_ConvertPtr($input, (void **) &$1, $1_descriptor,0)) == -1)
   {
 %#ifdef WITH_NUMPY
+    int size[1] = {-1};
     array = obj_to_array_contiguous_allow_conversion($input, PyArray_CFLOAT, &is_new_object);
     if (!array || !require_dimensions(array,1) || !require_size(array,size,1)) SWIG_fail;
     $1 = (float*) array->data;
@@ -468,11 +475,11 @@ TYPEMAP_IN3(double,  PyArray_DOUBLE)
 /* array of strings on input */
 %typemap(in) char** eval
          (ArrayObject* array=NULL, int is_new_object) {
-  int size[1] = {-1};
   stringArray* sarray;
   if ((SWIG_ConvertPtr($input, (void **) &sarray, $descriptor(stringArray *),0)) == -1)
   {
 %#ifdef WITH_NUMPY
+    int size[1] = {-1};
     array = obj_to_array_contiguous_allow_conversion($input, PyArray_STRING, &is_new_object);
     if (!array || !require_dimensions(array,1) || !require_size(array,size,1)) SWIG_fail;
     $1 = (char**) malloc(array_size(array,0)*sizeof(char*));
@@ -508,6 +515,7 @@ TYPEMAP_IN3(double,  PyArray_DOUBLE)
     if (!temp  || !require_contiguous(temp)) SWIG_fail;
     $1 = (type*) temp->data;
 %#else
+    temp = NULL;
     SWIG_exception(SWIG_TypeError, "type* expected");
 %#endif
   }
@@ -534,6 +542,7 @@ TYPEMAP_INPLACE3(double,  PyArray_DOUBLE)
     if (!temp  || !require_contiguous(temp)) SWIG_fail;
     $1 = (float*) temp->data;
 %#else
+    temp = NULL;
     SWIG_exception(SWIG_TypeError, "complex array expected");
 %#endif
   }
@@ -553,6 +562,7 @@ TYPEMAP_INPLACE3(double,  PyArray_DOUBLE)
     for(int i=0;i<array_size(temp,0);i++)
       $1[i]=(char*) temp->data+i*temp->strides[0];
 %#else
+    temp = NULL;
     SWIG_exception(SWIG_TypeError, "string array expected");
 %#endif
   }
@@ -570,6 +580,10 @@ TYPEMAP_INPLACE3(double,  PyArray_DOUBLE)
 {
   $1=(CORBA::Boolean)PyInt_AsLong($input);
 }
+%typemap(out) CORBA::Boolean
+{
+  $result=PyInt_FromLong($1 ? 1 : 0);
+}
 
 %define CORBAPTR(type)
 %typemap(in) type##_ptr
@@ -630,17 +644,29 @@ CORBAPTR(PortableServer::POA)
    }
    catch(Engines::DSC::PortNotDefined& _e) {
       Py_BLOCK_THREADS
-      PyErr_SetString(PyExc_ValueError,"Port not defined");
+      PyObject* excc = PyObject_GetAttrString(dsc, "PortNotDefined");
+      PyObject* exci = PyEval_CallObject(excc, (PyObject *)NULL);
+      PyErr_SetObject(excc, exci);
+      Py_XDECREF(excc);
+      Py_XDECREF(exci);
       return NULL;
    }
    catch(Engines::DSC::PortNotConnected& _e) {
       Py_BLOCK_THREADS
-      PyErr_SetString(PyExc_ValueError,"Port not connected");
+      PyObject* excc = PyObject_GetAttrString(dsc, "PortNotConnected");
+      PyObject* exci = PyEval_CallObject(excc, (PyObject *)NULL);
+      PyErr_SetObject(excc, exci);
+      Py_XDECREF(excc);
+      Py_XDECREF(exci);
       return NULL;
    }
    catch(Engines::DSC::BadPortType& _e) {
       Py_BLOCK_THREADS
-      PyErr_SetString(PyExc_ValueError,"Bad port type");
+      PyObject* excc = PyObject_GetAttrString(dsc, "BadPortType");
+      PyObject* exci = PyEval_CallObject(excc, (PyObject *)NULL);
+      PyErr_SetObject(excc, exci);
+      Py_XDECREF(excc);
+      Py_XDECREF(exci);
       return NULL;
    }
    catch (SALOME_Exception &e) {
@@ -650,6 +676,7 @@ CORBAPTR(PortableServer::POA)
    }
    catch (SALOME::SALOME_Exception &e) {
       Py_BLOCK_THREADS
+      //This one should be converted into a python corba exception
       PyErr_SetString(PyExc_RuntimeError,e.details.text);
       return NULL;
    }
@@ -750,6 +777,7 @@ class PySupervCompo:public Superv_Component_i
   virtual void add_provides_port(Ports::Port_ptr ref, const char* provides_port_name, Ports::PortProperties_ptr port_prop);
   virtual void add_uses_port(const char* repository_id, const char* uses_port_name, Ports::PortProperties_ptr port_prop);
   virtual Engines::DSC::uses_port * get_uses_port(const char* uses_port_name);
+  CORBA::Boolean is_connected(const char* port_name) throw (Engines::DSC::PortNotDefined);
 // End of DSC interface for python components
 
 
index a0e0a3e2fdbb413108b6c2b799d3aa9f7527a79e..969b510e81bb032a7e0f23df514504bf3f0d0e8f 100644 (file)
@@ -54,11 +54,20 @@ struct IsSameType<T1,T1> {
 };
 
 
+#include <boost/type_traits/remove_all_extents.hpp>
 
 namespace CalciumInterface {
   
   /********************* INTERFACE DE DECONNEXION *****************/
 
+  static inline void
+  ecp_cd (Superv_Component_i & component, std::string & instanceName)
+  { 
+    /* TODO : Trouver le nom de l'instance SALOME*/
+    if (instanceName.empty()) instanceName="UNDEFINED";
+
+  }
+
   static void
   ecp_fin (Superv_Component_i & component, bool provideLastGivenValue)
   { 
@@ -142,22 +151,6 @@ namespace CalciumInterface {
 
   /********************* INTERFACES DE LECTURE *****************/
 
-  // T1 est le type de données
-  template <typename T1 > static void
-  ecp_lecture ( Superv_Component_i & component,
-              CalciumTypes::DependencyType dependencyType,
-              double        & ti,
-              double const  & tf,
-              long          & i,
-              const string  & nomVar, 
-              size_t          bufferLength,
-              size_t        & nRead, 
-              T1            * &data )
-  {
-    ecp_lecture<T1,T1> (component,dependencyType,ti,tf,
-                       i,nomVar,bufferLength,nRead,data);
-  
-  }
 
   // T1 est le type de données
   // T2 est un <nom> de type Calcium permettant de sélectionner le port CORBA correspondant 
@@ -166,7 +159,7 @@ namespace CalciumInterface {
   //     le port à utiliser est le port cplx
   template <typename T1, typename T2 > static void
   ecp_lecture ( Superv_Component_i & component,
-              CalciumTypes::DependencyType dependencyType,
+              int    const  & dependencyType,
               double        & ti,
               double const  & tf,
               long          & i,
@@ -182,7 +175,9 @@ namespace CalciumInterface {
     typedef typename PortType::DataManipulator            DataManipulator;
     typedef typename DataManipulator::Type                CorbaDataType; // Attention != T1
     typedef typename DataManipulator::InnerType           InnerType;
-
+    CalciumTypes::DependencyType _dependencyType=              
+      static_cast<CalciumTypes::DependencyType>(dependencyType);
+    
     CorbaDataType     corbaData;
 
 #ifdef _DEBUG_
@@ -228,21 +223,21 @@ namespace CalciumInterface {
                             LOC(OSS()<<"Le mode de dépendance de la variable " 
                                 << nomVar << " est indéfini."));
 
-    if ( ( portDependencyType != dependencyType ) && 
-        ( dependencyType != CalciumTypes::SEQUENCE_DEPENDENCY ) ) 
+    if ( ( portDependencyType != _dependencyType ) && 
+        ( _dependencyType != CalciumTypes::SEQUENCE_DEPENDENCY ) ) 
       throw CalciumException(CalciumTypes::CPITVR,
                             LOC(OSS()<<"Le mode de dépendance de la variable " 
                                 << nomVar << ": " << portDependencyType 
                                 << " ne correspond pas au mode demandé."));
 
   
-    if ( dependencyType == CalciumTypes::TIME_DEPENDENCY ) {
+    if ( _dependencyType == CalciumTypes::TIME_DEPENDENCY ) {
       corbaData = port->get(ti,tf, 0);
 #ifdef _DEBUG_
       std::cout << "-------- CalciumInterface(ecp_lecture) MARK 5 ------------------" << std::endl;
 #endif
     } 
-    else if ( dependencyType == CalciumTypes::ITERATION_DEPENDENCY ) {
+    else if ( _dependencyType == CalciumTypes::ITERATION_DEPENDENCY ) {
       corbaData = port->get(0, i);
 #ifdef _DEBUG_
       std::cout << "-------- CalciumInterface(ecp_lecture) MARK 6 ------------------" << std::endl;
@@ -323,53 +318,68 @@ namespace CalciumInterface {
     return;
   }
 
+  // T1 est le type de données
+  template <typename T1 > static void
+  ecp_lecture ( Superv_Component_i & component,
+              int    const  & dependencyType,
+              double        & ti,
+              double const  & tf,
+              long          & i,
+              const string  & nomVar, 
+              size_t          bufferLength,
+              size_t        & nRead, 
+              T1            * &data )
+  {
+    ecp_lecture<T1,T1> (component,dependencyType,ti,tf,
+                       i,nomVar,bufferLength,nRead,data);
+  
+  }
 
   /********************* INTERFACES D'ECRITURE *****************/
 
-  template <typename T1> static void
-  ecp_ecriture ( Superv_Component_i & component,
-                CalciumTypes::DependencyType dependencyType,
-                double const  & t,
-                long   const  & i,
-                const string  & nomVar, 
-                size_t bufferLength,
-                T1  & data ) {
-    ecp_ecriture<T1,T1> (component,dependencyType,t,i,nomVar,bufferLength,data); 
-  }
-
+  // T1 : DataType
+  // T2 : PortType
   template <typename T1, typename T2> static void
   ecp_ecriture ( Superv_Component_i & component,
-                CalciumTypes::DependencyType dependencyType,
+                int    const  & dependencyType,
                 double const  & t,
                 long   const  & i,
                 const string  & nomVar, 
                 size_t bufferLength,
-                T1  & data ) 
+                T1     const  & data ) 
   {
     
     assert(&component);
 
-    //typedef typename StarTrait<TT>::NonStarType           T;
-    typedef typename UsesPortTraits<T2>::PortType          PortType;
-    typedef typename ProvidesPortTraits<T2>::PortType      ProvidesPortType;
-    typedef typename ProvidesPortType::DataManipulator     DataManipulator;
+    //typedef typename StarTrait<TT>::NonStarType                    T;
+    typedef typename boost::remove_all_extents< T2 >::type           T2_without_extent;
+    typedef typename boost::remove_all_extents< T1 >::type           T1_without_extent;
+
+    typedef typename UsesPortTraits    <T2_without_extent>::PortType UsesPortType;
+    typedef typename ProvidesPortTraits<T2_without_extent>::PortType ProvidesPortType;// pour obtenir un manipulateur de données
+    typedef typename ProvidesPortType::DataManipulator               DataManipulator;
     // Verifier que l'on peut définir UsesPortType::DataManipulator
     //    typedef typename PortType::DataManipulator            DataManipulator;
-    typedef typename DataManipulator::Type                CorbaDataType; // Attention != T1
-    typedef typename DataManipulator::InnerType           InnerType;
+    typedef typename DataManipulator::Type                           CorbaDataType; // Attention != T1
+    typedef typename DataManipulator::InnerType                      InnerType;
+    
+    T1_without_extent const & _data = data;
+
+    CalciumTypes::DependencyType _dependencyType=              
+      static_cast<CalciumTypes::DependencyType>(dependencyType);
 
 #ifdef _DEBUG_
     std::cerr << "-------- CalciumInterface(ecriture) MARK 1 ------------------" << std::endl;
 #endif
     if ( nomVar.empty() ) throw CalciumException(CalciumTypes::CPNMVR,
                                                    LOC("Le nom de la variable est <nul>"));
-    PortType * port;
+    UsesPortType * port;
 #ifdef _DEBUG_
     std::cout << "-------- CalciumInterface(ecriture) MARK 2 ------------------" << std::endl;
 #endif
 
     try {
-      port  = component.Superv_Component_i::get_port< PortType > (nomVar.c_str());
+      port  = component.Superv_Component_i::get_port< UsesPortType > (nomVar.c_str());
 #ifdef _DEBUG_
       std::cout << "-------- CalciumInterface(ecriture) MARK 3 ------------------" << std::endl;
 #endif
@@ -404,12 +414,12 @@ namespace CalciumInterface {
 //       throw (CalciumException(CalciumTypes::CPIT,ex));
 //     }
 
-    if ( dependencyType == CalciumTypes::UNDEFINED_DEPENDENCY )
+    if ( _dependencyType == CalciumTypes::UNDEFINED_DEPENDENCY )
       throw CalciumException(CalciumTypes::CPIT,
                                LOC(OSS()<<"Le mode de dépendance demandé pour la variable " 
                                    << nomVar << " est indéfini."));
 
-    if ( dependencyType == CalciumTypes::SEQUENCE_DEPENDENCY )
+    if ( _dependencyType == CalciumTypes::SEQUENCE_DEPENDENCY )
       throw CalciumException(CalciumTypes::CPIT,
                                LOC(OSS()<<"Le mode de dépendance SEQUENCE_DEPENDENCY pour la variable " 
                                    << nomVar << " est impossible en écriture."));
@@ -419,7 +429,7 @@ namespace CalciumInterface {
     // et vice-versa pour informer les provides port du mode dans lequel on est. Sinon il faut
     // modifier l'interface IDL pour y ajouter un mode de dépendance !
     // ---->
-//     if ( portDependencyType != dependencyType ) 
+//     if ( portDependencyType != _dependencyType ) 
 //       throw CalciumException(CalciumTypes::CPITVR,
 //                             LOC(OSS()<<"Le mode de dépendance de la variable " 
 //                                 << nomVar << " ne correspond pas au mode demandé."));
@@ -448,7 +458,7 @@ namespace CalciumInterface {
     //   OLD : la séquence locale. Or la méthode put récupère le buffer directement
     //   OLD : qui est alors le buffer utilisateur. Il pourrait alors arriver que :
     //   OLD :   * Le recepteur efface le buffer emetteur
-    //   OLD :   * Le port lui-même efface le buffer de l'ulisateur !
+    //   OLD :   * Le port lui-même efface le buffer de l'utilisateur !
     //   OLD : Cette copie est effectuée dans GenericPortUses::put 
     //   OLD : en fonction de la collocalisation ou non.
     // - OLD :En cas de connection multiples d'un port uses distant vers plusieurs port provides
@@ -456,10 +466,10 @@ namespace CalciumInterface {
     //   OLD : Il faut effectuer une copie dans le port provides.
     //   OLD : Cette copie est effectuée dans GenericPortUses::put 
     //   OLD : en fonction de la collocalisation ou non.
-    Copy2CorbaSpace<IsSameType<T1,InnerType>::value, DataManipulator >::apply(corbaData,data,bufferLength);
+    Copy2CorbaSpace<IsSameType<T1_without_extent,InnerType>::value, DataManipulator >::apply(corbaData,_data,bufferLength);
  
     //TODO : GERER LES EXCEPTIONS ICI : ex le port n'est pas connecté
-    if ( dependencyType == CalciumTypes::TIME_DEPENDENCY ) {
+    if ( _dependencyType == CalciumTypes::TIME_DEPENDENCY ) {
       try
       {
         port->put(*corbaData,t, -1); 
@@ -474,7 +484,7 @@ namespace CalciumInterface {
       std::cout << "-------- CalciumInterface(ecriture) MARK 5 ------------------" << std::endl;
 #endif
     } 
-    else if ( dependencyType == CalciumTypes::ITERATION_DEPENDENCY ) {
+    else if ( _dependencyType == CalciumTypes::ITERATION_DEPENDENCY ) {
       try
       {
         port->put(*corbaData,-1, i);
@@ -504,7 +514,18 @@ namespace CalciumInterface {
 #endif
    
     return;
-  }
+  };
+  
+  template <typename T1> static void
+  ecp_ecriture ( Superv_Component_i & component,
+                int    const  & dependencyType,
+                double const  & t,
+                long   const  & i,
+                const string  & nomVar, 
+                size_t bufferLength,
+                T1 const & data ) {
+    ecp_ecriture<T1,T1> (component,dependencyType,t,i,nomVar,bufferLength,data); 
+  };
 
 };
 
index 6f8fd6d9769eebc9bee5ffe01c2d2b8732dfadf0..9d90dfb7f91286f172ee8b3a91bd2f9366261bec 100644 (file)
                             public virtual POA_Ports::PortProperties,  \
                             public GenericProvidesPort< __VA_ARGS__ , CalciumCouplingPolicy, calcium_provides_port > { \
   private :                                                            \
-    omni_semaphore _mustnotdisconnectyet;                              \
+    omni_mutex     _disconnect_mutex; \
+    int            _mustnotdisconnect; \
   public :                                                             \
     typedef  __VA_ARGS__               DataManipulator;                        \
     typedef  DataManipulator::Type     CorbaDataType;                  \
     typedef GenericPort< DataManipulator ,                             \
       CalciumCouplingPolicy >          Port;                           \
+      specificPortName () : _mustnotdisconnect(0) {}; \
                                                                        \
-    specificPortName () :_mustnotdisconnectyet(0) {};                  \
-                                                                       \
     virtual ~ specificPortName ();                                     \
                                                                        \
     inline void disconnect(bool provideLastGivenValue) {               \
-      if (! _mustnotdisconnectyet.trywait() ) {                                \
-       Port::disconnect(provideLastGivenValue);                        \
-      }                                                                        \
-    }                                                                          \
+      _disconnect_mutex.lock();                       \
+      if(_mustnotdisconnect > 1)                      \
+      {                                               \
+        _mustnotdisconnect--;                         \
+      }                                               \
+      else if(_mustnotdisconnect == 1)                \
+      {                                               \
+        _mustnotdisconnect--;                         \
+        Port::disconnect(provideLastGivenValue);      \
+      }                                               \
+      _disconnect_mutex.unlock();                     \
+    }                                                \
     inline void setDependencyType(CalciumTypes::DependencyType dependencyType) { \
       Port::setDependencyType(dependencyType);                         \
     }                                                                  \
     virtual void provides_port_changed(int connection_nbr,             \
                                       const Engines::DSC::Message message) { \
       if ( message == Engines::DSC::AddingConnection)                  \
-       _mustnotdisconnectyet.post();                                   \
+        {                                                 \
+          _disconnect_mutex.lock();                \
+          _mustnotdisconnect++;                           \
+          _disconnect_mutex.unlock();              \
+        }                                                 \
       else if ( message == Engines::DSC::RemovingConnection )          \
-       disconnect(false);                                              \
+        {                                                 \
+          disconnect(false);                              \
+        }                                                 \
     }                                                                  \
   };                                                                   \
 
index 4d0ac6aac6833839d499650bc923ec549b25f226..5732b66018e75eda399cbe734aad56ee6e2d8d85 100644 (file)
@@ -29,7 +29,7 @@
 #ifndef _CALCIUM_INTERFACE_HXX_
 #define _CALCIUM_INTERFACE_HXX_
 
-//Interface C++
+//Interface CALCIUM des utilisateurs en C++ 
 #include "CalciumCxxInterface.hxx"
 
 #include "CalciumException.hxx"
@@ -37,6 +37,9 @@
 
 #include <stdio.h>
 
+//Ce fichier déclare et défini l'interfaçage entre l'API utilisteur C et C++
+//Les procédures déclarées n'ont pas vocation à être utilisées directement (celà est
+// cependant possible).  
 //#define _DEBUG_
 
 #ifdef _DEBUG_
@@ -94,30 +97,28 @@ ecp_fin_ (void * component, int code) {
     double         _tf=*tf;                                            \
     size_t         _nRead=0;                                           \
     size_t         _bufferLength=bufferLength;                         \
-    CalciumTypes::DependencyType _dependencyType=                      \
-      static_cast<CalciumTypes::DependencyType>(dependencyType);       \
                                                                        \
     if ( IsSameType< _name , cplx >::value ) _bufferLength*=2;         \
     DEBTRACE( "-------- CalciumInterface(lecture Inter Part) MARK 1 ------------------" ) \
     try {                                                              \
       CalciumInterface::ecp_lecture< _type, _name >( *_component,      \
-                                                    _dependencyType, \
+                                                    dependencyType,    \
                                                     _ti, _tf, *i,      \
                                                     nomvar,            \
                                                     _bufferLength, _nRead, *data); \
     } catch ( const CalciumException & ex) {                           \
       DEBTRACE( ex.what() );                                           \
       return ex.getInfo();                                             \
-    } catch ( ... ) {                          \
-      std::cerr << "Unexpected exception " << std::endl; \
-      return CalciumTypes::CPATAL;                                             \
+    } catch ( ... ) {                                                  \
+      std::cerr << "Unexpected exception " << std::endl;               \
+      return CalciumTypes::CPATAL;                                     \
     }                                                                  \
     if ( IsSameType< _name , cplx >::value ) { *nRead=_nRead/2;                \
       DEBTRACE( "-------- CalciumInterface(lecture Inter Part) IsSameType cplx -------------" ) \
       DEBTRACE( "-------- CalciumInterface(lecture Inter Part) _nRead  : " << _nRead ) \
       DEBTRACE( "-------- CalciumInterface(lecture Inter Part) *nRead  : " << *nRead ) \
     } else *nRead = _nRead;                                            \
-    if (_dependencyType == CalciumTypes::CP_SEQUENTIEL ) \
+    if (dependencyType == CalciumTypes::CP_SEQUENTIEL ) \
         *ti=(CalTimeType< _type _qual >::TimeType)(_ti);                       \
     DEBTRACE( "-------- CalciumInterface(lecture Inter Part), Data Ptr :" << *data ) \
     return CalciumTypes::CPOK;                                         \
@@ -142,10 +143,9 @@ ecp_fin_ (void * component, int code) {
     DEBTRACE( "-------- CalciumInterface(ecriture Inter Part) MARK 1 ------------------" ) \
     try {                                                              \
       /*printf("-------- CalciumInterface(ecriture Inter Part), cp_name : Nom de la var. de type %s : %s\n",#_type,nomvar);*/ \
-      std::string essai(nomvar);                                       \
-      DEBTRACE( "----------->-" << nomvar )            \
+      DEBTRACE( "----------->-" << nomvar )                            \
       CalciumInterface::ecp_ecriture< _type, _name >( *_component,     \
-                                                     static_cast<CalciumTypes::DependencyType>(dependencyType), \
+                                                     dependencyType,   \
                                                      _t,i,nomvar,_bufferLength,*data); \
     } catch ( const CalciumException & ex) {                           \
       std::cerr << ex.what() << std::endl;                             \
@@ -195,7 +195,7 @@ CALCIUM_C2CPP_INTERFACE_(str,char*,);
 //   double         _tf=*tf;                                           
 //   size_t         _nRead=0;                                          
 //   size_t         _bufferLength=bufferLength;                                
-//   CalciumTypes::DependencyType _dependencyType=                     
+//   CalciumTypes::DependencyType dependencyType=                      
 //     static_cast<CalciumTypes::DependencyType>(dependencyType);      
   
 //   // - GERER POINTEUR NULL : NOTHING TODO 
@@ -204,7 +204,7 @@ CALCIUM_C2CPP_INTERFACE_(str,char*,);
 //   DEBTRACE( "-------- CalciumInterface(lecture Inter Part) MARK 1 ------------------" ) 
 //     try {                                                           
 //       CalciumInterface::ecp_lecture< char*, char* >( *_component,   
-//                                                  _dependencyType, 
+//                                                  dependencyType, 
 //                                                  _ti, _tf, *i,      
 //                                                  nomvar,            
 //                                                  _bufferLength, _nRead, *data); 
@@ -215,7 +215,7 @@ CALCIUM_C2CPP_INTERFACE_(str,char*,);
     
 //     *nRead = _nRead;                                                
     
-//     if (_dependencyType == CalciumTypes::CP_SEQUENTIEL ) 
+//     if (dependencyType == CalciumTypes::CP_SEQUENTIEL ) 
 //       *ti=(float)(_ti);                     
     
 //     DEBTRACE( "-------- CalciumInterface(lecture Inter Part), Data Ptr :" << *data ) ;
index ededf2609efeca5012a411ab4ab241a94fa93e14..874345e3af51ddd839d10faa2110a98c18b5ba42 100644 (file)
 #include "Superv_Component_i.hxx"
 
 // PROVIDES PORT TRAITS
-struct UnknownProvidesPortType {};
+template <class T> struct UnknownProvidesPortType {};
+
 template <class T> struct ProvidesPortTraits {
-  typedef  UnknownProvidesPortType PortType;
+  typedef  UnknownProvidesPortType<T> PortType;
 };
 template <> struct ProvidesPortTraits<int> {
   typedef  calcium_integer_port_provides PortType;
@@ -70,9 +71,9 @@ template < typename T > struct StarTrait< T * > { typedef  T NonStarType; };
 
 
 // USES PORT TRAITS
-struct UnknownUsesPortType {};
+template <class T> struct UnknownUsesPortType {};
 template <class T> struct UsesPortTraits {
-  typedef  UnknownUsesPortType PortType;
+  typedef  UnknownUsesPortType<T> PortType;
 };
 template <> struct UsesPortTraits<int> {
   typedef  calcium_integer_port_uses PortType;
index a7210e8515277190e43384d154cfefb2060fcf97..0ff10190db393c7a5d416e4d64829e8c2ab546f1 100644 (file)
@@ -37,18 +37,21 @@ template <bool zerocopy, typename DataManipulator>
 struct Copy2CorbaSpace  {
 
   template <class T1, class T2>
-  static void apply( T1 * & corbaData, T2 & data, size_t nRead){
+  static void apply( T1 * & corbaData, T2 const & data, size_t nRead){
 
     typedef typename ProvidesPortTraits<T2>::PortType  PortType;
     //typedef typename UsesPortTraits<T2>::PortType      PortType;
-//ESSAI:     typedef typename PortType::DataManipulator         DataManipulator;
+    //ESSAI:     typedef typename PortType::DataManipulator         DataManipulator;
     typedef typename DataManipulator::InnerType        InnerType;
 
 #ifdef _DEBUG_
     std::cerr << "-------- Copy2CorbaSpace<true> MARK 1 ------------------" << std::endl;
 #endif
-    // Crée le type corba à partir du data sans lui en donner la propriété
-    corbaData = DataManipulator::create(nRead,&data,false);
+    // Crée le type corba à partir du data sans lui en donner la propriété.
+    // Le const_cast supprime le caractère const du type T2 const & de data car 
+    // DataManipulator::create n'a pas le caractère const sur son paramètre data pour le
+    // cas de figure où  la propriété de la donnée lui est donnée.
+    corbaData = DataManipulator::create(nRead,const_cast<T2 * > (&data),false);
 #ifdef _DEBUG_
     std::cerr << "-------- Copy2CorbaSpace<true> MARK 2 --(dataPtr : " 
              << DataManipulator::getPointer(corbaData,false)<<")----------------" << std::endl;
@@ -62,7 +65,7 @@ template <typename DataManipulator> struct
 Copy2CorbaSpace<false, DataManipulator>  {
   
   template <class T1, class T2>
-  static void apply( T1 * & corbaData,  T2 & data, size_t nRead){
+  static void apply( T1 * & corbaData,  T2 const & data, size_t nRead){
 
     typedef typename ProvidesPortTraits<T2>::PortType  PortType;
     // typedef typename UsesPortTraits<T2>::PortType     PortType;
index 3792dc9a2d2e49bf08ebf35404ea7a91c57e3fd2..da5a20b880e3e1aa6dfcd7720f3247546315b521 100644 (file)
@@ -79,7 +79,7 @@ COMMON_CPPFLAGS= -I$(top_srcdir)/src/DSC/DSC_User \
                 -I$(top_srcdir)/src/Utils \
                 -I$(top_srcdir)/src/Container \
                 -I$(top_srcdir)/src/Notification \
-                -I$(top_builddir)/salome_adm/unix \
+                -I$(top_builddir)/salome_adm/unix -include SALOMEconfig.h \
                 -I$(top_builddir)/idl \
                 @CORBA_CXXFLAGS@ @CORBA_INCLUDES@ @BOOST_CPPFLAGS@
 
index aea01def95a85b8b7a5ddbf62d1d97e73968cd58..8f883d1b60971aa6d87a7151abe12480d14a999c 100644 (file)
@@ -35,7 +35,7 @@ public:
 
   std::cout << "------------  TEST1 --------------" << std::endl;
 
-  int ret=0;
+  // int ret=0;
   
   CORBA::Long time=1,tag=1;
   typedef PalmCouplingPolicy::DataIdContainer DataIdContainer;  
@@ -76,7 +76,7 @@ public:
  
     std::cout << "------------  TEST2 --------------" << std::endl;
 
-   int ret=0;
+    // int ret=0;
   
   CORBA::Long time=1,tag=1;
   typedef PalmCouplingPolicy::DataIdContainer DataIdContainer;  
index ca947860dff1174faad47f9c635ea7f2d6f422d2..935c717a69b7f0557897df73566ca50fc4805bee 100644 (file)
@@ -23,5 +23,5 @@
 //  Author : Eric Fayolle (EDF)
 //  Module : KERNEL
 void fake_method(void) {
-int fake_int;
+  // int fake_int;
 };
index e2b898bbb3342b1a653b6c8537384bfe36fd92f3..96c76359877ec496f0c26c2d97a2f7da97646f90 100644 (file)
@@ -125,7 +125,7 @@ void HDFfile::InternalObjectIndentify(int rank, char *object_name)
     throw HDFexception("Can't identify an internal object");
 }
 
-int HDFfile::ExistInternalObject(char *object_name)
+int HDFfile::ExistInternalObject(const char *object_name)
 {
   int n,i;
   int ret = 0;
index 51c9aa7f12e8c11d247e64570e4a4f0c8316b27c..b1d32881f46384772c535114f3747f7da11f1572 100644 (file)
@@ -51,7 +51,7 @@ public :
 
   int nInternalObjects();
   void InternalObjectIndentify(int rank, char *object_name);
-  int ExistInternalObject(char *object_name);
+  int ExistInternalObject(const char *object_name);
   hdf_object_type InternalObjectType(char *object_name);
 
   int nAttributes();
index 2b0f2fb19fe72a16492b7a3e3353e9d2379cea39..d754e0496d4662664d3174622bf80ee34d6e1b4a 100644 (file)
@@ -100,7 +100,7 @@ void HDFgroup::InternalObjectIndentify(int rank, char *object_name)
     throw HDFexception("Can't identify an internal object");
 }
 
-int HDFgroup::ExistInternalObject(char *object_name)
+int HDFgroup::ExistInternalObject(const char *object_name)
 {
   int n,i;
   int ret = 0;
index 8c0d02b889a758e9bbcd948a12bc88d3f3499533..07e79e36e20810f0a734ab08648599fb0f2001b9 100644 (file)
@@ -56,7 +56,7 @@ public :
 
   int nInternalObjects();
   void InternalObjectIndentify(int rank, char *object_name);
-  int ExistInternalObject(char *object_name);
+  int ExistInternalObject(const char *object_name);
   hdf_object_type InternalObjectType(char *object_name);
 
   int nAttributes();
index ac48c4a419bec94a7528d17f3feb019091f180ae..19e08dbae7c185539d7064ee4b220abf5ee21b2f 100644 (file)
@@ -39,7 +39,7 @@ SALOME HDFPersist : implementation of HDF persitent ( save/ restore )
 hdf_err Num(hdf_idt id,const char *name, void *data);
 
 hdf_err
-HDFnObjects(hdf_idt fid,char *path,int *n)
+HDFnObjects(hdf_idt fid,const char *path,int *n)
 {
   int idx;
   int m = 0;
index 3c829822ab5fa91e2d932c5836c34e5e9a70d06f..9dafc444774b1f648d3014ef49e4f7c84a7b4358 100644 (file)
@@ -31,7 +31,7 @@ extern "C"
 {
 #include "HDFtypes.h"
 }
-#include <HDFexport.hxx>
+#include "HDFexport.hxx"
 
 class HDF_EXPORT HDFobject {
 protected :
index e5919d9e8259b4fd4bd6ea303bc61084bce3a0b1..8e87e3932ca59f5ab128ecf59399edecd397aa2a 100644 (file)
@@ -40,7 +40,7 @@ SALOME HDFPersist : implementation of HDF persitent ( save/ restore )
 
 hdf_err RankInfo(hdf_idt id, const char *name, void *data);
 
-hdf_err HDFobjectIdentify(hdf_idt fid,char *path,int i,char *name)
+hdf_err HDFobjectIdentify(hdf_idt fid,const char *path,int i,char *name)
 {
   int idx;
 
index 5bdc62da6ab178458bbbab9e8c364acb7a747e02..d5115dd208cfd183b24240c0806ed7e25daaaddc 100644 (file)
@@ -115,10 +115,10 @@ void HDFerrorModeLock();
 
 extern
 hdf_err
-HDFnObjects(hdf_idt fid,char *path,int *n);
+HDFnObjects(hdf_idt fid,const char *path,int *n);
 
 extern
-hdf_err HDFobjectIdentify(hdf_idt fid,char *path,int i,char *name);
+hdf_err HDFobjectIdentify(hdf_idt fid,const char *path,int i,char *name);
 
 extern
 hdf_err HDFobjectType(hdf_idt id, char *name, hdf_object_type *type);
index 5913d0ffb129d58c45fb19223bf5a3ad73072e99..a79dc3f91517da6ab75888978d52fa1cad97e8b3 100644 (file)
@@ -32,7 +32,7 @@ void AttachDebugger()
     {
       std::stringstream exec;
       exec << "$DEBUGGER SALOME_LauncherServer " << getpid() << "&";
-      std::cerr << exec.str() << std::endl;
+      MESSAGE ( exec.str() );
       system(exec.str().c_str());
       while(1);
     }
@@ -40,13 +40,13 @@ void AttachDebugger()
 
 void terminateHandler(void)
 {
-  std::cerr << "Terminate: not managed exception !"  << std::endl;
+  MESSAGE ( "Terminate: not managed exception !"  );
   AttachDebugger();
 }
 
 void unexpectedHandler(void)
 {
-  std::cerr << "Unexpected: unexpected exception !"  << std::endl;
+  MESSAGE ( "Unexpected: unexpected exception !"  );
   AttachDebugger();
 }
 
index 895c53581b70532adeede7e40b689b70858d961a..4ce5d8b973534c46fcf0fe47aece27f16d543b35 100644 (file)
@@ -183,9 +183,13 @@ string SALOME_FileTransferCORBA::getLocalFile(string localFile)
              toFollow = aBlock->length();
              SCRUTE(toFollow);
              CORBA::Octet *buf = aBlock->get_buffer();
+#if defined(_DEBUG_) || defined(_DEBUG)
              int nbWri = fwrite(buf, sizeof(CORBA::Octet), toFollow, fp);
-              delete aBlock;
              ASSERT(nbWri == toFollow);
+#else
+             fwrite(buf, sizeof(CORBA::Octet), toFollow, fp);
+#endif
+              delete aBlock;
            }
          fclose(fp);
          MESSAGE("end of transfer");
index d1b105a37dd662447a82f572c2a3ef2d01a0c925..9b399893d0ae808959e72bf6994f99804b6a8f9a 100644 (file)
@@ -82,7 +82,7 @@ SALOME_LifeCycleCORBA::SALOME_LifeCycleCORBA(SALOME_NamingService *ns)
   // be sure to have an instance of traceCollector, when used via SWIG
   // in a Python module
   int argc = 0;
-  char *xargv = "";
+  char *xargv = (char*)"";
   char **argv = &xargv;
   CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
   //  LocalTraceCollector *myThreadTrace = SALOMETraceCollector::instance(orb);
index 2c724e369cfbba30f4e650747045547a6c83156c..7a047fd388967eaab2ab1f7bed5ce46402696bb1 100644 (file)
@@ -64,7 +64,7 @@ LifeCycleCORBATest::setUp()
   bp1->deleteInstance(bp1);
 
   // --- trace on file
-  char *theFileName = TRACEFILE;
+  const char *theFileName = TRACEFILE;
 
   string s = "file:";
   s += theFileName;
@@ -84,7 +84,7 @@ LifeCycleCORBATest::setUp()
   // --- Get or initialize the orb
 
   int _argc = 1;
-  char* _argv[] = {""};
+  char* _argv[] = {(char*)""};
   ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
   ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting());
   _orb = init(_argc , _argv ) ;
index a0333207151754a724a911424ff5bdbf42cfc4f1..24ef7ba8e72e9fac94c7846178fc5b3c293fa423 100644 (file)
@@ -12,6 +12,7 @@
 #define AFX_LOGGER_H__96F2A3AB_F6F8_11D6_BFA6_000476A0958C__INCLUDED_
 
 #include <strstream>
+#include <SALOMEconfig.h>
 #include "Logger.hh"
 
 //these declarations for files don't using OCC includes (for example HDF)
index 87c1f80a90618569d9c5de4b5685287381f58c10..435951b2321023b7e3c7383c97a3cff012cb1407 100644 (file)
@@ -36,9 +36,9 @@ using namespace std;
 #include "utilities.h"
 
 #ifdef _DEBUG_
-static int MYDEBUG = 1;
+static int MYDEBUG = 0;
 #else
-static int MYDEBUG = 1;
+static int MYDEBUG = 0;
 #endif
 
 static const char* SEPARATOR     = "::";
@@ -688,14 +688,14 @@ SALOME_ModuleCatalogImpl::_parse_xml_file(const char* file,
       if (aDoc != NULL) 
        handler->ProcessXmlDocument(aDoc);
       else
-       INFOS("ModuleCatalog: could not parse file "<<file);
+       MESSAGE("ModuleCatalog: could not parse file "<<file);
 
       xmlFreeDoc(aDoc);
       xmlCleanupParser();
       fclose(aFile);
     }
   else
-    INFOS("ModuleCatalog: file "<<file<<" is not readable.");
+    MESSAGE("ModuleCatalog: file "<<file<<" is not readable.");
   
   delete handler;
   
index 965982293b32d97fd5e03564deb4631bb21248c4..80347d690597e17ffb7974efef8290b9510fd1be 100644 (file)
@@ -339,7 +339,7 @@ CORBA::Object_ptr SALOME_NamingService::Resolve(const char* Path)
 
   CosNaming::Name context_name;
   vector<string> splitPath;
-  int dimension_resultat = _createContextNameDir(Path,
+  _createContextNameDir(Path,
                                                 context_name,
                                                 splitPath,
                                                 false);
@@ -803,7 +803,7 @@ throw(ServiceUnreachable)
 //   SCRUTE(path);
   CosNaming::Name context_name;
   vector<string> splitPath;
-  int dimension_resultat = _createContextNameDir(path.c_str(),
+  _createContextNameDir(path.c_str(),
                                                 context_name,
                                                 splitPath,
                                                 true);
index e4a44d309227ab9827f859aef0b8523b486193d2..81ad8d15a94b01799eeb1f900daa6fbb29f4fc10 100644 (file)
@@ -32,6 +32,7 @@ import sys
 import time
 from omniORB import CORBA
 import CosNaming
+import string
 from string import *
 
 from SALOME_utilities import *
@@ -88,7 +89,7 @@ class SALOME_NamingServicePy_i(object):
             #delete first '/' before split
             Path=Path[1:]
 
-        result_resolve_path = split(Path,'/')
+        result_resolve_path = string.split(Path,'/')
         if len(result_resolve_path)>1:
             # A directory is treated (not only an object name)
             # We had to test if the directory where ObjRef should be recorded 
@@ -156,7 +157,7 @@ class SALOME_NamingServicePy_i(object):
             #delete first '/' before split
             Path=Path[1:]
 
-        result_resolve_path = split(Path,'/')
+        result_resolve_path = string.split(Path,'/')
         _context_name=[]
         for i in range(len(result_resolve_path)-1):
             _context_name.append(CosNaming.NameComponent(result_resolve_path[i],"dir"))
@@ -189,7 +190,7 @@ class SALOME_NamingServicePy_i(object):
             #delete first '/' before split
             Path=Path[1:]
 
-        result_resolve_path = split(Path,'/')
+        result_resolve_path = string.split(Path,'/')
         _context_name = []
         for i in range(len(result_resolve_path)):
             _context_name[CosNaming.NameComponent(result_resolve_path[i],"dir")]            
@@ -204,7 +205,46 @@ class SALOME_NamingServicePy_i(object):
                 MESSAGE ( "Create_Directory : CosNaming.NamingContext.CannotProceed" )
             except (CORBA.TRANSIENT,CORBA.OBJECT_NOT_EXIST,CORBA.COMM_FAILURE):
                 MESSAGE ( "Create_Directory : CORBA.TRANSIENT,CORBA.OBJECT_NOT_EXIST,CORBA.COMM_FAILURE" )
-
  
-
-    
+    def Destroy_Name(self,Path):
+      resolve_path=string.split(Path,'/')
+      if resolve_path[0] == '': del resolve_path[0]
+      dir_path=resolve_path[:-1]
+      context_name=[]
+      for e in dir_path:
+         context_name.append(CosNaming.NameComponent(e,"dir"))
+      context_name.append(CosNaming.NameComponent(resolve_path[-1],"object"))
+      
+      try:
+        self._root_context.unbind(context_name)
+      except CosNaming.NamingContext.NotFound, ex:
+        return
+      except CORBA.Exception,ex:
+        return
+
+    def Destroy_FullDirectory(self,Path):
+      context_name=[]
+      for e in string.split(Path,'/'):
+        if e == '':continue
+        context_name.append(CosNaming.NameComponent(e,"dir"))
+
+      try:
+        context=self._root_context.resolve(context_name)
+      except CosNaming.NamingContext.NotFound, ex:
+        return
+      except CORBA.Exception,ex:
+        return
+
+      bl,bi=context.list(0)
+      if bi is not None:
+         ok,b=bi.next_one()
+         while(ok):
+            for s in b.binding_name :
+               if s.kind == "object":
+                  context.unbind([s])
+               elif s.kind == "dir":
+                  context.unbind([s])
+            ok,b=bi.next_one()
+
+      context.destroy()
+      self._root_context.unbind(context_name)
index 2a9e1fca2b76c3d34d88cafb6d4c732259e3f169..690c3dfd7cb835069d5b071bda3d42eb3037b6d7 100644 (file)
@@ -111,7 +111,7 @@ NamingServiceTest::setUp()
   bp1->deleteInstance(bp1);
 
   // --- trace on file
-  char *theFileName = TRACEFILE;
+  const char *theFileName = TRACEFILE;
 
   string s = "file:";
   s += theFileName;
@@ -131,7 +131,7 @@ NamingServiceTest::setUp()
   // --- Get or initialize the orb
 
   int _argc = 1;
-  char* _argv[] = {""};
+  char* _argv[] = {(char*)""};
   ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
   ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting());
   _orb = init(_argc , _argv ) ;
index 52a3d1e9a75423b7ec2d9e44958d6291eed12e93..939c1adc61d708f8365bea76b044dc8cc8499ab0 100644 (file)
@@ -59,15 +59,19 @@ RegistryService::~RegistryService()
        map<int,client_infos *>::iterator im;
        for (im=_reg.begin();im!=_reg.end(); im++)
         {
+#if defined(_DEBUG_) || defined(_DEBUG)
                const client_infos &lesInfos = *(*im).second ;
                MESSAGE("Deletion") ; SCRUTE( lesInfos._name ) ;
+#endif
                _reg.erase ( im ) ;
        }
        ASSERT(_reg.size()==0) ;
        for (im=_fin.begin();im!=_fin.end(); im++)
         {
+#if defined(_DEBUG_) || defined(_DEBUG)
                const client_infos &lesInfos = *(*im).second ;
                MESSAGE("Deletion") ; SCRUTE( lesInfos._name ) ;
+#endif
                _fin.erase ( im ) ;
        }
        ASSERT(_fin.size()==0) ;
index 9b26f41f8b6357a5eb8b6766dfc5d310db3683d6..bc6097fcd92261a1657fb6adeac8af5f11049a01 100644 (file)
@@ -89,7 +89,7 @@ public :
 
        void SessionName( const char *sessionName ) ;
 
-        void SetOrb( CORBA::ORB_ptr orb ) { _orb = orb; return; }
+        void SetOrb( CORBA::ORB_ptr orb ) { _orb = CORBA::ORB::_duplicate(orb); return; }
 
         void Shutdown() { if(!CORBA::is_nil(_orb)) _orb->shutdown(0); }
 
index 50e608f31761496658512ad5c913176cd015820c..8183340c2b252251d38d3bf74f9a6231b8078d89 100644 (file)
@@ -170,6 +170,7 @@ int main( int argc , char **argv )
       ptrRegistry->SessionName( ptrSessionName ) ;
       ptrRegistry->SetOrb(orb);
       varComponents = ptrRegistry->_this() ;
+      ptrRegistry->_remove_ref(); //let poa manage registryservice deletion
       // The RegistryService must not already exist.
            
       try
index 57c00c16f2dd83273167107e2495e47c59bb0e09..8ee2138d2d080bf61c10fc3949113fab532eed1d 100644 (file)
@@ -138,7 +138,7 @@ SALOMEDS_EXPORT
     PortableServer::ObjectId_var aStudyManager_iid =  root_poa->activate_object(aStudyManager_i);
     //give ownership to the poa : the object will be deleted by the poa
     aStudyManager_i->_remove_ref();
-    aStudyManager_i->register_name("/myStudyManager");
+    aStudyManager_i->register_name((char*)"/myStudyManager");
   }
   return new SALOMEDS_StudyManager();
 }
index 804f4b1486f249804c65f4e67f35147a41734966..b420c7e7280799771ac5719a972777b27b640e90 100644 (file)
@@ -43,7 +43,7 @@ std::string SALOMEDS_AttributeUserID::Value()
   std::string aValue;
   if (_isLocal) {
     SALOMEDS::Locker lock;
-    char guid[40];
+    // char guid[40];
     aValue = dynamic_cast<SALOMEDSImpl_AttributeUserID*>(_local_impl)->Value();
   }
   else aValue = SALOMEDS::AttributeUserID::_narrow(_corba_impl)->Value();
index b0666a4d2a6990e7ea5df4556f76313a237645f8..56657e5b3b5e03eaec2a7e841afa62a137be41eb 100644 (file)
@@ -59,7 +59,7 @@ SALOMEDS_GenericAttribute::SALOMEDS_GenericAttribute(SALOMEDS::GenericAttribute_
 
   CORBA::LongLong addr = theGA->GetLocalImpl(GetHostname().c_str(), pid, _isLocal);
   if(_isLocal) {
-    _local_impl = ((SALOMEDSImpl_GenericAttribute*)(addr));
+    _local_impl = reinterpret_cast<SALOMEDSImpl_GenericAttribute*>(addr);
     _corba_impl = SALOMEDS::GenericAttribute::_nil();
   }
   else {
index 6c25a767af094a45e8a51ccb36206a1603e5fd27..78a3006e5e7f6b7e2e8e46461666d0663de53e08 100644 (file)
@@ -82,7 +82,7 @@ char* SALOMEDS_GenericAttribute_i::Type()
     return CORBA::string_dup(SALOMEDSImpl_GenericAttribute::Impl_GetType(_impl));
   }    
 
-  return "";
+  return (char*)"";
 }
 
 char* SALOMEDS_GenericAttribute_i::GetClassType()
@@ -92,7 +92,7 @@ char* SALOMEDS_GenericAttribute_i::GetClassType()
     return CORBA::string_dup(SALOMEDSImpl_GenericAttribute::Impl_GetClassType(_impl));
   }
 
-  return "";
+  return (char*)"";
 }
 
 
@@ -122,5 +122,5 @@ CORBA::LongLong SALOMEDS_GenericAttribute_i::GetLocalImpl(const char* theHostnam
   long pid = (long)getpid();
 #endif
   isLocal = (strcmp(theHostname, GetHostname().c_str()) == 0 && pid == thePID)?1:0;
-  return ((CORBA::LongLong)_impl);
+  return reinterpret_cast<CORBA::LongLong>(_impl);
 }
index b7b6e741064ebd6e948fecb6c5908f3e2f359334..2110c24dc8d46c2d2eff19d457ac9319f88496da 100644 (file)
@@ -63,7 +63,7 @@ SALOMEDS_SObject::SALOMEDS_SObject(SALOMEDS::SObject_ptr theSObject)
   theSObject->GetLocalImpl(GetHostname().c_str(), pid, _isLocal);
 
   if(_isLocal) {
-    _local_impl = ((SALOMEDSImpl_SObject*)(addr));
+    _local_impl = reinterpret_cast<SALOMEDSImpl_SObject*>(addr);
     _corba_impl = SALOMEDS::SObject::_duplicate(theSObject);
   }
   else {
index 9af322638b78b7f05b656603f101e47cbca70c00..08eddaa70b486a2b63dc0e5cfd8c82dc3a85f124 100644 (file)
@@ -332,5 +332,5 @@ CORBA::LongLong SALOMEDS_SObject_i::GetLocalImpl(const char* theHostname, CORBA:
   long pid = (long)getpid();
 #endif
   isLocal = (strcmp(theHostname, GetHostname().c_str()) == 0 && pid == thePID)?1:0;
-  return ((CORBA::LongLong)(void*)_impl);
+  return reinterpret_cast<CORBA::LongLong>(_impl);
 }
index 0aa3a240d9f6135a436e0d09dcb9b17ed9826450..3bfebc5b0101a29da7f1d4e666ceaeb0b3175dad 100644 (file)
@@ -81,7 +81,7 @@ SALOMEDS_Study::SALOMEDS_Study(SALOMEDS::Study_ptr theStudy)
 
   long addr = theStudy->GetLocalImpl(GetHostname().c_str(), pid, _isLocal);
   if(_isLocal) {
-    _local_impl = ((SALOMEDSImpl_Study*)(addr));
+    _local_impl = reinterpret_cast<SALOMEDSImpl_Study*>(addr);
     _corba_impl = SALOMEDS::Study::_duplicate(theStudy);
   }
   else {
index 1dae939cc4bb9ddc814c480c1e25b53fd97b38ed..edff1f88f8bfa58c55c63dfd2b03ed2c1f73e374 100644 (file)
@@ -59,7 +59,7 @@ SALOMEDS_StudyManager::SALOMEDS_StudyManager(SALOMEDS::StudyManager_ptr theManag
 
   CORBA::LongLong addr = theManager->GetLocalImpl(GetHostname().c_str(), pid, _isLocal);
   if(_isLocal) {
-    _local_impl = ((SALOMEDSImpl_StudyManager*)(addr));
+    _local_impl = reinterpret_cast<SALOMEDSImpl_StudyManager*>(addr);
     _corba_impl = SALOMEDS::StudyManager::_duplicate(theManager);
   }
   else {
@@ -87,7 +87,7 @@ SALOMEDS_StudyManager::SALOMEDS_StudyManager()
 
   CORBA::LongLong addr = theManager->GetLocalImpl(GetHostname().c_str(), pid, _isLocal);
   if(_isLocal) {
-    _local_impl = ((SALOMEDSImpl_StudyManager*)(addr));
+    _local_impl = reinterpret_cast<SALOMEDSImpl_StudyManager*>(addr);
     _corba_impl = SALOMEDS::StudyManager::_duplicate(theManager);
   }
   else {
index 7c5abcb944652f5d1509847e304d8e17661f039c..d40b1d772ec3e51f92bf7932b4c0e3e70828c877 100644 (file)
@@ -98,7 +98,7 @@ SALOMEDS_StudyManager_i::~SALOMEDS_StudyManager_i()
  *             context name
  */
 //============================================================================
-void SALOMEDS_StudyManager_i::register_name(char * name)
+void SALOMEDS_StudyManager_i::register_name(const char * name)
 {
   SALOMEDS::StudyManager_var aManager(_this());
   _name_service->Register(aManager.in(), name);
@@ -476,7 +476,7 @@ CORBA::LongLong SALOMEDS_StudyManager_i::GetLocalImpl(const char* theHostname, C
   long pid = (long)getpid();
 #endif
   isLocal = (strcmp(theHostname, GetHostname().c_str()) == 0 && pid == thePID)?1:0;
-  return ((CORBA::LongLong)(void*)_impl);
+  return reinterpret_cast<CORBA::LongLong>(_impl);
 }
 
 //===========================================================================
index a7ec9b17e3f47080db104cae357414e8b9a3f48a..d837acba1cf300ab367f946bdc658bc3b4a7bd93 100644 (file)
@@ -72,7 +72,7 @@ public:
   /*!
     \param char* arguments, the context to register the study manager in the NS
   */  
-  void register_name(char * name);
+  void register_name(const char * name);
   
  //! method to Create a New Study of name study_name
   /*!
index 137c34bd511777832eb72fd2f8e5a44efc84297c..1f5f2a1275ef5f44eab8ad873f2fa1713fa61ad6 100644 (file)
@@ -889,5 +889,5 @@ CORBA::LongLong SALOMEDS_Study_i::GetLocalImpl(const char* theHostname, CORBA::L
   long pid = (long)getpid();
 #endif  
   isLocal = (strcmp(theHostname, GetHostname().c_str()) == 0 && pid == thePID)?1:0;
-  return ((CORBA::LongLong)_impl);
+  return reinterpret_cast<CORBA::LongLong>(_impl);
 }
index 68de91733a8be24b4e57a7ba8aba84685ddd0d6e..5c8a88280c2905d396c877519d85afcd103f2304 100644 (file)
@@ -51,7 +51,7 @@ using namespace std;
 void SALOMEDSTest::setUp()
 {  
   int argc = 1;
-  char* argv[] = {""};
+  char* argv[] = {(char*)""};
 
   ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
   ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting());
@@ -128,7 +128,7 @@ void SALOMEDSTest::tearDown()
 void SALOMEDSTest_Embedded::setUp()
 {  
   int argc = 1;
-  char* argv[] = {""};
+  char* argv[] = {(char*)""};
 
   ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
   ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting());
index b8c88df49b3f45dafcbddeb0fcb76398b394ecf9..866265851d52e77718be717e1d0e41961363f276 100644 (file)
@@ -68,7 +68,7 @@ void SALOMEDSImpl_AttributeIOR::SetValue(const std::string& theValue)
 {
   CheckLocked();
 
-  SALOMEDSImpl_Study* aStudy = SALOMEDSImpl_Study::GetStudy(Label());
+  SALOMEDSImpl_Study::GetStudy(Label());
 
   Backup();
   myString = theValue;
index 350dc0b284ebed33530d6879dd18d82acd4ea9f0..8966b054e6c50fa0df24f836d772808e97b3d53e 100644 (file)
@@ -561,7 +561,7 @@ void SALOMEDSImpl_AttributeTableOfString::Load(const string& value)
     if(aStr[0] == '0') //If the first character of the key is 0, then empty value
       aValue = "";
     else {
-      long aSize = strtol(v[pos++].c_str(), NULL, 10);
+      strtol(v[pos++].c_str(), NULL, 10);
       aValue = v[pos++];
     }
     myTable[aKey] = aValue;
index d64f5eafb47c8d1e0c8a6ba6c4c815555ca884f4..6646fbba602d2da2e1b9f643b51728f5bd189b70 100644 (file)
@@ -65,7 +65,7 @@ BaseTraceCollector* FileTraceCollector::instance(const char *fileName)
          sem_init(&_sem,0,0); // to wait until run thread is initialized
          pthread_t traceThread;
          int bid = 0;
-         int re2 = pthread_create(&traceThread, NULL,
+         pthread_create(&traceThread, NULL,
                                   FileTraceCollector::run, (void *)bid);
          sem_wait(&_sem);
          _singleton = myInstance; // _singleton known only when init done
@@ -121,7 +121,7 @@ void* FileTraceCollector::run(void *bid)
          //break;
        }
 
-      int fullBuf = myTraceBuffer->retrieve(myTrace);
+      myTraceBuffer->retrieve(myTrace);
       if (myTrace.traceType == ABORT_MESS)
        {
 #ifndef WNT
index f41e57593b0c60599283b6b11c3468b1f44a820e..02fc9839da4a389faaaf789d3b69536705c93041 100644 (file)
@@ -87,8 +87,7 @@ LocalTraceBufferPool* LocalTraceBufferPool::instance()
          DEVTRACE("New buffer pool");
          LocalTraceBufferPool* myInstance = new LocalTraceBufferPool(); 
 
-         DESTRUCTOR_OF<LocalTraceBufferPool> *ptrDestroy =
-           new DESTRUCTOR_OF<LocalTraceBufferPool> (*myInstance);
+         new DESTRUCTOR_OF<LocalTraceBufferPool> (*myInstance);
          _singleton = myInstance;
 
          // --- start a trace Collector
@@ -101,7 +100,7 @@ LocalTraceBufferPool* LocalTraceBufferPool::instance()
            }
          else if (strncmp(traceKind,"file",strlen("file"))==0)
            {
-             char *fileName;
+             const char *fileName;
              if (strlen(traceKind) > strlen("file"))
                fileName = &traceKind[strlen("file")+1];
              else
@@ -223,7 +222,7 @@ int LocalTraceBufferPool::retrieve(LocalTrace_TraceInfo& aTrace)
   while (ret)
     {
       ret = sem_wait(&_fullBufferSemaphore);
-      if (ret) perror(" LocalTraceBufferPool::retrieve, sem_wait");
+      if (ret) MESSAGE (" LocalTraceBufferPool::retrieve, sem_wait");
     }
 
   // get the next buffer to print
index bd55a1dc293f58e2c4dc69cd8ea89b674fdae060..27dbf891aa1d907ab16551a1e272688d994887e4 100644 (file)
@@ -26,7 +26,7 @@
 
 #include "SALOME_LocalTrace.hxx"
 
-#define TRACE_BUFFER_SIZE 256  // number of entries in circular buffer
+#define TRACE_BUFFER_SIZE 512  // number of entries in circular buffer
                                // must be power of 2
 #define MAX_TRACE_LENGTH 1024   // messages are truncated at this size
 
index f341706576d8df1f38ed6200bfa12705e86e09fe..dbd9740c1c19b372cea8b0996d6551d043a14ba1 100644 (file)
@@ -56,7 +56,7 @@ BaseTraceCollector* LocalTraceCollector::instance()
 
          sem_init(&_sem,0,0); // to wait until run thread is initialized
          pthread_t traceThread;
-         int re2 = pthread_create(&traceThread, NULL,
+         pthread_create(&traceThread, NULL,
                                   LocalTraceCollector::run, NULL);
          sem_wait(&_sem);
          _singleton = myInstance; // _singleton known only when init done
@@ -97,7 +97,7 @@ void* LocalTraceCollector::run(void *bid)
          //break;
        }
 
-      int fullBuf = myTraceBuffer->retrieve(myTrace);
+      myTraceBuffer->retrieve(myTrace);
       if (myTrace.traceType == ABORT_MESS)
        {
          cout << flush ;
index 90bcb4db6e6b2b2c087f5391edabedf11a350dca..0d2a8ad783d140439f64798c959d5f081731b000 100644 (file)
@@ -64,7 +64,7 @@ void
 SALOMELocalTraceTest::testSingletonBufferPool()
 {
   // --- trace on file
-  char *theFileName = TRACEFILE;
+  const char *theFileName = TRACEFILE;
 
   string s = "file:";
   s += theFileName;
@@ -115,7 +115,7 @@ SALOMELocalTraceTest::testLoadBufferPoolLocal()
 
   for(t=0;t<numThread;t++)
     {
-      int ret = pthread_join(threads[t], NULL);
+      pthread_join(threads[t], NULL);
       MESSAGE("--------------------- end of PrintHello thread " << t);
     }
   MESSAGE(" ---- end of PrintHello threads ---- ");
@@ -134,7 +134,7 @@ SALOMELocalTraceTest::testLoadBufferPoolLocal()
 void 
 SALOMELocalTraceTest::testLoadBufferPoolFile()
 {
-  char *theFileName = TRACEFILE;
+  const char *theFileName = TRACEFILE;
 
   string s = "file:";
   s += theFileName;
@@ -161,7 +161,7 @@ SALOMELocalTraceTest::testLoadBufferPoolFile()
 
   for(t=0;t<NUM_THREADS;t++)
     {
-      int ret = pthread_join(threads[t], NULL);
+      pthread_join(threads[t], NULL);
       MESSAGE("--------------------- end of PrintHello thread " << t);
     }
   MESSAGE(" ---- end of PrintHello threads ---- ");
@@ -180,9 +180,11 @@ SALOMELocalTraceTest::testLoadBufferPoolFile()
 
 void *PrintHello(void *threadid)
 {
+#if defined(_DEBUG_) || defined(_DEBUG)
   long id_thread = (long)threadid;
   for (int i=0; i<NUM_MESSAGES;i++)
   MESSAGE("Hello World! This is a trace test : " << id_thread 
         << " - iter " << i);
+#endif
   pthread_exit(NULL);
 }
index c20c835a06c1fe7c841f9a495f56c25246c6db27..8aced915f24c465c33c5e4b17fb71b44215dc569 100644 (file)
 #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());
 
+// Macroses for messages with separated structure in c++ file in _DUBUG mode
+#define MESSAGE_BEGIN(msg) {std::ostringstream ss; ss <<__FILE__ <<" ["<<__LINE__<<"] : "<< msg; LocalTraceBufferPool::instance()->insert(NORMAL_MESS, ss.str().c_str());}
+#define MESSAGE_ADD(msg) {std::ostringstream ss; ss << msg; LocalTraceBufferPool::instance()->insert(NORMAL_MESS, ss.str().c_str());}
+#define MESSAGE_END(msg) {std::ostringstream ss; ss << msg << std::endl; LocalTraceBufferPool::instance()->insert(NORMAL_MESS, ss.str().c_str());}
+
 // --- Some macros are always defined (without _DEBUG_): for use with release version
 
 #define INFOS(msg) {MESS_BEGIN("- Trace ") << msg << MESS_END}
index b1286b9159ce0e64d7e34e80849e5aea333deed2..aee066270e073dbf56c47dacbdf4f0b35edfe1a0 100644 (file)
@@ -70,7 +70,7 @@ BaseTraceCollector* SALOMETraceCollector::instance()
          sem_init(&_sem,0,0); // to wait until run thread is initialized
          pthread_t traceThread;
          int bid = 0;
-         int re2 = pthread_create(&traceThread, NULL,
+         pthread_create(&traceThread, NULL,
                                   SALOMETraceCollector::run, (void *)bid);
          sem_wait(&_sem);
          _singleton = myInstance; // _singleton known only when init done
@@ -131,7 +131,7 @@ void* SALOMETraceCollector::run(void *bid)
          //break;
        }
 
-      int fullBuf = myTraceBuffer->retrieve(myTrace);
+      myTraceBuffer->retrieve(myTrace);
       if (!CORBA::is_nil(_orb))
        {
          if (myTrace.traceType == ABORT_MESS)
index fe6bcfde31335d73cb11d6680c7cc8596b0ba9ce..b945328c0413780eadb35e8f004e9bdb06f690e8 100644 (file)
@@ -82,7 +82,7 @@ SALOMETraceCollectorTest::testLoadBufferPoolCORBA()
 
   for(t=0;t<NUM_THREADS;t++)
     {
-      int ret = pthread_join(threads[t], NULL);
+      pthread_join(threads[t], NULL);
       MESSAGE("--------------------- end of PrintHello thread " << t);
     }
   MESSAGE(" ---- end of PrintHello threads ---- ");
@@ -101,9 +101,11 @@ SALOMETraceCollectorTest::testLoadBufferPoolCORBA()
 
 void *PrintHello(void *threadid)
 {
+#if defined(_DEBUG_) || defined(_DEBUG)
   long id_thread = (long)threadid;
       for (int i=0; i<NUM_MESSAGES;i++)        
        MESSAGE("Hello World! This is a trace test : " << id_thread 
                << " - iter " << i);
+#endif
   pthread_exit(NULL);
 }
index 4d0ccbc3a547edfa4400573cedafcc3bc8af70eb..deb12a8791f882791c4a99589aa4dd418f86c46b 100644 (file)
@@ -114,7 +114,7 @@ CORBA::Object_ptr TraceCollector_WaitForServerReadiness(CORBA::ORB_ptr orb,
                }
            }
 #ifndef WNT
-         int a = nanosleep(&ts_req,&ts_rem);
+         nanosleep(&ts_req,&ts_rem);
 #else
          Sleep(TIMESleep / 1000000);
 #endif
index e7a59bdc317142863490f0d5b9ed72f827623e02..e7df7d3be7820b59c79301b9ddb1841fe82a8c31 100644 (file)
@@ -27,6 +27,7 @@
 #ifndef _TRACECOLLECTOR_WAITFORSERVERREADINESS_HXX_
 #define _TRACECOLLECTOR_WAITFORSERVERREADINESS_HXX_
 
+#include <SALOMEconfig.h>
 #include <omniORB4/CORBA.h> 
 #include <string>
 
index 221f60d665031bcfdf55e05586c800976d62a161..a3a81c616cebd0a544ca804dd2a4f5edcb698f5c 100644 (file)
@@ -73,7 +73,7 @@ char* Engines_TestComponent_i::Coucou(CORBA::Long L)
 
 void Engines_TestComponent_i::Setenv()
 {
-  bool overwrite = true;
+  // bool overwrite = true;
   map<std::string,CORBA::Any>::iterator it;
   MESSAGE("set environment associated with keys in map _fieldsDict");
   for (it = _fieldsDict.begin(); it != _fieldsDict.end(); it++)
@@ -88,7 +88,7 @@ void Engines_TestComponent_i::Setenv()
          s+='=';
          s+=value;
          //char* cast because 1st arg of linux putenv function is not a const char* !!!
-         int ret=putenv((char *)s.c_str());
+         putenv((char *)s.c_str());
          //End of CCRT porting
          //int ret = setenv(cle.c_str(), value, overwrite);
          MESSAGE("--- setenv: "<<cle<<" = "<< value);
index 0ef063b74f296f90c56a2119401678ab178a1e65..2a2f834ea25c11b2406b3ba6c5eaa7af725d2077 100644 (file)
@@ -62,10 +62,14 @@ static ostream& operator<<(ostream& os, const CORBA::Exception& e)
 Engines::TestComponent_ptr create_instance(Engines::Container_ptr iGenFact,
                                           string componenttName)
 {
+#if defined(_DEBUG_) || defined(_DEBUG)
   bool isLib =
     iGenFact->load_component_Library(componenttName.c_str());
   //    iGenFact->load_component_Library("SalomeTestComponent");
   ASSERT(isLib);
+#else
+  iGenFact->load_component_Library(componenttName.c_str());
+#endif
   CORBA::Object_var obj =
     //    iGenFact->create_component_instance("SalomeTestComponent",
     iGenFact->create_component_instance(componenttName.c_str(),
index dd0c98891683b44ddab375b737e39f16cca13ec2..43bb29a06fbd5505697517ddffa5ff0067fbaacc 100644 (file)
@@ -47,7 +47,7 @@ UtilsTest::setUp()
   bp1->deleteInstance(bp1);
 
   // --- trace on file
-  char *theFileName = TRACEFILE;
+  const char *theFileName = TRACEFILE;
 
   string s = "file:";
   s += theFileName;
index 61239063a4dac4dd4a80954eb95b55071c1008e5..60c292fb5cd9e35e42b129cb762786a6372fe388 100644 (file)
@@ -36,12 +36,13 @@ extern "C"
 
 # include "Utils_DESTRUCTEUR_GENERIQUE.hxx"
 //# include "utilities.h"
+# include "LocalTraceBufferPool.hxx"
 void Nettoyage();
 
 #ifdef _DEBUG_
-static int MYDEBUG = 0;
+// static int MYDEBUG = 0;
 #else
-static int MYDEBUG = 0;
+// static int MYDEBUG = 0;
 #endif
 
 using namespace std;
@@ -83,6 +84,8 @@ public :
                DESTRUCTEUR_GENERIQUE_::Destructeurs = 
                       new std::list<DESTRUCTEUR_GENERIQUE_*> ; // Destructeur alloue dynamiquement (cf. ci-dessous) ,
                                                                   // il est utilise puis detruit par la fonction Nettoyage
+                //To be sure the trace singleton will be the last one to be destroyed initialize it here before calling atexit
+                LocalTraceBufferPool::instance();
                int cr = atexit( Nettoyage );                      // execute Nettoyage lors de exit, aprs la destruction des donnees statiques !
                assert(cr==0) ;
                ATEXIT_Done = true ;
index 9ae866266b03151f06d82d74ba8ff601adff591e..54e0bcd223e5a538b02a5be2b104e5ecc0eefeeb 100644 (file)
@@ -140,4 +140,4 @@ private :
 };
 
 
-# endif                /* # if !defined( __SINGLETON__H__ ) */
+# endif                /* # if !defined( __DESTRUCTEUR_GENERIQUE__H__ ) */
index 41e24858d9e6b9b135c78a9264d6086f12129c88..d95ea641cf9f831a2beecc7b568f6fd59fef7715 100644 (file)
@@ -51,16 +51,24 @@ const char* duplicate( const char *const str ) ;
 const struct utsname get_uname( void )
 {
        struct utsname          hostid;
+#if defined(_DEBUG_) || defined(_DEBUG)
        const int retour=uname(&hostid);
        ASSERT(retour>=0);
+#else
+       uname(&hostid);
+#endif
        return hostid ;
 }
 
 const char* get_adip( void )
 {
        struct utsname  hostid;
+#if defined(_DEBUG_) || defined(_DEBUG)
        const int retour=uname(&hostid);
        ASSERT(retour>=0);
+#else
+       uname(&hostid);
+#endif
 
        const hostent* pour_adip=gethostbyname(hostid.nodename);
        ASSERT(pour_adip!=NULL);
index 5c9207dbca48887051764ab87d04aaf6bf378dca..979b3e1378f2be7c87bbec799e5c8a8be9bfeadd 100644 (file)
@@ -34,6 +34,9 @@
 # include <exception>
 # include <iostream>
 
+#ifdef LOCALIZED
+#undef LOCALIZED
+#endif
 #ifdef _DEBUG_
 # define LOCALIZED(message) #message , __FILE__ , __LINE__
 #else
index ce11653a7a3a58feaa05dbe073e581ac56b5fbc7..e15c89a55f22ee0611b60d1f399c71f196bc6a01 100644 (file)
@@ -118,10 +118,12 @@ void Utils_Timer::Reset() {
 }
 
 void Utils_Timer::ShowAbsolute(){
+#if defined(_DEBUG_) || defined(_DEBUG)
 #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 ");
+#endif
 }