Документ взят из кэша поисковой машины. Адрес
оригинального документа
: http://rtm-cs.sinp.msu.ru/manual/mico/doc/node22.html
Дата изменения: Mon Jun 7 21:54:57 1999 Дата индексирования: Mon Oct 1 21:21:31 2012 Кодировка: |
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_services()
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_services (); for (int i = 0; i < ids->length(); ++i) cout << ids[i] << endl; ... }
Initial references can also be specified using the
-ORBInitRef
and -ORBDefaultInitRef
command line
options.