FIFO is StaticFIFO now, new FIFO using vector #127

Merged
gaisser merged 21 commits from KSat/fsfw:mueller_FIFO_static_normal into master 2020-09-01 13:09:00 +02:00
4 changed files with 36 additions and 48 deletions
Showing only changes of commit 5f76b03f3a - Show all commits

27
container/DynamicFIFO.h Normal file
View File

@ -0,0 +1,27 @@
#ifndef FRAMEWORK_CONTAINER_DYNAMICFIFO_H_
#define FRAMEWORK_CONTAINER_DYNAMICFIFO_H_
#include <framework/container/FIFOBase.h>
#include <vector>
/**
* @brief Simple First-In-First-Out data structure. The maximum size
* 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.
* @tparam T Entry Type
* @tparam capacity Maximum capacity
*/
template<typename T>
class DynamicFIFO: public FIFOBase<T> {
public:
DynamicFIFO(size_t maxCapacity): FIFOBase<T>(values.data(), maxCapacity),
values(maxCapacity) {};
private:
std::vector<T> values;
};
#endif /* FRAMEWORK_CONTAINER_DYNAMICFIFO_H_ */

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_ */

View File

@ -4,8 +4,6 @@
#include <framework/returnvalues/HasReturnvaluesIF.h>
#include <cstddef>
namespace fsfw {
template <typename T>
class FIFOBase {
public:
@ -60,6 +58,4 @@ private:
#include <framework/container/FIFOBase.tpp>
}
#endif /* FRAMEWORK_CONTAINER_FIFOBASE_H_ */

View File

@ -1,30 +0,0 @@
#ifndef FRAMEWORK_CONTAINER_STATICFIFO_H_
#define FRAMEWORK_CONTAINER_STATICFIFO_H_
#include <framework/returnvalues/HasReturnvaluesIF.h>
#include <framework/container/FIFOBase.h>
#include <array>
namespace fsfw {
/**
* @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 StaticFIFO: public FIFOBase<T> {
public:
StaticFIFO(): FIFOBase<T>(values.data(), capacity) {};
private:
std::array<T, capacity> values;
};
}
#endif /* FRAMEWORK_CONTAINERS_STATICFIFO_H_ */