[libcamera-devel] [PATCH 3/9] libcamera: flags: Add friend class IPADataSerializer

Laurent Pinchart laurent.pinchart at ideasonboard.com
Tue Aug 9 03:12:54 CEST 2022


Hi Paul,

Thank you for the patch.

On Wed, Aug 03, 2022 at 08:21:44PM +0900, Paul Elder via libcamera-devel wrote:
> To prepare for the ability to send Flags over IPC, add IPADataSerializer
> as a friend class to Flags.
> 
> Signed-off-by: Paul Elder <paul.elder at ideasonboard.com>
> ---
>  include/libcamera/base/flags.h | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/include/libcamera/base/flags.h b/include/libcamera/base/flags.h
> index a1b404bd..43afdf26 100644
> --- a/include/libcamera/base/flags.h
> +++ b/include/libcamera/base/flags.h
> @@ -137,6 +137,9 @@ public:
>  	}
>  
>  private:
> +	template<typename>
> +	friend class IPADataSerializer;

I'd rather not do this, to avoid exposing internals in the public API.
You can convert a Flags to the raw value with operator Type(), which is
called by

	static_cast<Flags<...>::Type>(flags)

I however suspect you need the friend statement for the other way
around. I think you can use the Flags(E flag) constructor then, casting
the deserialized uint32_t to a E first.

> +
>  	Type value_;
>  };
>  

-- 
Regards,

Laurent Pinchart


More information about the libcamera-devel mailing list