added copy ctor and assignment for FIFObase
This commit is contained in:
parent
444ee80f35
commit
6a6395313f
@ -18,7 +18,7 @@ template<typename T>
|
||||
class DynamicFIFO: public FIFOBase<T> {
|
||||
public:
|
||||
DynamicFIFO(size_t maxCapacity): FIFOBase<T>(values.data(), maxCapacity),
|
||||
values(maxCapacity) {};
|
||||
values(maxCapacity) {};
|
||||
|
||||
private:
|
||||
std::vector<T> values;
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
#include <framework/returnvalues/HasReturnvaluesIF.h>
|
||||
#include <cstddef>
|
||||
#include <cstring>
|
||||
|
||||
template <typename T>
|
||||
class FIFOBase {
|
||||
@ -43,6 +44,23 @@ 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:
|
||||
|
Loading…
Reference in New Issue
Block a user