1
0
forked from fsfw/fsfw

fifo replacements

This commit is contained in:
2020-07-07 17:42:37 +02:00
parent dd48f7ccad
commit 399fc0e287
10 changed files with 48 additions and 61 deletions

View File

@ -1,31 +1,26 @@
#ifndef FRAMEWORK_CONTAINER_FIFO_H_
#define FRAMEWORK_CONTAINER_FIFO_H_
#include <framework/returnvalues/HasReturnvaluesIF.h>
#include <framework/container/FIFOBase.h>
#include <vector>
namespace fsfw {
#include <array>
/**
* @brief Simple First-In-First-Out data structure. The maximum size
* can be set in the constructor.
* @brief Simple First-In-First-Out data structure with size fixed at
* compile time
* @details
* The maximum capacity can be determined at run-time, so this container
* performs dynamic memory allocation!
* 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>
template<typename T, size_t capacity>
class FIFO: public FIFOBase<T> {
public:
FIFO(size_t maxCapacity): FIFOBase<T>(values.data(), maxCapacity),
values(maxCapacity) {};
FIFO(): FIFOBase<T>(values.data(), capacity) {};
private:
std::vector<T> values;
std::array<T, capacity> values;
};
}
#endif /* FRAMEWORK_CONTAINER_FIFO_H_ */
#endif /* FRAMEWORK_CONTAINERS_STATICFIFO_H_ */