ipa: raspberrypi: Add RPiController::Metadata::mergeCopy

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>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
Naushir Patuck 2022-11-15 09:07:52 +00:00 committed by Laurent Pinchart
parent 33abc2b31e
commit 087f0c3c42

View file

@ -80,6 +80,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)
{