Message ID | 20241205112314.26296-1-jacopo.mondi@ideasonboard.com |
---|---|
State | Accepted |
Headers | show |
Series |
|
Related | show |
Hi Jacopo, Thank you for the patch. On Thu, Dec 05, 2024 at 12:23:13PM +0100, Jacopo Mondi wrote: > The StreamConfiguration class only implements toString() but doesn't > offer an overload of operator<<() which is more convenient to use. > > Add an overload for operator<<(StreamConfiguration) which is based on > the usage of StreamConfiguration::toString(). > > Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> > --- > include/libcamera/stream.h | 2 ++ > src/libcamera/stream.cpp | 13 +++++++++++++ > 2 files changed, 15 insertions(+) > > diff --git a/include/libcamera/stream.h b/include/libcamera/stream.h > index 071b71698acb..ea228aea7d56 100644 > --- a/include/libcamera/stream.h > +++ b/include/libcamera/stream.h > @@ -61,6 +61,8 @@ private: > StreamFormats formats_; > }; > > +std::ostream &operator<<(std::ostream &out, StreamConfiguration cfg); > + > enum class StreamRole { > Raw, > StillCapture, > diff --git a/src/libcamera/stream.cpp b/src/libcamera/stream.cpp > index 1f75dbbc5b64..a093abf48c7c 100644 > --- a/src/libcamera/stream.cpp > +++ b/src/libcamera/stream.cpp > @@ -395,6 +395,19 @@ std::string StreamConfiguration::toString() const > return size.toString() + "-" + pixelFormat.toString(); > } > > +/** > + * \brief Insert a text representation of a StreamConfiguration into an output > + * stream > + * \param[in] out The output stream > + * \param[in] cfg The StreamConfiguration > + * \return The output stream \a out > + */ > +std::ostream &operator<<(std::ostream &out, StreamConfiguration cfg) > +{ > + out << cfg.toString(); > + return out; > +} Would it be more efficient to instead implement toString() on top of operator<<(), like we do for the Request class for instance ? > + > /** > * \enum StreamRole > * \brief Identify the role a stream is intended to play
Hi Laurent On Thu, Dec 05, 2024 at 02:23:45PM +0200, Laurent Pinchart wrote: > Hi Jacopo, > > Thank you for the patch. > > On Thu, Dec 05, 2024 at 12:23:13PM +0100, Jacopo Mondi wrote: > > The StreamConfiguration class only implements toString() but doesn't > > offer an overload of operator<<() which is more convenient to use. > > > > Add an overload for operator<<(StreamConfiguration) which is based on > > the usage of StreamConfiguration::toString(). > > > > Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> > > --- > > include/libcamera/stream.h | 2 ++ > > src/libcamera/stream.cpp | 13 +++++++++++++ > > 2 files changed, 15 insertions(+) > > > > diff --git a/include/libcamera/stream.h b/include/libcamera/stream.h > > index 071b71698acb..ea228aea7d56 100644 > > --- a/include/libcamera/stream.h > > +++ b/include/libcamera/stream.h > > @@ -61,6 +61,8 @@ private: > > StreamFormats formats_; > > }; > > > > +std::ostream &operator<<(std::ostream &out, StreamConfiguration cfg); > > + > > enum class StreamRole { > > Raw, > > StillCapture, > > diff --git a/src/libcamera/stream.cpp b/src/libcamera/stream.cpp > > index 1f75dbbc5b64..a093abf48c7c 100644 > > --- a/src/libcamera/stream.cpp > > +++ b/src/libcamera/stream.cpp > > @@ -395,6 +395,19 @@ std::string StreamConfiguration::toString() const > > return size.toString() + "-" + pixelFormat.toString(); > > } > > > > +/** > > + * \brief Insert a text representation of a StreamConfiguration into an output > > + * stream > > + * \param[in] out The output stream > > + * \param[in] cfg The StreamConfiguration > > + * \return The output stream \a out > > + */ > > +std::ostream &operator<<(std::ostream &out, StreamConfiguration cfg) > > +{ > > + out << cfg.toString(); > > + return out; > > +} > > Would it be more efficient to instead implement toString() on top of > operator<<(), like we do for the Request class for instance ? > More efficiant I'm not sure, if it's more consistent I can do that. > > + > > /** > > * \enum StreamRole > > * \brief Identify the role a stream is intended to play > > -- > Regards, > > Laurent Pinchart
diff --git a/include/libcamera/stream.h b/include/libcamera/stream.h index 071b71698acb..ea228aea7d56 100644 --- a/include/libcamera/stream.h +++ b/include/libcamera/stream.h @@ -61,6 +61,8 @@ private: StreamFormats formats_; }; +std::ostream &operator<<(std::ostream &out, StreamConfiguration cfg); + enum class StreamRole { Raw, StillCapture, diff --git a/src/libcamera/stream.cpp b/src/libcamera/stream.cpp index 1f75dbbc5b64..a093abf48c7c 100644 --- a/src/libcamera/stream.cpp +++ b/src/libcamera/stream.cpp @@ -395,6 +395,19 @@ std::string StreamConfiguration::toString() const return size.toString() + "-" + pixelFormat.toString(); } +/** + * \brief Insert a text representation of a StreamConfiguration into an output + * stream + * \param[in] out The output stream + * \param[in] cfg The StreamConfiguration + * \return The output stream \a out + */ +std::ostream &operator<<(std::ostream &out, StreamConfiguration cfg) +{ + out << cfg.toString(); + return out; +} + /** * \enum StreamRole * \brief Identify the role a stream is intended to play
The StreamConfiguration class only implements toString() but doesn't offer an overload of operator<<() which is more convenient to use. Add an overload for operator<<(StreamConfiguration) which is based on the usage of StreamConfiguration::toString(). Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> --- include/libcamera/stream.h | 2 ++ src/libcamera/stream.cpp | 13 +++++++++++++ 2 files changed, 15 insertions(+) -- 2.47.0