equal
deleted
inserted
replaced
1 #ifndef NETWORK_PACKET_HH |
1 #ifndef NETWORK_PACKET_HH |
2 #define NETWORK_PACKET_HH |
2 #define NETWORK_PACKET_HH |
|
3 |
|
4 /** |
|
5 * @file |
|
6 * |
|
7 * Provides the NetworkPackets that are used to communicate over a NetworkTCP/NetworkUDP sockets. |
|
8 */ |
3 |
9 |
4 #include "Config.hh" |
10 #include "Config.hh" |
5 #include "../Types.hh" |
11 #include "../Types.hh" |
6 #include "../Error.hh" |
12 #include "../Error.hh" |
7 |
13 |
99 */ |
105 */ |
100 class NetworkPacketOutput { |
106 class NetworkPacketOutput { |
101 protected: |
107 protected: |
102 /** |
108 /** |
103 * Adjust size of the most recent write_ptr area of buf_len bytes to data_len bytes. |
109 * Adjust size of the most recent write_ptr area of buf_len bytes to data_len bytes. |
|
110 * |
|
111 * You must not call write() between calls to write_ptr() and write_ptr_adjust(). This is only valid for the |
|
112 * most recent write_ptr() |
104 */ |
113 */ |
105 virtual void write_ptr_adjust (size_t buf_len, size_t data_len) = 0; |
114 virtual void write_ptr_adjust (size_t buf_len, size_t data_len) = 0; |
106 |
115 |
107 public: |
116 public: |
108 /** |
117 /** |
180 /** |
189 /** |
181 * Pointer to the packet data |
190 * Pointer to the packet data |
182 */ |
191 */ |
183 char *buf_ptr; |
192 char *buf_ptr; |
184 |
193 |
185 // the buffer size, the amount of data in the buffer, and the current read/write offset |
|
186 /** |
194 /** |
187 * The size of the memory region pointed to by buf_ptr |
195 * The size of the memory region pointed to by buf_ptr |
188 */ |
196 */ |
189 size_t buf_size; |
197 size_t buf_size; |
190 |
198 |
261 */ |
269 */ |
262 virtual size_t tell_remaining (void); |
270 virtual size_t tell_remaining (void); |
263 |
271 |
264 /* |
272 /* |
265 * Accessor functions, used by the actual socket code to read/write the buffer |
273 * Accessor functions, used by the actual socket code to read/write the buffer |
|
274 * |
|
275 * XXX: own abstract class for these? Virtual methods <3 |
266 */ |
276 */ |
267 char* get_buf (void) { return buf_ptr; } |
277 char* get_buf (void) { return buf_ptr; } |
268 const char* get_buf (void) const { return buf_ptr; } |
278 const char* get_buf (void) const { return buf_ptr; } |
269 size_t get_data_size (void) const { return data_size; } |
279 size_t get_data_size (void) const { return data_size; } |
270 size_t get_buf_size (void) const { return buf_size; } |
280 size_t get_buf_size (void) const { return buf_size; } |