[libcamera-devel] [PATCH v6 3/5] ipa: raspberrypi: Add move/copy ctors and operators to Metadata class

Naushir Patuck naush at raspberrypi.com
Fri May 7 10:40:40 CEST 2021


Add a default, move and copy constructor as well as a move operator
implementation RPiController::Metadata class.

Signed-off-by: Naushir Patuck <naush at raspberrypi.com>
Reviewed-by: David Plowman <david.plowman at raspberrypi.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
---
 src/ipa/raspberrypi/controller/metadata.hpp | 24 +++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/src/ipa/raspberrypi/controller/metadata.hpp b/src/ipa/raspberrypi/controller/metadata.hpp
index 07dd28ed9e0a..319f2320fc70 100644
--- a/src/ipa/raspberrypi/controller/metadata.hpp
+++ b/src/ipa/raspberrypi/controller/metadata.hpp
@@ -19,6 +19,21 @@ namespace RPiController {
 class Metadata
 {
 public:
+	Metadata() = default;
+
+	Metadata(Metadata const &other)
+	{
+		std::lock_guard<std::mutex> other_lock(other.mutex_);
+		data_ = other.data_;
+	}
+
+	Metadata(Metadata &&other)
+	{
+		std::lock_guard<std::mutex> other_lock(other.mutex_);
+		data_ = std::move(other.data_);
+		other.data_.clear();
+	}
+
 	template<typename T>
 	void Set(std::string const &tag, T const &value)
 	{
@@ -51,6 +66,15 @@ public:
 		return *this;
 	}
 
+	Metadata &operator=(Metadata &&other)
+	{
+		std::lock_guard<std::mutex> lock(mutex_);
+		std::lock_guard<std::mutex> other_lock(other.mutex_);
+		data_ = std::move(other.data_);
+		other.data_.clear();
+		return *this;
+	}
+
 	template<typename T>
 	T *GetLocked(std::string const &tag)
 	{
-- 
2.25.1



More information about the libcamera-devel mailing list