From 6a6395313f8dce6ec9693acddb6b93d3cda9549a Mon Sep 17 00:00:00 2001
From: "Robin.Mueller" <robin.mueller.m@gmail.com>
Date: Sat, 11 Jul 2020 01:06:01 +0200
Subject: [PATCH] added copy ctor and assignment for FIFObase

---
 container/DynamicFIFO.h |  2 +-
 container/FIFOBase.h    | 18 ++++++++++++++++++
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/container/DynamicFIFO.h b/container/DynamicFIFO.h
index 3a5242c7..fca4c8e8 100644
--- a/container/DynamicFIFO.h
+++ b/container/DynamicFIFO.h
@@ -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;
diff --git a/container/FIFOBase.h b/container/FIFOBase.h
index 8bdb333f..082c596a 100644
--- a/container/FIFOBase.h
+++ b/container/FIFOBase.h
@@ -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: