[libcamera-devel] [PATCH] libcamera: request: Add operator<<()

Jacopo Mondi jacopo at jmondi.org
Fri Jun 3 18:12:11 CEST 2022


Hi Laurent

On Fri, Jun 03, 2022 at 03:46:45PM +0300, Laurent Pinchart wrote:
> Hi Jacopo,
>
> Thank you for the patch.
>
> On Fri, Jun 03, 2022 at 11:32:24AM +0200, Jacopo Mondi via libcamera-devel wrote:
> > With the recent addition of operator<<() to most libcamera core classes
> > to replace usage of the toString() function, the Request class was left
> > behind.
> >
> > Add operator<<() for the Request class.
> >
> > Signed-off-by: Jacopo Mondi <jacopo at jmondi.org>
> > ---
> >  include/libcamera/request.h |  3 +++
> >  src/libcamera/request.cpp   | 12 ++++++++++++
> >  2 files changed, 15 insertions(+)
> >
> > diff --git a/include/libcamera/request.h b/include/libcamera/request.h
> > index 1eb537e9b09b..dffde1536cad 100644
> > --- a/include/libcamera/request.h
> > +++ b/include/libcamera/request.h
> > @@ -9,6 +9,7 @@
> >
> >  #include <map>
> >  #include <memory>
> > +#include <ostream>
> >  #include <stdint.h>
> >  #include <string>
> >  #include <unordered_set>
> > @@ -75,4 +76,6 @@ private:
> >  	Status status_;
> >  };
> >
> > +std::ostream &operator<<(std::ostream &out, const Request &r);
> > +
> >  } /* namespace libcamera */
> > diff --git a/src/libcamera/request.cpp b/src/libcamera/request.cpp
> > index 5704972d86af..f630f0818cbd 100644
> > --- a/src/libcamera/request.cpp
> > +++ b/src/libcamera/request.cpp
> > @@ -594,4 +594,16 @@ std::string Request::toString() const
> >  	return ss.str();
> >  }
> >
> > +/**
> > + * \brief Insert a text representation of a Request into an output stream
> > + * \param[in] out The output stream
> > + * \param[in] r The Request
> > + * \return The output stream \a out
> > + */
> > +std::ostream &operator<<(std::ostream &out, const Request &r)
> > +{
> > +	out << r.toString();
> > +	return out;
>
> Request::toString() already uses an std::stringstream, it's thus better
> do to this the other way around, move the implementation to operator<<()
> and implement toString() as a wrapper. See V4L2SubdeviceFormat for
> instance.
>

If not that we need
         r._d()->pending_.size()
which is private.

Either we expose the pendin buffers array (so far we only have
Request::Private::hasPendingBuffers()) or we keep it the way it is.

> > +}
> > +
> >  } /* namespace libcamera */
>
> --
> Regards,
>
> Laurent Pinchart


More information about the libcamera-devel mailing list