fifo tweaks
This commit is contained in:
parent
e9166ec4c7
commit
5f76b03f3a
27
container/DynamicFIFO.h
Normal file
27
container/DynamicFIFO.h
Normal 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_ */
|
@ -1,31 +1,26 @@
|
|||||||
#ifndef FRAMEWORK_CONTAINER_FIFO_H_
|
#ifndef FRAMEWORK_CONTAINER_FIFO_H_
|
||||||
#define FRAMEWORK_CONTAINER_FIFO_H_
|
#define FRAMEWORK_CONTAINER_FIFO_H_
|
||||||
|
|
||||||
|
#include <framework/returnvalues/HasReturnvaluesIF.h>
|
||||||
#include <framework/container/FIFOBase.h>
|
#include <framework/container/FIFOBase.h>
|
||||||
#include <vector>
|
#include <array>
|
||||||
|
|
||||||
namespace fsfw {
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Simple First-In-First-Out data structure. The maximum size
|
* @brief Simple First-In-First-Out data structure with size fixed at
|
||||||
* can be set in the constructor.
|
* compile time
|
||||||
* @details
|
* @details
|
||||||
* The maximum capacity can be determined at run-time, so this container
|
* Performs no dynamic memory allocation.
|
||||||
* performs dynamic memory allocation!
|
|
||||||
* The public interface of FIFOBase exposes the user interface for the FIFO.
|
* The public interface of FIFOBase exposes the user interface for the FIFO.
|
||||||
* @tparam T Entry Type
|
* @tparam T Entry Type
|
||||||
* @tparam capacity Maximum capacity
|
* @tparam capacity Maximum capacity
|
||||||
*/
|
*/
|
||||||
template<typename T>
|
template<typename T, size_t capacity>
|
||||||
class FIFO: public FIFOBase<T> {
|
class FIFO: public FIFOBase<T> {
|
||||||
public:
|
public:
|
||||||
FIFO(size_t maxCapacity): FIFOBase<T>(values.data(), maxCapacity),
|
FIFO(): FIFOBase<T>(values.data(), capacity) {};
|
||||||
values(maxCapacity) {};
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<T> values;
|
std::array<T, capacity> values;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
#endif /* FRAMEWORK_CONTAINERS_STATICFIFO_H_ */
|
||||||
|
|
||||||
#endif /* FRAMEWORK_CONTAINER_FIFO_H_ */
|
|
||||||
|
@ -4,8 +4,6 @@
|
|||||||
#include <framework/returnvalues/HasReturnvaluesIF.h>
|
#include <framework/returnvalues/HasReturnvaluesIF.h>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
|
||||||
namespace fsfw {
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
class FIFOBase {
|
class FIFOBase {
|
||||||
public:
|
public:
|
||||||
@ -60,6 +58,4 @@ private:
|
|||||||
|
|
||||||
#include <framework/container/FIFOBase.tpp>
|
#include <framework/container/FIFOBase.tpp>
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* FRAMEWORK_CONTAINER_FIFOBASE_H_ */
|
#endif /* FRAMEWORK_CONTAINER_FIFOBASE_H_ */
|
||||||
|
@ -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_ */
|
|
Loading…
x
Reference in New Issue
Block a user