/* $Id: irior.cc 1490 2006-06-22 20:57:22Z rvosa $ */ /* Program to print the IOR of MICO's interface repository, ird. * The ird instanceis specified by the MICO command option: -ORBIfaceRepoAddr. * See the MICO documentation for details. * The code is derived from mico/demo/account2/client.cc and is therefore * licensed under the GNU GPL. */ #include #include extern "C" { void sleep(int); } int main( int argc, char *argv[] ) { CORBA::Object_var ir; int i; char addr[40] = "inet:localhost:"; if (argc < 2) { cerr << "Usage: irior \n"; return 2; } // ORB initialization CORBA::ORB_var orb = CORBA::ORB_init( argc, argv, "mico-local-orb" ); /* Create a MICO address string. */ strcpy(addr+15, argv[1]); /* Wait up to 10 seconds for ird to initialise. */ for (i = 0; i < 10; ++i) { /* Use _bind rather than orb->resolve_initial_references and * -ORBIfaceRepoAddr to prevent MICO from creating an * internal IR if ird is not yet ready. * ir = orb->resolve_initial_references("InterfaceRepository"); */ ir = orb->bind("IDL:omg.org/CORBA/Repository:1.0", addr); if (CORBA::is_nil(ir)) { sleep(1); } else { cout << orb->object_to_string(ir) << endl; return 0; } } return 1; }