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

Jacopo Mondi jacopo at jmondi.org
Thu Jan 7 10:47:33 CET 2021


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.

Reviewed-by: Niklas Söderlund <niklas.soderlund at ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo at jmondi.org>
---
 include/libcamera/internal/media_object.h | 1 +
 src/libcamera/media_object.cpp            | 5 +++++
 2 files changed, 6 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..94aeb50402ca 100644
--- a/src/libcamera/media_object.cpp
+++ b/src/libcamera/media_object.cpp
@@ -67,6 +67,11 @@ LOG_DECLARE_CATEGORY(MediaDevice)
 
 /**
  * \fn MediaObject::device()
+ * \copydoc MediaObject::device() const
+ */
+
+/**
+ * \fn MediaObject::device() const
  * \brief Retrieve the media device the media object belongs to
  * \return The MediaDevice
  */
-- 
2.29.2



More information about the libcamera-devel mailing list