diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2019-10-12 06:35:21 +0300 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2019-10-13 20:37:30 +0300 |
commit | 273b87c781554b33b641a9aea017a80570749b11 (patch) | |
tree | 1fb8a8df0f6f4a81482f9f7c5adb7e25442844fb /src | |
parent | 33ee44dc16dc7e6fd15926d76a10545601a20613 (diff) |
libcamera: controls: Add comparison operators for ControlValue
Add equality and non equality comparison operators for the ControlValue
class. This simplifies code that deals with control values.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Tested-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Diffstat (limited to 'src')
-rw-r--r-- | src/libcamera/controls.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
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 @@ -195,6 +195,33 @@ std::string ControlValue::toString() const } /** + * \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 * |