]> SALOME platform Git repositories - modules/superv.git/blob - src/Supervision/SuperV_Server_omniORB4.cxx
Salome HOME
afd0577865b18f4609b7677ff5509465f2e0fdec
[modules/superv.git] / src / Supervision / SuperV_Server_omniORB4.cxx
1
2 #include <iostream>
3 #include <CORBA.h>
4 #include "ObjRef_omniORB4.hh"
5
6 using namespace std;
7
8 class ObjRef_i : public POA_ObjRef_omniORB4::ObjRef {
9
10 public:
11
12 ObjRef_i() {} ;
13 virtual ~ObjRef_i() {} ;
14
15 virtual ObjRef_omniORB4::ObjRef_ptr getObjRef( const ObjRef_omniORB4::ObjRef_ptr anObjRef ) ;
16
17 virtual bool ping() ;
18
19 } ;
20
21
22 ObjRef_omniORB4::ObjRef_ptr ObjRef_i::getObjRef( const ObjRef_omniORB4::ObjRef_ptr anObjRef ) {
23
24   cout << "ObjRef_i::getObjRef" << endl ;
25   anObjRef->ping() ;
26   cout << "ObjRef_i::getObjRef will return the same object reference" << endl ;
27   return ObjRef_omniORB4::ObjRef::_duplicate( anObjRef ) ;
28
29 } ;
30
31 bool ObjRef_i::ping() {
32   cout << "ping" << endl ;
33   return true ;
34 }
35
36 int main( int argc , char ** argv ) {
37
38   try {
39     CORBA::ORB_var orb = CORBA::ORB_init( argc , argv , "omniORB4" ) ;
40     CORBA::Object_var obj = orb->resolve_initial_references( "RootPOA" ) ;
41     PortableServer::POA_var poa = PortableServer::POA::_narrow( obj ) ;
42     ObjRef_i * myObjRef = new ObjRef_i() ;
43     PortableServer::ObjectId_var myObjectId = poa->activate_object( myObjRef ) ;
44     obj = myObjRef->_this() ;
45     CORBA::String_var myIOR = orb->object_to_string( obj ) ;
46     cout << "myIOR : '" << (char * ) myIOR << "'" << endl ;
47     myObjRef->_remove_ref() ;
48     PortableServer::POAManager_var pman = poa->the_POAManager() ;
49     pman->activate() ;
50     orb->run() ;
51     orb->destroy() ;
52   }
53   catch(CORBA::SystemException & ) {
54     cout << "Caught CORBA::SystemException" << endl ;
55   }
56   catch(CORBA::Exception & ) {
57     cout << "Caught CORBA::Exception" << endl ;
58   }
59   catch(omniORB::fatalException & fe ) {
60     cout << "Caught omniORB::fatalException" << endl ;
61     cout << "      file   " << fe.file() << endl ;
62     cout << "      line   " << fe.line() << endl ;
63     cout << "      errmsg " << fe.errmsg() << endl ;
64   }
65   catch( ... ) {
66     cout << "Caught unknown exception" << endl ;
67   }
68   return 0 ;
69 }