span_manager Class Reference

Manages lists of numbers representing the completion of some activity. More...

#include <span_manager.h>

Collaboration diagram for span_manager:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 span_manager (int number_of_items)
 span_manager (const span_manager &to_copy)
 ~span_manager ()
span_manageroperator= (const span_manager &to_copy)
void reset (int number_of_items)
 sets up the span manager with a new configuration.
bool update (const int_array &new_spans)
 updates the span information.
int received_sequence () const
 returns the highest chunk number at which all chunks are ready.
int missing_sequence () const
 returns the number of the chunk where the first item is missing.
void make_received_list (int_array &spans, int max_spans=-1) const
 Creates a list for the received spans that are ready.
void make_missing_list (int_array &spans, int max_spans=-1) const
 creates a list representing the spans that are not ready yet.
const bit_vectorvector () const
 observes the held bit_vector that represents the spans.
bit_vectorvector ()
 provides access to the held bit_vector that represents the spans.
istring print_received_list () const
 prints out the span list for received blocks into a string.
istring print_missing_list () const
 prints out the span list for missing blocks into a string.

Detailed Description

Manages lists of numbers representing the completion of some activity.

A number is either present or absent from the list. The numbers are organized according to spans, where a span is simply a range of numbers, such as 33-238. the span manager allows numbers to be added or removed from the list. it also can create the full list of either the present or absent numbers.

Definition at line 32 of file span_manager.h.


Constructor & Destructor Documentation

span_manager::span_manager ( int  number_of_items  ) 

Definition at line 26 of file span_manager.cpp.

span_manager::span_manager ( const span_manager to_copy  ) 

Definition at line 30 of file span_manager.cpp.

span_manager::~span_manager (  ) 

Definition at line 34 of file span_manager.cpp.

References WHACK().


Member Function Documentation

span_manager & span_manager::operator= ( const span_manager to_copy  ) 

Definition at line 36 of file span_manager.cpp.

References _implementation.

void span_manager::reset ( int  number_of_items  ) 

sets up the span manager with a new configuration.

Definition at line 46 of file span_manager.cpp.

References bit_vector::resize().

Referenced by buffer::release().

bool span_manager::update ( const int_array new_spans  ) 

updates the span information.

the spans listed in the hold are added to the span manager. if the spans are successfully added, then true is returned.

Definition at line 115 of file span_manager.cpp.

References bit_vector::bits(), array< contents >::get(), array< contents >::length(), and bit_vector::light().

Referenced by buffer::buffer().

int span_manager::received_sequence (  )  const

returns the highest chunk number at which all chunks are ready.

or a negative number is returned if chunk 0 has still not been received yet.

Definition at line 52 of file span_manager.cpp.

References bit_vector::bits(), bit_vector::find_first(), and negative().

Referenced by main(), print_missing_list(), and print_received_list().

int span_manager::missing_sequence (  )  const

returns the number of the chunk where the first item is missing.

if none of them are missing, then a negative number is returned.

Definition at line 43 of file span_manager.cpp.

References bit_vector::find_first().

Referenced by main().

void span_manager::make_received_list ( int_array spans,
int  max_spans = -1 
) const

Creates a list for the received spans that are ready.

The numbers in the list refer to ranges of spans fully received. For example, if 0, 3, 4, 5, 8, 9, 12, 13, 14, and 28 have been received, the span list is [0-0], [3-5], [8-9], [12-14], and [28-28]. The "max_spans" is the longest the list is allowed to be, unless it is negative, which means include all of them.

Definition at line 59 of file span_manager.cpp.

References bit_vector::bits(), array< contents >::concatenate(), bit_vector::find_first(), array< contents >::length(), negative(), bit_vector::on(), and array< contents >::reset().

Referenced by main(), and print_received_list().

void span_manager::make_missing_list ( int_array spans,
int  max_spans = -1 
) const

creates a list representing the spans that are not ready yet.

Definition at line 127 of file span_manager.cpp.

References bit_vector::bits(), array< contents >::concatenate(), bit_vector::find_first(), array< contents >::length(), negative(), bit_vector::on(), and array< contents >::reset().

Referenced by main(), and print_missing_list().

const bit_vector & span_manager::vector (  )  const

observes the held bit_vector that represents the spans.

Definition at line 48 of file span_manager.cpp.

Referenced by linked_buffer::detailed_form(), buffer::detailed_form(), buffer::empty(), buffer::release(), buffer::store_packet(), and buffer::whole().

bit_vector & span_manager::vector (  ) 

provides access to the held bit_vector that represents the spans.

Definition at line 50 of file span_manager.cpp.

istring span_manager::print_received_list (  )  const

prints out the span list for received blocks into a string.

Definition at line 194 of file span_manager.cpp.

References make_received_list(), and received_sequence().

Referenced by linked_buffer::detailed_form(), buffer::detailed_form(), and main().

istring span_manager::print_missing_list (  )  const

prints out the span list for missing blocks into a string.

Definition at line 203 of file span_manager.cpp.

References make_missing_list(), and received_sequence().

Referenced by main().


The documentation for this class was generated from the following files:
Generated on Fri Nov 28 04:31:00 2008 for HOOPLE Libraries by  doxygen 1.5.1