summaryrefslogtreecommitdiff
path: root/src/ipa/raspberrypi/controller/metadata.hpp
diff options
context:
space:
mode:
authorNaushir Patuck <naush@raspberrypi.com>2021-05-10 10:58:13 +0100
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2021-05-11 03:14:22 +0300
commit2bbd1e4766c3cabf810bf06191ad9d747e278189 (patch)
tree3a1f8e42741c7851545639958fa2f563da4963f8 /src/ipa/raspberrypi/controller/metadata.hpp
parent7de2bbed9b0965e894dbbecd3b0d96c375b3ef90 (diff)
ipa: raspberrypi: Add move/copy ctors and operators to Metadata class
Add a default, move and copy constructor as well as a move operator implementation RPiController::Metadata class. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: David Plowman <david.plowman@raspberrypi.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'src/ipa/raspberrypi/controller/metadata.hpp')
-rw-r--r--src/ipa/raspberrypi/controller/metadata.hpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/ipa/raspberrypi/controller/metadata.hpp b/src/ipa/raspberrypi/controller/metadata.hpp
index e735cfbe..3a97a5f5 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::scoped_lock other_lock(other.mutex_);
+ data_ = other.data_;
+ }
+
+ Metadata(Metadata &&other)
+ {
+ std::scoped_lock other_lock(other.mutex_);
+ data_ = std::move(other.data_);
+ other.data_.clear();
+ }
+
template<typename T>
void Set(std::string const &tag, T const &value)
{
@@ -50,6 +65,14 @@ public:
return *this;
}
+ Metadata &operator=(Metadata &&other)
+ {
+ std::scoped_lock lock(mutex_, other.mutex_);
+ data_ = std::move(other.data_);
+ other.data_.clear();
+ return *this;
+ }
+
template<typename T>
T *GetLocked(std::string const &tag)
{