Salome HOME
PR: mergefrom_PRAS_br3_06Nov04
[modules/yacs.git] / src / Loader / SALOME_Session_Loader.cxx
1 //  Copyright (C) 2003  CEA/DEN, EDF R&D
2 //
3 //
4 //
5 //  File   : SALOME_Session_loader.cxx
6 //  Author : Paul RASCLE, EDF
7 //  Module : SALOME
8 //  $Header$
9
10 using namespace std;
11 /*! \file SALOME_Session_loader.cxx
12  */
13
14 #include <SALOMEconfig.h>
15 #include CORBA_CLIENT_HEADER(SALOME_Session)
16 #include CORBA_CLIENT_HEADER(Logger)
17
18 #include "Utils_ORB_INIT.hxx"
19 #include "Utils_SINGLETON.hxx"
20 #include "SALOME_NamingService.hxx"
21 #include "utilities.h"
22 #include "LocalTraceCollector.hxx"
23
24 //! CORBA client for SALOME Session server : launch GUI
25 /*!
26  *  SALOME_Session Loader launches a SALOME GUI on the SALOME session servant process
27  */
28
29 #include <qapplication.h>
30 #include "InquireServersQThread.h"
31
32 int main(int argc, char **argv)
33 {
34   CORBA::ORB_ptr orb = CORBA::ORB_init(argc,argv) ;
35   LocalTraceCollector *myThreadTrace = LocalTraceCollector::instance(orb);
36 //VRV: T2.4 - Trace management improvement
37   QApplication myQApp(argc, argv) ;
38   InquireServersGUI myIS;
39   myQApp.setMainWidget(&myIS);
40   ASSERT(QObject::connect(&myQApp, SIGNAL(lastWindowClosed()), &myQApp, SLOT(quit()) ) );
41   myIS.show();
42   myQApp.exec();
43
44   if (myIS.getExitStatus())
45     exit(1);
46 //VRV: T2.4 - Trace management improvement
47   if (myIS.withGUI()) {
48     try
49       { 
50         SALOME_NamingService &NS = *SINGLETON_<SALOME_NamingService>::Instance() ;
51         ASSERT(SINGLETON_<SALOME_NamingService>::IsAlreadyExisting()) ;
52         NS.init_orb( orb ) ;
53         
54         CORBA::Object_var obj = NS.Resolve("/Kernel/Session");
55         
56         SALOME::Session_var session = SALOME::Session::_narrow(obj) ;
57         ASSERT(! CORBA::is_nil(session));
58         MESSAGE("SALOME::Session::_narrow(obj)");
59         INFOS("Corba initialisation, Distant server");
60         
61         // -------------------------------------------------------------
62         
63         session->GetInterface() ;
64
65         // -------------------------------------------------------------
66         
67         orb->destroy() ;
68       }
69     catch (ServiceUnreachable&)
70       {
71         INFOS("Caught exception: Naming Service Unreachable");
72       }
73     catch (CORBA::COMM_FAILURE&)
74       {
75         INFOS("Caught CORBA::SystemException CommFailure.");
76       }
77     catch (CORBA::SystemException&)
78       {
79         INFOS("Caught CORBA::SystemException.");
80       }
81     catch (CORBA::Exception&)
82       {
83         INFOS("Caught CORBA::Exception.");
84       }
85     catch (...)
86       {
87         INFOS("Caught unknown exception.");
88       }
89   }
90   INFOS("Normal Exit"); // without this trace, Splash remains on screen !
91   delete myThreadTrace;
92   return 0 ;
93 }
94
95