diff options
| author | Michele Calgaro <michele.calgaro@yahoo.it> | 2022-05-30 19:40:31 +0900 | 
|---|---|---|
| committer | Slávek Banko <slavek.banko@axis.cz> | 2022-05-30 21:55:12 +0200 | 
| commit | 9d7329284fd42187092c829ae6ed030561002776 (patch) | |
| tree | 1d53503d17938eca725caee7ff783fccf52ca509 /src/include/ringbuffer.h | |
| parent | fac82f62f156c76cb4b23c313111283b30a778b5 (diff) | |
| download | tderadio-9d7329284fd42187092c829ae6ed030561002776.tar.gz tderadio-9d7329284fd42187092c829ae6ed030561002776.zip  | |
Standardize folder structure.
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
(cherry picked from commit d95a4fea540b371fa86493d069fdbd54f33c5b40)
Diffstat (limited to 'src/include/ringbuffer.h')
| -rw-r--r-- | src/include/ringbuffer.h | 58 | 
1 files changed, 58 insertions, 0 deletions
diff --git a/src/include/ringbuffer.h b/src/include/ringbuffer.h new file mode 100644 index 0000000..1f545ca --- /dev/null +++ b/src/include/ringbuffer.h @@ -0,0 +1,58 @@ +/*************************************************************************** +                          ringbuffer.h  -  description +                             ------------------- +    begin                : Sun March 21 2004 +    copyright            : (C) 2004 by Martin Witte +    email                : witte@kawo1.rwth-aachen.de + ***************************************************************************/ + +/*************************************************************************** + *                                                                         * + *   This program is free software; you can redistribute it and/or modify  * + *   it under the terms of the GNU General Public License as published by  * + *   the Free Software Foundation; either version 2 of the License, or     * + *   (at your option) any later version.                                   * + *                                                                         * + ***************************************************************************/ + +#ifndef _KRADIO_RING_BUFFER_H +#define _KRADIO_RING_BUFFER_H + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <sys/types.h> + +class RingBuffer +{ +public: +    RingBuffer(size_t size); +    ~RingBuffer(); + +    bool       resize(size_t new_size); + +    size_t   addData (const char *src, size_t size); +    size_t   takeData(char *dst, size_t size); + +    char      *getFreeSpace(size_t &size); +    size_t     removeFreeSpace(size_t size); + +    char      *getData(size_t &size); +    size_t     removeData(size_t size); + +    size_t    getSize()     const { return m_Size; } +    size_t    getFillSize() const { return m_FillSize; } +    size_t    getFreeSize() const { return m_Size - m_FillSize; } + +    void       clear(); + +protected: + +    char     *m_Buffer; +    size_t    m_Start; +    size_t    m_Size, +              m_FillSize; +}; + +#endif  | 
