]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
OK for session_i
authorAnthony GEAY <anthony.geay@edf.fr>
Fri, 19 Feb 2021 16:10:38 +0000 (17:10 +0100)
committerAnthony GEAY <anthony.geay@edf.fr>
Fri, 19 Feb 2021 16:10:38 +0000 (17:10 +0100)
src/Session/Session_NS_wrapper.cxx
src/Session/Session_NS_wrapper.hxx
src/Session/Session_ServerThread.cxx
src/Session/Session_Session_i.cxx
src/Session/Session_Session_i.hxx

index 77ffcace5b2199eefc9b966625d6b4de815b186f..e55f9c24ce4a59ead94a6268952eb1ada993f840 100644 (file)
 
 #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);
+}
index e5a023c64177d972582166a0df95189546c1fabd..69636394d493fb94d84c810f9d605a6197a909e7 100644 (file)
@@ -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;
 };
index aee8219daf3dff55246a539cde20e911b0cde35e..667a35f4e2ead50316365eff612cf9eba1a97aa2 100644 (file)
@@ -348,31 +348,7 @@ Session_SessionThread<MY_NS>::~Session_SessionThread()
 template<class MY_NS>
 void Session_SessionThread<MY_NS>::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<OldStyleNS>;
index 025ec9e8a51813be3952864a84ec95956785f6e3..60ddf437e9f7e14c5007200487a8f6c28fab233e 100644 (file)
 #include <unistd.h>
 #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<char*>(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<SALOME_NamingService*>(_NS.get()),_GUIMutex);
+      return ret;
+    }
   }
   CORBA::Object_var obj = SalomeApp_Engine_i::EngineForComponent(theLibraryName, true);
   if (!CORBA::is_nil(obj)){
index aa50f983eb4b716153c54b937f3f7dfed78beb08..1d9d5e850dcba56a9834dba4f1b10a0f0b245dc0 100644 (file)
 
 #include <memory>
 
-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<SALOME_NamingService> _NS;
+  std::unique_ptr<SALOME_NamingService_Abstract> _NS;
 
   int _argc ;
   char **_argv;