[libcamera-devel,4/2] libcamera: controls: Drop ControlList::contains()
diff mbox series

Message ID 20220719213314.11717-2-laurent.pinchart@ideasonboard.com
State Accepted
Commit 4d22621ec11a065b1819f6268335cae81dd50986
Headers show
Series
  • [libcamera-devel,1/2] licamera: controls: Drop unnecessary template qualifiers in documentation
Related show

Commit Message

Laurent Pinchart July 19, 2022, 9:33 p.m. UTC
The ControlList::contains(const ControlId &id) function isn't used, as
it has been replaced by usage of the get() function. Document get as
being the preferred way to check for the presence of a control in a
ControlList, and drop the contains() function.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 include/libcamera/controls.h |  1 -
 src/libcamera/controls.cpp   | 15 ++++-----------
 2 files changed, 4 insertions(+), 12 deletions(-)

Patch
diff mbox series

diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h
index 192be78434dc..85a56e621561 100644
--- a/include/libcamera/controls.h
+++ b/include/libcamera/controls.h
@@ -370,7 +370,6 @@  public:
 	void clear() { controls_.clear(); }
 	void merge(const ControlList &source);
 
-	bool contains(const ControlId &id) const;
 	bool contains(unsigned int id) const;
 
 	template<typename T>
diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp
index 20c27e65e725..df1f0d94c2e6 100644
--- a/src/libcamera/controls.cpp
+++ b/src/libcamera/controls.cpp
@@ -931,17 +931,6 @@  void ControlList::merge(const ControlList &source)
 	}
 }
 
-/**
- * \brief Check if the list contains a control with the specified \a id
- * \param[in] id The control ID
- *
- * \return True if the list contains a matching control, false otherwise
- */
-bool ControlList::contains(const ControlId &id) const
-{
-	return controls_.find(id.id()) != controls_.end();
-}
-
 /**
  * \brief Check if the list contains a control with the specified \a id
  * \param[in] id The control numerical ID
@@ -958,6 +947,10 @@  bool ControlList::contains(unsigned int id) const
  * \brief Get the value of control \a ctrl
  * \param[in] ctrl The control
  *
+ * Beside getting the value of a control, this function can also be used to
+ * check if a control is present in the ControlList by converting the returned
+ * std::optional<T> to bool (or calling its has_value() function).
+ *
  * \return A std::optional<T> containing the control value, or std::nullopt if
  * the control \a ctrl is not present in the list
  */