[v2,2/4] ipa: rpi: Add erase()/eraseLocked() to RPiController::Metadata
diff mbox series

Message ID 20241218083610.2397879-3-naush@raspberrypi.com
State New
Headers show
Series
  • Raspberry Pi: Various changes
Related show

Commit Message

Naushir Patuck Dec. 18, 2024, 8:34 a.m. UTC
These functions erase a key/value pair from the metadata object.

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

Patch
diff mbox series

diff --git a/src/ipa/rpi/controller/metadata.h b/src/ipa/rpi/controller/metadata.h
index b884490918c7..77d3b0745059 100644
--- a/src/ipa/rpi/controller/metadata.h
+++ b/src/ipa/rpi/controller/metadata.h
@@ -91,6 +91,12 @@  public:
 		data_.insert(other.data_.begin(), other.data_.end());
 	}
 
+	void erase(std::string const &tag)
+	{
+		std::scoped_lock lock(mutex_);
+		eraseLocked(tag);
+	}
+
 	template<typename T>
 	T *getLocked(std::string const &tag)
 	{
@@ -111,6 +117,14 @@  public:
 		data_[tag] = std::forward<T>(value);
 	}
 
+	void eraseLocked(std::string const &tag)
+	{
+		auto it = data_.find(tag);
+		if (it == data_.end())
+			return;
+		data_.erase(it);
+	}
+
 	/*
 	 * Note: use of (lowercase) lock and unlock means you can create scoped
 	 * locks with the standard lock classes.