[libcamera-devel,v2,04/24] libcamera: controls: Add operator== and operator!= to ControlRange

Message ID 20191108205409.18845-5-laurent.pinchart@ideasonboard.com
State Accepted
Headers show
Series
  • Control serialization and IPA C API
Related show

Commit Message

Laurent Pinchart Nov. 8, 2019, 8:53 p.m. UTC
Allow comparision of control ranges by adding the required operators.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 include/libcamera/controls.h |  9 +++++++++
 src/libcamera/controls.cpp   | 11 +++++++++++
 2 files changed, 20 insertions(+)

Comments

Niklas Söderlund Nov. 14, 2019, 8:14 a.m. UTC | #1
Hi Laurent,

Thanks for your patch.

On 2019-11-08 22:53:49 +0200, Laurent Pinchart wrote:
> Allow comparision of control ranges by adding the required operators.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

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

> ---
>  include/libcamera/controls.h |  9 +++++++++
>  src/libcamera/controls.cpp   | 11 +++++++++++
>  2 files changed, 20 insertions(+)
> 
> diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h
> index 42e6df7e613d..19075858fbba 100644
> --- a/include/libcamera/controls.h
> +++ b/include/libcamera/controls.h
> @@ -112,6 +112,15 @@ public:
>  
>  	std::string toString() const;
>  
> +	bool operator==(const ControlRange &other) const
> +	{
> +		return min_ == other.min_ && max_ == other.max_;
> +	}
> +	bool operator!=(const ControlRange &other) const
> +	{
> +		return !(*this == other);
> +	}
> +
>  private:
>  	ControlValue min_;
>  	ControlValue max_;
> diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp
> index 0c7cd449ad64..2c5c98633585 100644
> --- a/src/libcamera/controls.cpp
> +++ b/src/libcamera/controls.cpp
> @@ -383,6 +383,17 @@ std::string ControlRange::toString() const
>  	return ss.str();
>  }
>  
> +/**
> + * \fn bool ControlRange::operator==()
> + * \brief Compare ControlRange instances for equality
> + * \return True if the ranges have identical min and max, false otherwise
> + */
> +/**
> + * \fn bool ControlRange::operator!=()
> + * \brief Compare ControlRange instances for non equality
> + * \return False if the ranges have identical min and max, true otherwise
> + */
> +
>  /**
>   * \typedef ControlIdMap
>   * \brief A map of numerical control ID to ControlId
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel
Jacopo Mondi Nov. 15, 2019, 4:02 p.m. UTC | #2
Hi Laurent,

On Fri, Nov 08, 2019 at 10:53:49PM +0200, Laurent Pinchart wrote:
> Allow comparision of control ranges by adding the required operators.
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>  include/libcamera/controls.h |  9 +++++++++
>  src/libcamera/controls.cpp   | 11 +++++++++++
>  2 files changed, 20 insertions(+)
>
> diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h
> index 42e6df7e613d..19075858fbba 100644
> --- a/include/libcamera/controls.h
> +++ b/include/libcamera/controls.h
> @@ -112,6 +112,15 @@ public:
>
>  	std::string toString() const;
>
> +	bool operator==(const ControlRange &other) const
> +	{
> +		return min_ == other.min_ && max_ == other.max_;
> +	}

(optional) empty line ?

> +	bool operator!=(const ControlRange &other) const
> +	{
> +		return !(*this == other);
> +	}
> +
>  private:
>  	ControlValue min_;
>  	ControlValue max_;
> diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp
> index 0c7cd449ad64..2c5c98633585 100644
> --- a/src/libcamera/controls.cpp
> +++ b/src/libcamera/controls.cpp
> @@ -383,6 +383,17 @@ std::string ControlRange::toString() const
>  	return ss.str();
>  }
>
> +/**
> + * \fn bool ControlRange::operator==()
> + * \brief Compare ControlRange instances for equality
> + * \return True if the ranges have identical min and max, false otherwise
> + */

