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