Show a patch.

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

{
    "id": 1359,
    "url": "https://patchwork.libcamera.org/api/patches/1359/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/1359/",
    "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": "<20190605145413.9888-1-laurent.pinchart@ideasonboard.com>",
    "date": "2019-06-05T14:54:13",
    "name": "[libcamera-devel] libcamera: pipeline_handler: Optimise factory implementation",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "a71183e64f6a901564c667f8da8af6ebfd80f33e",
    "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/1359/mbox/",
    "series": [
        {
            "id": 337,
            "url": "https://patchwork.libcamera.org/api/series/337/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=337",
            "date": "2019-06-05T14:54:13",
            "name": "[libcamera-devel] libcamera: pipeline_handler: Optimise factory implementation",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/337/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/1359/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/1359/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<laurent.pinchart@ideasonboard.com>",
        "Received": [
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 6597566231\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  5 Jun 2019 16:54:35 +0200 (CEST)",
            "from pendragon.ideasonboard.com (85-76-142-100-nat.elisa-mobile.fi\n\t[85.76.142.100])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 82D1B84\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  5 Jun 2019 16:54:34 +0200 (CEST)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1559746475;\n\tbh=0P2ckfzEYfae/GANwOwDna+9Dx0PPVJKJeGdrmEAkdQ=;\n\th=From:To:Subject:Date:From;\n\tb=XFFtRW/lbPqjnlPQRPbbWpBjfBy+fhkuldpYC+grB4qUgnthPgXwrelAOdSYcV6FV\n\tcxAvvKVdrj3eXySFWlhrfJ90ef1xQvhwBjbjXx4dTcP9XlpBuKMM6ZZYjCe4JE6XVu\n\thP2tAjy3ZwizHNLhzdFbkrYHL7E+BM3bYR2RA/m4=",
        "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Wed,  5 Jun 2019 17:54:13 +0300",
        "Message-Id": "<20190605145413.9888-1-laurent.pinchart@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.21.0",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH] libcamera: pipeline_handler: Optimise\n\tfactory implementation",
        "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": "Wed, 05 Jun 2019 14:54:35 -0000"
    },
    "content": "The REGISTER_PIPELINE_HANDLER() macro defines and instantiates a\nsubclass of the PipelineHandlerFactory class that specialises the\nvirtual create() method. Now that create() does more than just creating\nan instance, boilerplate code gets duplicated between different\nfactories.\n\nFactor out the instance creation code to a new virtual createInstance()\nmethod, and turn create() into a non-virtual method of the base class\nthat can then be defined in the .cpp file.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/libcamera/include/pipeline_handler.h | 11 +++-----\n src/libcamera/pipeline_handler.cpp       | 33 +++++++++++++-----------\n 2 files changed, 22 insertions(+), 22 deletions(-)",
    "diff": "diff --git a/src/libcamera/include/pipeline_handler.h b/src/libcamera/include/pipeline_handler.h\nindex 84307e408772..36f0b84c0d6c 100644\n--- a/src/libcamera/include/pipeline_handler.h\n+++ b/src/libcamera/include/pipeline_handler.h\n@@ -107,7 +107,7 @@ public:\n \tPipelineHandlerFactory(const char *name);\n \tvirtual ~PipelineHandlerFactory() { };\n \n-\tvirtual std::shared_ptr<PipelineHandler> create(CameraManager *manager) = 0;\n+\tstd::shared_ptr<PipelineHandler> create(CameraManager *manager);\n \n \tconst std::string &name() const { return name_; }\n \n@@ -115,7 +115,7 @@ public:\n \tstatic std::vector<PipelineHandlerFactory *> &factories();\n \n protected:\n-\tvoid setInfo(PipelineHandler *handler, const char *name);\n+\tvirtual PipelineHandler *createInstance(CameraManager *manager) = 0;\n \n private:\n \tstd::string name_;\n@@ -126,12 +126,9 @@ class handler##Factory final : public PipelineHandlerFactory\t\t\\\n {\t\t\t\t\t\t\t\t\t\\\n public:\t\t\t\t\t\t\t\t\t\\\n \thandler##Factory() : PipelineHandlerFactory(#handler) {}\t\\\n-\tstd::shared_ptr<PipelineHandler> create(CameraManager *manager)\t\\\n+\tPipelineHandler *createInstance(CameraManager *manager)\t\t\\\n \t{\t\t\t\t\t\t\t\t\\\n-\t\tstd::shared_ptr<handler> h =\t\t\t\t\\\n-\t\t\tstd::make_shared<handler>(manager);\t\t\\\n-\t\tsetInfo(h.get(), #handler);\t\t\t\t\\\n-\t\treturn h;\t\t\t\t\t\t\\\n+\t\treturn new handler(manager);\t\t\t\t\\\n \t}\t\t\t\t\t\t\t\t\\\n };\t\t\t\t\t\t\t\t\t\\\n static handler##Factory global_##handler##Factory;\ndiff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp\nindex 800931d81337..af19f4a33187 100644\n--- a/src/libcamera/pipeline_handler.cpp\n+++ b/src/libcamera/pipeline_handler.cpp\n@@ -539,17 +539,18 @@ PipelineHandlerFactory::PipelineHandlerFactory(const char *name)\n }\n \n /**\n- * \\fn PipelineHandlerFactory::create()\n  * \\brief Create an instance of the PipelineHandler corresponding to the factory\n  * \\param[in] manager The camera manager\n  *\n- * This virtual function is implemented by the REGISTER_PIPELINE_HANDLER()\n- * macro. It creates a pipeline handler instance associated with the camera\n- * \\a manager.\n- *\n- * \\return a pointer to a newly constructed instance of the PipelineHandler\n- * subclass corresponding to the factory\n+ * \\return A shared pointer to a new instance of the PipelineHandler subclass\n+ * corresponding to the factory\n  */\n+std::shared_ptr<PipelineHandler> PipelineHandlerFactory::create(CameraManager *manager)\n+{\n+\tPipelineHandler *handler = createInstance(manager);\n+\thandler->name_ = name_.c_str();\n+\treturn std::shared_ptr<PipelineHandler>(handler);\n+}\n \n /**\n  * \\fn PipelineHandlerFactory::name()\n@@ -589,15 +590,17 @@ std::vector<PipelineHandlerFactory *> &PipelineHandlerFactory::factories()\n }\n \n /**\n- * \\brief Set the information of a given pipeline handler\n- * \\param[in] handler The handler whose info is to be set\n- * \\param[in] name The name of the pipeline handler\n+ * \\fn PipelineHandlerFactory::createInstance()\n+ * \\brief Create an instance of the PipelineHandler corresponding to the factory\n+ * \\param[in] manager The camera manager\n+ *\n+ * This virtual function is implemented by the REGISTER_PIPELINE_HANDLER()\n+ * macro. It creates a pipeline handler instance associated with the camera\n+ * \\a manager.\n+ *\n+ * \\return a pointer to a newly constructed instance of the PipelineHandler\n+ * subclass corresponding to the factory\n  */\n-void PipelineHandlerFactory::setInfo(PipelineHandler *handler,\n-\t\t\t\t     const char *name)\n-{\n-\thandler->name_ = name;\n-}\n \n /**\n  * \\def REGISTER_PIPELINE_HANDLER\n",
    "prefixes": [
        "libcamera-devel"
    ]
}