From 273b87c781554b33b641a9aea017a80570749b11 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Sat, 12 Oct 2019 06:35:21 +0300 Subject: libcamera: controls: Add comparison operators for ControlValue MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add equality and non equality comparison operators for the ControlValue class. This simplifies code that deals with control values. Signed-off-by: Laurent Pinchart Reviewed-by: Jacopo Mondi Tested-by: Niklas Söderlund Reviewed-by: Niklas Söderlund --- src/libcamera/controls.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'src/libcamera/controls.cpp') diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp index 70c1af48..bfab177f 100644 --- a/src/libcamera/controls.cpp +++ b/src/libcamera/controls.cpp @@ -194,6 +194,33 @@ std::string ControlValue::toString() const return ""; } +/** + * \brief Compare ControlValue instances for equality + * \return True if the values have identical types and values, false otherwise + */ +bool ControlValue::operator==(const ControlValue &other) const +{ + if (type_ != other.type_) + return false; + + switch (type_) { + case ControlTypeBool: + return bool_ == other.bool_; + case ControlTypeInteger32: + return integer32_ == other.integer32_; + case ControlTypeInteger64: + return integer64_ == other.integer64_; + default: + return false; + } +} + +/** + * \fn bool ControlValue::operator!=() + * \brief Compare ControlValue instances for non equality + * \return False if the values have identical types and values, true otherwise + */ + /** * \class ControlId * \brief Control static metadata -- cgit v1.2.1