#ifndef __CIRCULARBUFFER_HPP__
#define __CIRCULARBUFFER_HPP__

class CircularBuffer
{
public:
	CircularBuffer();
	CircularBuffer(uint count);

	void Resize(uint count);

	uint MaxReadBytes();
	uint MaxWriteBytes();

	// use these for fast access when each block is guaranteed not to wrap (wrapping operations will assert in debug mode).
	uint MaxContiguousReadBytes();
	byte *GetContiguousWritePointer(uint count);
	byte *GetContiguousReadPointer(uint count);
	byte *PeekContiguousReadPointer(uint count);

	void Peek(byte *destination, uint count);
	void Read(byte *destination, uint count);
	void Write(byte *data, uint count);
	void Clear();

private:
	byte *buffer;
	uint buffer_size;
	uint write_pos;
	uint read_pos;
	uint bytes_used;
};

#endif // __CIRCULARBUFFER_HPP__