[libcamera-devel,2/2] libcamera: media_device: Make getEntityByName() const

Message ID 20190102110016.5489-2-jacopo@jmondi.org
State Accepted
Headers show
Series
  • [libcamera-devel,1/2] libcamera: media_device: Tiny valid() documentation improvement
Related show

Commit Message

Jacopo Mondi Jan. 2, 2019, 11 a.m. UTC
The function does not modify the instance state. Mark it as const.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
---
 src/libcamera/include/media_device.h | 2 +-
 src/libcamera/media_device.cpp       | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

--
2.20.1

Comments

Laurent Pinchart Jan. 2, 2019, 11:11 a.m. UTC | #1
Hi Jacopo,

Thank you for the patch.

On Wednesday, 2 January 2019 13:00:16 EET Jacopo Mondi wrote:
> The function does not modify the instance state. Mark it as const.
> 
> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>

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

Please push.

> ---
>  src/libcamera/include/media_device.h | 2 +-
>  src/libcamera/media_device.cpp       | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/src/libcamera/include/media_device.h
> b/src/libcamera/include/media_device.h index d787be3..9db18bb 100644
> --- a/src/libcamera/include/media_device.h
> +++ b/src/libcamera/include/media_device.h
> @@ -34,7 +34,7 @@ public:
>  	const std::string devnode() const { return devnode_; }
> 
>  	const std::vector<MediaEntity *> &entities() const { return entities_; }
> -	MediaEntity *getEntityByName(const std::string &name);
> +	MediaEntity *getEntityByName(const std::string &name) const;
> 
>  private:
>  	std::string driver_;
> diff --git a/src/libcamera/media_device.cpp b/src/libcamera/media_device.cpp
> index 9fbc5a7..25d1825 100644
> --- a/src/libcamera/media_device.cpp
> +++ b/src/libcamera/media_device.cpp
> @@ -244,7 +244,7 @@ int MediaDevice::populate()
>   * \return The entity with \a name
>   * \return nullptr if no entity with \a name is found
>   */
> -MediaEntity *MediaDevice::getEntityByName(const std::string &name)
> +MediaEntity *MediaDevice::getEntityByName(const std::string &name) const
>  {
>  	for (MediaEntity *e : entities_)
>  		if (e->name() == name)
> --
> 2.20.1
> 
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel

Patch

diff --git a/src/libcamera/include/media_device.h b/src/libcamera/include/media_device.h
index d787be3..9db18bb 100644
--- a/src/libcamera/include/media_device.h
+++ b/src/libcamera/include/media_device.h
@@ -34,7 +34,7 @@  public:
 	const std::string devnode() const { return devnode_; }

 	const std::vector<MediaEntity *> &entities() const { return entities_; }
-	MediaEntity *getEntityByName(const std::string &name);
+	MediaEntity *getEntityByName(const std::string &name) const;

 private:
 	std::string driver_;
diff --git a/src/libcamera/media_device.cpp b/src/libcamera/media_device.cpp
index 9fbc5a7..25d1825 100644
--- a/src/libcamera/media_device.cpp
+++ b/src/libcamera/media_device.cpp
@@ -244,7 +244,7 @@  int MediaDevice::populate()
  * \return The entity with \a name
  * \return nullptr if no entity with \a name is found
  */
-MediaEntity *MediaDevice::getEntityByName(const std::string &name)
+MediaEntity *MediaDevice::getEntityByName(const std::string &name) const
 {
 	for (MediaEntity *e : entities_)
 		if (e->name() == name)