1 // SALOME Session : implementation of Session.idl
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : SALOME_Session_Server.cxx
25 // Author : Paul RASCLE, EDF
29 # include "Utils_ORB_INIT.hxx"
30 # include "Utils_SINGLETON.hxx"
36 // #include <qapplication.h>
37 // #include "Qtappl_example.hxx"
39 #include <SALOMEconfig.h>
40 #include CORBA_SERVER_HEADER(SALOME_Session)
42 #include "utilities.h"
44 #include "SALOME_Session_i.hxx"
46 //! CORBA server for SALOME Session
48 * SALOME_Session Server launches a SALOME session servant.
49 * The servant registers to the Naming Service.
50 * See SALOME_Session.idl for interface specification.
52 * Main services offered by the servant are:
54 * - stop Session (must be idle)
58 int main(int argc, char **argv)
63 ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
64 ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting()) ;
65 CORBA::ORB_var &orb = init( argc , argv ) ;
67 CORBA::Object_var obj =orb->resolve_initial_references("RootPOA") ;
68 //MESSAGE("orb->resolve_initial_references('Root_POA')")
69 PortableServer::POA_var poa = PortableServer::POA::_narrow(obj) ;
70 //MESSAGE("POA::_narrow(obj)")
74 SALOME_Session_i * mySALOME_Session = new SALOME_Session_i(argc, argv, orb, poa) ;
75 PortableServer::ObjectId_var mySALOME_Sessionid = poa->activate_object(mySALOME_Session) ;
76 MESSAGE("poa->activate_object(mySALOME_Session)")
78 obj = mySALOME_Session->_this() ;
79 CORBA::String_var sior(orb->object_to_string(obj)) ;
80 // MESSAGE("sior(orb->object-to-string(obj))")
81 // cerr << "'" << (char*) sior << "'" << endl ;
83 mySALOME_Session->NSregister();
85 mySALOME_Session->_remove_ref() ;
86 //MESSAGE("mySALOME_Session->_remove_ref()")
88 PortableServer::POAManager_var pman = poa->the_POAManager() ;
90 MESSAGE("pman->activate()")
95 catch (CORBA::SystemException&)
97 INFOS("Caught CORBA::SystemException.")
99 catch (CORBA::Exception&)
101 INFOS("Caught CORBA::Exception.")
105 INFOS("Caught unknown exception.")