{"id":2165,"url":"https://patchwork.libcamera.org/api/1.1/patches/2165/?format=json","web_url":"https://patchwork.libcamera.org/patch/2165/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20191012184407.31684-5-laurent.pinchart@ideasonboard.com>","date":"2019-10-12T18:43:57","name":"[libcamera-devel,v2,04/14] libcamera: controls: Add comparison operators for ControlValue","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"d1ab169a449d1ba8beea46c520a7350051d4b4d0","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/1.1/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/2165/mbox/","series":[{"id":531,"url":"https://patchwork.libcamera.org/api/1.1/series/531/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=531","date":"2019-10-12T18:43:53","name":"Use ControlList for both libcamera and V4L2 controls","version":2,"mbox":"https://patchwork.libcamera.org/series/531/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/2165/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/2165/checks/","tags":{},"headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 8F7BB61563\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 12 Oct 2019 20:44:18 +0200 (CEST)","from pendragon.bb.dnainternet.fi\n\t(dfj612yhrgyx302h3jwwy-3.rev.dnainternet.fi\n\t[IPv6:2001:14ba:21f5:5b00:ce28:277f:58d7:3ca4])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id B473B33A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 12 Oct 2019 20:44:17 +0200 (CEST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1570905858;\n\tbh=w8a1lB+CzP86yPSLqH/maQu2rcKF90DtfQQx6a9ulnA=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=cRnxiTMZoG1jr/rVa30G1Fw74FvdlSSacrechawZjfPspWU6FwoZBeEqVZ/kMRXX5\n\tl+k5oF26OSU9bqhsu2lmTkgCmSxgyGj4J0My7Ts7m9ZQhC8mbyqaf8CWrAFt0EMwYo\n\tp0HWGWuLf3nphhHY869HOMGjmrjF4ddDRGlJiXeE=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Sat, 12 Oct 2019 21:43:57 +0300","Message-Id":"<20191012184407.31684-5-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.21.0","In-Reply-To":"<20191012184407.31684-1-laurent.pinchart@ideasonboard.com>","References":"<20191012184407.31684-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v2 04/14] libcamera: controls: Add\n\tcomparison operators for ControlValue","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Sat, 12 Oct 2019 18:44:18 -0000"},"content":"Add equality and non equality comparison operators for the ControlValue\nclass. This simplifies code that deals with control values.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n include/libcamera/controls.h |  6 ++++++\n src/libcamera/controls.cpp   | 27 +++++++++++++++++++++++++++\n 2 files changed, 33 insertions(+)","diff":"diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h\nindex d8acd800b143..342251c21018 100644\n--- a/include/libcamera/controls.h\n+++ b/include/libcamera/controls.h\n@@ -40,6 +40,12 @@ public:\n \n \tstd::string toString() const;\n \n+\tbool operator==(const ControlValue &other) const;\n+\tbool operator!=(const ControlValue &other) const\n+\t{\n+\t\treturn !(*this == other);\n+\t}\n+\n private:\n \tControlType type_;\n \ndiff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp\nindex 70c1af481af2..bfab177fc508 100644\n--- a/src/libcamera/controls.cpp\n+++ b/src/libcamera/controls.cpp\n@@ -194,6 +194,33 @@ std::string ControlValue::toString() const\n \treturn \"<ValueType Error>\";\n }\n \n+/**\n+ * \\brief Compare ControlValue instances for equality\n+ * \\return True if the values have identical types and values, false otherwise\n+ */\n+bool ControlValue::operator==(const ControlValue &other) const\n+{\n+\tif (type_ != other.type_)\n+\t\treturn false;\n+\n+\tswitch (type_) {\n+\tcase ControlTypeBool:\n+\t\treturn bool_ == other.bool_;\n+\tcase ControlTypeInteger32:\n+\t\treturn integer32_ == other.integer32_;\n+\tcase ControlTypeInteger64:\n+\t\treturn integer64_ == other.integer64_;\n+\tdefault:\n+\t\treturn false;\n+\t}\n+}\n+\n+/**\n+ * \\fn bool ControlValue::operator!=()\n+ * \\brief Compare ControlValue instances for non equality\n+ * \\return False if the values have identical types and values, true otherwise\n+ */\n+\n /**\n  * \\class ControlId\n  * \\brief Control static metadata\n","prefixes":["libcamera-devel","v2","04/14"]}