1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/
23 #include "ObjRef_omniORB4.hh"
27 class ObjRef_i : public POA_ObjRef_omniORB4::ObjRef {
32 virtual ~ObjRef_i() {} ;
34 virtual ObjRef_omniORB4::ObjRef_ptr getObjRef( const ObjRef_omniORB4::ObjRef_ptr anObjRef ) ;
41 ObjRef_omniORB4::ObjRef_ptr ObjRef_i::getObjRef( const ObjRef_omniORB4::ObjRef_ptr anObjRef ) {
43 cout << "ObjRef_i::getObjRef" << endl ;
45 cout << "ObjRef_i::getObjRef will return the same object reference" << endl ;
46 return ObjRef_omniORB4::ObjRef::_duplicate( anObjRef ) ;
50 bool ObjRef_i::ping() {
51 cout << "ping" << endl ;
55 int main( int argc , char ** argv ) {
58 CORBA::ORB_var orb = CORBA::ORB_init( argc , argv , "omniORB4" ) ;
59 CORBA::Object_var obj = orb->resolve_initial_references( "RootPOA" ) ;
60 PortableServer::POA_var poa = PortableServer::POA::_narrow( obj ) ;
61 ObjRef_i * myObjRef = new ObjRef_i() ;
62 PortableServer::ObjectId_var myObjectId = poa->activate_object( myObjRef ) ;
63 obj = myObjRef->_this() ;
64 CORBA::String_var myIOR = orb->object_to_string( obj ) ;
65 cout << "myIOR : '" << (char * ) myIOR << "'" << endl ;
66 myObjRef->_remove_ref() ;
67 PortableServer::POAManager_var pman = poa->the_POAManager() ;
72 catch(CORBA::SystemException & ) {
73 cout << "Caught CORBA::SystemException" << endl ;
75 catch(CORBA::Exception & ) {
76 cout << "Caught CORBA::Exception" << endl ;
78 catch(omniORB::fatalException & fe ) {
79 cout << "Caught omniORB::fatalException" << endl ;
80 cout << " file " << fe.file() << endl ;
81 cout << " line " << fe.line() << endl ;
82 cout << " errmsg " << fe.errmsg() << endl ;
85 cout << "Caught unknown exception" << endl ;