Iterator.cpp

Go to the documentation of this file.
00001 //=============================================================================
00002 /**
00003  *  @file   Iterator.cpp
00004  *
00005  *  Iterator.cpp,v 1.9 2006/01/04 16:10:11 giovannd Exp
00006  *
00007  *  @brief  This file declares ImR's iterator.
00008  *
00009  *  @author Darrell Brunsch <brunsch@cs.wustl.edu>
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                       ACE_ENV_ARG_DECL)
00027   ACE_THROW_SPEC ((CORBA::SystemException))
00028 {
00029   ACE_NEW_THROW_EX (server_list,
00030     ImplementationRepository::ServerInformationList(0), CORBA::NO_MEMORY());
00031 
00032   Locator_Repository::SIMap::ENTRY* entry = 0;
00033   Locator_Repository::SIMap::ITERATOR it (this->repo_.servers ());
00034 
00035   // Number of servers that will go into the server_list.
00036   CORBA::ULong n = this->repo_.servers().current_size();
00037   if (n <= this->count_)
00038     {
00039       return 0; // We already finished.
00040     }
00041   else
00042     {
00043       n -= this->count_;
00044     }
00045 
00046   if (how_many > 0 && n > how_many)
00047     {
00048       n = how_many;
00049   }
00050 
00051   server_list->length (n);
00052 
00053   CORBA::ULong i = 0;
00054   for (; i < this->count_; ++i)
00055     {
00056       it.advance ();
00057     }
00058 
00059   for (i = 0; i < n; ++i)
00060     {
00061       it.next (entry);
00062       it.advance ();
00063       ACE_ASSERT(entry != 0);
00064 
00065       Server_Info_Ptr info = entry->int_id_;
00066 
00067       server_list[i].server = info->name.c_str ();
00068       server_list[i].startup.command_line = info->cmdline.c_str ();
00069       server_list[i].startup.environment = info->env_vars;
00070       server_list[i].startup.working_directory = info->dir.c_str ();
00071       server_list[i].startup.activation = info->activation_mode;
00072       server_list[i].startup.activator = info->activator.c_str ();
00073       server_list[i].startup.start_limit = info->start_limit;
00074       server_list[i].partial_ior = info->partial_ior.c_str ();
00075     }
00076 
00077   this->count_ += n;
00078 
00079   return 1;
00080 }
00081 
00082 
00083 void
00084 ImR_Iterator::destroy (ACE_ENV_SINGLE_ARG_DECL)
00085    ACE_THROW_SPEC ((CORBA::SystemException))
00086 {
00087   PortableServer::ObjectId_var oid = poa_->servant_to_id (this ACE_ENV_ARG_PARAMETER);
00088   ACE_CHECK;
00089   poa_->deactivate_object (oid.in() ACE_ENV_ARG_PARAMETER);
00090   ACE_CHECK;
00091 }

Generated on Thu Nov 9 13:36:19 2006 for TAO_Implementation_Repository by doxygen 1.3.6