#include <linked_buffer.h>
Inheritance diagram for linked_buffer:


Public Member Functions | |
| linked_buffer (const buffer_key &key, buffer *real_buffer) | |
| links to the "buffer" specified using the "key". | |
| virtual | ~linked_buffer () |
| releases any storage used by the buffer. | |
| IMPLEMENT_CLASS_NAME ("linked_buffer") | |
| buffer & | access_buffer () |
| special provision for linked_buffer allows a peek at the real buffer. | |
| virtual bool | alive () const |
| returns true if this buffer is still alive. | |
| virtual int | packets () const |
| the number of packets in this buffer. | |
| virtual buffer_key | key () const |
| observe the key for this buffer. | |
| virtual void | set_key (const buffer_key &to_set) |
| modify the key for this buffer. | |
| virtual outcome | store_packet (int packet_number, const byte_array &buffer) |
| puts a packet into the buffer at the "packet_number"th position. | |
| virtual byte_array | get_packet (int packet_number) const |
| returns a packet from the buffer. | |
| virtual int | packet_length (int packet_number) const |
| returns the length of a particular packet. | |
| virtual bool | whole () const |
| returns true if the entire buffer has been stored. | |
| virtual bool | empty () const |
| returns true if the buffer has no packets stored yet. | |
| virtual int | full_length (int offset=0) const |
| returns the full length of this buffer, ignoring first "offset" bytes. | |
| virtual int | guess_size (int offset=0) |
| provides an estimate of what the full size will eventually be. | |
| virtual bool | did_estimate () const |
| returns true if we have previously estimated a size for this buffer. | |
| virtual void | reset_estimate () |
| tosses our earlier estimate of the buffer's size. | |
| virtual int | estimate () const |
| returns our estimate, if we've made one. | |
| virtual outcome | dump (byte_array &storage_location, int offset=0) |
| stuffs the entire buffer into contiguous memory at "storage_location". | |
| virtual void | release (int packet_number, release_style status_handling=KEEP_STATUS) |
| frees the storage for the "packet_number"th packet. | |
| virtual void | release () |
| frees the entire buffer, returning it to an unallocated state. | |
| virtual istring | text_form () const |
| returns a text string representing the state of the buffer. | |
| virtual istring | detailed_form (bool really_detailed=false) const |
| returns a more detailed text string for this buffer. | |
| virtual time_stamp | last_add () const |
| returns the last time that the buffer was added to. | |
| virtual void | set_last_add (const time_stamp &new_last_add) |
| sets the last time that the buffer was added to. | |
| virtual bool | owner_alerted () const |
| records whether the buffer's owner was alerted to completion. | |
| virtual void | set_alerted (bool owner_alerted) |
| records that the owner was alerted, if "owner_alerted" is true. | |
| virtual void | get_attachment (byte_array &storage) const |
| the attachment allows extra information to be stored with each buffer. | |
| virtual void | set_attachment (const byte_array &new_attachment) |
| sets the attachment, which is empty until this is used. | |
| virtual span_manager | buffer_status () const |
| allows a peek at the object tracking our packet statuses. | |
| virtual int_array | packet_sizes () const |
| returns a list of the sizes of the packets for this buffer. | |
Identical buffers can be given to many different transports without needing to use space for each one.
Definition at line 30 of file linked_buffer.h.
| linked_buffer::linked_buffer | ( | const buffer_key & | key, | |
| buffer * | real_buffer | |||
| ) |
links to the "buffer" specified using the "key".
it does not matter what the real buffer's key is since only our "key" will be used.
Definition at line 29 of file linked_buffer.cpp.
References buffer::add_reference(), buffer_key::connection, and key().
| linked_buffer::~linked_buffer | ( | ) | [virtual] |
releases any storage used by the buffer.
Definition at line 37 of file linked_buffer.cpp.
References buffer_key::connection, NIL, buffer::references(), buffer::remove_reference(), and WHACK().
| linked_buffer::IMPLEMENT_CLASS_NAME | ( | "linked_buffer" | ) |
| buffer & linked_buffer::access_buffer | ( | ) |
special provision for linked_buffer allows a peek at the real buffer.
Definition at line 51 of file linked_buffer.cpp.
| bool linked_buffer::alive | ( | ) | const [virtual] |
returns true if this buffer is still alive.
Implements buffer_base.
Definition at line 97 of file linked_buffer.cpp.
References buffer::alive().
Referenced by text_form().
| int linked_buffer::packets | ( | ) | const [virtual] |
the number of packets in this buffer.
Implements buffer_base.
Definition at line 98 of file linked_buffer.cpp.
References buffer::packets().
Referenced by detailed_form().
| buffer_key linked_buffer::key | ( | ) | const [virtual] |
observe the key for this buffer.
Implements buffer_base.
Definition at line 53 of file linked_buffer.cpp.
Referenced by linked_buffer().
| void linked_buffer::set_key | ( | const buffer_key & | to_set | ) | [virtual] |
modify the key for this buffer.
Implements buffer_base.
Definition at line 59 of file linked_buffer.cpp.
| outcome linked_buffer::store_packet | ( | int | packet_number, | |
| const byte_array & | buffer | |||
| ) | [virtual] |
puts a packet into the buffer at the "packet_number"th position.
the packet numbering starts at zero. if the packet has already been stored previously, then IN_USE is returned.
Implements buffer_base.
Definition at line 99 of file linked_buffer.cpp.
References buffer::store_packet().
| byte_array linked_buffer::get_packet | ( | int | packet_number | ) | const [virtual] |
returns a packet from the buffer.
if that packet has not been stored yet, then NIL is returned.
Implements buffer_base.
Definition at line 101 of file linked_buffer.cpp.
References buffer::get_packet().
| int linked_buffer::packet_length | ( | int | packet_number | ) | const [virtual] |
returns the length of a particular packet.
Implements buffer_base.
Definition at line 103 of file linked_buffer.cpp.
References buffer::packet_length().
| bool linked_buffer::whole | ( | ) | const [virtual] |
returns true if the entire buffer has been stored.
Implements buffer_base.
Definition at line 105 of file linked_buffer.cpp.
References buffer::whole().
Referenced by text_form().
| bool linked_buffer::empty | ( | ) | const [virtual] |
returns true if the buffer has no packets stored yet.
Implements buffer_base.
Definition at line 106 of file linked_buffer.cpp.
References buffer::empty().
| int linked_buffer::full_length | ( | int | offset = 0 |
) | const [virtual] |
returns the full length of this buffer, ignoring first "offset" bytes.
the first "offset" bytes are not considered as part of the buffer, providing for a header's presence on each buffer. note that the full length is not actually known for sure until all packets are present in the buffer. BAD_INPUT is returned if the offset is invalid. INCOMPLETE is returned if the buffer was not whole yet. to receive an estimate of the size before the buffer is complete, use the guess_size() method.
Implements buffer_base.
Definition at line 107 of file linked_buffer.cpp.
References buffer::full_length().
Referenced by text_form().
| int linked_buffer::guess_size | ( | int | offset = 0 |
) | [virtual] |
provides an estimate of what the full size will eventually be.
once this measurement is provided, it is important that it remain constant; otherwise calculations based on it would be incorrect later. so, the did_estimate() method reports whether the size was ever guessed for this buffer and this function will return the same value until the buffer is released.
Implements buffer_base.
Definition at line 109 of file linked_buffer.cpp.
References buffer::guess_size().
| bool linked_buffer::did_estimate | ( | ) | const [virtual] |
returns true if we have previously estimated a size for this buffer.
Implements buffer_base.
Definition at line 111 of file linked_buffer.cpp.
References buffer::did_estimate().
| void linked_buffer::reset_estimate | ( | ) | [virtual] |
tosses our earlier estimate of the buffer's size.
Implements buffer_base.
Definition at line 113 of file linked_buffer.cpp.
References buffer::reset_estimate().
| int linked_buffer::estimate | ( | ) | const [virtual] |
returns our estimate, if we've made one.
Implements buffer_base.
Definition at line 114 of file linked_buffer.cpp.
References buffer::estimate().
Referenced by text_form().
| outcome linked_buffer::dump | ( | byte_array & | storage_location, | |
| int | offset = 0 | |||
| ) | [virtual] |
stuffs the entire buffer into contiguous memory at "storage_location".
if the buffer cannot be allocated, OUT_OF_MEMORY is returned. if the buffer is not complete, INCOMPLETE will be returned. if the "offset" is positive, then the packets stored in the buffer will have the first "offset" bytes chopped off of them before they are stored. if any packet is too short for the given offset (or if offset is negative), BAD_INPUT is returned.
Implements buffer_base.
Definition at line 115 of file linked_buffer.cpp.
References buffer::dump().
| void linked_buffer::release | ( | int | packet_number, | |
| release_style | status_handling = KEEP_STATUS | |||
| ) | [virtual] |
frees the storage for the "packet_number"th packet.
if keep_status is true, then packet's state of being present is retained; otherwise, the packet is considered not to have been received yet. if the status is kept, then the packet will appear to be there but will have zero length and a NIL content.
Implements buffer_base.
Definition at line 117 of file linked_buffer.cpp.
References buffer::release().
| void linked_buffer::release | ( | ) | [virtual] |
frees the entire buffer, returning it to an unallocated state.
Implements buffer_base.
Definition at line 119 of file linked_buffer.cpp.
References buffer::release().
| istring linked_buffer::text_form | ( | ) | const [virtual] |
returns a text string representing the state of the buffer.
Implements buffer_base.
Definition at line 65 of file linked_buffer.cpp.
References alive(), buffer_key::buff_id, buffer_key::connection, estimate(), full_length(), buffer::last_add(), buffer_key::msg_id, istring::observe(), unique_id< uniquifier >::raw_id(), istring::SPRINTF, time_stamp::text_form(), and whole().
Referenced by detailed_form().
| istring linked_buffer::detailed_form | ( | bool | really_detailed = false |
) | const [virtual] |
returns a more detailed text string for this buffer.
if "really_detailed" is true, then the status of each component of the buffer is included.
Implements buffer_base.
Definition at line 78 of file linked_buffer.cpp.
References buffer::buffer_status(), bit_vector::on(), buffer::packet_sizes(), packets(), span_manager::print_received_list(), istring::SPRINTF, text_form(), and span_manager::vector().
| time_stamp linked_buffer::last_add | ( | ) | const [virtual] |
returns the last time that the buffer was added to.
Implements buffer_base.
Definition at line 120 of file linked_buffer.cpp.
References buffer::last_add().
| void linked_buffer::set_last_add | ( | const time_stamp & | new_last_add | ) | [virtual] |
sets the last time that the buffer was added to.
Implements buffer_base.
Definition at line 121 of file linked_buffer.cpp.
References buffer::set_last_add().
| bool linked_buffer::owner_alerted | ( | ) | const [virtual] |
records whether the buffer's owner was alerted to completion.
this is only meaningful if the set_alerted() method is used when the buffer is first found to be finished.
Implements buffer_base.
Definition at line 123 of file linked_buffer.cpp.
References buffer::owner_alerted().
| void linked_buffer::set_alerted | ( | bool | owner_alerted | ) | [virtual] |
records that the owner was alerted, if "owner_alerted" is true.
Implements buffer_base.
Definition at line 125 of file linked_buffer.cpp.
References buffer::set_alerted().
| void linked_buffer::get_attachment | ( | byte_array & | storage | ) | const [virtual] |
the attachment allows extra information to be stored with each buffer.
Implements buffer_base.
Definition at line 127 of file linked_buffer.cpp.
References buffer::get_attachment().
| void linked_buffer::set_attachment | ( | const byte_array & | new_attachment | ) | [virtual] |
sets the attachment, which is empty until this is used.
Implements buffer_base.
Definition at line 129 of file linked_buffer.cpp.
References buffer::set_attachment().
| span_manager linked_buffer::buffer_status | ( | ) | const [virtual] |
allows a peek at the object tracking our packet statuses.
Implements buffer_base.
Definition at line 131 of file linked_buffer.cpp.
References buffer::buffer_status().
| int_array linked_buffer::packet_sizes | ( | ) | const [virtual] |
returns a list of the sizes of the packets for this buffer.
Implements buffer_base.
Definition at line 133 of file linked_buffer.cpp.
References buffer::packet_sizes().
1.5.1