[libcamera-devel,v5,08/10] libcamera: media_object: Add a const version of dev()
diff mbox series

Message ID 20210105123128.617543-9-jacopo@jmondi.org
State Superseded
Headers show
Series
  • libcamera: camera_sensor: Make validation more strict
Related show

Commit Message

Jacopo Mondi Jan. 5, 2021, 12:31 p.m. UTC
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@jmondi.org>
---
 include/libcamera/internal/media_object.h | 1 +
 src/libcamera/media_object.cpp            | 6 ++++++
 2 files changed, 7 insertions(+)

Comments

Niklas Söderlund Jan. 6, 2021, 10:51 a.m. UTC | #1
Hi Jacopo,

Thanks for your work.

On 2021-01-05 13:31:26 +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@jmondi.org>

Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>

> ---
>  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
> + * \brief Retrieve the const media device the media object belongs to
> + * \return The const MediaDevice
> + */
> +
>  /**
>   * \fn MediaObject::id()
>   * \brief Retrieve the media object id
> -- 
> 2.29.2
> 
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel
Laurent Pinchart Jan. 7, 2021, 2:52 a.m. UTC | #2
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@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@ideasonboard.com>

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

Patch
diff mbox series

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
+ * \brief Retrieve the const media device the media object belongs to
+ * \return The const MediaDevice
+ */
+
 /**
  * \fn MediaObject::id()
  * \brief Retrieve the media object id