#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;
}
}
+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();
{
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);
+}
#include "omniORB4/CORBA.h"
+class QMutex;
+class QWaitCondition;
+
class Engines_Container_i;
class OldStyleNS
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;
};
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;
};
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>;
#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);
}
/*!
*/
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)){
#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
protected:
//! Naming service interface
- std::unique_ptr<SALOME_NamingService> _NS;
+ std::unique_ptr<SALOME_NamingService_Abstract> _NS;
int _argc ;
char **_argv;