aboutsummaryrefslogtreecommitdiff
path: root/src/queuebuf.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/queuebuf.h')
-rw-r--r--src/queuebuf.h62
1 files changed, 62 insertions, 0 deletions
diff --git a/src/queuebuf.h b/src/queuebuf.h
new file mode 100644
index 0000000..3591959
--- /dev/null
+++ b/src/queuebuf.h
@@ -0,0 +1,62 @@
1/*
2 * Copyright (C) 2007-2010 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libbu++ library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
8#ifndef BU_QUEUE_BUF_H
9#define BU_QUEUE_BUF_H
10
11#include "bu/stream.h"
12
13namespace Bu
14{
15 /**
16 * A queuing buffer stream class. All data written to this class is
17 * appended to it, there is no stored position. All data read is read
18 * from the begining and then thrown away. It operates by using a linked
19 * list of small buffers, and deallocating or reusing them when it can.
20 */
21 class QueueBuf : public Bu::Stream
22 {
23 public:
24 QueueBuf( int iBlockSize=256 );
25 virtual ~QueueBuf();
26
27 int getSize();
28
29 virtual void close();
30 virtual size_t read( void *pBuf, size_t nBytes );
31 virtual size_t peek( void *pBuf, size_t nBytes );
32 virtual size_t write( const void *pBuf, size_t nBytes );
33 virtual long tell();
34 virtual void seek( long offset );
35 virtual void setPos( long pos );
36 virtual void setPosEnd( long pos );
37 virtual bool isEos();
38 virtual bool isOpen();
39 virtual void flush();
40 virtual bool canRead();
41 virtual bool canWrite();
42 virtual bool isReadable();
43 virtual bool isWritable();
44 virtual bool isSeekable();
45 virtual bool isBlocking();
46 virtual void setBlocking( bool bBlocking=true );
47
48 private:
49 void addBlock();
50 void removeBlock();
51
52 private:
53 int iBlockSize;
54 int iReadOffset;
55 int iWriteOffset;
56 size_t iTotalSize;
57 typedef Bu::List<char *> BlockList;
58 BlockList lBlocks;
59 };
60};
61
62#endif