From: Anthony Geay Date: Thu, 18 Feb 2021 13:26:31 +0000 (+0100) Subject: WIP X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=55609d9523ad3189d59e08a9770e3e8687dcc1ad;p=modules%2Fgui.git WIP --- diff --git a/src/Session/SALOME_Session_Server.cxx b/src/Session/SALOME_Session_Server.cxx index 67fa2103b..b73e8f180 100644 --- a/src/Session/SALOME_Session_Server.cxx +++ b/src/Session/SALOME_Session_Server.cxx @@ -549,7 +549,7 @@ int AbstractGUIApp::main(int argc, char **argv) SUIT_Session *aGUISession = 0; GetInterfaceThread *guiThread = 0; - Session_ServerLauncher *myServerLauncher = 0; + Session_ServerLauncher *myServerLauncher = nullptr; #if defined(WIN32) && defined(UNICODE) char **new_argv = NULL; @@ -627,9 +627,9 @@ int AbstractGUIApp::main(int argc, char **argv) } // Free memory allocated for CommandLineToArgvW arguments. LocalFree(szArglist); - myServerLauncher = new Session_ServerLauncher(nArgs, new_argv, orb, poa, &_GUIMutex, &_ServerLaunch, &_SessionMutex, &_SessionStarted); + myServerLauncher = new Session_ServerLauncher(nArgs, new_argv, orb, poa, &_GUIMutex, &_ServerLaunch, &_SessionMutex, &_SessionStarted); #else - myServerLauncher = new Session_ServerLauncher(argc, argv, orb, poa, &_GUIMutex, &_ServerLaunch, &_SessionMutex, &_SessionStarted); + myServerLauncher = new Session_ServerLauncher(argc, argv, orb, poa, &_GUIMutex, &_ServerLaunch, &_SessionMutex, &_SessionStarted); #endif // ...block this thread until launcher is ready _ServerLaunch.wait(&_GUIMutex); diff --git a/src/Session/Session_ServerLauncher.cxx b/src/Session/Session_ServerLauncher.cxx index 6471c26bc..f85a1b2c0 100644 --- a/src/Session/Session_ServerLauncher.cxx +++ b/src/Session/Session_ServerLauncher.cxx @@ -36,7 +36,8 @@ /*! default constructor not for use */ -Session_ServerLauncher::Session_ServerLauncher() +template +Session_ServerLauncher::Session_ServerLauncher() { ASSERT(0); // must not be called } @@ -44,14 +45,15 @@ Session_ServerLauncher::Session_ServerLauncher() /*! constructor */ -Session_ServerLauncher::Session_ServerLauncher(int argc, - char ** argv, - CORBA::ORB_ptr orb, - PortableServer::POA_ptr poa, - QMutex *GUIMutex, - QWaitCondition *ServerLaunch, - QMutex *SessionMutex, - QWaitCondition *SessionStarted) +template +Session_ServerLauncher::Session_ServerLauncher(int argc, + char ** argv, + CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa, + QMutex *GUIMutex, + QWaitCondition *ServerLaunch, + QMutex *SessionMutex, + QWaitCondition *SessionStarted) { _argc = argc; _argv = argv; @@ -69,14 +71,16 @@ Session_ServerLauncher::Session_ServerLauncher(int argc, /*! destructor */ -Session_ServerLauncher::~Session_ServerLauncher() +template +Session_ServerLauncher::~Session_ServerLauncher() { } /*! Check args and activate servers */ -void Session_ServerLauncher::run() +template +void Session_ServerLauncher::run() { // wait until main thread is ready _GUIMutex->lock(); // ... lock mutex (it is unlocked my calling thread @@ -104,7 +108,8 @@ void Session_ServerLauncher::run() /*! controls and dispatchs arguments given with command */ -void Session_ServerLauncher::CheckArgs() +template +void Session_ServerLauncher::CheckArgs() { int argState = 0; ServArg aServArg(0,0,0); @@ -135,8 +140,8 @@ void Session_ServerLauncher::CheckArgs() } // Temporary solution - for (int i=0; i::NB_SRV_TYP; i++) + if (strcmp(_argv[iarg],Session_ServerThread::_serverTypes[i])==0) { aServArg._servType = i; argState = 2; @@ -166,7 +171,7 @@ void Session_ServerLauncher::CheckArgs() if (strcmp(_argv[iarg],")")==0) // end of arguments = ')' { aServArg._lastArg=iarg-1; // arg before ')' - MESSAGE("server : "<< Session_ServerThread::_serverTypes[aServArg._servType]); + MESSAGE("server : "<< Session_ServerThread::_serverTypes[aServArg._servType]); for (int i=aServArg._firstArg; i<=aServArg._lastArg; i++) MESSAGE(" arg : " << _argCopy[i]); _argServToLaunch.push_back(aServArg); @@ -189,7 +194,8 @@ void Session_ServerLauncher::CheckArgs() throw SALOME_Exception(LOCALIZED("Error in command arguments, missing parenthesis ')'")); } -void Session_ServerLauncher::ActivateAll() +template +void Session_ServerLauncher::ActivateAll() { std::list::iterator itServ; for (itServ = _argServToLaunch.begin(); itServ !=_argServToLaunch.end(); itServ++) @@ -198,7 +204,7 @@ void Session_ServerLauncher::ActivateAll() 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]); + argv[0]=strdup(Session_ServerThread::_serverTypes[servType]); if (argc>1) { for (int i=0; i* aServerThread = new Session_ServerThread(argc, argv, _orb,_root_poa); _serverThreads.push_front(aServerThread); aServerThread->Init(); @@ -223,17 +228,19 @@ void Session_ServerLauncher::ActivateAll() int argc=1; char** argv = new char*[argc]; argv[0] = (char*)"Session"; - Session_SessionThread* aServerThread - = new Session_SessionThread(argc, argv, _orb,_root_poa,_SessionMutex,_SessionStarted); + Session_SessionThread* aServerThread + = new Session_SessionThread(argc, argv, _orb,_root_poa,_SessionMutex,_SessionStarted); _serverThreads.push_front(aServerThread); aServerThread->Init(); delete[] argv; } -void Session_ServerLauncher::ShutdownAll() +template +void Session_ServerLauncher::ShutdownAll() { MESSAGE("Session_ServerLauncher::ShutdownAll()"); - std::list::reverse_iterator itServ; + using Session_ServerThreadT = Session_ServerThread; + typename std::list::reverse_iterator itServ; for (itServ = _serverThreads.rbegin(); itServ !=_serverThreads.rend(); itServ++) { (*itServ)->Shutdown(); @@ -243,10 +250,12 @@ void Session_ServerLauncher::ShutdownAll() /*! Destruction des classes serveur dans l'ordre inverse de creation */ -void Session_ServerLauncher::KillAll() +template +void Session_ServerLauncher::KillAll() { MESSAGE("Session_ServerLauncher::KillAll()"); - std::list::reverse_iterator itServ; + using Session_ServerThreadT = Session_ServerThread; + typename std::list::reverse_iterator itServ; for (itServ = _serverThreads.rbegin(); itServ !=_serverThreads.rend(); itServ++) { delete (*itServ); diff --git a/src/Session/Session_ServerLauncher.hxx b/src/Session/Session_ServerLauncher.hxx index 33e8187a6..719157e40 100644 --- a/src/Session/Session_ServerLauncher.hxx +++ b/src/Session/Session_ServerLauncher.hxx @@ -48,12 +48,14 @@ inline ServArg::ServArg(int servType, int firstArg, int lastArg): _servType(servType),_firstArg(firstArg),_lastArg(lastArg) {} +template class Session_ServerThread; class QMutex; class QWaitCondition; -class SESSION_EXPORT Session_ServerLauncher: public QThread +template +class SESSION_EXPORT Session_ServerLauncher : public QThread { public: Session_ServerLauncher(); @@ -85,7 +87,7 @@ private: QWaitCondition* _SessionStarted; std::list _argServToLaunch; std::vector _argCopy; - std::list _serverThreads; + std::list< Session_ServerThread* > _serverThreads; }; #endif diff --git a/src/Session/Session_ServerThread.cxx b/src/Session/Session_ServerThread.cxx index d9f28bd01..8cc0a339f 100644 --- a/src/Session/Session_ServerThread.cxx +++ b/src/Session/Session_ServerThread.cxx @@ -49,18 +49,22 @@ #include #include -const int Session_ServerThread::NB_SRV_TYP = 6; -const char* Session_ServerThread::_serverTypes[NB_SRV_TYP] = {"Container", - "ModuleCatalog", - "Registry", - "SALOMEDS", - "Session", - "ContainerManager"}; +template +const int Session_ServerThread::NB_SRV_TYP = 6; + +template +const char* Session_ServerThread::_serverTypes[NB_SRV_TYP] = {"Container", + "ModuleCatalog", + "Registry", + "SALOMEDS", + "Session", + "ContainerManager"}; /*! default constructor not for use */ -Session_ServerThread::Session_ServerThread() +template +Session_ServerThread::Session_ServerThread() { ASSERT(0); // must not be called } @@ -68,7 +72,8 @@ Session_ServerThread::Session_ServerThread() /*! constructor */ -Session_ServerThread::Session_ServerThread(int argc, +template +Session_ServerThread::Session_ServerThread(int argc, char ** argv, CORBA::ORB_ptr orb, PortableServer::POA_ptr poa) @@ -91,7 +96,8 @@ Session_ServerThread::Session_ServerThread(int argc, /*! destructor */ -Session_ServerThread::~Session_ServerThread() +template +Session_ServerThread::~Session_ServerThread() { for (int i = 0; i <_argc ; i++ ) free( _argv[i] ); @@ -102,7 +108,8 @@ Session_ServerThread::~Session_ServerThread() run the thread : activate one servant, the servant type is given by argument _argv[0] */ -void Session_ServerThread::Init() +template +void Session_ServerThread::Init() { MESSAGE("Session_ServerThread::Init "<< _argv[0]); @@ -165,12 +172,14 @@ void Session_ServerThread::Init() } } -void Session_ServerThread::Shutdown() +template +void Session_ServerThread::Shutdown() { if ( _container ) _container->Shutdown(); } -void Session_ServerThread::ActivateModuleCatalog(int argc, +template +void Session_ServerThread::ActivateModuleCatalog(int argc, char ** argv) { try { @@ -205,7 +214,8 @@ void Session_ServerThread::ActivateModuleCatalog(int argc, } } -void Session_ServerThread::ActivateSALOMEDS(int /*argc*/, char** /*argv*/) +template +void Session_ServerThread::ActivateSALOMEDS(int /*argc*/, char** /*argv*/) { try { MESSAGE("SALOMEDS thread started"); @@ -232,7 +242,8 @@ void Session_ServerThread::ActivateSALOMEDS(int /*argc*/, char** /*argv*/) } } -void Session_ServerThread::ActivateRegistry(int argc, char ** argv) +template +void Session_ServerThread::ActivateRegistry(int argc, char ** argv) { MESSAGE("Registry thread started"); SCRUTE(argc); @@ -290,7 +301,8 @@ void Session_ServerThread::ActivateRegistry(int argc, char ** argv) } } -void Session_ServerThread::ActivateContainerManager(int /*argc*/, char** /*argv*/) +template +void Session_ServerThread::ActivateContainerManager(int /*argc*/, char** /*argv*/) { try { PortableServer::POA_var root_poa=PortableServer::POA::_the_root_poa(); @@ -314,7 +326,8 @@ void Session_ServerThread::ActivateContainerManager(int /*argc*/, char** /*argv* } } -void Session_ServerThread::ActivateContainer(int argc, char** argv) +template +void Session_ServerThread::ActivateContainer(int argc, char** argv) { try { MESSAGE("Container thread started"); @@ -386,47 +399,45 @@ void Session_ServerThread::ActivateContainer(int argc, char** argv) } } -void Session_ServerThread::ActivateSession(int /*argc*/, char** /*argv*/) +template +void Session_ServerThread::ActivateSession(int /*argc*/, char** /*argv*/) { MESSAGE("Session_ServerThread::ActivateSession() not implemented!"); } -/*! - constructor -*/ -Session_SessionThread::Session_SessionThread(int argc, +template +Session_SessionThread::Session_SessionThread(int argc, char** argv, CORBA::ORB_ptr orb, PortableServer::POA_ptr poa, QMutex* GUIMutex, QWaitCondition* GUILauncher) -: Session_ServerThread(argc, argv, orb, poa), +: Session_ServerThread(argc, argv, orb, poa), _GUIMutex( GUIMutex ), _GUILauncher( GUILauncher ) { } -/*! - destructor -*/ -Session_SessionThread::~Session_SessionThread() +template +Session_SessionThread::~Session_SessionThread() { } -void Session_SessionThread::ActivateSession(int argc, char ** argv) +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, _orb, _root_poa, _GUIMutex, _GUILauncher) ; + = new SALOME_Session_i(argc, argv, this->_orb, this->_root_poa, _GUIMutex, _GUILauncher) ; PortableServer::ObjectId_var mySALOME_Sessionid - = _root_poa->activate_object(mySALOME_Session); + = 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(_orb->object_to_string(obj)); + CORBA::String_var sior(this->_orb->object_to_string(obj)); mySALOME_Session->_remove_ref(); mySALOME_Session->NSregister(); diff --git a/src/Session/Session_ServerThread.hxx b/src/Session/Session_ServerThread.hxx index 03296bf82..1df729038 100644 --- a/src/Session/Session_ServerThread.hxx +++ b/src/Session/Session_ServerThread.hxx @@ -38,6 +38,7 @@ void WaitForServerReadiness(std::string serverName); class SALOME_NamingService; class Engines_Container_i; +template class SESSION_EXPORT Session_ServerThread { public: @@ -66,14 +67,15 @@ protected: int _servType; CORBA::ORB_var _orb; PortableServer::POA_var _root_poa; - std::unique_ptr _NS; + std::unique_ptr _NS; Engines_Container_i* _container; }; class QMutex; class QWaitCondition; -class SESSION_EXPORT Session_SessionThread : public Session_ServerThread +template +class SESSION_EXPORT Session_SessionThread : public Session_ServerThread { public: Session_SessionThread() {} @@ -93,4 +95,3 @@ private: }; #endif -