From c16262bb3b2026dd7481591fff40a9cb1aba97dd Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Wed, 13 Jan 2021 15:28:14 +0100 Subject: [PATCH] Agressive Session management to skip NS fetch. To improve --- src/SALOMEDS/SALOMEDS_Study_i.cxx | 63 ++++++++++++++++++++++++------- src/SALOMEDS/SALOMEDS_Study_i.hxx | 10 +++-- 2 files changed, 55 insertions(+), 18 deletions(-) diff --git a/src/SALOMEDS/SALOMEDS_Study_i.cxx b/src/SALOMEDS/SALOMEDS_Study_i.cxx index 3fb2626d2..25ed605f0 100644 --- a/src/SALOMEDS/SALOMEDS_Study_i.cxx +++ b/src/SALOMEDS/SALOMEDS_Study_i.cxx @@ -76,7 +76,7 @@ SALOMEDS::Study_ptr KERNEL::getStudyServantSA() if(CORBA::is_nil(aStudy)) { CORBA::ORB_ptr orb = KERNEL::getORB(); - SALOMEDS_Study_i *servant = new SALOMEDS_Study_i(orb); + SALOMEDS_Study_i *servant = new SALOMEDS_Study_i(orb,SALOME::Session::_nil()); aStudy = servant->_this(); } return SALOMEDS::Study::_duplicate(aStudy); @@ -242,6 +242,21 @@ namespace SALOMEDS }; + //================================================================================ + /*! + * \brief emitMessageOneWay to SALOME::Session + */ + //================================================================================ + + void sendMessageToGUIGivenSession(SALOME::Session_ptr session, const char* msg ) + { + if ( !CORBA::is_nil(session) ) { + SALOMEDS::unlock(); + session->emitMessageOneWay( msg ); + SALOMEDS::lock(); + } + } + //================================================================================ /*! * \brief emitMessageOneWay to SALOME::Session @@ -253,28 +268,36 @@ namespace SALOMEDS SALOME_NamingService *aNamingService = KERNEL::getNamingService(); CORBA::Object_var obj = aNamingService->Resolve("/Kernel/Session"); SALOME::Session_var aSession = SALOME::Session::_narrow(obj); - if ( !CORBA::is_nil(aSession) ) { - SALOMEDS::unlock(); - aSession->emitMessageOneWay( msg ); - SALOMEDS::lock(); - } + sendMessageToGUIGivenSession(aSession,msg); } } // namespace SALOMEDS +SALOMEDS_Study_i::SALOMEDS_Study_i(CORBA::ORB_ptr orb) +{ + _orb = CORBA::ORB::_duplicate(orb); + _impl = new SALOMEDSImpl_Study(); + _factory = new SALOMEDS_DriverFactory_i(_orb); + _closed = true; + SALOME_NamingService *aNamingService = KERNEL::getNamingService(); + CORBA::Object_var obj = aNamingService->Resolve("/Kernel/Session"); + SALOME::Session_var aSession = SALOME::Session::_narrow(obj); + Init(aSession); +} + //============================================================================ /*! Function : SALOMEDS_Study_i * Purpose : SALOMEDS_Study_i constructor */ //============================================================================ -SALOMEDS_Study_i::SALOMEDS_Study_i(CORBA::ORB_ptr orb) +SALOMEDS_Study_i::SALOMEDS_Study_i(CORBA::ORB_ptr orb, SALOME::Session_ptr session) { _orb = CORBA::ORB::_duplicate(orb); _impl = new SALOMEDSImpl_Study(); _factory = new SALOMEDS_DriverFactory_i(_orb); _closed = true; - Init(); + Init(session); } //============================================================================ @@ -289,12 +312,20 @@ SALOMEDS_Study_i::~SALOMEDS_Study_i() delete _impl; } +void SALOMEDS_Study_i::Init() +{ + SALOME_NamingService *aNamingService = KERNEL::getNamingService(); + CORBA::Object_var obj = aNamingService->Resolve("/Kernel/Session"); + SALOME::Session_var aSession = SALOME::Session::_narrow(obj); + Init(aSession); +} + //============================================================================ /*! Function : Init * Purpose : Initialize study components */ //============================================================================ -void SALOMEDS_Study_i::Init() +void SALOMEDS_Study_i::Init(SALOME::Session_ptr session) { if (!_closed) //throw SALOMEDS::Study::StudyInvalidReference(); @@ -314,10 +345,10 @@ void SALOMEDS_Study_i::Init() _impl->setGenObjRegister( _genObjRegister ); // Notify GUI that study was created - SALOMEDS::sendMessageToGUI( "studyCreated" ); + SALOMEDS::sendMessageToGUIGivenSession( session, "studyCreated" ); // update desktop title with new study name - NameChanged(); + NameChanged(session); } //============================================================================ @@ -993,7 +1024,10 @@ void SALOMEDS_Study_i::URL(const wchar_t* wurl) _impl->URL(Kernel_Utils::encode_s(wurl)); // update desktop title with new study name - NameChanged(); + SALOME_NamingService *aNamingService = KERNEL::getNamingService(); + CORBA::Object_var obj = aNamingService->Resolve("/Kernel/Session"); + SALOME::Session_var aSession = SALOME::Session::_narrow(obj); + NameChanged(aSession); } void SALOMEDS_Study_i::UpdateIORLabelMap(const char* anIOR, const char* anEntry) @@ -1697,7 +1731,8 @@ CORBA::LongLong SALOMEDS_Study_i::GetLocalImpl(const char* theHostname, CORBA::L return reinterpret_cast(_impl); } -void SALOMEDS_Study_i::NameChanged() +void SALOMEDS_Study_i::NameChanged(SALOME::Session_ptr session) { - SALOMEDS::sendMessageToGUI( "studyNameChanged" ); + + SALOMEDS::sendMessageToGUIGivenSession(session,"studyNameChanged" ); } diff --git a/src/SALOMEDS/SALOMEDS_Study_i.hxx b/src/SALOMEDS/SALOMEDS_Study_i.hxx index 856abdf45..36d0ef962 100644 --- a/src/SALOMEDS/SALOMEDS_Study_i.hxx +++ b/src/SALOMEDS/SALOMEDS_Study_i.hxx @@ -33,7 +33,7 @@ #include #include CORBA_SERVER_HEADER(SALOME_GenericObj) #include CORBA_SERVER_HEADER(SALOMEDS) - +#include CORBA_CLIENT_HEADER(SALOME_Session) #include //SALOMEDS headers @@ -55,7 +55,7 @@ class Standard_EXPORT SALOMEDS_Study_i: public POA_SALOMEDS::Study { private: - void NameChanged(); + void NameChanged(SALOME::Session_ptr session); CORBA::ORB_var _orb; SALOMEDSImpl_Study* _impl; SALOMEDS_StudyBuilder_i* _builder; @@ -65,9 +65,10 @@ private: bool _closed; public: - //! standard constructor SALOMEDS_Study_i(CORBA::ORB_ptr); + //! standard constructor + SALOMEDS_Study_i(CORBA::ORB_ptr, SALOME::Session_ptr session); //! standard destructor @@ -75,7 +76,8 @@ public: virtual PortableServer::POA_ptr _default_POA(); - virtual void Init(); + virtual void Init() override; + virtual void Init(SALOME::Session_ptr session); virtual void Clear(); //! method to open a Study -- 2.39.2