Merge pull request 'fifo enhancement' (#57) from KSat/fsfw:mueller_fifo_enhancement into master

Implements #57
This commit is contained in:
Steffen Gaisser 2020-05-25 14:48:29 +02:00
commit 5e91363d2d

View File

@ -3,6 +3,11 @@
#include <framework/returnvalues/HasReturnvaluesIF.h>
/**
* @brief Simple First-In-First-Out data structure
* @tparam T Entry Type
* @tparam capacity Maximum capacity
*/
template<typename T, uint8_t capacity>
class FIFO {
private:
@ -54,6 +59,21 @@ public:
return HasReturnvaluesIF::RETURN_OK;
}
}
ReturnValue_t peek(T * value) {
if(empty()) {
return EMPTY;
} else {
*value = data[readIndex];
return HasReturnvaluesIF::RETURN_OK;
}
}
ReturnValue_t pop() {
T value;
return this->retrieve(&value);
}
static const uint8_t INTERFACE_ID = CLASS_ID::FIFO_CLASS;
static const ReturnValue_t FULL = MAKE_RETURN_CODE(1);
static const ReturnValue_t EMPTY = MAKE_RETURN_CODE(2);