FIFO updates
This commit is contained in:
parent
a634875b4b
commit
bec562ece0
@ -22,7 +22,7 @@ public:
|
|||||||
// trying to pass the pointer of the uninitialized vector
|
// trying to pass the pointer of the uninitialized vector
|
||||||
// to the FIFOBase constructor directly lead to a super evil bug.
|
// to the FIFOBase constructor directly lead to a super evil bug.
|
||||||
// So we do it like this now.
|
// So we do it like this now.
|
||||||
this->setData(fifoVector.data());
|
this->setContainer(fifoVector.data());
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -31,7 +31,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
DynamicFIFO(const DynamicFIFO& other): FIFOBase<T>(other),
|
DynamicFIFO(const DynamicFIFO& other): FIFOBase<T>(other),
|
||||||
fifoVector(other.maxCapacity) {
|
fifoVector(other.maxCapacity) {
|
||||||
this->setData(fifoVector.data());
|
this->setContainer(fifoVector.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#ifndef FRAMEWORK_CONTAINER_FIFO_H_
|
#ifndef FSFW_CONTAINER_FIFO_H_
|
||||||
#define FRAMEWORK_CONTAINER_FIFO_H_
|
#define FSFW_CONTAINER_FIFO_H_
|
||||||
|
|
||||||
#include "FIFOBase.h"
|
#include "FIFOBase.h"
|
||||||
#include <array>
|
#include <array>
|
||||||
@ -16,18 +16,20 @@
|
|||||||
template<typename T, size_t capacity>
|
template<typename T, size_t capacity>
|
||||||
class FIFO: public FIFOBase<T> {
|
class FIFO: public FIFOBase<T> {
|
||||||
public:
|
public:
|
||||||
FIFO(): FIFOBase<T>(fifoArray.data(), capacity) {};
|
FIFO(): FIFOBase<T>(nullptr, capacity) {
|
||||||
|
this->setContainer(fifoArray.data());
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Custom copy constructor to set pointer correctly.
|
* @brief Custom copy constructor to set pointer correctly.
|
||||||
* @param other
|
* @param other
|
||||||
*/
|
*/
|
||||||
FIFO(const FIFO& other): FIFOBase<T>(other) {
|
FIFO(const FIFO& other): FIFOBase<T>(other) {
|
||||||
this->setData(fifoArray.data());
|
this->setContainer(fifoArray.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::array<T, capacity> fifoArray;
|
std::array<T, capacity> fifoArray;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* FRAMEWORK_CONTAINERS_STATICFIFO_H_ */
|
#endif /* FSFW_CONTAINER_FIFO_H_ */
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#ifndef FRAMEWORK_CONTAINER_FIFOBASE_H_
|
#ifndef FSFW_CONTAINER_FIFOBASE_H_
|
||||||
#define FRAMEWORK_CONTAINER_FIFOBASE_H_
|
#define FSFW_CONTAINER_FIFOBASE_H_
|
||||||
|
|
||||||
#include "../returnvalues/HasReturnvaluesIF.h"
|
#include "../returnvalues/HasReturnvaluesIF.h"
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
@ -48,7 +48,7 @@ public:
|
|||||||
size_t getMaxCapacity() const;
|
size_t getMaxCapacity() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void setData(T* data);
|
void setContainer(T* data);
|
||||||
size_t maxCapacity = 0;
|
size_t maxCapacity = 0;
|
||||||
|
|
||||||
T* values;
|
T* values;
|
||||||
@ -60,6 +60,6 @@ protected:
|
|||||||
size_t next(size_t current);
|
size_t next(size_t current);
|
||||||
};
|
};
|
||||||
|
|
||||||
#include "../container/FIFOBase.tpp"
|
#include "FIFOBase.tpp"
|
||||||
|
|
||||||
#endif /* FRAMEWORK_CONTAINER_FIFOBASE_H_ */
|
#endif /* FSFW_CONTAINER_FIFOBASE_H_ */
|
||||||
|
@ -80,7 +80,7 @@ inline size_t FIFOBase<T>::getMaxCapacity() const {
|
|||||||
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline void FIFOBase<T>::setData(T *data) {
|
inline void FIFOBase<T>::setContainer(T *data) {
|
||||||
this->values = data;
|
this->values = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user