[libcamera-devel] [PATCH v6 4/5] ipa: raspberrypi: Add Overwrite method to RPiController::Metadata
Laurent Pinchart
laurent.pinchart at ideasonboard.com
Sat May 8 02:32:18 CEST 2021
Hi Naush,
Thank you for the patch.
On Fri, May 07, 2021 at 09:40:41AM +0100, Naushir Patuck wrote:
> Add a new Overwrite method to the Metadata class. This will overwrite
> all key/value pairs in a destination object that have an identical key
> in the source metadata object. Once complete, the source Metadata
> object will be empty.
>
> Signed-off-by: Naushir Patuck <naush at raspberrypi.com>
> ---
> src/ipa/raspberrypi/controller/metadata.hpp | 20 ++++++++++++++++++++
> 1 file changed, 20 insertions(+)
>
> diff --git a/src/ipa/raspberrypi/controller/metadata.hpp b/src/ipa/raspberrypi/controller/metadata.hpp
> index 319f2320fc70..ac64f17f617c 100644
> --- a/src/ipa/raspberrypi/controller/metadata.hpp
> +++ b/src/ipa/raspberrypi/controller/metadata.hpp
> @@ -75,6 +75,26 @@ public:
> return *this;
> }
>
> + void Overwrite(Metadata &other)
I may have used an rvalue reference to force the caller to acknowledge
that other will be cleared, but that doesn't matter much.
Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
> + {
> + std::lock_guard<std::mutex> lock(mutex_);
> + std::lock_guard<std::mutex> other_lock(other.mutex_);
> +
> + /*
> + * Overwrite any contents of data_ with identical keys from
> + * other.data_. Any keys from other.data_ that are not preset in
> + * data_ will simply be copied across.
> + *
> + * The reason for the seemingly illogical steps below is because
> + * std::map::merge() does not overwrite existing keys.
> + */
> + other.data_.merge(data_);
> + std::swap(data_, other.data_);
> +
> + /* Render the other object as empty now! */
> + other.data_.clear();
> + }
> +
> template<typename T>
> T *GetLocked(std::string const &tag)
> {
--
Regards,
Laurent Pinchart
More information about the libcamera-devel
mailing list