[{"id":18087,"web_url":"https://patchwork.libcamera.org/comment/18087/","msgid":"<YOtdS12CRhZP3DSu@pendragon.ideasonboard.com>","date":"2021-07-11T21:06:19","subject":"Re: [libcamera-devel] [PATCH v2 1/3] libcamera: base: class: Expose\n\tExtensible private data to other classes","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"On Sun, Jul 11, 2021 at 08:03:57PM +0300, Laurent Pinchart wrote:\n> Despite sharing the same name, the private data class created by the\n> Extensible design pattern and the C++ private access specifier have\n> different goals. The latter specifies class members private to the\n> class, while the former stores data not visible to the application.\n> \n> There are use cases for accessing the private data class from other\n> classes inside libcamera. Make this possible by exposing public _d()\n> functions in the class deriving from Extensible. This won't allow access\n> to the private data by applications as the definition of the Private\n> class isn't visible outside of libcamera.\n> \n> The _d() functions need to be defined as template functions to delay\n> their evaluation, as the static_cast() operator in the Extensible::_d()\n> functions needs the Private class to be fully defined.\n\nThis should read\n\nThe _d() functions need to be defined as template functions to delay\ntheir evaluation, as the static_cast() operator in the Extensible::_d()\nfunctions needs the Private class to be fully defined. The template\nargument is defaulted an ignored, as only its presence is required to\ndelay evaluation.\n\n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>\n> Reviewed-by: Hirokazu Honda <hiroh@chromium.org>\n> ---\n>  include/libcamera/base/class.h | 14 ++++++++++++--\n>  1 file changed, 12 insertions(+), 2 deletions(-)\n> \n> diff --git a/include/libcamera/base/class.h b/include/libcamera/base/class.h\n> index a07dac057331..8212c3d4a5ae 100644\n> --- a/include/libcamera/base/class.h\n> +++ b/include/libcamera/base/class.h\n> @@ -33,14 +33,24 @@ namespace libcamera {\n>  #define LIBCAMERA_DECLARE_PRIVATE()\t\t\t\t\t\\\n>  public:\t\t\t\t\t\t\t\t\t\\\n>  \tclass Private;\t\t\t\t\t\t\t\\\n> -\tfriend class Private;\n> +\tfriend class Private;\t\t\t\t\t\t\\\n> +\ttemplate <bool B = true>\t\t\t\t\t\\\n> +\tconst Private *_d() const\t\t\t\t\t\\\n> +\t{\t\t\t\t\t\t\t\t\\\n> +\t\treturn Extensible::_d<Private>();\t\t\t\\\n> +\t}\t\t\t\t\t\t\t\t\\\n> +\ttemplate <bool B = true>\t\t\t\t\t\\\n> +\tPrivate *_d()\t\t\t\t\t\t\t\\\n> +\t{\t\t\t\t\t\t\t\t\\\n> +\t\treturn Extensible::_d<Private>();\t\t\t\\\n> +\t}\n>  \n>  #define LIBCAMERA_DECLARE_PUBLIC(klass)\t\t\t\t\t\\\n>  \tfriend class klass;\t\t\t\t\t\t\\\n>  \tusing Public = klass;\n>  \n>  #define LIBCAMERA_D_PTR()\t\t\t\t\t\t\\\n> -\t_d<Private>();\n> +\t_d();\n>  \n>  #define LIBCAMERA_O_PTR()\t\t\t\t\t\t\\\n>  \t_o<Public>();","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 862FABD794\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun, 11 Jul 2021 21:07:07 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id EEABF6851D;\n\tSun, 11 Jul 2021 23:07:06 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 5A7CD68519\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 11 Jul 2021 23:07:05 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id CA012CC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 11 Jul 2021 23:07:04 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"nfMdqMap\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1626037625;\n\tbh=S7eemU7ZhCf+6Qtg5Gt169wnzcsffCjDb8npQoXbeTA=;\n\th=Date:From:To:Subject:References:In-Reply-To:From;\n\tb=nfMdqMapTb6zfErXTs8VtfH2FuaSFGO6mbJ0qmBb391b3tMAP6enz2qKdMcu1yjB4\n\tkUKCP1TpKEzq36AqhbX6KsTlzNmuGDhfpqS9Koh+IbvfHodBWbwVU5DfBCRHxzsphN\n\tmoiQBXtYbkbz9y01pKrlcSyJsjfZVFWfuxRuzhmI=","Date":"Mon, 12 Jul 2021 00:06:19 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Message-ID":"<YOtdS12CRhZP3DSu@pendragon.ideasonboard.com>","References":"<20210711170359.300-1-laurent.pinchart@ideasonboard.com>\n\t<20210711170359.300-2-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20210711170359.300-2-laurent.pinchart@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v2 1/3] libcamera: base: class: Expose\n\tExtensible private data to other classes","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":18101,"web_url":"https://patchwork.libcamera.org/comment/18101/","msgid":"<5f2167b2-9352-c788-c5c9-75d599de6601@ideasonboard.com>","date":"2021-07-12T08:28:00","subject":"Re: [libcamera-devel] [PATCH v2 1/3] libcamera: base: class: Expose\n\tExtensible private data to other classes","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Hi Laurent,\n\nOn 11/07/2021 22:06, Laurent Pinchart wrote:\n> On Sun, Jul 11, 2021 at 08:03:57PM +0300, Laurent Pinchart wrote:\n>> Despite sharing the same name, the private data class created by the\n>> Extensible design pattern and the C++ private access specifier have\n>> different goals. The latter specifies class members private to the\n>> class, while the former stores data not visible to the application.\n>>\n>> There are use cases for accessing the private data class from other\n>> classes inside libcamera. Make this possible by exposing public _d()\n>> functions in the class deriving from Extensible. This won't allow access\n>> to the private data by applications as the definition of the Private\n>> class isn't visible outside of libcamera.\n>>\n>> The _d() functions need to be defined as template functions to delay\n>> their evaluation, as the static_cast() operator in the Extensible::_d()\n>> functions needs the Private class to be fully defined.\n> \n> This should read\n> \n> The _d() functions need to be defined as template functions to delay\n> their evaluation, as the static_cast() operator in the Extensible::_d()\n> functions needs the Private class to be fully defined. The template\n> argument is defaulted an ignored, as only its presence is required to\n\ns/an/and/\n\n> delay evaluation.\n> \n>> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n>> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n>> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>\n>> Reviewed-by: Hirokazu Honda <hiroh@chromium.org>\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n>> ---\n>>  include/libcamera/base/class.h | 14 ++++++++++++--\n>>  1 file changed, 12 insertions(+), 2 deletions(-)\n>>\n>> diff --git a/include/libcamera/base/class.h b/include/libcamera/base/class.h\n>> index a07dac057331..8212c3d4a5ae 100644\n>> --- a/include/libcamera/base/class.h\n>> +++ b/include/libcamera/base/class.h\n>> @@ -33,14 +33,24 @@ namespace libcamera {\n>>  #define LIBCAMERA_DECLARE_PRIVATE()\t\t\t\t\t\\\n>>  public:\t\t\t\t\t\t\t\t\t\\\n>>  \tclass Private;\t\t\t\t\t\t\t\\\n>> -\tfriend class Private;\n>> +\tfriend class Private;\t\t\t\t\t\t\\\n>> +\ttemplate <bool B = true>\t\t\t\t\t\\\n>> +\tconst Private *_d() const\t\t\t\t\t\\\n>> +\t{\t\t\t\t\t\t\t\t\\\n>> +\t\treturn Extensible::_d<Private>();\t\t\t\\\n>> +\t}\t\t\t\t\t\t\t\t\\\n>> +\ttemplate <bool B = true>\t\t\t\t\t\\>> +\tPrivate *_d()\t\t\t\t\t\t\t\\\n>> +\t{\t\t\t\t\t\t\t\t\\\n>> +\t\treturn Extensible::_d<Private>();\t\t\t\\\n>> +\t}\n>>  \n>>  #define LIBCAMERA_DECLARE_PUBLIC(klass)\t\t\t\t\t\\\n>>  \tfriend class klass;\t\t\t\t\t\t\\\n>>  \tusing Public = klass;\n>>  \n>>  #define LIBCAMERA_D_PTR()\t\t\t\t\t\t\\\n>> -\t_d<Private>();\n>> +\t_d();\n>>  \n>>  #define LIBCAMERA_O_PTR()\t\t\t\t\t\t\\\n>>  \t_o<Public>();\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id C96CFC3224\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 12 Jul 2021 08:28:05 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 44E5868524;\n\tMon, 12 Jul 2021 10:28:05 +0200 (CEST)","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 8C71D68506\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 12 Jul 2021 10:28:03 +0200 (CEST)","from [192.168.0.20]\n\t(cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 2575FCC;\n\tMon, 12 Jul 2021 10:28:03 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"d5vj23Jd\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1626078483;\n\tbh=RoXBS8/CZlqNazprwVDvL2ZJ7bFQI49Sz/h4dQ4oD5I=;\n\th=Subject:To:References:From:Date:In-Reply-To:From;\n\tb=d5vj23JdI3yalfZP+CmtgpVIDiFh/re7B9TLwVAqznRf38i1NpQqUQIpkMb3xQ1QP\n\twfvl28ZnN21aTwHjbY1a7N2Nl8WzTKtqkLe4oU2LKsY0brT5Nfkqey0u9c9IpajPEA\n\tkFtMCzsSEaETOGMsO5mBDeXvdC+XYFy1JhVOg+8w=","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20210711170359.300-1-laurent.pinchart@ideasonboard.com>\n\t<20210711170359.300-2-laurent.pinchart@ideasonboard.com>\n\t<YOtdS12CRhZP3DSu@pendragon.ideasonboard.com>","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Message-ID":"<5f2167b2-9352-c788-c5c9-75d599de6601@ideasonboard.com>","Date":"Mon, 12 Jul 2021 09:28:00 +0100","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101\n\tThunderbird/78.11.0","MIME-Version":"1.0","In-Reply-To":"<YOtdS12CRhZP3DSu@pendragon.ideasonboard.com>","Content-Type":"text/plain; charset=utf-8","Content-Language":"en-GB","Content-Transfer-Encoding":"7bit","Subject":"Re: [libcamera-devel] [PATCH v2 1/3] libcamera: base: class: Expose\n\tExtensible private data to other classes","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]