#ifndef FSFW_CONTAINER_FIFOBASE_TPP_ #define FSFW_CONTAINER_FIFOBASE_TPP_ #ifndef FSFW_CONTAINER_FIFOBASE_H_ #error Include FIFOBase.h before FIFOBase.tpp! #endif template inline FIFOBase::FIFOBase(T* values, const size_t maxCapacity) : maxCapacity(maxCapacity), values(values){}; template inline ReturnValue_t FIFOBase::insert(T value) { if (full()) { return FULL; } else { values[writeIndex] = value; writeIndex = next(writeIndex); ++currentSize; return HasReturnvaluesIF::RETURN_OK; } }; template inline ReturnValue_t FIFOBase::retrieve(T* value) { if (empty()) { return EMPTY; } else { if (value == nullptr) { return HasReturnvaluesIF::RETURN_FAILED; } *value = values[readIndex]; readIndex = next(readIndex); --currentSize; return HasReturnvaluesIF::RETURN_OK; } }; template inline ReturnValue_t FIFOBase::peek(T* value) { if (empty()) { return EMPTY; } else { if (value == nullptr) { return HasReturnvaluesIF::RETURN_FAILED; } *value = values[readIndex]; return HasReturnvaluesIF::RETURN_OK; } }; template inline ReturnValue_t FIFOBase::pop() { T value; return this->retrieve(&value); }; template inline bool FIFOBase::empty() { return (currentSize == 0); }; template inline bool FIFOBase::full() { return (currentSize == maxCapacity); } template inline size_t FIFOBase::size() { return currentSize; } template inline size_t FIFOBase::next(size_t current) { ++current; if (current == maxCapacity) { current = 0; } return current; } template inline size_t FIFOBase::getMaxCapacity() const { return maxCapacity; } template inline void FIFOBase::setContainer(T* data) { this->values = data; } #endif