Salome HOME
NRI : Check if a component-username is already associated with a component-name.
[modules/kernel.git] / src / Session / SALOME_Session_Server.cxx
1 using namespace std;
2 //=============================================================================
3 // File      : SALOME_Session_Server.cxx
4 // Created   : mar jun 19 13:26:24 CEST 2001
5 // Author    : Paul RASCLE, EDF
6 // Project   : SALOME
7 // Copyright : EDF 2001
8 // $Header$
9 //=============================================================================
10
11 /*! \file SALOME_Session_Server.cxx
12  */
13
14 using namespace std;
15 # include "Utils_ORB_INIT.hxx"
16 # include "Utils_SINGLETON.hxx"
17
18 #include <iostream.h>
19 #include <unistd.h>
20
21 // #include <qapplication.h>
22 // #include "Qtappl_example.hxx"
23
24 #include <SALOMEconfig.h>
25 #include CORBA_SERVER_HEADER(SALOME_Session)
26
27 #include "utilities.h"
28
29 #include "SALOME_Session_i.hxx"
30
31 //! CORBA server for SALOME Session
32 /*!
33  *  SALOME_Session Server launches a SALOME session servant.
34  *  The servant registers to the Naming Service.
35  *  See SALOME_Session.idl for interface specification.
36  *
37  *  Main services offered by the servant are:
38  *   - launch GUI
39  *   - stop Session (must be idle)
40  *   - get session state
41  */
42
43 int main(int argc, char **argv)
44 {
45
46   try
47     {
48     ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
49     ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting()) ;
50     CORBA::ORB_var &orb = init( argc , argv ) ;
51
52     CORBA::Object_var obj =orb->resolve_initial_references("RootPOA") ;
53     //MESSAGE("orb->resolve_initial_references('Root_POA')")
54     PortableServer::POA_var poa = PortableServer::POA::_narrow(obj) ;
55     //MESSAGE("POA::_narrow(obj)")
56
57     // servant
58
59     SALOME_Session_i * mySALOME_Session = new SALOME_Session_i(argc, argv, orb, poa) ;
60     PortableServer::ObjectId_var mySALOME_Sessionid = poa->activate_object(mySALOME_Session) ;
61     MESSAGE("poa->activate_object(mySALOME_Session)")
62
63     obj = mySALOME_Session->_this() ;
64     CORBA::String_var sior(orb->object_to_string(obj)) ;
65     // MESSAGE("sior(orb->object-to-string(obj))")
66     // cerr << "'" << (char*) sior << "'" << endl ;
67
68     mySALOME_Session->NSregister();
69
70     mySALOME_Session->_remove_ref() ;
71     //MESSAGE("mySALOME_Session->_remove_ref()")
72
73     PortableServer::POAManager_var pman = poa->the_POAManager() ;
74     pman->activate() ;
75     MESSAGE("pman->activate()")
76
77     orb->run() ;
78     orb->destroy() ;
79     }
80     catch (CORBA::SystemException&)
81     {
82       INFOS("Caught CORBA::SystemException.")
83     }
84     catch (CORBA::Exception&)
85     {
86       INFOS("Caught CORBA::Exception.")
87     }
88     catch (...)
89     {
90       INFOS("Caught unknown exception.")
91     }
92   return 0 ;
93 }