Commit 40906cb1 authored by Hrvoje's avatar Hrvoje

Update documentation

parent a9987d2a
/**
* @file RingBuffer.h
* @author Dino Sharich (dino@aconno.de)
* @author Hrvoje Brezak (hrvoje@aconno.de)
* @brief Class implementing FIFO buffer with limited size.
* @version v0.1
* @date 2020-07-27
* @version v0.2
* @date 2020-09-30
*
* @copyright aconno GmbH (c) 2020
*
......@@ -30,9 +31,10 @@ namespace Collections
//------------------------- NAMESPACE STRUCTURES ------------------------------
//---------------------------- CLASS DEFINITION -------------------------------
/**
* @brief Class implementing FIFO buffer with limited size.
*
* @details Buffer stops filling when full, does not overwrite oldest elements.
*/
template<typename T, size_t N>
class RingBuffer {
......
/**
* @file RingBuffer.cpp
* @author Dino Sharich (dino@aconno.de)
* @brief Class wrapping linux pipes, which are a FIFO buffer.
* @version v0.1
* @date 2020-07-27
* @author Hrvoje Brezak (hrvoje@aconno.de)
* @brief Class implementing FIFO buffer with limited size.
* @version v0.2
* @date 2020-09-30
*
* @copyright aconno GmbH (c) 2020
*
......@@ -14,10 +15,11 @@
//--------------------------- EXPOSED FUNCTIONS --------------------------------
/**
* @brief Reads from the the container in a blocking way. Element is removed
* from the buffer.
* @brief Return oldest element of the buffer and discard it from buffer.
*
* @param element[out] Returns oldest element from the ring buffer.
*
* @return Oldest element from the ring buffer.
* @return Error::Empty if empty, else Error::None
*/
template<typename T, size_t N>
Error::Code Collections::RingBuffer<T, N>::pop(T& element)
......@@ -35,10 +37,11 @@ Error::Code Collections::RingBuffer<T, N>::pop(T& element)
}
/**
* @brief Reads from the the container in a blocking way. Element is not
* removed from the buffer.
* @brief Return oldest element of the buffer and leave it in the buffer.
*
* @param element[out] Returns oldest element from the ring buffer.
*
* @return Oldest element from the ring buffer.
* @return Error::Empty if empty, else Error::None
*/
template<typename T, size_t N>
Error::Code Collections::RingBuffer<T, N>::peek(T& element)
......@@ -53,10 +56,13 @@ Error::Code Collections::RingBuffer<T, N>::peek(T& element)
}
/**
* @brief Write to the container, doesn't block, if there is no room removes
* the oldest element.
* @brief Insert new element into the buffer.
*
* @details If buffer is full, returns error. Does not overwrite older elements.
*
* @param element[in] Element to write into the container.
* @param element[in] Element to write into the buffer.
*
* @return Error::MaxReached if full, else Error::None
*/
template<typename T, size_t N>
Error::Code Collections::RingBuffer<T, N>::push(const T& element)
......@@ -75,18 +81,33 @@ Error::Code Collections::RingBuffer<T, N>::push(const T& element)
return Error::None;
}
/**
* @brief Query if buffer is empty.
*
* @return 'true' if buffer is empty, 'false' if it contains elements
*/
template<typename T, size_t N>
bool Collections::RingBuffer<T, N>::isEmpty()
{
return (popI == pushI) && !isFullVar;
}
/**
* @brief Query if buffer is full.
*
* @return 'true' if buffer is full, 'false' if still has available slots
*/
template<typename T, size_t N>
bool Collections::RingBuffer<T, N>::isFull()
{
return isFullVar;
}
/**
* @brief Reset buffer to empty state.
*
* @return None.
*/
template<typename T, size_t N>
void Collections::RingBuffer<T, N>::reset()
{
......@@ -95,6 +116,11 @@ void Collections::RingBuffer<T, N>::reset()
isFullVar = false;
}
/**
* @brief Query current number of elements in the buffer.
*
* @return Number of elements in the buffer.
*/
template<typename T, size_t N>
size_t Collections::RingBuffer<T, N>::getCurrentSize()
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment