Show a patch.

GET /api/1.1/patches/2930/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 2930,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/2930/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/2930/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/1.1/projects/1/?format=api",
        "name": "libcamera",
        "link_name": "libcamera",
        "list_id": "libcamera_core",
        "list_email": "libcamera-devel@lists.libcamera.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": ""
    },
    "msgid": "<20200229164254.23604-13-laurent.pinchart@ideasonboard.com>",
    "date": "2020-02-29T16:42:35",
    "name": "[libcamera-devel,12/31] libcamera: controls: Move ControlValue get() and set() to controls.h",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "9a84ee9ff7782f322fab7c85ee8b30c293d378fd",
    "submitter": {
        "id": 2,
        "url": "https://patchwork.libcamera.org/api/1.1/people/2/?format=api",
        "name": "Laurent Pinchart",
        "email": "laurent.pinchart@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/2930/mbox/",
    "series": [
        {
            "id": 696,
            "url": "https://patchwork.libcamera.org/api/1.1/series/696/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=696",
            "date": "2020-02-29T16:42:23",
            "name": "libcamera: Add support for array controls",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/696/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/2930/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/2930/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<laurent.pinchart@ideasonboard.com>",
        "Received": [
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 61F4F62789\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 29 Feb 2020 17:43:26 +0100 (CET)",
            "from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 01664A28\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 29 Feb 2020 17:43:25 +0100 (CET)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1582994606;\n\tbh=kjlGLweGKYC3rHM+BnPYckKBUCNnYZR4sEgFzQal6QM=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=LH1kwMxqJ+C1Gxf5uoG8ZpUyooAH6c5DO+X6Q3gTbOfNziRJvdkDm+XZxGmjGrUUu\n\tRDAJKbiz6Xi7EGT43mQKztGl4A7PZwbx8H545zdWtdEAmoVk7pP2MQsVeAgkMhwWwB\n\tvUKA6DFLZKcjaGug/B6LAa2zcVLW+A2Eice9OrSs=",
        "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Sat, 29 Feb 2020 18:42:35 +0200",
        "Message-Id": "<20200229164254.23604-13-laurent.pinchart@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.24.1",
        "In-Reply-To": "<20200229164254.23604-1-laurent.pinchart@ideasonboard.com>",
        "References": "<20200229164254.23604-1-laurent.pinchart@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH 12/31] libcamera: controls: Move\n\tControlValue get() and set() to controls.h",
        "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, 29 Feb 2020 16:43:26 -0000"
    },
    "content": "To avoid defining all specializations of ControlValue::get() and\nControlValue::set() manually, move the definition of those functions to\ncontrols.h.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n include/libcamera/controls.h | 15 ++++++++++--\n src/libcamera/controls.cpp   | 47 ------------------------------------\n 2 files changed, 13 insertions(+), 49 deletions(-)",
    "diff": "diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h\nindex 429f01b0fd24..39e240438861 100644\n--- a/include/libcamera/controls.h\n+++ b/include/libcamera/controls.h\n@@ -8,6 +8,7 @@\n #ifndef __LIBCAMERA_CONTROLS_H__\n #define __LIBCAMERA_CONTROLS_H__\n \n+#include <assert.h>\n #include <string>\n #include <unordered_map>\n \n@@ -70,9 +71,19 @@ public:\n \t}\n \n \ttemplate<typename T>\n-\tT get() const;\n+\tT get() const\n+\t{\n+\t\tassert(type_ == details::control_type<std::remove_cv_t<T>>::value);\n+\n+\t\treturn *reinterpret_cast<const T *>(&bool_);\n+\t}\n+\n \ttemplate<typename T>\n-\tvoid set(const T &value);\n+\tvoid set(const T &value)\n+\t{\n+\t\ttype_ = details::control_type<std::remove_cv_t<T>>::value;\n+\t\t*reinterpret_cast<T *>(&bool_) = value;\n+\t}\n \n private:\n \tControlType type_;\ndiff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp\nindex 6a0d66fbea8d..f3d79785e6a8 100644\n--- a/src/libcamera/controls.cpp\n+++ b/src/libcamera/controls.cpp\n@@ -175,53 +175,6 @@ bool ControlValue::operator==(const ControlValue &other) const\n  * \\param[in] value The control value\n  */\n \n-#ifndef __DOXYGEN__\n-template<>\n-bool ControlValue::get<bool>() const\n-{\n-\tASSERT(type_ == ControlTypeBool);\n-\n-\treturn bool_;\n-}\n-\n-template<>\n-int32_t ControlValue::get<int32_t>() const\n-{\n-\tASSERT(type_ == ControlTypeInteger32);\n-\n-\treturn integer32_;\n-}\n-\n-template<>\n-int64_t ControlValue::get<int64_t>() const\n-{\n-\tASSERT(type_ == ControlTypeInteger64);\n-\n-\treturn integer64_;\n-}\n-\n-template<>\n-void ControlValue::set<bool>(const bool &value)\n-{\n-\ttype_ = ControlTypeBool;\n-\tbool_ = value;\n-}\n-\n-template<>\n-void ControlValue::set<int32_t>(const int32_t &value)\n-{\n-\ttype_ = ControlTypeInteger32;\n-\tinteger32_ = value;\n-}\n-\n-template<>\n-void ControlValue::set<int64_t>(const int64_t &value)\n-{\n-\ttype_ = ControlTypeInteger64;\n-\tinteger64_ = value;\n-}\n-#endif /* __DOXYGEN__ */\n-\n /**\n  * \\class ControlId\n  * \\brief Control static metadata\n",
    "prefixes": [
        "libcamera-devel",
        "12/31"
    ]
}