summaryrefslogtreecommitdiff
path: root/src/buffer.hh
diff options
context:
space:
mode:
authorJoel Klinghed <the_jk@yahoo.com>2017-02-28 21:50:44 +0100
committerJoel Klinghed <the_jk@yahoo.com>2017-02-28 21:50:44 +0100
commitc029d90d1975e124d237605f1edb2be16bd05b5d (patch)
tree9df87ffb365354bdb74a969440b32c8304bdbcb7 /src/buffer.hh
Initial commit
Diffstat (limited to 'src/buffer.hh')
-rw-r--r--src/buffer.hh30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/buffer.hh b/src/buffer.hh
new file mode 100644
index 0000000..92a7566
--- /dev/null
+++ b/src/buffer.hh
@@ -0,0 +1,30 @@
+// -*- mode: c++; c-basic-offset: 2; -*-
+
+#ifndef BUFFER_HH
+#define BUFFER_HH
+
+#include <cstddef>
+
+class Buffer {
+public:
+ virtual ~Buffer() {}
+
+ static Buffer* create(size_t capacity, size_t min_avail);
+
+ bool empty() const;
+
+ virtual void const* read_ptr(size_t* avail) const = 0;
+ virtual void consume(size_t bytes) = 0;
+
+ virtual void* write_ptr(size_t* avail) = 0;
+ virtual void commit(size_t bytes) = 0;
+
+ size_t read(void* data, size_t max);
+ void write(void const* data, size_t size);
+
+protected:
+ Buffer() {}
+ Buffer(Buffer const&) = delete;
+};
+
+#endif // BUFFER_HH