[libcamera-devel,02/11] libcamera: log: Mark Loggable::_log() methods as const

Message ID 20190415165700.22970-3-laurent.pinchart@ideasonboard.com
State Superseded
Headers show
Series
  • Rockchip ISP pipeline handler
Related show

Commit Message

Laurent Pinchart April 15, 2019, 4:56 p.m. UTC
The methods don't modify the object instance, mark them as const. This
allows using the LOG() macro from a const method of a Loggable object.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 src/libcamera/include/log.h | 5 +++--
 src/libcamera/log.cpp       | 5 +++--
 2 files changed, 6 insertions(+), 4 deletions(-)

Comments

Niklas Söderlund April 15, 2019, 8:16 p.m. UTC | #1
Hi Laurent,

Thanks for your patch.

On 2019-04-15 19:56:51 +0300, Laurent Pinchart wrote:
> The methods don't modify the object instance, mark them as const. This
> allows using the LOG() macro from a const method of a Loggable object.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

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

> ---
>  src/libcamera/include/log.h | 5 +++--
>  src/libcamera/log.cpp       | 5 +++--
>  2 files changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/src/libcamera/include/log.h b/src/libcamera/include/log.h
> index 8ea5a1eb673a..35a6fc105448 100644
> --- a/src/libcamera/include/log.h
> +++ b/src/libcamera/include/log.h
> @@ -76,9 +76,10 @@ protected:
>  	virtual std::string logPrefix() const = 0;
>  
>  	LogMessage _log(const char *file, unsigned int line,
> -			LogSeverity severity);
> +			LogSeverity severity) const;
>  	LogMessage _log(const char *file, unsigned int line,
> -			const LogCategory &category, LogSeverity severity);
> +			const LogCategory &category,
> +			LogSeverity severity) const;
>  };
>  
>  LogMessage _log(const char *file, unsigned int line, LogSeverity severity);
> diff --git a/src/libcamera/log.cpp b/src/libcamera/log.cpp
> index 71cfbc422ba0..77927ec35b62 100644
> --- a/src/libcamera/log.cpp
> +++ b/src/libcamera/log.cpp
> @@ -506,7 +506,7 @@ Loggable::~Loggable()
>   * \return A log message
>   */
>  LogMessage Loggable::_log(const char *fileName, unsigned int line,
> -			  LogSeverity severity)
> +			  LogSeverity severity) const
>  {
>  	LogMessage msg(fileName, line, severity);
>  
> @@ -527,7 +527,8 @@ LogMessage Loggable::_log(const char *fileName, unsigned int line,
>   * \return A log message
>   */
>  LogMessage Loggable::_log(const char *fileName, unsigned int line,
> -			  const LogCategory &category, LogSeverity severity)
> +			  const LogCategory &category,
> +			  LogSeverity severity) const
>  {
>  	LogMessage msg(fileName, line, category, severity);
>  
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel
Jacopo Mondi April 16, 2019, 2:54 p.m. UTC | #2
Hi Laurent,

On Mon, Apr 15, 2019 at 07:56:51PM +0300, Laurent Pinchart wrote:
> The methods don't modify the object instance, mark them as const. This
> allows using the LOG() macro from a const method of a Loggable object.
>

Thanks,
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>

> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>  src/libcamera/include/log.h | 5 +++--
>  src/libcamera/log.cpp       | 5 +++--
>  2 files changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/src/libcamera/include/log.h b/src/libcamera/include/log.h
> index 8ea5a1eb673a..35a6fc105448 100644
> --- a/src/libcamera/include/log.h
> +++ b/src/libcamera/include/log.h
> @@ -76,9 +76,10 @@ protected:
>  	virtual std::string logPrefix() const = 0;
>
>  	LogMessage _log(const char *file, unsigned int line,
> -			LogSeverity severity);
> +			LogSeverity severity) const;
>  	LogMessage _log(const char *file, unsigned int line,
> -			const LogCategory &category, LogSeverity severity);
> +			const LogCategory &category,
> +			LogSeverity severity) const;
>  };
>
>  LogMessage _log(const char *file, unsigned int line, LogSeverity severity);
> diff --git a/src/libcamera/log.cpp b/src/libcamera/log.cpp
> index 71cfbc422ba0..77927ec35b62 100644
> --- a/src/libcamera/log.cpp
> +++ b/src/libcamera/log.cpp
> @@ -506,7 +506,7 @@ Loggable::~Loggable()
>   * \return A log message
>   */
>  LogMessage Loggable::_log(const char *fileName, unsigned int line,
> -			  LogSeverity severity)
> +			  LogSeverity severity) const
>  {
>  	LogMessage msg(fileName, line, severity);
>
> @@ -527,7 +527,8 @@ LogMessage Loggable::_log(const char *fileName, unsigned int line,
>   * \return A log message
>   */
>  LogMessage Loggable::_log(const char *fileName, unsigned int line,
> -			  const LogCategory &category, LogSeverity severity)
> +			  const LogCategory &category,
> +			  LogSeverity severity) const
>  {
>  	LogMessage msg(fileName, line, category, severity);
>
> --
> Regards,
>
> Laurent Pinchart
>
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel

Patch

diff --git a/src/libcamera/include/log.h b/src/libcamera/include/log.h
index 8ea5a1eb673a..35a6fc105448 100644
--- a/src/libcamera/include/log.h
+++ b/src/libcamera/include/log.h
@@ -76,9 +76,10 @@  protected:
 	virtual std::string logPrefix() const = 0;
 
 	LogMessage _log(const char *file, unsigned int line,
-			LogSeverity severity);
+			LogSeverity severity) const;
 	LogMessage _log(const char *file, unsigned int line,
-			const LogCategory &category, LogSeverity severity);
+			const LogCategory &category,
+			LogSeverity severity) const;
 };
 
 LogMessage _log(const char *file, unsigned int line, LogSeverity severity);
diff --git a/src/libcamera/log.cpp b/src/libcamera/log.cpp
index 71cfbc422ba0..77927ec35b62 100644
--- a/src/libcamera/log.cpp
+++ b/src/libcamera/log.cpp
@@ -506,7 +506,7 @@  Loggable::~Loggable()
  * \return A log message
  */
 LogMessage Loggable::_log(const char *fileName, unsigned int line,
-			  LogSeverity severity)
+			  LogSeverity severity) const
 {
 	LogMessage msg(fileName, line, severity);
 
@@ -527,7 +527,8 @@  LogMessage Loggable::_log(const char *fileName, unsigned int line,
  * \return A log message
  */
 LogMessage Loggable::_log(const char *fileName, unsigned int line,
-			  const LogCategory &category, LogSeverity severity)
+			  const LogCategory &category,
+			  LogSeverity severity) const
 {
 	LogMessage msg(fileName, line, category, severity);