ringbuffer.h

Go to the documentation of this file.
00001 /***************************************************************************
00002                           ringbuffer.h  -  description
00003                              -------------------
00004     begin                : Sun March 21 2004
00005     copyright            : (C) 2004 by Martin Witte
00006     email                : witte@kawo1.rwth-aachen.de
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 #ifndef _KRADIO_RING_BUFFER_H
00019 #define _KRADIO_RING_BUFFER_H
00020 
00021 #ifdef HAVE_CONFIG_H
00022 #include <config.h>
00023 #endif
00024 
00025 #include <sys/types.h>
00026 
00027 class RingBuffer
00028 {
00029 public:
00030     RingBuffer(size_t size);
00031     ~RingBuffer();
00032 
00033     bool       resize(size_t new_size);
00034 
00035     size_t   addData (const char *src, size_t size);
00036     size_t   takeData(char *dst, size_t size);
00037 
00038     char      *getFreeSpace(size_t &size);
00039     size_t     removeFreeSpace(size_t size);
00040 
00041     char      *getData(size_t &size);
00042     size_t     removeData(size_t size);
00043 
00044     size_t    getSize()     const { return m_Size; }
00045     size_t    getFillSize() const { return m_FillSize; }
00046     size_t    getFreeSize() const { return m_Size - m_FillSize; }
00047 
00048     void       clear();
00049 
00050 protected:
00051 
00052     char     *m_Buffer;
00053     size_t    m_Start;
00054     size_t    m_Size,
00055               m_FillSize;
00056 };
00057 
00058 #endif

Generated on Fri Jan 28 16:28:08 2011 for kradio by  doxygen 1.4.7