Show a patch.

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

{
    "id": 370,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/370/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/370/",
    "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": "<20190124113020.7203-2-jacopo@jmondi.org>",
    "date": "2019-01-24T11:30:19",
    "name": "[libcamera-devel,1/2] libcamera: pipeline_handler: Add CameraData",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "2287751271f69166cbd89db892ab0735c69d0ed1",
    "submitter": {
        "id": 3,
        "url": "https://patchwork.libcamera.org/api/1.1/people/3/?format=api",
        "name": "Jacopo Mondi",
        "email": "jacopo@jmondi.org"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/370/mbox/",
    "series": [
        {
            "id": 127,
            "url": "https://patchwork.libcamera.org/api/1.1/series/127/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=127",
            "date": "2019-01-24T11:30:18",
            "name": "Add pipeline-specific per-camera data",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/127/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/370/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/370/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<jacopo@jmondi.org>",
        "Received": [
            "from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net\n\t[217.70.183.196])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 53E2C60C80\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 24 Jan 2019 12:30:13 +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 relay4-d.mail.gandi.net (Postfix) with ESMTPSA id DCBBFE0018;\n\tThu, 24 Jan 2019 11:30:12 +0000 (UTC)"
        ],
        "X-Originating-IP": "2.224.242.101",
        "From": "Jacopo Mondi <jacopo@jmondi.org>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Thu, 24 Jan 2019 12:30:19 +0100",
        "Message-Id": "<20190124113020.7203-2-jacopo@jmondi.org>",
        "X-Mailer": "git-send-email 2.20.1",
        "In-Reply-To": "<20190124113020.7203-1-jacopo@jmondi.org>",
        "References": "<20190124113020.7203-1-jacopo@jmondi.org>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH 1/2] libcamera: pipeline_handler: Add\n\tCameraData",
        "X-BeenThere": "libcamera-devel@lists.libcamera.org",
        "X-Mailman-Version": "2.1.23",
        "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": "Thu, 24 Jan 2019 11:30:13 -0000"
    },
    "content": "Add class definition and methods to associate a Camera with specific data\n in the pipeline_handler base class.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/libcamera/include/pipeline_handler.h | 24 +++++++-\n src/libcamera/pipeline_handler.cpp       | 73 ++++++++++++++++++++++++\n 2 files changed, 96 insertions(+), 1 deletion(-)",
    "diff": "diff --git a/src/libcamera/include/pipeline_handler.h b/src/libcamera/include/pipeline_handler.h\nindex b03217d..41699a5 100644\n--- a/src/libcamera/include/pipeline_handler.h\n+++ b/src/libcamera/include/pipeline_handler.h\n@@ -11,17 +11,39 @@\n #include <string>\n #include <vector>\n \n+#include <libcamera/camera.h>\n+\n namespace libcamera {\n \n class CameraManager;\n class DeviceEnumerator;\n \n+class CameraData\n+{\n+public:\n+\tvirtual ~CameraData() {}\n+\n+protected:\n+\tCameraData() {}\n+\n+private:\n+\tCameraData(const CameraData &) = delete;\n+\tvoid operator=(const CameraData &) = delete;\n+};\n+\n class PipelineHandler\n {\n public:\n-\tvirtual ~PipelineHandler() { };\n+\tvirtual ~PipelineHandler();\n \n \tvirtual bool match(CameraManager *manager, DeviceEnumerator *enumerator) = 0;\n+\n+protected:\n+\tCameraData *cameraData(const Camera *camera);\n+\tvoid setCameraData(const Camera *camera, std::unique_ptr<CameraData> data);\n+\n+private:\n+\tstd::map<const Camera *, std::unique_ptr<CameraData>> cameraData_;\n };\n \n class PipelineHandlerFactory\ndiff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp\nindex c24feea..fb49fde 100644\n--- a/src/libcamera/pipeline_handler.cpp\n+++ b/src/libcamera/pipeline_handler.cpp\n@@ -8,6 +8,8 @@\n #include \"log.h\"\n #include \"pipeline_handler.h\"\n \n+#include <libcamera/camera.h>\n+\n /**\n  * \\file pipeline_handler.h\n  * \\brief Create pipelines and cameras from a set of media devices\n@@ -26,6 +28,20 @@ namespace libcamera {\n \n LOG_DEFINE_CATEGORY(Pipeline)\n \n+/**\n+ * \\class CameraData\n+ * \\brief Base class for platform-specific data associated with a camera\n+ *\n+ * The CameraData base abstract class represents platform specific-data\n+ * a pipeline handler might want to associate with a Camera to access them\n+ * at a later time.\n+ *\n+ * Pipeline handlers are expected to extend this base class with platform\n+ * specific implementation, associate instances of the derived classes\n+ * using the setCameraData() method, and access them at a later time\n+ * with cameraData().\n+ */\n+\n /**\n  * \\class PipelineHandler\n  * \\brief Create and manage cameras based on a set of media devices\n@@ -66,6 +82,63 @@ LOG_DEFINE_CATEGORY(Pipeline)\n  * created, or false otherwise\n  */\n \n+/**\n+ * \\brief Delete the pipeline handler\n+ *\n+ * Release the cameraData_ map, causing all data there referenced to be\n+ * deleted, as they are stored as unique_ptr<CameraData>\n+ */\n+PipelineHandler::~PipelineHandler()\n+{\n+\tcameraData_.clear();\n+};\n+\n+/**\n+ * \\brief Retrieve the pipeline-specific data associated with a Camera\n+ * \\param camera The camera data is associate with\n+ *\n+ * \\return A pointer to the pipeline-specific data set with setCameraData().\n+ * The returned pointer lifetime is associated with the one of the pipeline\n+ * handler, and caller of this function shall never release it manually.\n+ */\n+CameraData *PipelineHandler::cameraData(const Camera *camera)\n+{\n+\tif (!cameraData_.count(camera)) {\n+\t\tLOG(Pipeline, Error)\n+\t\t\t<< \"Cannot get data associated with camera \"\n+\t\t\t<< camera->name();\n+\t\treturn nullptr;\n+\t}\n+\n+\treturn cameraData_[camera].get();\n+}\n+\n+/**\n+ * \\brief Set pipeline-specific data in the camera\n+ * \\param camera The camera to associate data to\n+ * \\param data The pipeline-specific data\n+ *\n+ * This method allows pipeline handlers to associate pipeline-specific\n+ * information with \\a camera. The \\a data lifetime gets associated with\n+ * the pipeline handler one, and gets released at deletion time.\n+ *\n+ * If pipeline-specific data has already been associated with the camera by a\n+ * previous call to this method, is it replaced by \\a data and the previous data\n+ * are deleted, rendering all references to them invalid.\n+ *\n+ * The data can be retrieved by pipeline handlers using the cameraData() method.\n+ */\n+void PipelineHandler::setCameraData(const Camera *camera,\n+\t\t\t\t    std::unique_ptr<CameraData> data)\n+{\n+\tif (cameraData_.count(camera))\n+\t\tLOG(Pipeline, Debug)\n+\t\t\t<< \"Replacing data associated with \"\n+\t\t\t<< camera->name();\n+\n+\tcameraData_[camera] = std::move(data);\n+}\n+\n /**\n  * \\class PipelineHandlerFactory\n  * \\brief Registration of PipelineHandler classes and creation of instances\n",
    "prefixes": [
        "libcamera-devel",
        "1/2"
    ]
}