Show a patch.

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

{
    "id": 2989,
    "url": "https://patchwork.libcamera.org/api/patches/2989/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/2989/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/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": "<20200306160002.30549-18-laurent.pinchart@ideasonboard.com>",
    "date": "2020-03-06T15:59:47",
    "name": "[libcamera-devel,v2,17/32] libcamera: controls: Allow passing an std::initializer list to set()",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "e62b85af845a5770d37d1eca8085524fc97e1d72",
    "submitter": {
        "id": 2,
        "url": "https://patchwork.libcamera.org/api/people/2/?format=api",
        "name": "Laurent Pinchart",
        "email": "laurent.pinchart@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/2989/mbox/",
    "series": [
        {
            "id": 703,
            "url": "https://patchwork.libcamera.org/api/series/703/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=703",
            "date": "2020-03-06T15:59:30",
            "name": "libcamera: Add support for array controls",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/703/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/2989/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/2989/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 72362628B5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  6 Mar 2020 17:00:22 +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 1A1C424B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  6 Mar 2020 17:00:22 +0100 (CET)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1583510422;\n\tbh=Y9NNa4ZR945n/emsic1UFPuZDNHwoiB30UwD/XOCVic=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=ZOgx8w2BdGCOnZRxwggoJrGg+D/vgks+/3b6E9HXriJICJbebN2/5BZVRBI3iJstA\n\tMxwNW52Y++mZeUpdLBThZrcPnC5N3H0XnVVMhZtIPBmF2w/q27C0QLkcCBlVi1ZDa3\n\txgwR9eUKRBB8YQnRbmKUaXgHvojR+lu+f+G3RC6o=",
        "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Fri,  6 Mar 2020 17:59:47 +0200",
        "Message-Id": "<20200306160002.30549-18-laurent.pinchart@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.24.1",
        "In-Reply-To": "<20200306160002.30549-1-laurent.pinchart@ideasonboard.com>",
        "References": "<20200306160002.30549-1-laurent.pinchart@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v2 17/32] libcamera: controls: Allow\n\tpassing an std::initializer list to set()",
        "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": "Fri, 06 Mar 2020 16:00:22 -0000"
    },
    "content": "For array controls, the ControlList::set() function takes a value as a\ntype convertible to Span<T>. This allows passing an std::array or an\nstd::vector in addition to an explicit Span, but doesn't accept an\nstd::initializer list as Span has no constructor that takes an\ninitializer list. Callers are thus forced to create temporary objects\nexplicitly, which isn't nice.\n\nFix the issue by providing a ControlList::set() function that takes an\nstd::initializer_list, and convert it to a Span internally.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n include/libcamera/controls.h | 10 ++++++++++\n src/libcamera/controls.cpp   |  6 ++++++\n 2 files changed, 16 insertions(+)",
    "diff": "diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h\nindex 1e24ae30ab36..2102d5711384 100644\n--- a/include/libcamera/controls.h\n+++ b/include/libcamera/controls.h\n@@ -335,6 +335,16 @@ public:\n \t\tval->set<T>(value);\n \t}\n \n+\ttemplate<typename T, typename V>\n+\tvoid set(const Control<T> &ctrl, const std::initializer_list<V> &value)\n+\t{\n+\t\tControlValue *val = find(ctrl.id());\n+\t\tif (!val)\n+\t\t\treturn;\n+\n+\t\tval->set<T>(Span<const typename std::remove_cv_t<V>>{ value.begin(), value.size() });\n+\t}\n+\n \tconst ControlValue &get(unsigned int id) const;\n \tvoid set(unsigned int id, const ControlValue &value);\n \ndiff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp\nindex a1eca992884c..3dd740e5f17e 100644\n--- a/src/libcamera/controls.cpp\n+++ b/src/libcamera/controls.cpp\n@@ -802,6 +802,12 @@ bool ControlList::contains(unsigned int id) const\n  * object that the list refers to.\n  */\n \n+/**\n+ * \\fn template<typename T, typename V> \\\n+ * void ControlList::set(const Control<T> &ctrl, const std::initializer_list<V> &value)\n+ * \\copydoc ControlList::set(const Control<T> &ctrl, const V &value)\n+ */\n+\n /**\n  * \\brief Get the value of control \\a id\n  * \\param[in] id The control numerical ID\n",
    "prefixes": [
        "libcamera-devel",
        "v2",
        "17/32"
    ]
}