From patchwork Sat Jun 4 09:24:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 16148 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 7B876BD160 for ; Sat, 4 Jun 2022 09:24:30 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8065B65631; Sat, 4 Jun 2022 11:24:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1654334669; bh=dPlzdrnJoT70ePJbttXHgrVTXRJMziBvK1IHSsPFwmM=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=yoD1wFTvRETzKeFc6bBE/AK0FTE+YgAjABT1OyHYgi7OjtWBLpMLz0Qmj9OdvciH6 FJBVflfLQ7mfz6faGdiWW6lsbqu+Sc6xRh3i9qkliUJRcXgKqWweFaNAfuOM18CB57 pOt2tl+4aC0AKPzAEukHTx9zr46CnDdbkAqPetx7noeAmn2rBVd6p//AwyW4MSycId rwuUVp7Qod5RKJBicRayWDtxmTKlSrdkMFgtYIACzDjB28lvhdooDQJm7499K/EBch /OyqWqEWiVFQ1XvIEREPfqLukE9k/KJx3iotDfhKPjGJI46OuNy1viRfGZksHC6rLN ykFEFWBx976FQ== Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 685336559A for ; Sat, 4 Jun 2022 11:24:28 +0200 (CEST) Received: (Authenticated sender: jacopo@jmondi.org) by mail.gandi.net (Postfix) with ESMTPSA id D74ADFF806; Sat, 4 Jun 2022 09:24:27 +0000 (UTC) To: libcamera-devel@lists.libcamera.org Date: Sat, 4 Jun 2022 11:24:22 +0200 Message-Id: <20220604092422.77185-1-jacopo@jmondi.org> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2] libcamera: request: Add operator<<() X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jacopo Mondi via libcamera-devel From: Jacopo Mondi Reply-To: Jacopo Mondi Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" 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 Reviewed-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- v2: - reimplement toString() using operator<< --- include/libcamera/internal/request.h | 1 + include/libcamera/request.h | 3 +++ src/libcamera/request.cpp | 20 ++++++++++++++++---- 3 files changed, 20 insertions(+), 4 deletions(-) -- 2.35.1 diff --git a/include/libcamera/internal/request.h b/include/libcamera/internal/request.h index 1f2499896e23..9dadd6c60361 100644 --- a/include/libcamera/internal/request.h +++ b/include/libcamera/internal/request.h @@ -44,6 +44,7 @@ public: private: friend class PipelineHandler; + friend std::ostream &operator<<(std::ostream &out, const Request &r); void doCancelRequest(); void emitPrepareCompleted(); 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 #include +#include #include #include #include @@ -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..51d74b294d38 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 */