2020-07-05 23:53:13 +02:00
|
|
|
#ifndef FRAMEWORK_CONTAINER_FIFO_H_
|
|
|
|
#define FRAMEWORK_CONTAINER_FIFO_H_
|
2016-06-15 23:48:41 +02:00
|
|
|
|
2020-07-05 23:53:13 +02:00
|
|
|
#include <framework/container/FIFOBase.h>
|
|
|
|
#include <vector>
|
2016-06-15 23:48:41 +02:00
|
|
|
|
2020-07-06 13:41:07 +02:00
|
|
|
namespace fsfw {
|
|
|
|
|
2020-04-23 15:03:55 +02:00
|
|
|
/**
|
2020-07-05 23:53:13 +02:00
|
|
|
* @brief Simple First-In-First-Out data structure. The maximum size
|
2020-07-06 13:41:07 +02:00
|
|
|
* can be set in the constructor.
|
|
|
|
* @details
|
|
|
|
* The maximum capacity can be determined at run-time, so this container
|
|
|
|
* performs dynamic memory allocation!
|
|
|
|
* The public interface of FIFOBase exposes the user interface for the FIFO.
|
2020-04-23 15:03:55 +02:00
|
|
|
* @tparam T Entry Type
|
|
|
|
* @tparam capacity Maximum capacity
|
|
|
|
*/
|
2020-07-05 23:53:13 +02:00
|
|
|
template<typename T>
|
|
|
|
class FIFO: public FIFOBase<T> {
|
2016-06-15 23:48:41 +02:00
|
|
|
public:
|
2020-07-05 23:53:13 +02:00
|
|
|
FIFO(size_t maxCapacity): FIFOBase<T>(values.data(), maxCapacity) {
|
|
|
|
values.reserve(maxCapacity);
|
|
|
|
values.resize(maxCapacity);
|
|
|
|
};
|
2016-06-15 23:48:41 +02:00
|
|
|
|
2020-07-05 23:53:13 +02:00
|
|
|
private:
|
|
|
|
std::vector<T> values;
|
2016-06-15 23:48:41 +02:00
|
|
|
};
|
|
|
|
|
2020-07-06 13:41:07 +02:00
|
|
|
}
|
|
|
|
|
2020-07-05 23:53:13 +02:00
|
|
|
#endif /* FRAMEWORK_CONTAINER_FIFO_H_ */
|