[{"id":23317,"web_url":"https://patchwork.libcamera.org/comment/23317/","msgid":"<Ypt3xtlxuIKz9U0T@pendragon.ideasonboard.com>","date":"2022-06-04T15:18:30","subject":"Re: [libcamera-devel] [PATCH v2] libcamera: request: Add\n\toperator<<()","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Jacopo,\n\nThank you for the patch.\n\nOn Sat, Jun 04, 2022 at 11:24:22AM +0200, Jacopo Mondi via libcamera-devel wrote:\n> With the recent addition of operator<<() in most libcamera core classes\n> to replace usage of the toString() function the Request class was left\n> behind.\n> \n> Add operator<<() for the Request class and reimplement toString().\n> \n> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> ---\n> v2:\n> - reimplement toString() using operator<<\n> \n> ---\n>  include/libcamera/internal/request.h |  1 +\n>  include/libcamera/request.h          |  3 +++\n>  src/libcamera/request.cpp            | 20 ++++++++++++++++----\n>  3 files changed, 20 insertions(+), 4 deletions(-)\n> \n> diff --git a/include/libcamera/internal/request.h b/include/libcamera/internal/request.h\n> index 1f2499896e23..9dadd6c60361 100644\n> --- a/include/libcamera/internal/request.h\n> +++ b/include/libcamera/internal/request.h\n> @@ -44,6 +44,7 @@ public:\n> \n>  private:\n>  \tfriend class PipelineHandler;\n> +\tfriend std::ostream &operator<<(std::ostream &out, const Request &r);\n> \n>  \tvoid doCancelRequest();\n>  \tvoid emitPrepareCompleted();\n> diff --git a/include/libcamera/request.h b/include/libcamera/request.h\n> index 1eb537e9b09b..dffde1536cad 100644\n> --- a/include/libcamera/request.h\n> +++ b/include/libcamera/request.h\n> @@ -9,6 +9,7 @@\n> \n>  #include <map>\n>  #include <memory>\n> +#include <ostream>\n>  #include <stdint.h>\n>  #include <string>\n>  #include <unordered_set>\n> @@ -75,4 +76,6 @@ private:\n>  \tStatus status_;\n>  };\n> \n> +std::ostream &operator<<(std::ostream &out, const Request &r);\n> +\n>  } /* namespace libcamera */\n> diff --git a/src/libcamera/request.cpp b/src/libcamera/request.cpp\n> index 5704972d86af..51d74b294d38 100644\n> --- a/src/libcamera/request.cpp\n> +++ b/src/libcamera/request.cpp\n> @@ -582,16 +582,28 @@ bool Request::hasPendingBuffers() const\n>  std::string Request::toString() const\n>  {\n>  \tstd::stringstream ss;\n> +\tss << *this;\n> \n> +\treturn ss.str();\n> +}\n> +\n> +/**\n> + * \\brief Insert a text representation of a Request into an output stream\n> + * \\param[in] out The output stream\n> + * \\param[in] r The Request\n> + * \\return The output stream \\a out\n> + */\n> +std::ostream &operator<<(std::ostream &out, const Request &r)\n> +{\n>  \t/* Pending, Completed, Cancelled(X). */\n>  \tstatic const char *statuses = \"PCX\";\n> \n>  \t/* Example Output: Request(55:P:1/2:6523524) */\n> -\tss << \"Request(\" << sequence() << \":\" << statuses[status_] << \":\"\n> -\t   << _d()->pending_.size() << \"/\" << bufferMap_.size() << \":\"\n> -\t   << cookie_ << \")\";\n> +\tout << \"Request(\" << r.sequence() << \":\" << statuses[r.status()] << \":\"\n> +\t    << r._d()->pending_.size() << \"/\" << r.buffers().size() << \":\"\n> +\t    << r.cookie() << \")\";\n> \n> -\treturn ss.str();\n> +\treturn out;\n>  }\n> \n>  } /* namespace libcamera */","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id B00A0BD161\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSat,  4 Jun 2022 15:18:37 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E0A6065631;\n\tSat,  4 Jun 2022 17:18:36 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 6A27D60104\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat,  4 Jun 2022 17:18:35 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(lmontsouris-659-1-41-236.w92-154.abo.wanadoo.fr [92.154.76.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 06CF330A;\n\tSat,  4 Jun 2022 17:18:34 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1654355916;\n\tbh=g+Tkwq5MJy9zL0oAZVpkHrzb5EoMNnpDylvaTwomiCI=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=EXVDcwHVu889UONGeIPnkcNNVTwqaVaUxm/xSHNxMHoAn2RXSwvDwonzdzDBseE8x\n\twqEV/or6cpBw7gDm3Ews4/Vip6X50uenAvY+g9jLHheOTI3MVll0OXX5okNgjOdrNf\n\tuxmGhsus6fYEpcN4BvSk8RGBU7tp68LeTk3CJxaIWnYAiWOszpsrz4R9HLxj4zl7Az\n\tJo00gSxX7ez7rmqgzIO2LYp4M790MNu0He3lN5njko2lPeBa55cIrUtH1BE+H99B/r\n\t7KjEi8In1H5+XJI0t0+WcE07MhwoHjCfIN4w6Sr+T5rjZ7cK7ai7go4iGQ5h/csMf8\n\tjgnC3GE4TASpg==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1654355915;\n\tbh=g+Tkwq5MJy9zL0oAZVpkHrzb5EoMNnpDylvaTwomiCI=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=Cs63Msp0qR8IJRdj/jXvkxRpUQEx+rHBKzIg93UApYP4ajyfhfug2GqBoowYQ9/GK\n\tlFv2KlJ0Y10oCBH98AjX0VUrn9b6VfP//fsg29fe+BgNYozSF2Y2OyHzp4HEYjmTF2\n\tuU8yA4bj9MuIOt9wKPh+8Pp6arCC9Q2JBU4drRcM="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"Cs63Msp0\"; dkim-atps=neutral","Date":"Sat, 4 Jun 2022 18:18:30 +0300","To":"Jacopo Mondi <jacopo@jmondi.org>","Message-ID":"<Ypt3xtlxuIKz9U0T@pendragon.ideasonboard.com>","References":"<20220604092422.77185-1-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20220604092422.77185-1-jacopo@jmondi.org>","Subject":"Re: [libcamera-devel] [PATCH v2] libcamera: request: Add\n\toperator<<()","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","From":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":23341,"web_url":"https://patchwork.libcamera.org/comment/23341/","msgid":"<165451687880.3884725.6083583453585666445@Monstersaurus>","date":"2022-06-06T12:01:18","subject":"Re: [libcamera-devel] [PATCH v2] libcamera: request: Add\n\toperator<<()","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Jacopo Mondi via libcamera-devel (2022-06-04 10:24:22)\n> With the recent addition of operator<<() in most libcamera core classes\n> to replace usage of the toString() function the Request class was left\n> behind.\n> \n> Add operator<<() for the Request class and reimplement toString().\n> \n> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n\nLooks fine to me.\n\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> \n> ---\n> v2:\n> - reimplement toString() using operator<<\n> \n> ---\n>  include/libcamera/internal/request.h |  1 +\n>  include/libcamera/request.h          |  3 +++\n>  src/libcamera/request.cpp            | 20 ++++++++++++++++----\n>  3 files changed, 20 insertions(+), 4 deletions(-)\n> \n> diff --git a/include/libcamera/internal/request.h b/include/libcamera/internal/request.h\n> index 1f2499896e23..9dadd6c60361 100644\n> --- a/include/libcamera/internal/request.h\n> +++ b/include/libcamera/internal/request.h\n> @@ -44,6 +44,7 @@ public:\n> \n>  private:\n>         friend class PipelineHandler;\n> +       friend std::ostream &operator<<(std::ostream &out, const Request &r);\n> \n>         void doCancelRequest();\n>         void emitPrepareCompleted();\n> diff --git a/include/libcamera/request.h b/include/libcamera/request.h\n> index 1eb537e9b09b..dffde1536cad 100644\n> --- a/include/libcamera/request.h\n> +++ b/include/libcamera/request.h\n> @@ -9,6 +9,7 @@\n> \n>  #include <map>\n>  #include <memory>\n> +#include <ostream>\n>  #include <stdint.h>\n>  #include <string>\n>  #include <unordered_set>\n> @@ -75,4 +76,6 @@ private:\n>         Status status_;\n>  };\n> \n> +std::ostream &operator<<(std::ostream &out, const Request &r);\n> +\n>  } /* namespace libcamera */\n> diff --git a/src/libcamera/request.cpp b/src/libcamera/request.cpp\n> index 5704972d86af..51d74b294d38 100644\n> --- a/src/libcamera/request.cpp\n> +++ b/src/libcamera/request.cpp\n> @@ -582,16 +582,28 @@ bool Request::hasPendingBuffers() const\n>  std::string Request::toString() const\n>  {\n>         std::stringstream ss;\n> +       ss << *this;\n> \n> +       return ss.str();\n> +}\n> +\n> +/**\n> + * \\brief Insert a text representation of a Request into an output stream\n> + * \\param[in] out The output stream\n> + * \\param[in] r The Request\n> + * \\return The output stream \\a out\n> + */\n> +std::ostream &operator<<(std::ostream &out, const Request &r)\n> +{\n>         /* Pending, Completed, Cancelled(X). */\n>         static const char *statuses = \"PCX\";\n> \n>         /* Example Output: Request(55:P:1/2:6523524) */\n> -       ss << \"Request(\" << sequence() << \":\" << statuses[status_] << \":\"\n> -          << _d()->pending_.size() << \"/\" << bufferMap_.size() << \":\"\n> -          << cookie_ << \")\";\n> +       out << \"Request(\" << r.sequence() << \":\" << statuses[r.status()] << \":\"\n> +           << r._d()->pending_.size() << \"/\" << r.buffers().size() << \":\"\n> +           << r.cookie() << \")\";\n> \n> -       return ss.str();\n> +       return out;\n>  }\n> \n>  } /* namespace libcamera */\n> --\n> 2.35.1\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 4D749BD160\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  6 Jun 2022 12:01:23 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E974365635;\n\tMon,  6 Jun 2022 14:01:22 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 74947633A7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  6 Jun 2022 14:01:21 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id D2B6C30A;\n\tMon,  6 Jun 2022 14:01:20 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1654516882;\n\tbh=L9/QwxSUR1ZbZQvhzFtqe0TrpOaOCQWGG+qcvaAA0H0=;\n\th=In-Reply-To:References:To:Date:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=kKpZOhe6Gk3G+7fZb9beBGNK1UZXSTVbNw+BKa3xZ2T+cPcYv+MGS/sgoduYSig9b\n\t5oEQqjNZpVdqbHTt9ANeF4ha587rlcsDDSi7wY6k0AIfhZ5pyv461+BsVdJ1GRBzIu\n\tkP/6IYkEy7003YLuoAeiqb+QPTwmiF0Vu3q88/vjrK1D+dnhgkFj7hysgV2Xni3LHq\n\tGcRfUX//jkm2JhbmQLQ+Kh0Da3LousfYZ6Eg+DRX+P0tNicAQjScLN/f5ec5WsZxYA\n\tpCnHN5lcOCDtuqj+h8JJQ0Lkp1BD6/SRWGVNIfqeg4g8qgW0yT00bIKnq5v/Bz5M4P\n\tAfXa2f0raoyLg==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1654516880;\n\tbh=L9/QwxSUR1ZbZQvhzFtqe0TrpOaOCQWGG+qcvaAA0H0=;\n\th=In-Reply-To:References:Subject:From:To:Date:From;\n\tb=koFxP33EGK5J0Rx/K1qj3mQKusm+hxrMnk3j0N5rAn8jy1rbyEyazzmSmaiJ43ba+\n\tABAGk00nXiW7GC7W7vvbd+pVs3NUQUEicIzNAAdu73rR8budUUBUz0+CxaRagtm74O\n\tFknoC+nSLPL+BhZNmDVgVQj9eMVG1CKjpsirYiMM="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"koFxP33E\"; dkim-atps=neutral","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20220604092422.77185-1-jacopo@jmondi.org>","References":"<20220604092422.77185-1-jacopo@jmondi.org>","To":"Jacopo Mondi <jacopo@jmondi.org>, libcamera-devel@lists.libcamera.org","Date":"Mon, 06 Jun 2022 13:01:18 +0100","Message-ID":"<165451687880.3884725.6083583453585666445@Monstersaurus>","User-Agent":"alot/0.10","Subject":"Re: [libcamera-devel] [PATCH v2] libcamera: request: Add\n\toperator<<()","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","From":"Kieran Bingham via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]