From c18b78b423670110944d897920edf0c02f23eb4c Mon Sep 17 00:00:00 2001 From: prascle Date: Wed, 7 Apr 2004 11:01:27 +0000 Subject: [PATCH] PR: manual merge from tag V1_4_0 and QT_THREAD branch (without modifs from BSEC_br1 branch) --- bin/runSalome.py | 63 ++- salome_adm/unix/config_files/check_omniorb.m4 | 62 ++- salome_adm/unix/config_files/check_pyqt.m4 | 118 ++-- src/Container/Container_i.cxx | 86 ++- src/Container/SALOME_Container_i.hxx | 26 +- src/NamingService/SALOME_NamingService.hxx | 3 +- src/Registry/Makefile.in | 9 +- src/SALOMEDS/Makefile.in | 4 + src/SALOMEDS/SALOMEDS_Client.cxx | 7 +- src/SALOMEDS/SALOMEDS_StudyManager_i.cxx | 4 +- src/SALOMEGUI/QAD_Desktop.cxx | 2 +- src/SALOMEGUI/QAD_ObjectBrowser.cxx | 5 +- src/SALOMELocalTrace/SALOME_Log.cxx | 15 +- src/SALOMELocalTrace/SALOME_Log.hxx | 14 +- src/SALOMELogger/SALOME_LoggerClient.cxx | 19 +- src/Session/Makefile.in | 9 +- src/Session/SALOME_Session_Server.cxx | 276 ++++++---- src/Session/SALOME_Session_i.cxx | 67 +-- src/Session/SALOME_Session_i.hxx | 8 +- src/Session/Session_ServerLauncher.cxx | 216 ++++++++ src/Session/Session_ServerLauncher.hxx | 88 +++ src/Session/Session_ServerThread.cxx | 513 ++++++++++++++++++ src/Session/Session_ServerThread.hxx | 80 +++ src/Utils/Utils_ORB_INIT.cxx | 9 +- src/Utils/utilities.h | 23 +- 25 files changed, 1365 insertions(+), 361 deletions(-) create mode 100644 src/Session/Session_ServerLauncher.cxx create mode 100644 src/Session/Session_ServerLauncher.hxx create mode 100644 src/Session/Session_ServerThread.cxx create mode 100644 src/Session/Session_ServerThread.hxx diff --git a/bin/runSalome.py b/bin/runSalome.py index 19d91294b..3a5ea4e55 100755 --- a/bin/runSalome.py +++ b/bin/runSalome.py @@ -100,14 +100,15 @@ if "SUPERV" in modules_list and not 'superv' in args['containers']: class Server: CMD=[] if args['xterm']: - ARGS=['xterm', '-iconic', '-sb', '-sl', '500', '-e'] + ARGS=['xterm', '-iconic', '-sb', '-sl', '500', '-hold', '-e'] else: ARGS=[] def run(self): global process_id - command = self.ARGS+self.CMD - #print "args = ", args + env_ld_library_path=['env', 'LD_LIBRARY_PATH='+ os.getenv("LD_LIBRARY_PATH")] + command = self.ARGS+ env_ld_library_path + self.CMD + #print "command = ", command pid = os.spawnvp(os.P_NOWAIT, command[0], command) process_id[pid]=self.CMD @@ -159,7 +160,23 @@ class SessionLoader(Server): CMD=CMD+['GUI'] class SessionServer(Server): - CMD=['SALOME_Session_Server'] + #CMD=['SALOME_Session_Server'] + SCMD1=['SALOME_Session_Server', + '--with','Registry','(','--salome_session','theSession',')', + '--with','ModuleCatalog','(','-common'] + SCMD2=['-personal','${HOME}/Salome/resources/CatalogModulePersonnel.xml',')', + '--with','SALOMEDS','(',')', + '--with','Container','(','FactoryServer',')'] + def setpath(self,modules_list): + cata_path=[] + list_modules = modules_list[:] + list_modules.reverse() + for module in ["KERNEL"] + list_modules: + module_root_dir=modules_root_dir[module] + module_cata=module+"Catalog.xml" + print " ", module_cata + cata_path.extend(glob.glob(os.path.join(module_root_dir,"share",args['appname'],"resources",module_cata))) + self.CMD=self.SCMD1 + [string.join(cata_path,':')] + self.SCMD2 class NotifyServer(Server): myLogName = os.environ["LOGNAME"] @@ -257,28 +274,28 @@ def startSalome(): # Lancement Registry Server # - RegistryServer().run() + #RegistryServer().run() # # Attente de la disponibilité du Registry dans le Naming Service # - clt.waitNS("/Registry") + #clt.waitNS("/Registry") # # Lancement Catalog Server # - cataServer=CatalogServer() - cataServer.setpath(modules_list) - cataServer.run() + #cataServer=CatalogServer() + #cataServer.setpath(modules_list) + #cataServer.run() # # Attente de la disponibilité du Catalog Server dans le Naming Service # - import SALOME_ModuleCatalog - clt.waitNS("/Kernel/ModulCatalog",SALOME_ModuleCatalog.ModuleCatalog) + #import SALOME_ModuleCatalog + #clt.waitNS("/Kernel/ModulCatalog",SALOME_ModuleCatalog.ModuleCatalog) # # Lancement SalomeDS Server @@ -286,7 +303,7 @@ def startSalome(): os.environ["CSF_PluginDefaults"]=os.path.join(modules_root_dir["KERNEL"],"share",args['appname'],"resources") os.environ["CSF_SALOMEDS_ResourcesDefaults"]=os.path.join(modules_root_dir["KERNEL"],"share",args['appname'],"resources") - SalomeDSServer().run() + #SalomeDSServer().run() if "GEOM" in modules_list: print "GEOM OCAF Resources" @@ -297,21 +314,29 @@ def startSalome(): # Attente de la disponibilité du SalomeDS dans le Naming Service # - clt.waitNS("/myStudyManager") + #clt.waitNS("/myStudyManager") # # Lancement Session Server # - SessionServer().run() + mySessionServ=SessionServer() + mySessionServ.setpath(modules_list) + mySessionServ.run() + #SessionServer().run() # # Attente de la disponibilité du Session Server dans le Naming Service # - import SALOME - session=clt.waitNS("/Kernel/Session",SALOME.Session) + #import SALOME + #session=clt.waitNS("/Kernel/Session",SALOME.Session) + if os.getenv("HOSTNAME") == None: + if os.getenv("HOST") == None: + os.environ["HOSTNAME"]="localhost" + else: + os.environ["HOSTNAME"]=os.getenv("HOST") theComputer = os.getenv("HOSTNAME") computerSplitName = theComputer.split('.') @@ -320,14 +345,14 @@ def startSalome(): # # Lancement Container C++ local # - if 'cpp' in args['containers']: - ContainerCPPServer().run() + #if 'cpp' in args['containers']: + #ContainerCPPServer().run() # # Attente de la disponibilité du Container C++ local dans le Naming Service # - clt.waitNS("/Containers/" + theComputer + "/FactoryServer") + #clt.waitNS("/Containers/" + theComputer + "/FactoryServer") # # Lancement Container Python local diff --git a/salome_adm/unix/config_files/check_omniorb.m4 b/salome_adm/unix/config_files/check_omniorb.m4 index 500abac31..c7a9699e3 100644 --- a/salome_adm/unix/config_files/check_omniorb.m4 +++ b/salome_adm/unix/config_files/check_omniorb.m4 @@ -30,19 +30,35 @@ then AC_SUBST(OMNIORB_IDL) OMNIORB_BIN=`echo ${OMNIORB_IDL} | sed -e "s,[[^/]]*$,,;s,/$,,;s,^$,.,"` - OMNIORB_LIB=`echo ${OMNIORB_BIN} | sed -e "s,bin,lib,"` - - OMNIORB_ROOT=`echo ${OMNIORB_BIN} | sed -e "s,[[^/]]*$,,;s,/$,,;s,^$,.,"` - OMNIORB_ROOT=`echo ${OMNIORB_ROOT} | sed -e "s,[[^/]]*$,,;s,/$,,;s,^$,.,"` + OMNIORB_ROOT=${OMNIORB_BIN} + # one-level up + OMNIORB_ROOT=`echo ${OMNIORB_ROOT} | sed -e "s,[[^/]]*$,,;s,/$,,;s,^$,.,"` + # + # + if test -d $OMNIORB_ROOT/include ; then + # if $OMNIORB_ROOT/include exists, there are a lot of chance that + # this is omniORB4.x installed via configure && make && make install + OMNIORB_LIB=`echo ${OMNIORB_BIN} | sed -e "s,bin\$,lib,"` + OMNIORB_VERSION=4 + else + # omniORB has been installed old way + OMNIORB_LIB=`echo ${OMNIORB_BIN} | sed -e "s,bin/,lib/,"` + # one-level up again + OMNIORB_ROOT=`echo ${OMNIORB_ROOT} | sed -e "s,[[^/]]*$,,;s,/$,,;s,^$,.,"` + if test -d $OMNIORB_ROOT/include/omniORB4 ; then + OMNIORB_VERSION=4 + else + OMNIORB_VERSION=3 + fi + fi AC_SUBST(OMNIORB_ROOT) - OMNIORB_INCLUDES="-I$OMNIORB_ROOT/include -I$OMNIORB_ROOT/include/omniORB3 -I$OMNIORB_ROOT/include/COS" -dnl OMNIORB_INCLUDES="-I$OMNIORB_ROOT/include -I$OMNIORB_ROOT/include/omniORB4 -I$OMNIORB_ROOT/include/COS" + OMNIORB_INCLUDES="-I$OMNIORB_ROOT/include -I$OMNIORB_ROOT/include/omniORB${OMNIORB_VERSION} -I$OMNIORB_ROOT/include/COS" AC_SUBST(OMNIORB_INCLUDES) ENABLE_PTHREADS - OMNIORB_CXXFLAGS= + OMNIORB_CXXFLAGS="-DOMNIORB_VERSION=$OMNIORB_VERSION" case $build_cpu in sparc*) AC_DEFINE(__sparc__) @@ -120,16 +136,23 @@ then AC_CHECK_LIB(nsl,gethostbyname, LIBS="-lnsl $LIBS",,) LIBS_old=$LIBS - OMNIORB_LIBS="$OMNIORB_LDFLAGS -lomniORB3 -ltcpwrapGK -lomniDynamic3 -lomnithread -lCOS3 -lCOSDynamic3" -dnl OMNIORB_LIBS="$OMNIORB_LDFLAGS -lomniORB4 -lomniDynamic4 -lomnithread -lCOS4 -lCOSDynamic4" + OMNIORB_LIBS="$OMNIORB_LDFLAGS" + OMNIORB_LIBS="$OMNIORB_LIBS -lomniORB${OMNIORB_VERSION}" + OMNIORB_LIBS="$OMNIORB_LIBS -lomniDynamic${OMNIORB_VERSION}" + OMNIORB_LIBS="$OMNIORB_LIBS -lCOS${OMNIORB_VERSION}" + OMNIORB_LIBS="$OMNIORB_LIBS -lCOSDynamic${OMNIORB_VERSION}" + OMNIORB_LIBS="$OMNIORB_LIBS -lomnithread" + if test $OMNIORB_VERSION = 3 ; then + OMNIORB_LIBS="$OMNIORB_LIBS -ltcpwrapGK" + fi AC_SUBST(OMNIORB_LIBS) LIBS="$OMNIORB_LIBS $LIBS" CXXFLAGS_old=$CXXFLAGS CXXFLAGS="$CXXFLAGS $OMNIORB_CXXFLAGS $OMNIORB_INCLUDES" - AC_MSG_CHECKING(whether we can link with omniORB3) - AC_CACHE_VAL(salome_cv_lib_omniorb3,[ + AC_MSG_CHECKING(whether we can link with omniORB) + AC_CACHE_VAL(salome_cv_lib_omniorb,[ AC_TRY_LINK( #include , CORBA::ORB_var orb, @@ -184,21 +207,22 @@ then CORBA_ORB_INIT_HAVE_3_ARGS=1 AC_DEFINE(CORBA_ORB_INIT_HAVE_3_ARGS) - CORBA_ORB_INIT_THIRD_ARG='"omniORB3"' - AC_DEFINE(CORBA_ORB_INIT_THIRD_ARG, "omniORB3") + CORBA_ORB_INIT_THIRD_ARG='"omniORB"' + AC_DEFINE(CORBA_ORB_INIT_THIRD_ARG, "omniORB") fi omniORBpy_ok=no if test "x$omniORB_ok" = "xyes" then - AC_MSG_CHECKING(omniORBpy (CORBA.py file available)) - if test -f ${OMNIORB_ROOT}/lib/python/CORBA.py - then - omniORBpy_ok=yes - PYTHONPATH=${OMNIORB_ROOT}/lib/python:${OMNIORB_LIB}:${PYTHON_PREFIX}/lib/python${PYTHON_VERSION}:${PYTHONPATH} - AC_SUBST(PYTHONPATH) + AC_MSG_CHECKING(omniORBpy) + $PYTHON -c "import omniORB" &> /dev/null + if test $? = 0 ; then AC_MSG_RESULT(yes) + omniORBpy_ok=yes + else + AC_MSG_RESULT(no, check your installation of omniORBpy) + omniORBpy_ok=no fi fi diff --git a/salome_adm/unix/config_files/check_pyqt.m4 b/salome_adm/unix/config_files/check_pyqt.m4 index e0d320185..6764c325a 100644 --- a/salome_adm/unix/config_files/check_pyqt.m4 +++ b/salome_adm/unix/config_files/check_pyqt.m4 @@ -3,31 +3,6 @@ dnl Copyright (C) 2003 CEA/DEN, EDF R&D AC_DEFUN([CHECK_PYQT],[ AC_REQUIRE([CHECK_PYTHON])dnl -AC_CHECKING(for pyqt) - -pyqt_ok=no - -PYTHON_SITE_PACKPYQT=$PYTHON_PREFIX/lib/python$PYTHON_VERSION/site-packages -AC_CHECK_FILES($PYTHON_SITE_PACKPYQT/qt.py $PYTHON_SITE_PACKPYQT/libqtcmodule.so,pyqt_ok=yes,pyqt_ok=no) -if test "x$pyqt_ok" = xyes ; then - PYQT_INCLUDES="-I $PYTHON_SITE_PACKPYQT" - PYQT_LIBS="-L$PYTHON_SITE_PACKPYQT -lqtcmodule" -fi - -if test "x$pyqt_ok" = xyes ; then - AC_CHECK_FILES(/usr/share/sip/qt/qtmod.sip,pyqt_ok=yes,pyqt_ok=no) - if test "x$pyqt_ok" = xyes ; then - PYQT_SIPS="/usr/share/sip/qt" - fi - AC_SUBST(PYQT_INCLUDES) - AC_SUBST(PYQT_LIBS) - AC_SUBST(PYQT_SIPS) - AC_MSG_RESULT(yes) -else - - pyqt_ok=yes - dnl were is pyqt ? - AC_ARG_WITH(pyqt, [ --with-pyqt=DIR root directory path to PyQt installation ], [PYQTDIR="$withval" @@ -47,67 +22,66 @@ AC_ARG_WITH(pyuic, AC_MSG_RESULT("select $withval as pyqt executable") ]) +AC_CHECKING(for pyqt) + +pyqt_ok=no -if test -z $PYQTDIR; then - PYQTDIR="/usr/lib/python${PYTHON_VERSION}/site-packages" -else - if test -z $PYQT_SIPS; then - PYQT_SIPS="$PYQTDIR/sip" - fi - if test -z $PYUIC; then - AC_CHECK_FILE("$PYQTDIR/pyuic",pyqt_ok=yes,pyqt_ok=no) - if test "x$pyqt_ok" = xyes ; then - PYUIC="$PYQTDIR/pyuic" - else - AC_PATH_PROG(PYUIC, pyuic) - fi - fi +if test "x$PYQTDIR" = x; then + PYQTDIR="/usr" fi -if test -z $PYQT_SIPS; then - PYQT_SIPS="/usr/share/sip/qt" +if test "x$PYQT_SIPS" = x; then + PYQT_SIPS="/usr/share/sip/qt" fi -if test -z $PYUIC; then - PYUIC="/usr/bin/pyuic" +if test -d $PYQTDIR/lib/python${PYTHON_VERSION}/site-packages; then + PYQTLIB=$PYQTDIR/lib/python${PYTHON_VERSION}/site-packages +else + if test -d $PYQTDIR/lib; then + PYQTLIB=$PYQTDIR/lib + else + PYQTLIB=$PYQTDIR + fi fi -PYQT_ROOT=$PYQTDIR -PYQT_INCLUDES="-I$PYQT_SIPS" -PYQT_LIBS="-L$PYQTDIR -lqtcmodule" +if test -d $PYQTDIR/bin; then + PYQTBIN=$PYQTDIR/bin +else + PYQTBIN=$PYQTDIR +fi + +AC_CHECK_FILE("$PYQTBIN/pyuic",pyqt_ok=yes,pyqt_ok=no) + +if test "x$pyqt_ok" = xyes ; then + AC_CHECK_FILES("$PYQTLIB/qt.py",pyqt_ok=yes,pyqt_ok=no) +fi -AC_CHECK_FILES($PYQTDIR/qt.py $PYQTDIR/qt/qt.py $PYQTDIR/lib/qt.py,pyqt_ok=yes,pyqt_ok=no) if test "x$pyqt_ok" = xno ; then - AC_MSG_WARN(qt.py not found) -else - AC_CHECK_FILE("$PYQTDIR/libqtcmodule.so",pyqt_ok=yes,pyqt_ok=no) - if test "x$pyqt_ok" = xyes ; then - PYQT_ROOT=$PYQTDIR - PYQT_LIBS="-L$PYQTDIR -lqtcmodule" - fi - if test "x$pyqt_ok" = xno ; then - AC_CHECK_FILE("$PYQTDIR/lib/libqtcmodule.so",pyqt_ok=yes,pyqt_ok=no) - if test "x$pyqt_ok" = xyes ; then - PYQT_ROOT=$PYQTDIR - PYQT_LIBS="-L$PYQTDIR/lib -lqtcmodule" - fi - fi - - AC_CHECK_FILE("$PYQT_SIPS/copying.sip",pyqt_ok=$pyqt_ok,pyqt_ok=no) - if test "x$pyqt_ok" = xyes ; then - PYQT_INCLUDES="-I$PYQT_SIPS" - fi + AC_CHECK_FILES("$PYQTLIB/qt/qt.py",pyqt_ok=yes,pyqt_ok=no) fi -AC_SUBST(PYQT_ROOT) -AC_SUBST(PYQT_INCLUDES) -AC_SUBST(PYUIC) -AC_SUBST(PYQT_SIPS) -AC_SUBST(PYQT_LIBS) +if test "x$pyqt_ok" = xyes ; then + AC_CHECK_FILE("$PYQTLIB/libqtcmodule.so",pyqt_ok=yes,pyqt_ok=no) +fi -AC_MSG_RESULT(for pyqt: $pyqt_ok) +if test "x$pyqt_ok" = xyes ; then + AC_CHECK_FILES("$PYQT_SIPS/qtmod.sip",pyqt_ok=yes,pyqt_ok=no) +fi +if test "x$pyqt_ok" = xyes ; then + AC_CHECK_FILE("$PYQT_SIPS/copying.sip",pyqt_ok=yes,pyqt_ok=no) +fi +if test "x$pyqt_ok" = xyes ; then + PYQT_ROOT=$PYQTDIR + PYQT_INCLUDES="-I$PYQT_SIPS" + PYQT_LIBS="-L$PYQTLIB -lqtcmodule" + AC_SUBST(PYQT_ROOT) + AC_SUBST(PYQT_INCLUDES) + AC_SUBST(PYQT_LIBS) + AC_SUBST(PYQT_SIPS) + AC_SUBST(PYUIC) fi + ])dnl dnl diff --git a/src/Container/Container_i.cxx b/src/Container/Container_i.cxx index 91383b168..9c68bb2a1 100644 --- a/src/Container/Container_i.cxx +++ b/src/Container/Container_i.cxx @@ -26,7 +26,6 @@ // Module : SALOME // $Header$ -using namespace std; #include #include CORBA_SERVER_HEADER(SALOME_Component) #include "SALOME_Container_i.hxx" @@ -38,6 +37,7 @@ using namespace std; #include #include "utilities.h" +using namespace std; bool _Sleeping = false ; @@ -52,15 +52,23 @@ char ** _ArgV ; extern "C" {void ActSigIntHandler() ; } extern "C" {void SigIntHandler(int, siginfo_t *, void *) ; } +Engines_Container_i::Engines_Container_i () : + _numInstance(0) +{ +} + Engines_Container_i::Engines_Container_i (CORBA::ORB_ptr orb, PortableServer::POA_ptr poa, char *containerName , - int argc , char* argv[] ) : + int argc , char* argv[], + bool regist, + bool activ ) : _numInstance(0) { _pid = (long)getpid(); - ActSigIntHandler() ; + if(regist) + ActSigIntHandler() ; _ArgC = argc ; _ArgV = argv ; @@ -77,7 +85,7 @@ Engines_Container_i::Engines_Container_i (CORBA::ORB_ptr orb, } string hostname = GetHostname(); MESSAGE(hostname << " " << getpid() << " Engines_Container_i starting argc " - << _argc << " Thread " << pthread_self() ) ; + << _argc << " Thread " << pthread_self() ) ; i = 0 ; while ( _argv[ i ] ) { MESSAGE(" argv" << i << " " << _argv[ i ]) ; @@ -104,44 +112,24 @@ Engines_Container_i::Engines_Container_i (CORBA::ORB_ptr orb, _orb = CORBA::ORB::_duplicate(orb) ; _poa = PortableServer::POA::_duplicate(poa) ; - MESSAGE("activate object"); - _id = _poa->activate_object(this); - -// _NS = new SALOME_NamingService(_orb); - _NS = SINGLETON_::Instance() ; - ASSERT(SINGLETON_::IsAlreadyExisting()) ; - _NS->init_orb( orb ) ; - - Engines::Container_ptr pCont - = Engines::Container::_narrow(_this()); - SCRUTE(_containerName); - _NS->Register(pCont, _containerName.c_str()); -} - -// Constructeur pour composant parallele : ne pas faire appel au naming service -Engines_Container_i::Engines_Container_i (CORBA::ORB_ptr orb, - PortableServer::POA_ptr poa, - char *containerName, - int flag ) - : _numInstance(0) -{ - _pid = (long)getpid(); - string hostname = GetHostname(); - SCRUTE(hostname); - - _containerName = "/Containers/"; - if (strlen(containerName)== 0) - { - _containerName += hostname; - } - else - { - _containerName += containerName; - } - - _orb = CORBA::ORB::_duplicate(orb) ; - _poa = PortableServer::POA::_duplicate(poa) ; + // Pour les containers paralleles: il ne faut pas activer le container generique, mais le container specialise + if(activ){ + MESSAGE("activate object"); + _id = _poa->activate_object(this); + } + // Pour les containers paralleles: il ne faut pas enregistrer le container generique, mais le container specialise + if(regist){ + // _NS = new SALOME_NamingService(_orb); + _NS = SINGLETON_::Instance() ; + ASSERT(SINGLETON_::IsAlreadyExisting()) ; + _NS->init_orb( orb ) ; + + Engines::Container_ptr pCont + = Engines::Container::_narrow(_this()); + SCRUTE(_containerName); + _NS->Register(pCont, _containerName.c_str()); + } } Engines_Container_i::~Engines_Container_i() @@ -166,6 +154,7 @@ void Engines_Container_i::ping() MESSAGE("Engines_Container_i::ping() pid "<< getpid()); } +//! Kill current container bool Engines_Container_i::Kill_impl() { MESSAGE("Engines_Container_i::Kill() pid "<< getpid() << " containerName " << _containerName.c_str() << " machineName " @@ -173,6 +162,7 @@ bool Engines_Container_i::Kill_impl() { exit( 0 ) ; } +//! Launch a new container from the current container Engines::Container_ptr Engines_Container_i::start_impl( const char* ContainerName ) { MESSAGE("start_impl argc " << _argc << " ContainerName " << ContainerName @@ -186,12 +176,12 @@ Engines::Container_ptr Engines_Container_i::start_impl( cont += machineName() ; cont += "/" ; cont += ContainerName; - MESSAGE(machineName() << " start_impl unknown container " << cont.c_str() + INFOS(machineName() << " start_impl unknown container " << cont.c_str() << " try to Resolve" ); obj = _NS->Resolve( cont.c_str() ); nilvar = CORBA::is_nil( obj ) ; if ( nilvar ) { - MESSAGE(machineName() << " start_impl unknown container " + INFOS(machineName() << " start_impl unknown container " << ContainerName); } } @@ -226,12 +216,12 @@ Engines::Container_ptr Engines_Container_i::start_impl( MESSAGE("system(" << shstr << ")") ; int status = system( shstr.c_str() ) ; if (status == -1) { - MESSAGE("Engines_Container_i::start_impl SALOME_Container failed (system command status -1)") ; + INFOS("Engines_Container_i::start_impl SALOME_Container failed (system command status -1)") ; } else if (status == 217) { - MESSAGE("Engines_Container_i::start_impl SALOME_Container failed (system command status 217)") ; + INFOS("Engines_Container_i::start_impl SALOME_Container failed (system command status 217)") ; } - MESSAGE(machineName() << " Engines_Container_i::start_impl SALOME_Container launch done"); + INFOS(machineName() << " Engines_Container_i::start_impl SALOME_Container launch done"); // pid_t pid = fork() ; // if ( pid == 0 ) { @@ -271,7 +261,7 @@ Engines::Container_ptr Engines_Container_i::start_impl( obj = _NS->Resolve(cont.c_str()); nilvar = CORBA::is_nil( obj ) ; if ( nilvar ) { - MESSAGE(count << ". " << machineName() + INFOS(count << ". " << machineName() << " start_impl unknown container " << cont.c_str()); count -= 1 ; } @@ -420,7 +410,7 @@ void ActSigIntHandler() { exit(0) ; } else { - MESSAGE(pthread_self() << "SigIntHandler activated") ; + INFOS(pthread_self() << "SigIntHandler activated") ; } } diff --git a/src/Container/SALOME_Container_i.hxx b/src/Container/SALOME_Container_i.hxx index bcb57ef22..4e83c867b 100644 --- a/src/Container/SALOME_Container_i.hxx +++ b/src/Container/SALOME_Container_i.hxx @@ -40,8 +40,6 @@ #include #include -using namespace std; - class SALOME_NamingService; class Engines_Container_i: public POA_Engines::Container, @@ -52,40 +50,44 @@ public: Engines_Container_i(CORBA::ORB_ptr orb, PortableServer::POA_ptr poa, char * containerName , - int argc, char* argv[]); -// Constructeur pour composant parallele : ne pas faire appel au naming service - Engines_Container_i(CORBA::ORB_ptr orb, - PortableServer::POA_ptr poa, - char * containerName, - int flag); + int argc, char* argv[], + bool regist = true, + bool activ = true); virtual ~Engines_Container_i(); + //! Launch a new container from the current container Engines::Container_ptr start_impl(const char* ContainerName); + //! Load component in current container Engines::Component_ptr load_impl(const char* nameToRegister, const char* componentName); + + //! Unload component from current container void remove_impl(Engines::Component_ptr component_i); void finalize_removal(); char* name(); char* machineName(); void ping(); + + //! Kill current container bool Kill_impl() ; + char* getHostName(); long getPID(); protected: SALOME_NamingService *_NS ; - string _library_path; - string _containerName; + std::string _library_path; + std::string _containerName; CORBA::ORB_var _orb; PortableServer::POA_var _poa; PortableServer::ObjectId * _id ; int _numInstance ; - map handle_map ; - map remove_map ; + std::map handle_map ; + std::map remove_map ; omni_mutex _numInstanceMutex ; // if several threads on the same object private: diff --git a/src/NamingService/SALOME_NamingService.hxx b/src/NamingService/SALOME_NamingService.hxx index e22bf2d16..cd4683155 100644 --- a/src/NamingService/SALOME_NamingService.hxx +++ b/src/NamingService/SALOME_NamingService.hxx @@ -30,8 +30,7 @@ #define SALOME_NAMINGSERVICE_H #include "utilities.h" -//#include -#include +#include #include #include diff --git a/src/Registry/Makefile.in b/src/Registry/Makefile.in index 5ff83cb1d..2219e4235 100644 --- a/src/Registry/Makefile.in +++ b/src/Registry/Makefile.in @@ -37,17 +37,20 @@ VPATH=.:@srcdir@:@top_srcdir@/idl EXPORT_PYSCRIPTS = EXPORT_HEADERS = \ - RegistryConnexion.hxx + RegistryConnexion.hxx \ + RegistryService.hxx # Libraries targets LIB = libRegistry.la -LIB_SRC = RegistryConnexion.cxx +LIB_SRC = \ + RegistryConnexion.cxx \ + RegistryService.cxx LIB_CLIENT_IDL = SALOME_Registry.idl # Executables targets BIN = SALOME_Registry_Server -BIN_SRC = RegistryService.cxx +BIN_SRC = BIN_SERVER_IDL = SALOME_Registry.idl LDFLAGS+= -lSalomeNS -lOpUtil -lSALOMELocalTrace diff --git a/src/SALOMEDS/Makefile.in b/src/SALOMEDS/Makefile.in index 84cb2949f..7c2273ccd 100644 --- a/src/SALOMEDS/Makefile.in +++ b/src/SALOMEDS/Makefile.in @@ -33,6 +33,10 @@ VPATH=.:@srcdir@:@top_srcdir@/idl:$(top_srcdir)/idl @COMMENCE@ +EXPORT_HEADERS= \ + SALOMEDS_StudyManager_i.hxx \ + SALOMEDS_OCAFApplication.hxx \ + Handle_SALOMEDS_OCAFApplication.hxx # Libraries targets diff --git a/src/SALOMEDS/SALOMEDS_Client.cxx b/src/SALOMEDS/SALOMEDS_Client.cxx index aa39a9f52..a0cc035ce 100644 --- a/src/SALOMEDS/SALOMEDS_Client.cxx +++ b/src/SALOMEDS/SALOMEDS_Client.cxx @@ -26,12 +26,12 @@ // Module : SALOME // $Header$ -using namespace std; #include #include CORBA_SERVER_HEADER(SALOMEDS) #include "SALOMEDS_StudyManager_i.hxx" #include "utilities.h" #include "SALOMEDS_AttributeName_i.hxx" +using namespace std; //============================================================================ /*! Function : @@ -279,8 +279,13 @@ int main(int argc, char** argv) { try { // Initialise the ORB. +#if OMNIORB_VERSION >= 4 + const char* options[][2] = { { "giopMaxMsgSize", "104857600" }, { 0, 0 } }; + CORBA::ORB_var orb = CORBA::ORB_init( argc , argv , "omniORB4", options) ; +#else CORBA::ORB_var orb = CORBA::ORB_init(argc, argv, "omniORB3"); omniORB::MaxMessageSize(100 * 1024 * 1024); +#endif // Obtain a reference to the root POA. CORBA::Object_var obj = orb->resolve_initial_references("RootPOA"); diff --git a/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx b/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx index 8c8daa9c7..222a6fe27 100644 --- a/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx +++ b/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx @@ -26,7 +26,6 @@ // Module : SALOME // $Header$ -using namespace std; #include "utilities.h" #include "SALOME_LifeCycleCORBA.hxx" #include "SALOMEDS_StudyManager_i.hxx" @@ -75,8 +74,9 @@ using namespace std; #include "Utils_CorbaException.hxx" #include +using namespace std; -#include +#include "SALOME_GenericObj_i.hh" #include "Utils_ExceptHandlers.hxx" diff --git a/src/SALOMEGUI/QAD_Desktop.cxx b/src/SALOMEGUI/QAD_Desktop.cxx index c113b87cc..380702a0d 100644 --- a/src/SALOMEGUI/QAD_Desktop.cxx +++ b/src/SALOMEGUI/QAD_Desktop.cxx @@ -30,7 +30,6 @@ \class QAD_Desktop QAD_Desktop.h \brief Main desktop of QAD-based application. */ -using namespace std; # include "Utils_ORB_INIT.hxx" # include "Utils_SINGLETON.hxx" @@ -105,6 +104,7 @@ using namespace std; #include #include #include +using namespace std; static const char* SEPARATOR = ":"; diff --git a/src/SALOMEGUI/QAD_ObjectBrowser.cxx b/src/SALOMEGUI/QAD_ObjectBrowser.cxx index 079462ef3..9fa4ef038 100644 --- a/src/SALOMEGUI/QAD_ObjectBrowser.cxx +++ b/src/SALOMEGUI/QAD_ObjectBrowser.cxx @@ -26,7 +26,6 @@ // Module : SALOME // $Header$ -using namespace std; #include "QAD_ObjectBrowserItem.h" #include "QAD_ObjectBrowser.h" #include "QAD_Application.h" @@ -56,6 +55,7 @@ using namespace std; #include #include #include +using namespace std; //VRV: porting on Qt 3.0.5 #if QT_VERSION >= 0x030005 @@ -150,6 +150,8 @@ QAD_ObjectBrowser::QAD_ObjectBrowser( SALOMEDS::Study_var study, QWidget* parent myStudy = SALOMEDS::Study::_duplicate( study ); myListViewMap.clear(); myUseCaseMap.clear(); + myListView=0; // must be done before setupListView(): setCornerWidget() provoque call to eventFilter + myUseCaseView=0; // and test myUseCaseView->viewport() before initialisation setupListView(); } @@ -339,6 +341,7 @@ bool QAD_ObjectBrowser::eventFilter( QObject* o, QEvent* e ) return QTabWidget::eventFilter( o, e ); SALOMEDS::UseCaseBuilder_var UCBuilder = myStudy->GetUseCaseBuilder(); + if (! myUseCaseView) return QTabWidget::eventFilter( o, e ); if (o == myUseCaseView->viewport()) { if ( e->type() == QEvent::MouseButtonPress ) { // Test if clicked on selection and start drag if necessary diff --git a/src/SALOMELocalTrace/SALOME_Log.cxx b/src/SALOMELocalTrace/SALOME_Log.cxx index 476d987f4..c7059d855 100644 --- a/src/SALOMELocalTrace/SALOME_Log.cxx +++ b/src/SALOMELocalTrace/SALOME_Log.cxx @@ -29,11 +29,15 @@ #include #include +#include "SALOME_Log.hxx" using namespace std; -#include "SALOME_Log.hxx" +SALOME_Log* SALOME_Log::_singleton = 0; -SALOME_Log::SALOME_Log() +// log line size: if too short, log line is truncated, without crash... +char SALOME_LogStr[1024]; + +SALOME_Log::SALOME_Log(): ostrstream(SALOME_LogStr,sizeof(SALOME_LogStr)) { } @@ -41,10 +45,10 @@ SALOME_Log::~SALOME_Log() { } -SALOME_Log& SALOME_Log::Instance() +SALOME_Log* SALOME_Log::Instance() { - static SALOME_Log instance; - return instance; + if (_singleton == 0) _singleton = new SALOME_Log(); + return _singleton; } void SALOME_Log::putMessage(std::ostream& msg) @@ -55,3 +59,4 @@ void SALOME_Log::putMessage(std::ostream& msg) seekp(0); } + diff --git a/src/SALOMELocalTrace/SALOME_Log.hxx b/src/SALOMELocalTrace/SALOME_Log.hxx index 043d1e1c2..30694062b 100644 --- a/src/SALOMELocalTrace/SALOME_Log.hxx +++ b/src/SALOMELocalTrace/SALOME_Log.hxx @@ -61,25 +61,25 @@ # endif /* WNT */ -using namespace std; #include #include +using namespace std; class SALOME_Log : public ostrstream { -public: - virtual ~SALOME_Log(); - static Standard_EXPORT SALOME_Log& Instance(); - Standard_EXPORT void putMessage(std::ostream& msg); - +private: + static SALOME_Log* _singleton; protected: //disable creation of instances: force use static SALOME_Log& Instance() SALOME_Log(); +public: + virtual ~SALOME_Log(); + static Standard_EXPORT SALOME_Log* Instance(); + Standard_EXPORT void putMessage(std::ostream& msg); }; - #define SLog SALOME_Log::Instance() #endif diff --git a/src/SALOMELogger/SALOME_LoggerClient.cxx b/src/SALOMELogger/SALOME_LoggerClient.cxx index 70f765038..a468e9ffe 100644 --- a/src/SALOMELogger/SALOME_LoggerClient.cxx +++ b/src/SALOMELogger/SALOME_LoggerClient.cxx @@ -36,15 +36,14 @@ using namespace std; #include #include CORBA_CLIENT_HEADER(Logger) -// class SALOME_LoggerClient : public SALOME_Log -// { -// protected: -// SALOME_Logger::Logger_var m_pInterfaceLogger; // object reference on Logger server -// }; - SALOME_Logger::Logger_ptr m_pInterfaceLogger; // object reference on Logger server -SALOME_Log::SALOME_Log() +SALOME_Log* SALOME_Log::_singleton = 0; + +// log line size: if too short, log line is truncated, without crash... +char SALOME_LogStr[1024]; + +SALOME_Log::SALOME_Log(): ostrstream(SALOME_LogStr,sizeof(SALOME_LogStr)) { cout << "SALOME_LoggerClient: constructor" << endl; //get reference on object reference from NS @@ -131,10 +130,10 @@ SALOME_Log::~SALOME_Log() { } -SALOME_Log& SALOME_Log::Instance() +SALOME_Log* SALOME_Log::Instance() { - static SALOME_Log instance; - return instance; + if (_singleton == 0) _singleton = new SALOME_Log(); + return _singleton; } void SALOME_Log::putMessage(std::ostream& msg) diff --git a/src/Session/Makefile.in b/src/Session/Makefile.in index 36ba65dde..4d2bd69b9 100644 --- a/src/Session/Makefile.in +++ b/src/Session/Makefile.in @@ -40,8 +40,9 @@ EXPORT_HEADERS= SALOME_Session_i.hxx # Libraries targets LIB = libSalomeSession.la LIB_SRC=\ - SALOME_Session_QThread.cxx \ - SALOME_Session_i.cxx + SALOME_Session_i.cxx \ + Session_ServerThread.cxx \ + Session_ServerLauncher.cxx # Executables targets BIN = SALOME_Session_Server @@ -49,9 +50,9 @@ BIN_SRC = BIN_SERVER_IDL = SALOME_Session.idl BIN_CLIENT_IDL = SALOMEDS.idl SALOMEDS_Attributes.idl SALOME_Component.idl SALOME_Registry.idl SALOME_ModuleCatalog.idl SALOME_Exception.idl -CPPFLAGS+=$(QT_MT_INCLUDES) $(OCC_INCLUDES) $(PYTHON_INCLUDES) +CPPFLAGS+=$(QT_MT_INCLUDES) $(OCC_INCLUDES) $(PYTHON_INCLUDES) $(HDF5_INCLUDES) CXXFLAGS+=$(OCC_CXXFLAGS) -LDFLAGS+=$(QT_MT_LIBS) -lSalomeNS -lSalomeGUI -lSalomeObject -lSalomeLifeCycleCORBA -lqsplitterP -lOpUtil -lPlot2d -lSalomeVTKFilter -lSALOMELocalTrace +LDFLAGS+=$(QT_MT_LIBS) $(HDF5_LIBS) -lSalomeHDFPersist -lSalomeNS -lSalomeGUI -lSalomeObject -lSalomeLifeCycleCORBA -lqsplitterP -lOpUtil -lPlot2d -lSalomeVTKFilter -lSALOMELocalTrace -lSalomeContainer -lRegistry -lSalomeNotification -lSalomeDS -lTOOLSDS -lSalomeGenericObj -lSalomeCatalog @CONCLUDE@ diff --git a/src/Session/SALOME_Session_Server.cxx b/src/Session/SALOME_Session_Server.cxx index 5294abd94..408ed1728 100644 --- a/src/Session/SALOME_Session_Server.cxx +++ b/src/Session/SALOME_Session_Server.cxx @@ -33,13 +33,47 @@ #include using namespace std; +#include +#include +#include +#include + +#include "SALOMEGUI_Application.h" +#include "QAD.h" +#include "QAD_MessageBox.h" +#include "QAD_Application.h" +#include "QAD_Settings.h" +#include "QAD_Config.h" +#include "QAD_Tools.h" +#include "QAD_ResourceMgr.h" +#include "Utils_CatchSignals.h" +#include "Utils_SALOME_Exception.hxx" +#include "Utils_CorbaException.hxx" +#include "SALOMEGUI_QtCatchCorbaException.hxx" + + #include #include CORBA_SERVER_HEADER(SALOME_Session) +#include CORBA_SERVER_HEADER(SALOMEDS) #include "utilities.h" #include "SALOME_Session_i.hxx" +#include "Session_ServerLauncher.hxx" + +/*! - read arguments, define list of server to launch with their arguments. + * - wait for naming service + * - create and run a thread for launch of all servers + * + */ + +// ---------------------------------------------------------------------------- + + + +// ---------------------------------------------------------------------------- + //! CORBA server for SALOME Session /*! * SALOME_Session Server launches a SALOME session servant. @@ -54,116 +88,162 @@ using namespace std; int main(int argc, char **argv) { - try { ORB_INIT &init = *SINGLETON_::Instance() ; ASSERT(SINGLETON_::IsAlreadyExisting()) ; - CORBA::ORB_var &orb = init( argc , argv ) ; - - // - long TIMESleep = 250000000; - int NumberOfTries = 40; - int a; - timespec ts_req; - ts_req.tv_nsec=TIMESleep; - ts_req.tv_sec=0; - timespec ts_rem; - ts_rem.tv_nsec=0; - ts_rem.tv_sec=0; - CosNaming::NamingContext_var inc; - PortableServer::POA_var poa; - CORBA::Object_var theObj; - CORBA::Object_var obj; - CORBA::Object_var object; - SALOME_NamingService &naming = *SINGLETON_::Instance() ; - int SESSION=0; - const char * Env = getenv("USE_LOGGER"); - int EnvL =0; - if ((Env!=NULL) && (strlen(Env))) - EnvL=1; - CosNaming::Name name; - name.length(1); - name[0].id=CORBA::string_dup("Logger"); - PortableServer::POAManager_var pman; - for (int i = 1; i<=NumberOfTries; i++){ - if (i!=1) - a=nanosleep(&ts_req,&ts_rem); - try - { - obj = orb->resolve_initial_references("RootPOA"); - if(!CORBA::is_nil(obj)) - poa = PortableServer::POA::_narrow(obj); - if(!CORBA::is_nil(poa)) - pman = poa->the_POAManager(); - if(!CORBA::is_nil(orb)) - theObj = orb->resolve_initial_references("NameService"); - if (!CORBA::is_nil(theObj)) - inc = CosNaming::NamingContext::_narrow(theObj); - } - catch( CORBA::COMM_FAILURE& ) - { - INFOS( "Session Server: CORBA::COMM_FAILURE: Unable to contact the Naming Service" ); - } - if(!CORBA::is_nil(inc)) - { - MESSAGE( "Session Server: Naming Service was found" ); - if(EnvL==1) - { - for(int j=1; j<=NumberOfTries; j++) - { - if (j!=1) - a=nanosleep(&ts_req, &ts_rem); - try - { - object = inc->resolve(name); - } - catch(CosNaming::NamingContext::NotFound) - { INFOS( "Session Server: Logger Server wasn't found" ); - } - catch(...) - { - INFOS( "Session Server: Unknown exception" ); - } - if (!CORBA::is_nil(object)) - { - MESSAGE( "Session Server: Loger Server was found" ); - SESSION=1; - break; - } - } - } - } - if ((SESSION==1)||((EnvL==0)&&(!CORBA::is_nil(inc)))) - break; - } - - // servant - SALOME_Session_i * mySALOME_Session = new SALOME_Session_i(argc, argv, orb, poa) ; - PortableServer::ObjectId_var mySALOME_Sessionid = poa->activate_object(mySALOME_Session) ; - MESSAGE("poa->activate_object(mySALOME_Session)") - - obj = mySALOME_Session->_this() ; - CORBA::String_var sior(orb->object_to_string(obj)) ; - - mySALOME_Session->NSregister(); - - mySALOME_Session->_remove_ref() ; - - //DECOMMENT PortableServer::POAManager_var pman = poa->the_POAManager() ; + int orbArgc = 1; + CORBA::ORB_var &orb = init( orbArgc , argv ) ; + + CORBA::Object_var obj = orb->resolve_initial_references("RootPOA"); + PortableServer::POA_var poa = PortableServer::POA::_narrow(obj); + + PortableServer::POAManager_var pman = poa->the_POAManager() ; pman->activate() ; - MESSAGE("pman->activate()") + INFOS("pman->activate()"); + + SALOME_NamingService *_NS = new SALOME_NamingService(orb); + + Utils_CatchSignals aCatch; + aCatch.Activate(); - orb->run() ; - orb->destroy() ; + // CORBA Servant Launcher + + QMutex _GUIMutex ; + QWaitCondition _ServerLaunch; + _GUIMutex.lock(); // to block Launch server thread until wait(mutex) + + Session_ServerLauncher* myServerLauncher + = new Session_ServerLauncher(argc, argv, orb, poa, &_GUIMutex, &_ServerLaunch); + myServerLauncher->start(); + + MESSAGE("waiting wakeAll()"); + _ServerLaunch.wait(&_GUIMutex); // to be reseased by Launch server thread when ready: + // atomic operation lock - unlock on mutex + // unlock mutex: serverThread runs, calls _ServerLaunch->wakeAll() + // this thread wakes up, and lock mutex + + INFOS("Session activated, Launch IAPP..."); + + int qappArgc = 1; + QApplication *_qappl = new QApplication(qappArgc, argv ); + INFOS("creation QApplication"); + _GUIMutex.unlock(); + + QAD_ASSERT ( QObject::connect(_qappl, SIGNAL(lastWindowClosed()), _qappl, SLOT(quit()) ) ); + SALOMEGUI_Application* _mw = new SALOMEGUI_Application ( "MDTV-Standard", "HDF", "hdf" ); + INFOS("creation SALOMEGUI_Application"); + + SCRUTE(_NS); + if ( !SALOMEGUI_Application::addToDesktop ( _mw, _NS ) ) + { + QAD_MessageBox::error1 ( 0, + QObject::tr("ERR_ERROR"), + QObject::tr("ERR_APP_INITFAILED"), + QObject::tr("BUT_OK") ); + } + else + { + + QFileInfo prgInfo(argv[0]); + QDir prgDir(prgInfo.dirPath(true)); + QAD_CONFIG->setPrgDir(prgDir); // CWD is program directory + QAD_CONFIG->createConfigFile(false); // Create config file + // ~/.tr(MEN_APPNAME)/tr(MEN_APPNAME).conf if there's none + QAD_CONFIG->readConfigFile(); // Read config file + + _qappl->setPalette( QAD_Application::getPalette() ); + + //Utils_CatchSignals aCatch; + //aCatch.Activate(); + + /* Run 'SALOMEGUI' application */ + QAD_Application::run(); + + // T2.12 - catch exceptions thrown on attempts to modified a locked study + while (1) + { + try + { + MESSAGE("run(): starting the main event loop"); + int _ret = _qappl->exec(); + break; + } + catch (SALOME::SALOME_Exception& e) + { + QtCatchCorbaException(e); + } + catch(SALOMEDS::StudyBuilder::LockProtection&) + { + INFOS("run(): An attempt to modify a locked study has not been handled by QAD_Operation"); + QApplication::restoreOverrideCursor(); + QAD_MessageBox::warn1 ( (QWidget*)QAD_Application::getDesktop(), + QObject::tr("WRN_WARNING"), + QObject::tr("WRN_STUDY_LOCKED"), + QObject::tr("BUT_OK") ); + } + catch (const CORBA::Exception& e) + { + CORBA::Any tmp; + tmp<<= e; + CORBA::TypeCode_var tc = tmp.type(); + const char *p = tc->name(); + INFOS ("run(): CORBA exception of the kind : "<createConfigFile(true); + } + aCatch.Deactivate(); } - catch (CORBA::SystemException&) + catch (SALOME_Exception& e) + { + INFOS("run(): SALOME::SALOME_Exception is caught: "<name(); + INFOS ("run(): CORBA exception of the kind : "< #include #include +using namespace std; //============================================================================= /*! SALOME_Session_i @@ -48,15 +48,15 @@ using namespace std; */ //============================================================================= -SALOME_Session_i::SALOME_Session_i(int argc, char ** argv, CORBA::ORB_ptr orb, PortableServer::POA_ptr poa) +SALOME_Session_i::SALOME_Session_i(int argc, char ** argv, CORBA::ORB_ptr orb, PortableServer::POA_ptr poa, QMutex* GUIMutex) { _argc = argc ; _argv = argv ; - _IAPPThread = new SALOME_Session_QThread(_argc, _argv) ; _isGUI = FALSE ; _runningStudies= 0 ; _orb = CORBA::ORB::_duplicate(orb) ; _poa = PortableServer::POA::_duplicate(poa) ; + _GUIMutex = GUIMutex; MESSAGE("constructor end"); } @@ -66,14 +66,16 @@ SALOME_Session_i::SALOME_Session_i(int argc, char ** argv, CORBA::ORB_ptr orb, P */ //============================================================================= -Engines::Component_ptr SALOME_Session_i::GetVisuComponent() { +Engines::Component_ptr SALOME_Session_i::GetVisuComponent() +{ MESSAGE("SALOME_Session_i::GetVisuGen"); - typedef Engines::Component_ptr VisuGen(CORBA::ORB_ptr,PortableServer::POA_ptr, + typedef Engines::Component_ptr VisuGen(CORBA::ORB_ptr, + PortableServer::POA_ptr, SALOME_NamingService*,QMutex*); OSD_SharedLibrary visuSharedLibrary("libVISUEngine.so"); if(visuSharedLibrary.DlOpen(OSD_RTLD_LAZY)) if(OSD_Function osdFun = visuSharedLibrary.DlSymb("GetVisuGen")) - return ((VisuGen (*)) osdFun)(_orb,_poa,_NS,&_GUIMutex); + return ((VisuGen (*)) osdFun)(_orb,_poa,_NS,_GUIMutex); return Engines::Component::_nil(); } @@ -102,7 +104,6 @@ void SALOME_Session_i::NSregister() { _NS = new SALOME_NamingService(_orb); _NS->Register(pSession, "/Kernel/Session"); - _IAPPThread->setNamingService(_NS); } catch (ServiceUnreachable&) { @@ -113,7 +114,7 @@ void SALOME_Session_i::NSregister() { INFOS("Caught unknown exception from Naming Service"); } - MESSAGE("NSregister end"); + MESSAGE("Session registered in Naming Service"); } //============================================================================= @@ -125,13 +126,14 @@ void SALOME_Session_i::NSregister() void SALOME_Session_i::GetInterface() { - _GUIMutex.lock() ; // get access to boolean _isGUI - _isGUI = _IAPPThread->running(); - if(!_isGUI){ - _isGUI = TRUE ; - _IAPPThread->start() ; - } - _GUIMutex.unlock() ; // release access to boolean _isGUI + _GUIMutex->lock() ; // get access to boolean _isGUI + //_isGUI = _IAPPThread->running(); + if(!_isGUI) + { + _isGUI = TRUE ; + //_IAPPThread->start() ; + } + _GUIMutex->unlock() ; // release access to boolean _isGUI } //============================================================================= @@ -145,21 +147,6 @@ void SALOME_Session_i::StopSession() qApp->lock(); QAD_Application::getDesktop()->closeDesktop( true ); qApp->unlock(); -/* - _GUIMutex.lock(); // get access to boolean _isGUI - if ((! _isGUI) && (! _runningStudies)) - { - MESSAGE("Ask for Session Kill, OK"); - exit(0); - } - else - { - _GUIMutex.unlock() ; // release access to boolean _isGUI - MESSAGE("Ask for Session Kill, NOK"); - if (_isGUI) throw SALOME::Session::GUIActive(); - if (_runningStudies) throw SALOME::Session::RunningStudies(); - } -*/ } //============================================================================= @@ -173,16 +160,18 @@ SALOME::StatSession SALOME_Session_i::GetStatSession() { // update Session state //qApp->lock(); // rollback bug - _GUIMutex.lock(); - _isGUI = _IAPPThread->running(); + _GUIMutex->lock(); + //_isGUI = _IAPPThread->running(); + _isGUI = 1; _runningStudies = 0; - if (_isGUI) { - qApp->lock(); - if ( QAD_Application::getDesktop() && QAD_Application::getDesktop()->getActiveApp() ) - _runningStudies = QAD_Application::getDesktop()->getActiveApp()->getStudies().count(); - qApp->unlock(); - } - _GUIMutex.unlock(); + if (_isGUI) + { + qApp->lock(); + if ( QAD_Application::getDesktop() && QAD_Application::getDesktop()->getActiveApp() ) + _runningStudies = QAD_Application::getDesktop()->getActiveApp()->getStudies().count(); + qApp->unlock(); + } + _GUIMutex->unlock(); //qApp->unlock(); // getting stat info SALOME::StatSession_var myStats = new SALOME::StatSession ; diff --git a/src/Session/SALOME_Session_i.hxx b/src/Session/SALOME_Session_i.hxx index 0d52f118e..438b93f62 100644 --- a/src/Session/SALOME_Session_i.hxx +++ b/src/Session/SALOME_Session_i.hxx @@ -41,8 +41,8 @@ class SALOME_Session_i: public virtual POA_SALOME::Session, public virtual PortableServer::RefCountServantBase { public: - SALOME_Session_i(int argc, char ** argv, CORBA::ORB_ptr orb, PortableServer::POA_ptr poa) ; - ~SALOME_Session_i() ; + SALOME_Session_i(int argc, char ** argv, CORBA::ORB_ptr orb, PortableServer::POA_ptr poa, QMutex* GUIMutex); + ~SALOME_Session_i(); //! Launch Graphical User Interface void GetInterface(); @@ -62,8 +62,6 @@ public: void ping(){}; protected: - //! A QT Thread for the GUI - SALOME_Session_QThread *_IAPPThread ; //! Naming service interface SALOME_NamingService *_NS; @@ -71,7 +69,7 @@ protected: int _argc ; char **_argv; CORBA::Boolean _isGUI ; - QMutex _GUIMutex ; + QMutex* _GUIMutex ; int _runningStudies ; CORBA::ORB_var _orb; PortableServer::POA_var _poa; diff --git a/src/Session/Session_ServerLauncher.cxx b/src/Session/Session_ServerLauncher.cxx new file mode 100644 index 000000000..54cf11cba --- /dev/null +++ b/src/Session/Session_ServerLauncher.cxx @@ -0,0 +1,216 @@ +// SALOME Session : implementation of Session_ServerLauncher.cxx +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : Session_ServerLauncher.xx +// Author : Paul RASCLE, EDF +// Module : SALOME +// $Header$ + +#include "Session_ServerLauncher.hxx" + +#include "Utils_SALOME_Exception.hxx" +#include "utilities.h" + +//============================================================================= +/*! + * default constructor not for use + */ +//============================================================================= + +Session_ServerLauncher::Session_ServerLauncher() +{ + ASSERT(0); // must not be called +} + +//============================================================================= +/*! + * constructor + */ +//============================================================================= + +Session_ServerLauncher::Session_ServerLauncher(int argc, + char ** argv, + CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa, + QMutex *GUIMutex, + QWaitCondition *ServerLaunch) +{ + _argc = argc; + _argv = argv; + _orb = CORBA::ORB::_duplicate(orb); + _root_poa = PortableServer::POA::_duplicate(poa); + _GUIMutex = GUIMutex; + _ServerLaunch = ServerLaunch; +} + +//============================================================================= +/*! + * destructor + */ +//============================================================================= + +Session_ServerLauncher::~Session_ServerLauncher() +{ +} + +//============================================================================= +/*! + * Check args and activate servers + */ +//============================================================================= + +void Session_ServerLauncher::run() +{ + MESSAGE("Session_ServerLauncher::run"); + _GUIMutex->lock(); // lock released by calling thread when ready: wait(mutex) + MESSAGE("Server Launcher thread free to go..."); + _GUIMutex->unlock(); + + CheckArgs(); + ActivateAll(); + + _ServerLaunch->wakeAll(); + _orb->run(); // this thread wait, during omniORB process events +} + +//============================================================================= +/*! + * controls and dispatchs arguments given with command + */ +//============================================================================= + +void Session_ServerLauncher::CheckArgs() +{ + int argState = 0; + ServArg aServArg(0,0,0); + _argCopy.reserve(_argc); + for (int iarg=0; iarg <_argc; iarg++) + { + SCRUTE(iarg); + SCRUTE(_argv[iarg]); + _argCopy.push_back(_argv[iarg]); + switch (argState) + { + case 0: // looking for "--with" + { + if (strcmp(_argv[iarg],"--with")==0) + argState = 1; + break; + } + case 1: // looking for server type + { + for (int i=0; i::iterator itServ; + for (itServ = _argServToLaunch.begin(); itServ !=_argServToLaunch.end(); itServ++) + { + int argc = 2 + (*itServ)._lastArg - (*itServ)._firstArg; + char** argv = new char*[argc+1]; + argv[argc]=0; // for Engines_Container_i constructor... + int servType = (*itServ)._servType; + argv[0]=strdup(Session_ServerThread::_serverTypes[servType]); + if (argc>1) + { + for (int i=0; iInit(); + } + + // Always launch Session Server + + int argc=1; + char** argv = new char*[argc]; + argv[0] = "Session"; + Session_ServerThread* aServerThread + = new Session_ServerThread(argc, argv, _orb,_root_poa,_GUIMutex); + _serverThreads.push_back(aServerThread); + + aServerThread->Init(); +} + diff --git a/src/Session/Session_ServerLauncher.hxx b/src/Session/Session_ServerLauncher.hxx new file mode 100644 index 000000000..893754ac0 --- /dev/null +++ b/src/Session/Session_ServerLauncher.hxx @@ -0,0 +1,88 @@ +// SALOME Session : implementation of Session_ServerLauncher.hxx +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : Session_ServerLauncher.hxx +// Author : Paul RASCLE, EDF +// Module : SALOME +// $Header$ + +#ifndef _SESSION_SERVERLAUNCHER_HXX_ +#define _SESSION_SERVERLAUNCHER_HXX_ + +#include "Session_ServerThread.hxx" + +#include +#include +#include +#include +#include +#include + +using namespace std; + +class ServArg + { + public: + int _servType; + int _firstArg; + int _lastArg; + inline ServArg(int servType=0, int firstArg=0, int lastArg=0); +}; + +inline ServArg::ServArg(int servType, int firstArg, int lastArg): + _servType(servType),_firstArg(firstArg),_lastArg(lastArg) +{} + +class Session_ServerLauncher: public QThread +{ +public: + Session_ServerLauncher(); + Session_ServerLauncher(int argc, + char ** argv, + CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa, + QMutex *GUIMutex, + QWaitCondition *ServerLaunch); + virtual ~Session_ServerLauncher(); + void run(); +protected: + + void CheckArgs(); + + void ActivateAll(); + +private: + + int _argc; + char ** _argv; + CORBA::ORB_var _orb; + PortableServer::POA_var _root_poa; + QMutex* _GUIMutex; + QWaitCondition *_ServerLaunch; + list _argServToLaunch; + vector _argCopy; + list _serverThreads; +}; + +#endif + diff --git a/src/Session/Session_ServerThread.cxx b/src/Session/Session_ServerThread.cxx new file mode 100644 index 000000000..1cf8ca856 --- /dev/null +++ b/src/Session/Session_ServerThread.cxx @@ -0,0 +1,513 @@ +// SALOME Session : implementation of Session_ServerThread.cxx +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : Session_ServerThread.cxx +// Author : Paul RASCLE, EDF +// Module : SALOME +// $Header$ + +// #include +// #include CORBA_SERVER_HEADER(SALOME_Session) +// #include CORBA_SERVER_HEADER(SALOMEDS) + +#include "Session_ServerThread.hxx" + +#include "SALOME_Container_i.hxx" +#include "SALOMEDS_StudyManager_i.hxx" +#include "SALOME_ModuleCatalog_impl.hxx" +#include "RegistryService.hxx" +#include "SALOME_Session_i.hxx" + +#include "Utils_ORB_INIT.hxx" +#include "Utils_SINGLETON.hxx" +#include "Utils_SALOME_Exception.hxx" +#include "OpUtil.hxx" +#include "utilities.h" + +#include +#include + +using namespace std; + +const int Session_ServerThread::NB_SRV_TYP = 5; +const char* Session_ServerThread::_serverTypes[NB_SRV_TYP] = {"Container", + "ModuleCatalog", + "Registry", + "SALOMEDS", + "Session"}; + +//============================================================================= +/*! + * Wait until the given server is ready i.e. is name is found in namingService. + * Try 40 times, with 250 ms sleep between each try. + * If Logger is used for traces, it must be ready before this call, because + * SALOME_NamingService client uses SALOME traces. So, Logger readiness must be + * checked in Launch script before execution of WaitForServerReadiness. + */ +//============================================================================= + +void WaitForServerReadiness(SALOME_NamingService* NS, string serverName) +{ + long TIMESleep = 250000000; // 250 ms. + int NumberOfTries = 40; // total wait = 10 s. + int found = 0; + + timespec ts_req; + ts_req.tv_nsec=TIMESleep; + ts_req.tv_sec=0; + timespec ts_rem; + ts_rem.tv_nsec=0; + ts_rem.tv_sec=0; + + for (int itry=0; itry < NumberOfTries; itry++) + { + try + { + if (serverName.length() == 0) + { + string curdir = NS->Current_Directory(); // to wait for naming service + found = 1; + break; // naming service found + } + else + { + CORBA::Object_ptr obj = NS->Resolve(serverName.c_str()); + if (! CORBA::is_nil(obj)) + { + found =1; + break; // server found, no more try to do + } + MESSAGE("Server "<< serverName <<" not yet ready, waiting..."); + int a = nanosleep(&ts_req,&ts_rem); // wait before retry + } + } + catch( ServiceUnreachable& ) + { + MESSAGE("CORBA::COMM_FAILURE: Naming Service not yet ready, waiting..."); + int a = nanosleep(&ts_req,&ts_rem); // wait before retry + } + } + if (!found) + { + INFOS("Server "<< serverName <<" not found, abort..."); + exit(EXIT_FAILURE); + } +} + +//============================================================================= +/*! + * default constructor not for use + */ +//============================================================================= + +Session_ServerThread::Session_ServerThread() +{ + ASSERT(0); // must not be called +} + +//============================================================================= +/*! + * constructor + */ +//============================================================================= + +Session_ServerThread::Session_ServerThread(int argc, + char ** argv, + CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa, + QMutex *GUIMutex) +{ + MESSAGE("Session_ServerThread Constructor " << argv[0]); + _argc = argc; + _argv = argv; + _orb = CORBA::ORB::_duplicate(orb); + _root_poa = PortableServer::POA::_duplicate(poa); + _GUIMutex = GUIMutex; + _servType =-1; + _NS = new SALOME_NamingService(_orb); // one instance per server to limit + // multi thread coherence problems +} + +//============================================================================= +/*! + * destructor + */ +//============================================================================= + +Session_ServerThread::~Session_ServerThread() +{ + MESSAGE("~Session_ServerThread "<< _argv[0]); +} + +//============================================================================= +/*! + * run the thread : activate one servant, the servant type is given by + * argument _argv[0] + */ +//============================================================================= + +void Session_ServerThread::Init() +{ + MESSAGE("Session_ServerThread::Init "<< _argv[0]); + + for (int i=0; i<_argc; i++) SCRUTE(_argv[i]); + for (int i=0; iactivate_object (Catalogue_i); + MESSAGE("---"); + + CORBA::Object_ptr myCata = Catalogue_i->_this(); + MESSAGE("---"); + _NS->Register(myCata ,"/Kernel/ModulCatalog"); + MESSAGE("---"); + } + catch(CORBA::SystemException&) + { + INFOS( "Caught CORBA::SystemException." ); + } + catch(CORBA::Exception&) + { + INFOS( "Caught CORBA::Exception." ); + } + catch(omniORB::fatalException& fe) + { + INFOS( "Caught omniORB::fatalException:" ); + INFOS( " file: " << fe.file() ); + INFOS( " line: " << fe.line() ); + INFOS( " mesg: " << fe.errmsg() ); + } + catch(...) + { + INFOS( "Caught unknown exception." ); + } +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +void Session_ServerThread::ActivateSALOMEDS(int argc, + char ** argv) +{ + try + { + INFOS("SALOMEDS thread started"); + // We allocate the objects on the heap. Since these are reference + // counted objects, they will be deleted by the POA when they are no + // longer needed. + + SALOMEDS_StudyManager_i * myStudyManager_i + = new SALOMEDS_StudyManager_i(_orb); + + // Activate the objects. This tells the POA that the objects are + // ready to accept requests. + + PortableServer::ObjectId_var myStudyManager_iid + = _root_poa->activate_object(myStudyManager_i); + + myStudyManager_i->register_name("/myStudyManager"); + } + catch(CORBA::SystemException&) + { + INFOS( "Caught CORBA::SystemException." ); + } + catch(CORBA::Exception&) + { + INFOS( "Caught CORBA::Exception." ); + } + catch(omniORB::fatalException& fe) + { + INFOS( "Caught omniORB::fatalException:" ); + INFOS( " file: " << fe.file() ); + INFOS( " line: " << fe.line() ); + INFOS( " mesg: " << fe.errmsg() ); + } + catch(...) + { + INFOS( "Caught unknown exception." ); + } +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +void Session_ServerThread::ActivateRegistry(int argc, + char ** argv) +{ + INFOS("Registry thread started"); + SCRUTE(argc); + if( argc<3 ) + { + INFOS("you must provide the Salome session name when you call SALOME_Registry_Server"); + throw CommException("you must provide the Salome session name when you call SALOME_Registry_Server"); + } + const char *ptrSessionName=0; + + int k=0 ; + for ( k=1 ; k0); + const char *registryName = "Registry"; + Registry::Components_var varComponents; + try + { + RegistryService *ptrRegistry = SINGLETON_::Instance(); + ptrRegistry->SessionName( ptrSessionName ); + varComponents = ptrRegistry->_this(); + // The RegistryService must not already exist. + + try + { + CORBA::Object_var pipo = _NS->Resolve( registryName ); + if (CORBA::is_nil(pipo) ) throw ServiceUnreachable(); + INFOS("RegistryService servant already existing" ); + ASSERT(0); + } + catch( const ServiceUnreachable &ex ) + { + } + catch( const CORBA::Exception &exx ) + { + } + string absoluteName = string("/") + registryName; + _NS->Register( varComponents , absoluteName.c_str() ); + MESSAGE("On attend les requetes des clients"); + } + catch( const SALOME_Exception &ex ) + { + INFOS( "Communication Error : " << ex.what() ); + ASSERT(0); + } +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +void Session_ServerThread::ActivateContainer(int argc, + char ** argv) +{ + try + { + INFOS("Container thread started"); + + // get or create the child POA + + PortableServer::POA_var factory_poa; + try + { + factory_poa = _root_poa->find_POA("factory_poa",0); + // 0 = no activation (already done if exists) + } + catch (PortableServer::POA::AdapterNonExistent&) + { + INFOS("factory_poa does not exists, create..."); + // define policy objects + PortableServer::ImplicitActivationPolicy_var implicitActivation = + _root_poa->create_implicit_activation_policy( + PortableServer::NO_IMPLICIT_ACTIVATION); + MESSAGE("---"); + // default = NO_IMPLICIT_ACTIVATION + PortableServer::ThreadPolicy_var threadPolicy = + _root_poa->create_thread_policy(PortableServer::ORB_CTRL_MODEL); + // default = ORB_CTRL_MODEL, other choice SINGLE_THREAD_MODEL + MESSAGE("---"); + + // create policy list + CORBA::PolicyList policyList; + policyList.length(2); + policyList[0] = PortableServer::ImplicitActivationPolicy:: + _duplicate(implicitActivation); + policyList[1] = PortableServer::ThreadPolicy:: + _duplicate(threadPolicy); + MESSAGE("---"); + + PortableServer::POAManager_var nil_mgr + = PortableServer::POAManager::_nil(); + factory_poa = _root_poa->create_POA("factory_poa", + nil_mgr, + policyList); + //with nil_mgr instead of pman, + //a new POA manager is created with the new POA + MESSAGE("---"); + + // destroy policy objects + implicitActivation->destroy(); + threadPolicy->destroy(); + MESSAGE("---"); + + // obtain the factory poa manager + PortableServer::POAManager_var pmanfac = factory_poa->the_POAManager(); + pmanfac->activate(); + MESSAGE("pmanfac->activate()"); + } + + MESSAGE("---"); + char *containerName = ""; + if (argc >1) + { + containerName = argv[1]; + } + + Engines_Container_i * myContainer + = new Engines_Container_i(_orb, factory_poa, containerName , argc , argv ); + } + catch(CORBA::SystemException&) + { + INFOS("Caught CORBA::SystemException."); + } + catch(PortableServer::POA::WrongPolicy&) + { + INFOS("Caught CORBA::WrongPolicyException."); + } + catch(PortableServer::POA::ServantAlreadyActive&) + { + INFOS("Caught CORBA::ServantAlreadyActiveException"); + } + catch(CORBA::Exception&) + { + INFOS("Caught CORBA::Exception."); + } + catch(...) + { + INFOS("Caught unknown exception."); + } +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +void Session_ServerThread::ActivateSession(int argc, + char ** argv) +{ + try + { + INFOS("Session thread started"); + SALOME_Session_i * mySALOME_Session + = new SALOME_Session_i(argc, argv, _orb, _root_poa, _GUIMutex) ; + PortableServer::ObjectId_var mySALOME_Sessionid + = _root_poa->activate_object(mySALOME_Session); + INFOS("poa->activate_object(mySALOME_Session)"); + + CORBA::Object_var obj = mySALOME_Session->_this(); + CORBA::String_var sior(_orb->object_to_string(obj)); + + mySALOME_Session->NSregister(); + } + catch (CORBA::SystemException&) + { + INFOS("Caught CORBA::SystemException."); + } + catch (CORBA::Exception&) + { + INFOS("Caught CORBA::Exception."); + } + catch (...) + { + INFOS("Caught unknown exception."); + } +} diff --git a/src/Session/Session_ServerThread.hxx b/src/Session/Session_ServerThread.hxx new file mode 100644 index 000000000..3c12b138e --- /dev/null +++ b/src/Session/Session_ServerThread.hxx @@ -0,0 +1,80 @@ +// SALOME Session : implementation of Session_ServerThread.hxx +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : Session_ServerThread.hxx +// Author : Paul RASCLE, EDF +// Module : SALOME +// $Header$ + +#ifndef _SESSION_SERVERTHREAD_HXX_ +#define _SESSION_SERVERTHREAD_HXX_ + +#include +#include + +#include "SALOME_NamingService.hxx" +#include + +using namespace std; + +void WaitForServerReadiness(string serverName); + + +class Session_ServerThread +{ +public: + static const int NB_SRV_TYP; + static const char* _serverTypes[]; + + Session_ServerThread(); + Session_ServerThread(int argc, + char ** argv, + CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa, + QMutex *GUIMutex); + virtual ~Session_ServerThread(); + void Init(); +protected: + void ActivateModuleCatalog(int argc, + char ** argv); + void ActivateSALOMEDS(int argc, + char ** argv); + void ActivateRegistry(int argc, + char ** argv); + void ActivateContainer(int argc, + char ** argv); + void ActivateSession(int argc, + char ** argv); + +private: + int _argc; + char ** _argv; + int _servType; + CORBA::ORB_var _orb; + PortableServer::POA_var _root_poa; + QMutex* _GUIMutex; + SALOME_NamingService *_NS; +}; + +#endif + diff --git a/src/Utils/Utils_ORB_INIT.cxx b/src/Utils/Utils_ORB_INIT.cxx index bd8e5965f..5ac639246 100644 --- a/src/Utils/Utils_ORB_INIT.cxx +++ b/src/Utils/Utils_ORB_INIT.cxx @@ -26,9 +26,9 @@ // Module : SALOME // $Header$ -using namespace std; # include "Utils_ORB_INIT.hxx" # include "utilities.h" +using namespace std; ORB_INIT::ORB_INIT( void ): _orb( CORBA::ORB::_nil() ) { @@ -54,12 +54,15 @@ CORBA::ORB_var &ORB_INIT::operator() ( int argc , char **argv ) throw( CommExcep { try { - // const char* options[][2] = { { "giopMaxMsgSize", "104857600" }, { 0, 0 } }; - // _orb = CORBA::ORB_init( argc , argv , "omniORB4", options) ; +#if OMNIORB_VERSION >= 4 + const char* options[][2] = { { "giopMaxMsgSize", "104857600" }, { 0, 0 } }; + _orb = CORBA::ORB_init( argc , argv , "omniORB4", options) ; +#else _orb = CORBA::ORB_init( argc , argv ) ; //set GIOP message size equal to 50Mb for transferring brep shapes as //sequence of bytes using C++ streams omniORB::MaxMessageSize(100*1024*1024); +#endif } catch( const CORBA::Exception &ex ) { diff --git a/src/Utils/utilities.h b/src/Utils/utilities.h index 91a5be11c..1cf18d27a 100644 --- a/src/Utils/utilities.h +++ b/src/Utils/utilities.h @@ -33,12 +33,13 @@ #include #include +#include #include "SALOME_Log.hxx" /* --- INFOS is always defined (without _DEBUG_): to be used for warnings, with release version --- */ -#define INFOS(msg) {SLog.putMessage(SLog<<__FILE__<<" ["<<__LINE__<<"] : "<putMessage(*SLog<<__FILE__<<" ["<<__LINE__<<"] : "<putMessage(*SLog<<"---PYSCRIPT--- "<putMessage(\ + *SLog<<__FILE__<<" ["<< __LINE__<<"] : "\ << "COMPILED with " << COMPILER \ << ", " << __DATE__ \ - << " at " << __TIME__ <