[libcamera-devel,v4,4/7] ipa: raspberrypi: Add RPiController::Metadata::mergeCopy
diff mbox series

Message ID 20221019090107.19975-5-naush@raspberrypi.com
State Superseded
Headers show
Series
  • Raspberry Pi AGC digital gain fixes
Related show

Commit Message

Naushir Patuck Oct. 19, 2022, 9:01 a.m. UTC
Add a new member function to RPiController::Metadata that copies unique
key/value pairs from one object to the other. This is different from
std::map::merge that would remove the key/value pairs from the source object.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
---
 src/ipa/raspberrypi/controller/metadata.h | 10 ++++++++++
 1 file changed, 10 insertions(+)

Comments

Kieran Bingham Oct. 28, 2022, 12:07 p.m. UTC | #1
Quoting Naushir Patuck via libcamera-devel (2022-10-19 10:01:04)
> Add a new member function to RPiController::Metadata that copies unique
> key/value pairs from one object to the other. This is different from
> std::map::merge that would remove the key/value pairs from the source object.
> 
> Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
> ---
>  src/ipa/raspberrypi/controller/metadata.h | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/src/ipa/raspberrypi/controller/metadata.h b/src/ipa/raspberrypi/controller/metadata.h
> index 0f7ebfaf4c25..ddce491784e9 100644
> --- a/src/ipa/raspberrypi/controller/metadata.h
> +++ b/src/ipa/raspberrypi/controller/metadata.h
> @@ -78,6 +78,16 @@ public:
>                 data_.merge(other.data_);
>         }
>  
> +       void mergeCopy(const Metadata &other)
> +       {
> +               std::scoped_lock lock(mutex_, other.mutex_);
> +               /*
> +                * If the metadata key exists, ignore this item and copy only
> +                * unique key/value pairs.
> +                */
> +               data_.insert(other.data_.begin(), other.data_.end());

I keep coming back to this and wondering if the mergeCopy should be
called insert, or if I just hate how STL handles merging two datasets.

I think it's the later ;-) I've wanted to do similar things with
ControlLists.

That said, this is under ipa/raspberrypi/ so it's left for you to
maintain, so I'm fine with this.

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>


> +       }
> +
>         template<typename T>
>         T *getLocked(std::string const &tag)
>         {
> -- 
> 2.25.1
>

Patch
diff mbox series

diff --git a/src/ipa/raspberrypi/controller/metadata.h b/src/ipa/raspberrypi/controller/metadata.h
index 0f7ebfaf4c25..ddce491784e9 100644
--- a/src/ipa/raspberrypi/controller/metadata.h
+++ b/src/ipa/raspberrypi/controller/metadata.h
@@ -78,6 +78,16 @@  public:
 		data_.merge(other.data_);
 	}
 
+	void mergeCopy(const Metadata &other)
+	{
+		std::scoped_lock lock(mutex_, other.mutex_);
+		/*
+		 * If the metadata key exists, ignore this item and copy only
+		 * unique key/value pairs.
+		 */
+		data_.insert(other.data_.begin(), other.data_.end());
+	}
+
 	template<typename T>
 	T *getLocked(std::string const &tag)
 	{