{"id":2633,"url":"https://patchwork.libcamera.org/api/patches/2633/?format=json","web_url":"https://patchwork.libcamera.org/patch/2633/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/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":"<20200113164245.52535-19-jacopo@jmondi.org>","date":"2020-01-13T16:42:40","name":"[libcamera-devel,18/23] libcamera: controls: Re-oder ControlValue methods","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"19206ae8c6000fbec22f2e417774aaeb26275739","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/?format=json","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"delegate":{"id":15,"url":"https://patchwork.libcamera.org/api/users/15/?format=json","username":"jmondi","first_name":"Jacopo","last_name":"Mondi","email":"jacopo@jmondi.org"},"mbox":"https://patchwork.libcamera.org/patch/2633/mbox/","series":[{"id":618,"url":"https://patchwork.libcamera.org/api/series/618/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=618","date":"2020-01-13T16:42:22","name":"Properties and compound controls","version":1,"mbox":"https://patchwork.libcamera.org/series/618/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/2633/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/2633/checks/","tags":{},"headers":{"Return-Path":"<jacopo@jmondi.org>","Received":["from relay11.mail.gandi.net (relay11.mail.gandi.net\n\t[217.70.178.231])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id EF23260703\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 13 Jan 2020 17:40:37 +0100 (CET)","from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101])\n\t(Authenticated sender: jacopo@jmondi.org)\n\tby relay11.mail.gandi.net (Postfix) with ESMTPSA id 8CA03100005;\n\tMon, 13 Jan 2020 16:40:37 +0000 (UTC)"],"From":"Jacopo Mondi <jacopo@jmondi.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Mon, 13 Jan 2020 17:42:40 +0100","Message-Id":"<20200113164245.52535-19-jacopo@jmondi.org>","X-Mailer":"git-send-email 2.24.0","In-Reply-To":"<20200113164245.52535-1-jacopo@jmondi.org>","References":"<20200113164245.52535-1-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH 18/23] libcamera: controls: Re-oder\n\tControlValue methods","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":"Mon, 13 Jan 2020 16:40:38 -0000"},"content":"Re-order operation in ControlValue class to group const methods\ntogether.\n\nCosmetic change only.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n include/libcamera/controls.h |  10 +-\n src/libcamera/controls.cpp   | 222 +++++++++++++++++------------------\n 2 files changed, 116 insertions(+), 116 deletions(-)","diff":"diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h\nindex d13144b69198..9343a947764b 100644\n--- a/include/libcamera/controls.h\n+++ b/include/libcamera/controls.h\n@@ -50,11 +50,6 @@ public:\n \tbool isNone() const { return type_ == ControlTypeNone; }\n \tstd::size_t numElements() const { return numElements_; }\n \n-\ttemplate<typename T>\n-\tT get() const;\n-\ttemplate<typename T>\n-\tvoid set(const T &value);\n-\n \tstd::string toString() const;\n \n \tbool operator==(const ControlValue &other) const;\n@@ -63,6 +58,11 @@ public:\n \t\treturn !(*this == other);\n \t}\n \n+\ttemplate<typename T>\n+\tT get() const;\n+\ttemplate<typename T>\n+\tvoid set(const T &value);\n+\n private:\n \tControlType type_;\n \ndiff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp\nindex fd04d2311db3..750c36bd011e 100644\n--- a/src/libcamera/controls.cpp\n+++ b/src/libcamera/controls.cpp\n@@ -269,6 +269,117 @@ ControlValue &ControlValue::operator=(const ControlValue &other)\n  * \\return The number of elements stored in the ControlValue\n  */\n \n+std::string ControlValue::elemToString(unsigned int i) const\n+{\n+\tswitch (type_) {\n+\tcase ControlTypeBool:\n+\t\treturn bool_ ? \"True \" : \"False \";\n+\tcase ControlTypeInteger32:\n+\t\treturn std::to_string(integer32_);\n+\tcase ControlTypeInteger64:\n+\t\treturn std::to_string(integer64_);\n+\tcase ControlTypeFloat:\n+\t\treturn std::to_string(float_);\n+\tcase ControlTypeCompoundBool:\n+\t\treturn pbool_[i] ? \"True \" : \"False \";\n+\tcase ControlTypeCompoundInt32:\n+\t\treturn std::to_string(p32_[i]) + \" \";\n+\tcase ControlTypeCompoundInt64:\n+\t\treturn std::to_string(p64_[i]) + \" \";\n+\tcase ControlTypeCompoundFloat:\n+\t\treturn std::to_string(pfloat_[i]) + \" \";\n+\tdefault:\n+\t\treturn \"<None>\";\n+\t}\n+}\n+\n+/**\n+ * \\brief Assemble and return a string describing the value\n+ * \\return A string describing the ControlValue\n+ */\n+std::string ControlValue::toString() const\n+{\n+\tif (ControlTypeNone)\n+\t\treturn \"<ValueType Error>\";\n+\n+\tstd::string str;\n+\tfor (unsigned int i = 0; i < numElements_; ++i)\n+\t\tstr += elemToString(i);\n+\n+\treturn str;\n+}\n+\n+bool ControlValue::compareElement(const ControlValue &other) const\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+\tcase ControlTypeFloat:\n+\t\treturn float_ == other.float_;\n+\tdefault:\n+\t\treturn false;\n+\t}\n+}\n+\n+bool ControlValue::compareElement(const ControlValue &other, unsigned int i) const\n+{\n+\tswitch (type_) {\n+\tcase ControlTypeCompoundBool:\n+\t\treturn pbool_[i] == other.pbool_[i];\n+\tcase ControlTypeCompoundInt32:\n+\t\treturn p32_[i] == other.p32_[i];\n+\tcase ControlTypeCompoundInt64:\n+\t\treturn p64_[i] == other.p64_[i];\n+\tcase ControlTypeCompoundFloat:\n+\t\treturn pfloat_[i] == other.pfloat_[i];\n+\tdefault:\n+\t\treturn false;\n+\t}\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+\tif (numElements_ != other.numElements())\n+\t\treturn false;\n+\n+\tswitch (type_) {\n+\tcase ControlTypeBool:\n+\tcase ControlTypeInteger32:\n+\tcase ControlTypeInteger64:\n+\tcase ControlTypeFloat:\n+\t\treturn compareElement(other);\n+\tcase ControlTypeCompoundBool:\n+\tcase ControlTypeCompoundInt32:\n+\tcase ControlTypeCompoundInt64:\n+\tcase ControlTypeCompoundFloat:\n+\t\tfor (unsigned int i = 0; i < numElements_; ++i) {\n+\t\t\tif (!compareElement(other, i))\n+\t\t\t\treturn false;\n+\t\t}\n+\n+\t\treturn true;\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  * \\fn template<typename T> const T ControlValue::get() const\n  * \\brief Get the control values\n@@ -454,117 +565,6 @@ void ControlValue::set<Span<float>>(const Span<float> &values)\n \n #endif /* __DOXYGEN__ */\n \n-std::string ControlValue::elemToString(unsigned int i) const\n-{\n-\tswitch (type_) {\n-\tcase ControlTypeBool:\n-\t\treturn bool_ ? \"True \" : \"False \";\n-\tcase ControlTypeInteger32:\n-\t\treturn std::to_string(integer32_);\n-\tcase ControlTypeInteger64:\n-\t\treturn std::to_string(integer64_);\n-\tcase ControlTypeFloat:\n-\t\treturn std::to_string(float_);\n-\tcase ControlTypeCompoundBool:\n-\t\treturn pbool_[i] ? \"True \" : \"False \";\n-\tcase ControlTypeCompoundInt32:\n-\t\treturn std::to_string(p32_[i]) + \" \";\n-\tcase ControlTypeCompoundInt64:\n-\t\treturn std::to_string(p64_[i]) + \" \";\n-\tcase ControlTypeCompoundFloat:\n-\t\treturn std::to_string(pfloat_[i]) + \" \";\n-\tdefault:\n-\t\treturn \"<None>\";\n-\t}\n-}\n-\n-/**\n- * \\brief Assemble and return a string describing the value\n- * \\return A string describing the ControlValue\n- */\n-std::string ControlValue::toString() const\n-{\n-\tif (ControlTypeNone)\n-\t\treturn \"<ValueType Error>\";\n-\n-\tstd::string str;\n-\tfor (unsigned int i = 0; i < numElements_; ++i)\n-\t\tstr += elemToString(i);\n-\n-\treturn str;\n-}\n-\n-bool ControlValue::compareElement(const ControlValue &other) const\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-\tcase ControlTypeFloat:\n-\t\treturn float_ == other.float_;\n-\tdefault:\n-\t\treturn false;\n-\t}\n-}\n-\n-bool ControlValue::compareElement(const ControlValue &other, unsigned int i) const\n-{\n-\tswitch (type_) {\n-\tcase ControlTypeCompoundBool:\n-\t\treturn pbool_[i] == other.pbool_[i];\n-\tcase ControlTypeCompoundInt32:\n-\t\treturn p32_[i] == other.p32_[i];\n-\tcase ControlTypeCompoundInt64:\n-\t\treturn p64_[i] == other.p64_[i];\n-\tcase ControlTypeCompoundFloat:\n-\t\treturn pfloat_[i] == other.pfloat_[i];\n-\tdefault:\n-\t\treturn false;\n-\t}\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-\tif (numElements_ != other.numElements())\n-\t\treturn false;\n-\n-\tswitch (type_) {\n-\tcase ControlTypeBool:\n-\tcase ControlTypeInteger32:\n-\tcase ControlTypeInteger64:\n-\tcase ControlTypeFloat:\n-\t\treturn compareElement(other);\n-\tcase ControlTypeCompoundBool:\n-\tcase ControlTypeCompoundInt32:\n-\tcase ControlTypeCompoundInt64:\n-\tcase ControlTypeCompoundFloat:\n-\t\tfor (unsigned int i = 0; i < numElements_; ++i) {\n-\t\t\tif (!compareElement(other, i))\n-\t\t\t\treturn false;\n-\t\t}\n-\n-\t\treturn true;\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","18/23"]}