{"id":326,"url":"https://patchwork.libcamera.org/api/1.1/patches/326/?format=json","web_url":"https://patchwork.libcamera.org/patch/326/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20190122181225.12922-2-jacopo@jmondi.org>","date":"2019-01-22T18:12:24","name":"[libcamera-devel,RFC,1/2] libcamera: camera: Add CameraData","commit_ref":null,"pull_url":null,"state":"rejected","archived":false,"hash":"42d742cb49f77d4b2f627c8bb677243237575af2","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/1.1/people/3/?format=json","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/326/mbox/","series":[{"id":114,"url":"https://patchwork.libcamera.org/api/1.1/series/114/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=114","date":"2019-01-22T18:12:23","name":"Add support for pipeline specific data to Cameras","version":1,"mbox":"https://patchwork.libcamera.org/series/114/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/326/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/326/checks/","tags":{},"headers":{"Return-Path":"<jacopo@jmondi.org>","Received":["from relay11.mail.gandi.net (relay11.mail.gandi.net\n\t[217.70.178.231])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A277460B23\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 22 Jan 2019 19:12:23 +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 relay11.mail.gandi.net (Postfix) with ESMTPSA id 38E3B10000B;\n\tTue, 22 Jan 2019 18:12:23 +0000 (UTC)"],"From":"Jacopo Mondi <jacopo@jmondi.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Tue, 22 Jan 2019 19:12:24 +0100","Message-Id":"<20190122181225.12922-2-jacopo@jmondi.org>","X-Mailer":"git-send-email 2.20.1","In-Reply-To":"<20190122181225.12922-1-jacopo@jmondi.org>","References":"<20190122181225.12922-1-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [RFC 1/2] libcamera: camera: Add CameraData","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":"Tue, 22 Jan 2019 18:12:23 -0000"},"content":"Add abstract base class CameraData for pipeline handlers to store\npipeline specific data in Camera class instances.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n include/libcamera/camera.h | 13 ++++++++++\n src/libcamera/camera.cpp   | 50 ++++++++++++++++++++++++++++++++++++++\n 2 files changed, 63 insertions(+)","diff":"diff --git a/include/libcamera/camera.h b/include/libcamera/camera.h\nindex 2ea1a68..50041f1 100644\n--- a/include/libcamera/camera.h\n+++ b/include/libcamera/camera.h\n@@ -12,6 +12,15 @@\n \n namespace libcamera {\n \n+class CameraData\n+{\n+public:\n+\tvirtual ~CameraData() { }\n+protected:\n+\tCameraData() { }\n+\tCameraData(CameraData &) = delete;\n+};\n+\n class Camera final\n {\n public:\n@@ -22,11 +31,15 @@ public:\n \n \tconst std::string &name() const;\n \n+\tCameraData *cameraData() const { return data_.get(); }\n+\tvoid setCameraData(CameraData *data);\n+\n private:\n \texplicit Camera(const std::string &name);\n \t~Camera();\n \n \tstd::string name_;\n+\tstd::unique_ptr<CameraData> data_;\n };\n \n } /* namespace libcamera */\ndiff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp\nindex acf912b..1e2c858 100644\n--- a/src/libcamera/camera.cpp\n+++ b/src/libcamera/camera.cpp\n@@ -33,6 +33,26 @@\n \n namespace libcamera {\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 Camera::setCameraData() method, and access them at a later time\n+ * with Camera::cameraData().\n+ *\n+ * Once associated with a camera, lifetime of derived classes instances will\n+ * be tied to the one of the Camera instance itself.\n+ *\n+ * \\sa Camera::setCameraData()\n+ * \\sa Camera::cameraData()\n+ */\n+\n /**\n  * \\class Camera\n  * \\brief Camera device\n@@ -83,6 +103,36 @@ const std::string &Camera::name() const\n \treturn name_;\n }\n \n+/**\n+ * \\fn CameraData *Camera::cameraData()\n+ * \\brief Retrieve the pipeline specific data\n+ *\n+ * Borrow a reference to the platform specific data, associated to a camera\n+ * by pipeline handlers using the setCameraData() method.\n+ */\n+\n+/**\n+ * \\brief Set pipeline specific data in the camera\n+ *\n+ * Pipeline handlers might need to associate platform-specific informations to\n+ * camera instances, this method allows them to do so while also transferring\n+ * ownership of the \\a cameraData to the Camera instance.\n+ *\n+ * Pipeline specific data are stored as unique_ptr<> to guarantee its\n+ * destruction at Camera deletion time.\n+ *\n+ * Pipeline specific data can be accessed again by pipeline handlers by\n+ * borrowing a (mutable) reference using the cameraData() method.\n+ *\n+ * \\sa Camera::cameraData()\n+ * \\sa CameraData\n+ */\n+void Camera::setCameraData(CameraData *data)\n+{\n+\tdata_ = std::unique_ptr<CameraData>(data);\n+\n+}\n+\n Camera::Camera(const std::string &name)\n \t: name_(name)\n {\n","prefixes":["libcamera-devel","RFC","1/2"]}