SUIT_Session *aGUISession = 0;
GetInterfaceThread *guiThread = 0;
- Session_ServerLauncher *myServerLauncher = 0;
+ Session_ServerLauncher<SALOME_NamingService> *myServerLauncher = nullptr;
#if defined(WIN32) && defined(UNICODE)
char **new_argv = NULL;
}
// 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<SALOME_NamingService>(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<SALOME_NamingService>(argc, argv, orb, poa, &_GUIMutex, &_ServerLaunch, &_SessionMutex, &_SessionStarted);
#endif
// ...block this thread until launcher is ready
_ServerLaunch.wait(&_GUIMutex);
/*!
default constructor not for use
*/
-Session_ServerLauncher::Session_ServerLauncher()
+template<class MY_NS>
+Session_ServerLauncher<MY_NS>::Session_ServerLauncher()
{
ASSERT(0); // must not be called
}
/*!
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<class MY_NS>
+Session_ServerLauncher<MY_NS>::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;
/*!
destructor
*/
-Session_ServerLauncher::~Session_ServerLauncher()
+template<class MY_NS>
+Session_ServerLauncher<MY_NS>::~Session_ServerLauncher()
{
}
/*!
Check args and activate servers
*/
-void Session_ServerLauncher::run()
+template<class MY_NS>
+void Session_ServerLauncher<MY_NS>::run()
{
// wait until main thread is ready
_GUIMutex->lock(); // ... lock mutex (it is unlocked my calling thread
/*!
controls and dispatchs arguments given with command
*/
-void Session_ServerLauncher::CheckArgs()
+template<class MY_NS>
+void Session_ServerLauncher<MY_NS>::CheckArgs()
{
int argState = 0;
ServArg aServArg(0,0,0);
}
// Temporary solution
- for (int i=0; i<Session_ServerThread::NB_SRV_TYP; i++)
- if (strcmp(_argv[iarg],Session_ServerThread::_serverTypes[i])==0)
+ for (int i=0; i<Session_ServerThread<MY_NS>::NB_SRV_TYP; i++)
+ if (strcmp(_argv[iarg],Session_ServerThread<MY_NS>::_serverTypes[i])==0)
{
aServArg._servType = i;
argState = 2;
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<MY_NS>::_serverTypes[aServArg._servType]);
for (int i=aServArg._firstArg; i<=aServArg._lastArg; i++)
MESSAGE(" arg : " << _argCopy[i]);
_argServToLaunch.push_back(aServArg);
throw SALOME_Exception(LOCALIZED("Error in command arguments, missing parenthesis ')'"));
}
-void Session_ServerLauncher::ActivateAll()
+template<class MY_NS>
+void Session_ServerLauncher<MY_NS>::ActivateAll()
{
std::list<ServArg>::iterator itServ;
for (itServ = _argServToLaunch.begin(); itServ !=_argServToLaunch.end(); itServ++)
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<MY_NS>::_serverTypes[servType]);
if (argc>1)
{
for (int i=0; i<argc-1; i++)
MESSAGE("*** activating [" << argc << "] : " << argv[0]);
- Session_ServerThread* aServerThread
- = new Session_ServerThread(argc, argv, _orb,_root_poa);
+ Session_ServerThread<MY_NS>* aServerThread = new Session_ServerThread<MY_NS>(argc, argv, _orb,_root_poa);
_serverThreads.push_front(aServerThread);
aServerThread->Init();
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<MY_NS>* aServerThread
+ = new Session_SessionThread<MY_NS>(argc, argv, _orb,_root_poa,_SessionMutex,_SessionStarted);
_serverThreads.push_front(aServerThread);
aServerThread->Init();
delete[] argv;
}
-void Session_ServerLauncher::ShutdownAll()
+template <class MY_NS>
+void Session_ServerLauncher<MY_NS>::ShutdownAll()
{
MESSAGE("Session_ServerLauncher::ShutdownAll()");
- std::list<Session_ServerThread*>::reverse_iterator itServ;
+ using Session_ServerThreadT = Session_ServerThread<MY_NS>;
+ typename std::list<Session_ServerThreadT*>::reverse_iterator itServ;
for (itServ = _serverThreads.rbegin(); itServ !=_serverThreads.rend(); itServ++)
{
(*itServ)->Shutdown();
/*!
Destruction des classes serveur dans l'ordre inverse de creation
*/
-void Session_ServerLauncher::KillAll()
+template <class MY_NS>
+void Session_ServerLauncher<MY_NS>::KillAll()
{
MESSAGE("Session_ServerLauncher::KillAll()");
- std::list<Session_ServerThread*>::reverse_iterator itServ;
+ using Session_ServerThreadT = Session_ServerThread<MY_NS>;
+ typename std::list<Session_ServerThreadT*>::reverse_iterator itServ;
for (itServ = _serverThreads.rbegin(); itServ !=_serverThreads.rend(); itServ++)
{
delete (*itServ);
_servType(servType),_firstArg(firstArg),_lastArg(lastArg)
{}
+template <class MY_NS>
class Session_ServerThread;
class QMutex;
class QWaitCondition;
-class SESSION_EXPORT Session_ServerLauncher: public QThread
+template<class MY_NS>
+class SESSION_EXPORT Session_ServerLauncher : public QThread
{
public:
Session_ServerLauncher();
QWaitCondition* _SessionStarted;
std::list<ServArg> _argServToLaunch;
std::vector<std::string> _argCopy;
- std::list<Session_ServerThread*> _serverThreads;
+ std::list< Session_ServerThread<MY_NS>* > _serverThreads;
};
#endif
#include <QMutex>
#include <QWaitCondition>
-const int Session_ServerThread::NB_SRV_TYP = 6;
-const char* Session_ServerThread::_serverTypes[NB_SRV_TYP] = {"Container",
- "ModuleCatalog",
- "Registry",
- "SALOMEDS",
- "Session",
- "ContainerManager"};
+template<class MY_NS>
+const int Session_ServerThread<MY_NS>::NB_SRV_TYP = 6;
+
+template<class MY_NS>
+const char* Session_ServerThread<MY_NS>::_serverTypes[NB_SRV_TYP] = {"Container",
+ "ModuleCatalog",
+ "Registry",
+ "SALOMEDS",
+ "Session",
+ "ContainerManager"};
/*!
default constructor not for use
*/
-Session_ServerThread::Session_ServerThread()
+template<class MY_NS>
+Session_ServerThread<MY_NS>::Session_ServerThread()
{
ASSERT(0); // must not be called
}
/*!
constructor
*/
-Session_ServerThread::Session_ServerThread(int argc,
+template<class MY_NS>
+Session_ServerThread<MY_NS>::Session_ServerThread(int argc,
char ** argv,
CORBA::ORB_ptr orb,
PortableServer::POA_ptr poa)
/*!
destructor
*/
-Session_ServerThread::~Session_ServerThread()
+template<class MY_NS>
+Session_ServerThread<MY_NS>::~Session_ServerThread()
{
for (int i = 0; i <_argc ; i++ )
free( _argv[i] );
run the thread : activate one servant, the servant type is given by
argument _argv[0]
*/
-void Session_ServerThread::Init()
+template<class MY_NS>
+void Session_ServerThread<MY_NS>::Init()
{
MESSAGE("Session_ServerThread::Init "<< _argv[0]);
}
}
-void Session_ServerThread::Shutdown()
+template<class MY_NS>
+void Session_ServerThread<MY_NS>::Shutdown()
{
if ( _container ) _container->Shutdown();
}
-void Session_ServerThread::ActivateModuleCatalog(int argc,
+template<class MY_NS>
+void Session_ServerThread<MY_NS>::ActivateModuleCatalog(int argc,
char ** argv)
{
try {
}
}
-void Session_ServerThread::ActivateSALOMEDS(int /*argc*/, char** /*argv*/)
+template<class MY_NS>
+void Session_ServerThread<MY_NS>::ActivateSALOMEDS(int /*argc*/, char** /*argv*/)
{
try {
MESSAGE("SALOMEDS thread started");
}
}
-void Session_ServerThread::ActivateRegistry(int argc, char ** argv)
+template<class MY_NS>
+void Session_ServerThread<MY_NS>::ActivateRegistry(int argc, char ** argv)
{
MESSAGE("Registry thread started");
SCRUTE(argc);
}
}
-void Session_ServerThread::ActivateContainerManager(int /*argc*/, char** /*argv*/)
+template<class MY_NS>
+void Session_ServerThread<MY_NS>::ActivateContainerManager(int /*argc*/, char** /*argv*/)
{
try {
PortableServer::POA_var root_poa=PortableServer::POA::_the_root_poa();
}
}
-void Session_ServerThread::ActivateContainer(int argc, char** argv)
+template<class MY_NS>
+void Session_ServerThread<MY_NS>::ActivateContainer(int argc, char** argv)
{
try {
MESSAGE("Container thread started");
}
}
-void Session_ServerThread::ActivateSession(int /*argc*/, char** /*argv*/)
+template<class MY_NS>
+void Session_ServerThread<MY_NS>::ActivateSession(int /*argc*/, char** /*argv*/)
{
MESSAGE("Session_ServerThread::ActivateSession() not implemented!");
}
-/*!
- constructor
-*/
-Session_SessionThread::Session_SessionThread(int argc,
+template<class MY_NS>
+Session_SessionThread<MY_NS>::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<MY_NS>(argc, argv, orb, poa),
_GUIMutex( GUIMutex ),
_GUILauncher( GUILauncher )
{
}
-/*!
- destructor
-*/
-Session_SessionThread::~Session_SessionThread()
+template<class MY_NS>
+Session_SessionThread<MY_NS>::~Session_SessionThread()
{
}
-void Session_SessionThread::ActivateSession(int argc, char ** argv)
+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, _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();
class SALOME_NamingService;
class Engines_Container_i;
+template<class MY_NS>
class SESSION_EXPORT Session_ServerThread
{
public:
int _servType;
CORBA::ORB_var _orb;
PortableServer::POA_var _root_poa;
- std::unique_ptr<SALOME_NamingService> _NS;
+ std::unique_ptr<MY_NS> _NS;
Engines_Container_i* _container;
};
class QMutex;
class QWaitCondition;
-class SESSION_EXPORT Session_SessionThread : public Session_ServerThread
+template<class MY_NS>
+class SESSION_EXPORT Session_SessionThread : public Session_ServerThread<MY_NS>
{
public:
Session_SessionThread() {}
};
#endif
-