21 #ifndef BT_CIRCULARBUFFER_H
22 #define BT_CIRCULARBUFFER_H
24 #include <ktorrent_export.h>
25 #include <util/constants.h>
34 class KTORRENT_EXPORT CircularBuffer
37 CircularBuffer(bt::Uint32 cap = 64 * 1024);
38 virtual ~CircularBuffer();
46 virtual bt::Uint32 read(bt::Uint8* ptr,bt::Uint32 max_len);
54 virtual bt::Uint32 write(
const bt::Uint8* ptr,bt::Uint32 len);
57 bool empty()
const {
return buf_size == 0;}
60 bool full()
const {
return buf_size == buf_capacity;}
63 bt::Uint32 size()
const {
return buf_size;}
66 bt::Uint32 capacity()
const {
return buf_capacity;}
69 bt::Uint32 available()
const {
return buf_capacity - buf_size;}
72 typedef std::pair<bt::Uint8*,bt::Uint32> Range;
80 bt::Uint32 buf_capacity;
87 #endif // BT_CIRCULARBUFFER_H