From: Anthony GEAY Date: Fri, 19 Feb 2021 16:10:38 +0000 (+0100) Subject: OK for session_i X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=bd11bdfff33fe118d9599d39eff02c8870902e91;p=modules%2Fgui.git OK for session_i --- diff --git a/src/Session/Session_NS_wrapper.cxx b/src/Session/Session_NS_wrapper.cxx index 77ffcace5..e55f9c24c 100644 --- a/src/Session/Session_NS_wrapper.cxx +++ b/src/Session/Session_NS_wrapper.cxx @@ -19,10 +19,44 @@ #include "Session_NS_wrapper.hxx" +#include "SALOME_Fake_NamingService.hxx" #include "SALOME_Container_i.hxx" #include "SALOME_Launcher.hxx" +#include "Session_Session_i.hxx" +#include "Session_Promises.hxx" #include "utilities.h" +void CommonActivateSession(CORBA::ORB_var orb, PortableServer::POA_var poa, QMutex *GUIMutex, QWaitCondition *GUILauncher, SALOME_NamingService_Abstract *ns, int argc, char ** argv) +{ + try { + MESSAGE("Session thread started"); + SALOME_Session_i * mySALOME_Session = nullptr; + if(!ns) + mySALOME_Session = new SALOME_Session_i(argc, argv, orb, poa, GUIMutex, GUILauncher); + else + mySALOME_Session = new SALOME_Session_i(argc, argv, orb, poa, GUIMutex, GUILauncher,ns); + PortableServer::ObjectId_var mySALOME_Sessionid = poa->activate_object(mySALOME_Session); + MESSAGE("poa->activate_object(mySALOME_Session)"); + + CORBA::Object_var obj = mySALOME_Session->_this(); + SALOME::Session_var objC = SALOME::Session::_narrow(obj); + GetSessionRefSingleton()->set_value(objC); + CORBA::String_var sior(orb->object_to_string(obj)); + mySALOME_Session->_remove_ref(); + + mySALOME_Session->NSregister(); + } + catch (CORBA::SystemException&) { + INFOS("Caught CORBA::SystemException."); + } + catch (CORBA::Exception&) { + INFOS("Caught CORBA::Exception."); + } + catch (...) { + INFOS("Caught unknown exception."); + } +} + Engines_Container_i *OldStyleNS::activateContainer(CORBA::ORB_var orb, PortableServer::POA_var poa, int argc, char **argv) { Engines_Container_i *_container = nullptr; @@ -128,6 +162,11 @@ void OldStyleNS::activateContainerManager(CORBA::ORB_var orb) } } +void OldStyleNS::activateSession(CORBA::ORB_var orb, PortableServer::POA_var poa, QMutex *GUIMutex, QWaitCondition *GUILauncher, int argc, char ** argv) +{ + CommonActivateSession(orb,poa,GUIMutex,GUILauncher,nullptr,argc,argv); +} + Engines_Container_i *NewStyleNS::activateContainer(CORBA::ORB_var orb, PortableServer::POA_var poa, int argc, char **argv) { return KERNEL::getContainerSA(); @@ -137,3 +176,9 @@ void NewStyleNS::activateContainerManager(CORBA::ORB_var orb) { KERNEL::getLauncherSA(); } + +void NewStyleNS::activateSession(CORBA::ORB_var orb, PortableServer::POA_var poa, QMutex *GUIMutex, QWaitCondition *GUILauncher, int argc, char ** argv) +{ + SALOME_Fake_NamingService *ns=new SALOME_Fake_NamingService; + CommonActivateSession(orb,poa,GUIMutex,GUILauncher,ns,argc,argv); +} diff --git a/src/Session/Session_NS_wrapper.hxx b/src/Session/Session_NS_wrapper.hxx index e5a023c64..69636394d 100644 --- a/src/Session/Session_NS_wrapper.hxx +++ b/src/Session/Session_NS_wrapper.hxx @@ -23,6 +23,9 @@ #include "omniORB4/CORBA.h" +class QMutex; +class QWaitCondition; + class Engines_Container_i; class OldStyleNS @@ -36,6 +39,7 @@ public: RealNS *getNS() { return &_NS; } Engines_Container_i *activateContainer(CORBA::ORB_var orb, PortableServer::POA_var poa, int argc, char** argv); void activateContainerManager(CORBA::ORB_var orb); + void activateSession(CORBA::ORB_var orb, PortableServer::POA_var poa, QMutex *GUIMutex, QWaitCondition *GUILauncher, int argc, char ** argv); private: RealNS _NS; }; @@ -53,6 +57,7 @@ public: RealNS *getNS() { return &_NS; } Engines_Container_i *activateContainer(CORBA::ORB_var orb, PortableServer::POA_var poa, int argc, char** argv); void activateContainerManager(CORBA::ORB_var orb); + void activateSession(CORBA::ORB_var orb, PortableServer::POA_var poa, QMutex *GUIMutex, QWaitCondition *GUILauncher, int argc, char ** argv); private: RealNS _NS; }; diff --git a/src/Session/Session_ServerThread.cxx b/src/Session/Session_ServerThread.cxx index aee8219da..667a35f4e 100644 --- a/src/Session/Session_ServerThread.cxx +++ b/src/Session/Session_ServerThread.cxx @@ -348,31 +348,7 @@ Session_SessionThread::~Session_SessionThread() template void Session_SessionThread::ActivateSession(int argc, char ** argv) { - try { - MESSAGE("Session thread started"); - SALOME_Session_i * mySALOME_Session - = new SALOME_Session_i(argc, argv, this->_orb, this->_root_poa, _GUIMutex, _GUILauncher) ; - PortableServer::ObjectId_var mySALOME_Sessionid - = this->_root_poa->activate_object(mySALOME_Session); - MESSAGE("poa->activate_object(mySALOME_Session)"); - - CORBA::Object_var obj = mySALOME_Session->_this(); - SALOME::Session_var objC = SALOME::Session::_narrow(obj); - GetSessionRefSingleton()->set_value(objC); - CORBA::String_var sior(this->_orb->object_to_string(obj)); - mySALOME_Session->_remove_ref(); - - mySALOME_Session->NSregister(); - } - catch (CORBA::SystemException&) { - INFOS("Caught CORBA::SystemException."); - } - catch (CORBA::Exception&) { - INFOS("Caught CORBA::Exception."); - } - catch (...) { - INFOS("Caught unknown exception."); - } + this->_NS->activateSession(this->_orb,this->_root_poa,_GUIMutex,_GUILauncher,argc,argv); } template class Session_ServerThread; diff --git a/src/Session/Session_Session_i.cxx b/src/Session/Session_Session_i.cxx index 025ec9e8a..60ddf437e 100644 --- a/src/Session/Session_Session_i.cxx +++ b/src/Session/Session_Session_i.cxx @@ -52,26 +52,18 @@ #include #endif -/*! - constructor -*/ -SALOME_Session_i::SALOME_Session_i(int argc, - char ** argv, - CORBA::ORB_ptr orb, - PortableServer::POA_ptr poa, - QMutex* GUIMutex, - QWaitCondition* GUILauncher) +SALOME_Session_i::SALOME_Session_i(int argc, char ** argv, CORBA::ORB_ptr orb, PortableServer::POA_ptr poa, QMutex* GUIMutex, QWaitCondition* GUILauncher): +_argc(argc),_argv(argv),_isGUI(false),_GUIMutex(GUIMutex),_GUILauncher(GUILauncher), +_orb(CORBA::ORB::_duplicate(orb)),_poa(PortableServer::POA::_duplicate(poa)),_isShuttingDown(false) { - _argc = argc ; - _argv = argv ; - _isGUI = false ; - _orb = CORBA::ORB::_duplicate(orb) ; - _poa = PortableServer::POA::_duplicate(poa) ; - _GUIMutex = GUIMutex; - _GUILauncher = GUILauncher; _NS.reset(new SALOME_NamingService(_orb)); - _isShuttingDown = false; - //MESSAGE("constructor end"); +} + +SALOME_Session_i::SALOME_Session_i(int argc, char ** argv, CORBA::ORB_ptr orb, PortableServer::POA_ptr poa, QMutex* GUIMutex, QWaitCondition* GUILauncher, SALOME_NamingService_Abstract *NS): +_argc(argc),_argv(argv),_isGUI(false),_GUIMutex(GUIMutex),_GUILauncher(GUILauncher), +_orb(CORBA::ORB::_duplicate(orb)),_poa(PortableServer::POA::_duplicate(poa)),_isShuttingDown(false) +{ + _NS.reset(NS); } /*! @@ -79,13 +71,14 @@ SALOME_Session_i::SALOME_Session_i(int argc, */ Engines::EngineComponent_ptr SALOME_Session_i::GetComponent(const char* theLibraryName) { - typedef Engines::EngineComponent_ptr TGetImpl(CORBA::ORB_ptr, - PortableServer::POA_ptr, - SALOME_NamingService*,QMutex*); + using TGetImpl = Engines::EngineComponent_ptr (*)(CORBA::ORB_ptr, PortableServer::POA_ptr, SALOME_NamingService*,QMutex*); OSD_SharedLibrary aSharedLibrary(const_cast(theLibraryName)); if (aSharedLibrary.DlOpen(OSD_RTLD_LAZY)) { if (OSD_Function anOSDFun = aSharedLibrary.DlSymb("GetImpl")) - return ((TGetImpl (*)) anOSDFun)(_orb,_poa,_NS.get(),_GUIMutex); + { + Engines::EngineComponent_ptr ret = ((TGetImpl) anOSDFun)(_orb,_poa,dynamic_cast(_NS.get()),_GUIMutex); + return ret; + } } CORBA::Object_var obj = SalomeApp_Engine_i::EngineForComponent(theLibraryName, true); if (!CORBA::is_nil(obj)){ diff --git a/src/Session/Session_Session_i.hxx b/src/Session/Session_Session_i.hxx index aa50f983e..1d9d5e850 100644 --- a/src/Session/Session_Session_i.hxx +++ b/src/Session/Session_Session_i.hxx @@ -34,21 +34,15 @@ #include -class SALOME_NamingService; - class QMutex; class QWaitCondition; +class SALOME_NamingService_Abstract; -class SESSION_EXPORT SALOME_Session_i: public virtual POA_SALOME::Session, - public virtual PortableServer::ServantBase +class SESSION_EXPORT SALOME_Session_i : public virtual POA_SALOME::Session, public virtual PortableServer::ServantBase { public: - SALOME_Session_i(int argc, - char ** argv, - CORBA::ORB_ptr orb, - PortableServer::POA_ptr poa, - QMutex* GUIMutex, - QWaitCondition* GUILauncher); + SALOME_Session_i(int argc, char ** argv, CORBA::ORB_ptr orb, PortableServer::POA_ptr poa, QMutex* GUIMutex, QWaitCondition* GUILauncher); + SALOME_Session_i(int argc, char ** argv, CORBA::ORB_ptr orb, PortableServer::POA_ptr poa, QMutex* GUIMutex, QWaitCondition* GUILauncher, SALOME_NamingService_Abstract *NS); ~SALOME_Session_i(); //! Launch Graphical User Interface @@ -88,7 +82,7 @@ public: protected: //! Naming service interface - std::unique_ptr _NS; + std::unique_ptr _NS; int _argc ; char **_argv;