]> SALOME platform Git repositories - modules/kernel.git/blob - src/Loader/SALOME_Session_Loader.cxx
Salome HOME
cc69f08688763a7010c3f5ea43a2b5d625c15280
[modules/kernel.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 /*! \file SALOME_Session_loader.cxx
11  */
12
13 #include <SALOMEconfig.h>
14 #include CORBA_CLIENT_HEADER(SALOME_Session)
15 #include CORBA_CLIENT_HEADER(Logger)
16
17 #include "Utils_ORB_INIT.hxx"
18 #include "Utils_SINGLETON.hxx"
19 #include "SALOME_NamingService.hxx"
20 #include "utilities.h"
21 #include "SALOMETraceCollector.hxx"
22
23 //! CORBA client for SALOME Session server : launch GUI
24 /*!
25  *  SALOME_Session Loader launches a SALOME GUI on the SALOME session servant process
26  */
27
28 #include <qapplication.h>
29 #include "InquireServersQThread.h"
30 using namespace std;
31
32 void MessageOutput( QtMsgType type, const char *msg )
33 {
34   switch ( type ) {
35   case QtDebugMsg:
36     MESSAGE( "Debug: " << msg );
37     break;
38   case QtWarningMsg:
39     MESSAGE( "Warning: " << msg );
40     break;
41   case QtFatalMsg:
42     MESSAGE( "Fatal: " << msg );
43     break;
44   }
45 }
46
47 int main(int argc, char **argv)
48 {
49   CORBA::ORB_ptr orb = CORBA::ORB_init(argc,argv) ;
50   SALOMETraceCollector *myThreadTrace = SALOMETraceCollector::instance(orb);
51   qInstallMsgHandler( MessageOutput );
52 //VRV: T2.4 - Trace management improvement
53   QApplication myQApp(argc, argv) ;
54   InquireServersGUI myIS;
55   myQApp.setMainWidget(&myIS);
56   ASSERT(QObject::connect(&myQApp, SIGNAL(lastWindowClosed()), &myQApp, SLOT(quit()) ) );
57   myIS.show();
58   myQApp.exec();
59
60   if (myIS.getExitStatus())
61     exit(1);
62 //VRV: T2.4 - Trace management improvement
63   if (myIS.withGUI()) {
64     try
65       {
66         SALOME_NamingService &NS = *SINGLETON_<SALOME_NamingService>::Instance() ;
67         ASSERT(SINGLETON_<SALOME_NamingService>::IsAlreadyExisting()) ;
68         NS.init_orb( orb ) ;
69         
70         CORBA::Object_var obj = NS.Resolve("/Kernel/Session");
71         
72         SALOME::Session_var session = SALOME::Session::_narrow(obj) ;
73         ASSERT(! CORBA::is_nil(session));
74         MESSAGE("SALOME::Session::_narrow(obj)");
75         INFOS("Corba initialisation, Distant server");
76         
77         // -------------------------------------------------------------
78         
79         session->GetInterface() ;
80
81         // -------------------------------------------------------------
82         
83         orb->destroy() ;
84       }
85     catch (ServiceUnreachable&)
86       {
87         INFOS("Caught exception: Naming Service Unreachable");
88       }
89     catch (CORBA::COMM_FAILURE&)
90       {
91         INFOS("Caught CORBA::SystemException CommFailure.");
92       }
93     catch (CORBA::SystemException&)
94       {
95         INFOS("Caught CORBA::SystemException.");
96       }
97     catch (CORBA::Exception&)
98       {
99         INFOS("Caught CORBA::Exception.");
100       }
101     catch (...)
102       {
103         INFOS("Caught unknown exception.");
104       }
105     return 0 ;
106   }
107   INFOS("Normal Exit"); // without this trace, Splash remains on screen !
108   delete myThreadTrace;
109   return 0 ;
110 }
111
112