Show a patch.

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

{
    "id": 2001,
    "url": "https://patchwork.libcamera.org/api/patches/2001/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/2001/",
    "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": "<20190924172503.30864-3-jacopo@jmondi.org>",
    "date": "2019-09-24T17:24:44",
    "name": "[libcamera-devel,02/21] libcamera: Define interface for serializable data types",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "55897661a5eff9730da5a946e797ae5cad6a0727",
    "submitter": {
        "id": 3,
        "url": "https://patchwork.libcamera.org/api/people/3/?format=api",
        "name": "Jacopo Mondi",
        "email": "jacopo@jmondi.org"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/2001/mbox/",
    "series": [
        {
            "id": 506,
            "url": "https://patchwork.libcamera.org/api/series/506/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=506",
            "date": "2019-09-24T17:24:42",
            "name": "Implement control serialization",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/506/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/2001/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/2001/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<jacopo@jmondi.org>",
        "Received": [
            "from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net\n\t[217.70.183.195])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7C93762379\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 24 Sep 2019 19:23:29 +0200 (CEST)",
            "from uno.homenet.telecomitalia.it\n\t(host89-248-dynamic.45-213-r.retail.telecomitalia.it [213.45.248.89])\n\t(Authenticated sender: jacopo@jmondi.org)\n\tby relay3-d.mail.gandi.net (Postfix) with ESMTPSA id 0FD0360005\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 24 Sep 2019 17:23:28 +0000 (UTC)"
        ],
        "X-Originating-IP": "213.45.248.89",
        "From": "Jacopo Mondi <jacopo@jmondi.org>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Tue, 24 Sep 2019 19:24:44 +0200",
        "Message-Id": "<20190924172503.30864-3-jacopo@jmondi.org>",
        "X-Mailer": "git-send-email 2.23.0",
        "In-Reply-To": "<20190924172503.30864-1-jacopo@jmondi.org>",
        "References": "<20190924172503.30864-1-jacopo@jmondi.org>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH 02/21] libcamera: Define interface for\n\tserializable data types",
        "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": "Tue, 24 Sep 2019 17:23:29 -0000"
    },
    "content": "Define an interface to be implemented by data types that support\nserialization and deserialization of their data to a memory buffer.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n include/libcamera/meson.build    |   1 +\n include/libcamera/serializable.h |  44 +++++++++++++\n src/libcamera/meson.build        |   1 +\n src/libcamera/serializable.cpp   | 110 +++++++++++++++++++++++++++++++\n 4 files changed, 156 insertions(+)\n create mode 100644 include/libcamera/serializable.h\n create mode 100644 src/libcamera/serializable.cpp",
    "diff": "diff --git a/include/libcamera/meson.build b/include/libcamera/meson.build\nindex e3f3ad504446..7790bfb4907b 100644\n--- a/include/libcamera/meson.build\n+++ b/include/libcamera/meson.build\n@@ -13,6 +13,7 @@ libcamera_api = files([\n     'object.h',\n     'request.h',\n     'signal.h',\n+    'serializable.h',\n     'stream.h',\n     'timer.h',\n ])\ndiff --git a/include/libcamera/serializable.h b/include/libcamera/serializable.h\nnew file mode 100644\nindex 000000000000..fae2ea0fb8fe\n--- /dev/null\n+++ b/include/libcamera/serializable.h\n@@ -0,0 +1,44 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2019, Google Inc.\n+ *\n+ * serializable.h - Serializable data types\n+ */\n+#ifndef __LIBCAMERA_SERIALIZABLE_H__\n+#define __LIBCAMERA_SERIALIZABLE_H__\n+\n+#include <cstdint>\n+#include <memory>\n+\n+#include <libcamera/data_value.h>\n+\n+namespace libcamera {\n+\n+class DataBlob\n+{\n+public:\n+\tDataBlob(size_t blobSize);\n+\t~DataBlob();\n+\n+\tuint8_t *data() const { return data_; }\n+\tsize_t size() const { return size_; }\n+\tbool valid() const { return valid_; }\n+\n+private:\n+\tuint8_t *data_;\n+\tsize_t size_;\n+\tbool valid_;\n+};\n+\n+class Serializable\n+{\n+public:\n+\tvirtual ~Serializable() {}\n+\n+\tvirtual std::unique_ptr<DataBlob> serialize() const = 0;\n+\tvirtual int deserialize(uint8_t *data, size_t len) = 0;\n+};\n+\n+} /* namespace libcamera */\n+\n+#endif /* __LIBCAMERA_SERIALIZABLE_H__ */\ndiff --git a/src/libcamera/meson.build b/src/libcamera/meson.build\nindex c4fcd0569bd7..973b20269943 100644\n--- a/src/libcamera/meson.build\n+++ b/src/libcamera/meson.build\n@@ -27,6 +27,7 @@ libcamera_sources = files([\n     'process.cpp',\n     'request.cpp',\n     'signal.cpp',\n+    'serializable.cpp',\n     'stream.cpp',\n     'thread.cpp',\n     'timer.cpp',\ndiff --git a/src/libcamera/serializable.cpp b/src/libcamera/serializable.cpp\nnew file mode 100644\nindex 000000000000..4e075baca56a\n--- /dev/null\n+++ b/src/libcamera/serializable.cpp\n@@ -0,0 +1,110 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2019, Google Inc.\n+ *\n+ * serializable.cpp - Serializable data types\n+ */\n+\n+#include <libcamera/serializable.h>\n+\n+#include <string.h>\n+\n+/**\n+ * \\file serializable.h\n+ * \\brief Interface for serializable data types\n+ */\n+\n+namespace libcamera {\n+\n+/**\n+ * \\class DataBlob\n+ * \\brief Wraps a memory buffer containing serialized data to provide automatic\n+ * allocation and deletion\n+ */\n+\n+/**\n+ * \\brief Construct a DataBlob reserving a buffer of size \\a blobSize\n+ * \\param[in] blobSize The data buffer memory size\n+ *\n+ * Constructing a DataBlob allocates the memory area where to serialize\n+ * data. If memory allocation is successful the data blob is valid and its size\n+ * is set to \\a blobSize.\n+ */\n+DataBlob::DataBlob(size_t blobSize)\n+\t: data_(nullptr), size_(0), valid_(false)\n+{\n+\tdata_ = new uint8_t[blobSize];\n+\tif (!data_)\n+\t\treturn;\n+\n+\t::memset(data_, 0, blobSize);\n+\n+\tvalid_ = true;\n+\tsize_ = blobSize;\n+}\n+\n+/**\n+ * \\brief Destroy the DataBlob and release the memory area it wraps\n+ */\n+DataBlob::~DataBlob()\n+{\n+\tif (data_)\n+\t\tdelete[] data_;\n+}\n+\n+/**\n+ * \\fn DataBlob::data()\n+ * \\brief Retrieve a pointer to the memory area the DataBlob wraps\n+ * \\return A pointer to the wrapped memory area\n+ */\n+\n+/**\n+ * \\fn DataBlob::size()\n+ * \\brief Retrieve the size of the wrapped memory area\n+ * \\return The size of the wrapped memory area in bytes, 0 if memory reservation\n+ * failed\n+ */\n+\n+/**\n+ * \\fn DataBlob::valid()\n+ * \\brief Retrieve if a DataBlob is valid\n+ * \\return True if the memory area was correctly reserved, false otherwise\n+ */\n+\n+/**\n+ * \\class Serializable\n+ * \\brief Interface for serializable data types\n+ *\n+ * Classes that can be serialized to a binary memory buffer shall implement\n+ * the interface defined by this class.\n+ */\n+\n+/**\n+ * \\fn Serializable::serialize()\n+ * \\brief Serialize data to a memory buffer\n+ *\n+ * Implementations of this pure virtual operation serialize the content of\n+ * the derived class to a memory buffer.\n+ *\n+ * The ownership of the DataBlob containing the serialized data is returned to\n+ * the caller, which is responsible for its life cycle management.\n+ */\n+\n+/**\n+ * \\fn Serializable::deserialize()\n+ * \\brief Deserialize from data in a memory buffer\n+ * \\param[in] data The memory buffer containing serialized control info data\n+ * \\param[in] len The memory buffer length in bytes\n+ *\n+ *\n+ * Implementations of this pure virtual operation de-serialize the content of\n+ * the derived class from a memory buffer.\n+ *\n+ * The ownership of the DataBlob \\a blob containing data to de-serialize is\n+ * passed to this operation which destroys its content after having\n+ * de-serialized it.\n+ *\n+ * \\return 0 on success, a negative error coder otherwise\n+ */\n+\n+} /* namespace libcamera */\n",
    "prefixes": [
        "libcamera-devel",
        "02/21"
    ]
}