From ceac394c2133d44e81db2eb633ff54a9ad6ce7c5 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Thu, 10 Nov 2005 05:52:11 +0000 Subject: This commit was generated by cvs2svn to compensate for changes in r3865, which included commits to RCS files with non-trunk default branches. svn path=/trunk/extensions/gripd/; revision=3866 --- src/midiio/include/CircularBuffer.h | 66 +++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 src/midiio/include/CircularBuffer.h (limited to 'src/midiio/include/CircularBuffer.h') diff --git a/src/midiio/include/CircularBuffer.h b/src/midiio/include/CircularBuffer.h new file mode 100644 index 0000000..6bb3071 --- /dev/null +++ b/src/midiio/include/CircularBuffer.h @@ -0,0 +1,66 @@ +// +// Copyright 1997-1998 by Craig Stuart Sapp, All Rights Reserved. +// Programmer: Craig Stuart Sapp +// Creation Date: 19 December 1997 +// Last Modified: Wed Jan 21 23:08:13 GMT-0800 1998 +// Filename: ...sig/maint/code/base/CircularBuffer/CircularBuffer.h +// Web Address: http://sig.sapp.org/include/sigBase/CircularBuffer.cpp +// Documentation: http://sig.sapp.org/doc/classes/CircularBuffer +// Syntax: C++ +// +// Description: A Circular buffer designed to handle MIDI input, +// but able to store any type of object. Elements +// can be read out of the buffer in two ways. +// (1) from a read pointer which extracts the +// elements in order by following the write pointer, +// and (2) from an index operator related to the +// write pointer's location, for example, +// object[0] is the last value written into the +// buffer and object[-1] (or object[1]) is the +// item written just before that. +// + +#ifndef _CIRCULARBUFFER_H_INCLUDED +#define _CIRCULARBUFFER_H_INCLUDED + + +template +class CircularBuffer { + public: + CircularBuffer (void); + CircularBuffer (int maxElements); + CircularBuffer (const CircularBuffer& + anotherBuffer); + ~CircularBuffer (); + + int capacity (void) const; + type extract (void); + int getCount (void) const; + int getSize (void) const; + void insert (const type& aMessage); + type& operator[] (int index); + type read (void); + void reset (void); + void setSize (int aSize); + void write (const type& aMessage); + + protected: + type* buffer; + int size; + int writeIndex; + int readIndex; + int itemCount; + + void increment (int& index); +}; + + +#include "CircularBuffer.cpp" + + + +#endif /* _CIRCULARBUFFER_H_INCLUDED */ + + + +// md5sum: 2857693ec37fdcb6df09db479faf110b - CircularBuffer.h =css= 20030102 -- cgit v1.2.1