00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include "Iterator.h"
00014
00015 ImR_Iterator::ImR_Iterator (CORBA::ULong n, Locator_Repository& repo, PortableServer::POA_ptr poa)
00016 : repo_(repo)
00017 , count_(n)
00018 , poa_(poa)
00019 {
00020 }
00021
00022
00023 CORBA::Boolean
00024 ImR_Iterator::next_n (CORBA::ULong how_many,
00025 ImplementationRepository::ServerInformationList_out server_list)
00026 {
00027 ACE_NEW_THROW_EX (server_list,
00028 ImplementationRepository::ServerInformationList(0), CORBA::NO_MEMORY());
00029
00030 Locator_Repository::SIMap::ENTRY* entry = 0;
00031 Locator_Repository::SIMap::ITERATOR it (this->repo_.servers ());
00032
00033
00034 CORBA::ULong n = this->repo_.servers().current_size();
00035 if (n <= this->count_)
00036 {
00037 return 0;
00038 }
00039 else
00040 {
00041 n -= this->count_;
00042 }
00043
00044 if (how_many > 0 && n > how_many)
00045 {
00046 n = how_many;
00047 }
00048
00049 server_list->length (n);
00050
00051 CORBA::ULong i = 0;
00052 for (; i < this->count_; ++i)
00053 {
00054 it.advance ();
00055 }
00056
00057 for (i = 0; i < n; ++i)
00058 {
00059 it.next (entry);
00060 it.advance ();
00061 ACE_ASSERT(entry != 0);
00062
00063 Server_Info_Ptr info = entry->int_id_;
00064
00065 server_list[i].server = info->name.c_str ();
00066 server_list[i].startup.command_line = info->cmdline.c_str ();
00067 server_list[i].startup.environment = info->env_vars;
00068 server_list[i].startup.working_directory = info->dir.c_str ();
00069 server_list[i].startup.activation = info->activation_mode;
00070 server_list[i].startup.activator = info->activator.c_str ();
00071 server_list[i].startup.start_limit = info->start_limit;
00072 server_list[i].partial_ior = info->partial_ior.c_str ();
00073 }
00074
00075 this->count_ += n;
00076
00077 return 1;
00078 }
00079
00080
00081 void
00082 ImR_Iterator::destroy (void)
00083 {
00084 PortableServer::ObjectId_var oid = poa_->servant_to_id (this);
00085 poa_->deactivate_object (oid.in());
00086 }