[libcamera-devel] [PATCH v5 08/10] libcamera: media_object: Add a const version of dev()

Laurent Pinchart laurent.pinchart at ideasonboard.com
Thu Jan 7 03:52:13 CET 2021


Hi Jacopo,

Thank you for the patch.

On Tue, Jan 05, 2021 at 01:31:26PM +0100, Jacopo Mondi wrote:
> Add a const version of the MediaObject::dev() method to be able to
> retrieve a pointer to a const MediaDevice from a constant instance of
> a MediaObject sub-class.
> 
> Signed-off-by: Jacopo Mondi <jacopo at jmondi.org>
> ---
>  include/libcamera/internal/media_object.h | 1 +
>  src/libcamera/media_object.cpp            | 6 ++++++
>  2 files changed, 7 insertions(+)
> 
> diff --git a/include/libcamera/internal/media_object.h b/include/libcamera/internal/media_object.h
> index 43a35bef8f35..2b336961f98d 100644
> --- a/include/libcamera/internal/media_object.h
> +++ b/include/libcamera/internal/media_object.h
> @@ -22,6 +22,7 @@ class MediaObject
>  {
>  public:
>  	MediaDevice *device() { return dev_; }
> +	const MediaDevice *device() const { return dev_; }
>  	unsigned int id() const { return id_; }
>  
>  protected:
> diff --git a/src/libcamera/media_object.cpp b/src/libcamera/media_object.cpp
> index 056036635902..cd3cd8ac17a4 100644
> --- a/src/libcamera/media_object.cpp
> +++ b/src/libcamera/media_object.cpp
> @@ -71,6 +71,12 @@ LOG_DECLARE_CATEGORY(MediaDevice)
>   * \return The MediaDevice
>   */
>  
> +/**
> + * \fn const MediaObject::device() const

You can drop the first const.

> + * \brief Retrieve the const media device the media object belongs to
> + * \return The const MediaDevice
> + */

Do you know about copydoc ?

 /**
  * \fn MediaObject::device() const
  * \copydoc MediaObject::device()
  */

(You may need to move the documentation of the existing function to the
const version, and use \copydoc MediaObject::device() const in the
non-const version, if doxygen has trouble with the above)

Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>

> +
>  /**
>   * \fn MediaObject::id()
>   * \brief Retrieve the media object id

-- 
Regards,

Laurent Pinchart


More information about the libcamera-devel mailing list