The ORB offers two functions for obtaining object references for the
interface repository, the implementation repository, and the naming
service. Here is an example that shows how to obtain a reference for
the interface repository using resolve_initial_references()
:
int main (int argc, char *argv[]) { CORBA::ORB_var orb = CORBA::ORB_init (argc, argv, "mico-local-orb"); ... CORBA::Object_var obj = orb->resolve_initial_references ("InterfaceRepository"); CORBA::Respository_var repo = CORBA::Repository::_narrow (obj); ... }
If you specify the interface repository by using the ORB command line option
-ORBIfaceRepoAddr
or -ORBIfaceRepoIOR
, the reference returned
from resolve_initial_references()
will be the one you specified.
Otherwise the ORB will run a local interface repository and you will get
a reference to this one.
Obtaining a reference to the implementation repository
("ImplementationRepository"
) and the naming service
("NameService"
) works the same way as for the interface repository.
There is another method called list_initial_reference()
that returns
a list of names which can be used as arguments for
resolve_initial_references()
. Here is how to use it:
int main (int argc, char *argv[]) { CORBA::ORB_var orb = CORBA::ORB_init (argc, argv, "mico-local-orb"); ... CORBA::ORB::ObjectIdList_var ids = orb->list_initial_references (); for (int i = 0; i < ids->length(); ++i) cout << ids[i] << endl; ... }