fsfw/container/FIFO.h

36 lines
824 B
C
Raw Normal View History

2020-09-01 12:54:33 +02:00
#ifndef FSFW_CONTAINER_FIFO_H_
#define FSFW_CONTAINER_FIFO_H_
2020-08-28 18:33:29 +02:00
2020-09-01 12:48:51 +02:00
#include "FIFOBase.h"
2020-08-28 18:33:29 +02:00
#include <array>
/**
* @brief Simple First-In-First-Out data structure with size fixed at
* compile time
* @details
* Performs no dynamic memory allocation.
* The public interface of FIFOBase exposes the user interface for the FIFO.
* @tparam T Entry Type
* @tparam capacity Maximum capacity
*/
template<typename T, size_t capacity>
class FIFO: public FIFOBase<T> {
public:
2020-09-01 12:54:33 +02:00
FIFO(): FIFOBase<T>(nullptr, capacity) {
this->setContainer(fifoArray.data());
};
2020-08-28 18:33:29 +02:00
/**
* @brief Custom copy constructor to set pointer correctly.
* @param other
*/
FIFO(const FIFO& other): FIFOBase<T>(other) {
2020-09-01 12:54:33 +02:00
this->setContainer(fifoArray.data());
2020-08-28 18:33:29 +02:00
}
private:
std::array<T, capacity> fifoArray;
};
2020-09-01 12:54:33 +02:00
#endif /* FSFW_CONTAINER_FIFO_H_ */