empty line?

> +/**
> + * \fn bool ControlRange::operator!=()
> + * \brief Compare ControlRange instances for non equality
> + * \return False if the ranges have identical min and max, true otherwise
> + */
> +

minor nits apart
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>

Thanks
  j

>  /**
>   * \typedef ControlIdMap
>   * \brief A map of numerical control ID to ControlId
> --
> Regards,
>
> Laurent Pinchart
>
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel
Laurent Pinchart Nov. 18, 2019, 12:47 a.m. UTC | #3
Hi Jacopo,

On Fri, Nov 15, 2019 at 05:02:17PM +0100, Jacopo Mondi wrote:
> On Fri, Nov 08, 2019 at 10:53:49PM +0200, Laurent Pinchart wrote:
> > Allow comparision of control ranges by adding the required operators.
> >
> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > ---
> >  include/libcamera/controls.h |  9 +++++++++
> >  src/libcamera/controls.cpp   | 11 +++++++++++
> >  2 files changed, 20 insertions(+)
> >
> > diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h
> > index 42e6df7e613d..19075858fbba 100644
> > --- a/include/libcamera/controls.h
> > +++ b/include/libcamera/controls.h
> > @@ -112,6 +112,15 @@ public:
> >
> >  	std::string toString() const;
> >
> > +	bool operator==(const ControlRange &other) const
> > +	{
> > +		return min_ == other.min_ && max_ == other.max_;
> > +	}
> 
> (optional) empty line ?
> 
> > +	bool operator!=(const ControlRange &other) const
> > +	{
> > +		return !(*this == other);
> > +	}
> > +
> >  private:
> >  	ControlValue min_;
> >  	ControlValue max_;
> > diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp
> > index 0c7cd449ad64..2c5c98633585 100644
> > --- a/src/libcamera/controls.cpp
> > +++ b/src/libcamera/controls.cpp
> > @@ -383,6 +383,17 @@ std::string ControlRange::toString() const
> >  	return ss.str();
> >  }
> >
> > +/**
> > + * \fn bool ControlRange::operator==()
> > + * \brief Compare ControlRange instances for equality
> > + * \return True if the ranges have identical min and max, false otherwise
> > + */
> 
> empty line?

Empty lines added, thanks for catching this.

> > +/**
> > + * \fn bool ControlRange::operator!=()
> > + * \brief Compare ControlRange instances for non equality
> > + * \return False if the ranges have identical min and max, true otherwise
> > + */
> > +
> 
> minor nits apart
> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
> 
> >  /**
> >   * \typedef ControlIdMap
> >   * \brief A map of numerical control ID to ControlId

Patch

diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h
index 42e6df7e613d..19075858fbba 100644
--- a/include/libcamera/controls.h
+++ b/include/libcamera/controls.h
@@ -112,6 +112,15 @@  public:
 
 	std::string toString() const;
 
+	bool operator==(const ControlRange &other) const
+	{
+		return min_ == other.min_ && max_ == other.max_;
+	}
+	bool operator!=(const ControlRange &other) const
+	{
+		return !(*this == other);
+	}
+
 private:
 	ControlValue min_;
 	ControlValue max_;
diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp
index 0c7cd449ad64..2c5c98633585 100644
--- a/src/libcamera/controls.cpp
+++ b/src/libcamera/controls.cpp
@@ -383,6 +383,17 @@  std::string ControlRange::toString() const
 	return ss.str();
 }
 
+/**
+ * \fn bool ControlRange::operator==()
+ * \brief Compare ControlRange instances for equality
+ * \return True if the ranges have identical min and max, false otherwise
+ */
+/**
+ * \fn bool ControlRange::operator!=()
+ * \brief Compare ControlRange instances for non equality
+ * \return False if the ranges have identical min and max, true otherwise
+ */
+
 /**
  * \typedef ControlIdMap
  * \brief A map of numerical control ID to ControlId