1
0
forked from fsfw/fsfw

dynamic fifo bug fixed

This commit is contained in:
2020-07-11 02:36:04 +02:00
parent 6a6395313f
commit 35d4267b40
5 changed files with 44 additions and 28 deletions

View File

@ -44,29 +44,15 @@ public:
bool full();
size_t size();
FIFOBase(const FIFOBase& other): readIndex(other.readIndex),
writeIndex(other.writeIndex), currentSize(other.currentSize),
maxCapacity(other.maxCapacity) {
std::memcpy(values, other.values, sizeof(T) * currentSize);
}
FIFOBase& operator=(const FIFOBase& other) {
if(&other == this)
return *this;
maxCapacity = other.maxCapacity;
readIndex = other.readIndex;
writeIndex = other.writeIndex;
currentSize = other.currentSize;
std::memcpy(values, other.values, sizeof(T) * currentSize);
return *this;
}
size_t getMaxCapacity() const;
private:
T* values;
protected:
void setData(T* data);
size_t maxCapacity = 0;
T* values;
size_t readIndex = 0;
size_t writeIndex = 0;
size_t currentSize = 0;