00001
00002
00003
00004 #ifndef DEV_W3_ORG__2001_BLINDFOLD_SRC_BYTEFIFO_H
00005 #define DEV_W3_ORG__2001_BLINDFOLD_SRC_BYTEFIFO_H
00006 #include "config.h"
00007
00008 #include "ByteSink.h"
00009 #include "ByteSource.h"
00010
00019 class ByteFIFO : public ByteSink, public ByteSource {
00020
00021 public:
00022
00023
00025
00026 ByteFIFO(const ByteFIFO& other);
00027 const ByteFIFO& operator=(const ByteFIFO& other);
00028 bool operator==(const ByteFIFO& other) const;
00029 bool operator<(const ByteFIFO& other) const;
00030 size_t hash() const;
00031 friend std::ostream& operator<<(std::ostream& s, const ByteFIFO& me);
00032 std::ostream& print_to(std::ostream& stream) const;
00033 ~ByteFIFO();
00034
00035
00036
00037 virtual size_t read(void* byteBuffer, size_t maxBytes);
00038 virtual void write(const void* byteBuffer, size_t numBytes);
00039 virtual void* peek();
00040 virtual size_t size() { return nextToWrite - nextToRead; }
00041 virtual void skip(size_t bytes);
00042
00043 private:
00044
00045 char *buffer;
00046 size_t bytesAllocated;
00047 char *nextToRead;
00048 char *nextToWrite;
00049
00050 void makeRoom(size_t additionalBytes);
00051 };
00052
00053
00054 STANDARD_EXTERNAL(ByteFIFO)
00055
00056 #endif