summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJacopo Mondi <jacopo@jmondi.org>2022-06-03 11:30:25 +0200
committerJacopo Mondi <jacopo@jmondi.org>2022-06-05 14:48:08 +0200
commit161d24377c34c9254a132a9e769fbf11456b5b17 (patch)
tree36516af0c39b3dc329a7cc37810f8fd6fb805d3f /src
parent38e427f605a59f584c497d472c373bf383939997 (diff)
libcamera: request: Add operator<<()
With the recent addition of operator<<() in most libcamera core classes to replace usage of the toString() function the Request class was left behind. Add operator<<() for the Request class and reimplement toString(). Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'src')
-rw-r--r--src/libcamera/request.cpp20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/libcamera/request.cpp b/src/libcamera/request.cpp
index 5704972d..51d74b29 100644
--- a/src/libcamera/request.cpp
+++ b/src/libcamera/request.cpp
@@ -582,16 +582,28 @@ bool Request::hasPendingBuffers() const
std::string Request::toString() const
{
std::stringstream ss;
+ ss << *this;
+ 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)
+{
/* Pending, Completed, Cancelled(X). */
static const char *statuses = "PCX";
/* Example Output: Request(55:P:1/2:6523524) */
- ss << "Request(" << sequence() << ":" << statuses[status_] << ":"
- << _d()->pending_.size() << "/" << bufferMap_.size() << ":"
- << cookie_ << ")";
+ out << "Request(" << r.sequence() << ":" << statuses[r.status()] << ":"
+ << r._d()->pending_.size() << "/" << r.buffers().size() << ":"
+ << r.cookie() << ")";
- return ss.str();
+ return out;
}
} /* namespace libcamera */