00001 #ifndef BUFFER_CLASS 00002 #define BUFFER_CLASS 00003 00004 /*****************************************************************************\ 00005 * * 00006 * Name : buffer * 00007 * Author : Chris Koeritz * 00008 * * 00009 ******************************************************************************* 00010 * Copyright (c) 1992-$now By Author. This program is free software; you can * 00011 * redistribute it and/or modify it under the terms of the GNU General Public * 00012 * License as published by the Free Software Foundation; either version 2 of * 00013 * the License or (at your option) any later version. This is online at: * 00014 * http://www.fsf.org/copyleft/gpl.html * 00015 * Please send any updates to: fred@gruntose.com * 00016 \*****************************************************************************/ 00017 00018 #include "buffer_base.h" 00019 #include "dll_buffers.h" 00020 00021 // forward: 00022 class buffer_pack_array; 00023 class span_manager; 00024 00026 00031 class BUFFERS_CLASS_STYLE buffer : public buffer_base 00032 { 00033 public: 00034 buffer(const buffer_key &key, byte_array &contents, int packet_size); 00036 00040 buffer(const buffer_key &key, int total_packets, int maximum_packet); 00042 00048 buffer(const buffer_key &key, const buffer_base &to_copy); 00050 00052 virtual ~buffer(); 00054 00055 IMPLEMENT_CLASS_NAME("buffer"); 00056 00057 virtual bool alive() const; 00059 00060 virtual int packets() const; 00062 00063 virtual buffer_key key() const; 00064 virtual void set_key(const buffer_key &to_set); 00066 00067 virtual outcome store_packet(int packet_number, const byte_array &buffer); 00069 00072 virtual byte_array get_packet(int packet_number) const; 00074 00076 virtual int packet_length(int packet_number) const; 00078 00079 virtual bool whole() const; 00081 00082 virtual bool empty() const; 00084 00085 virtual int full_length(int offset = 0) const; 00087 00092 virtual int guess_size(int offset = 0); 00094 00100 virtual bool did_estimate() const; 00102 virtual void reset_estimate(); 00104 virtual int estimate() const; 00105 00106 virtual outcome dump(byte_array &storage_location, int offset = 0); 00108 00115 virtual void release(int packet_number, 00116 release_style status_handling = KEEP_STATUS); 00118 00123 virtual void release(); 00125 00126 virtual istring text_form() const; 00128 00129 virtual istring detailed_form(bool really_detailed = false) const; 00131 00134 virtual time_stamp last_add() const; 00136 virtual void set_last_add(const time_stamp &new_last_add); 00138 00139 virtual bool owner_alerted() const; 00141 virtual void set_alerted(bool owner_alerted); 00143 00144 virtual void get_attachment(byte_array &storage) const; 00146 virtual void set_attachment(const byte_array &new_attachment); 00148 00150 virtual span_manager buffer_status() const; 00152 virtual int_array packet_sizes() const; 00154 00155 // reference count management: we record the references in terms of 00156 // connection identifiers. 00157 00158 int references() const; 00160 int_set get_references() const; 00162 void add_reference(int conn_id); 00164 void remove_reference(int conn_id); 00166 00167 private: 00168 mutex *_lock; 00169 bool _owner_alerted; 00170 bool _alive; 00171 int _maximum_packet; 00172 buffer_key *_key; 00173 byte_array *_actual_storage; 00175 00178 bool _is_storage_active; 00180 time_stamp *_last_add; 00182 byte_array *_attachment; 00184 buffer_pack_array *_packet_list; 00186 00188 span_manager *_buffer_status; 00190 int _estimation; 00191 int_set *_references; 00192 00193 // disallowed operations. 00194 buffer(const buffer &unused); 00195 buffer &operator =(const buffer &unused); 00196 }; 00197 00198 #endif 00199
1.5.1