From patchwork Sun Feb 20 00:52:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nejc Galof X-Patchwork-Id: 15369 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 3E52EBE08A for ; Sun, 20 Feb 2022 00:53:09 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 70F1E61121; Sun, 20 Feb 2022 01:53:08 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="kKQVXPrg"; dkim-atps=neutral Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A6DC8601F7 for ; Sun, 20 Feb 2022 01:53:06 +0100 (CET) Received: by mail-ej1-x62d.google.com with SMTP id qk11so23908242ejb.2 for ; Sat, 19 Feb 2022 16:53:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id; bh=pZ/zwfYxj+ywyblg2W8gT3fPKT/I25PrX23fzbPqd4c=; b=kKQVXPrgfPjMk5y55LbSCPENTjZewscDNOEPZWrcdOf6j04ZEk7LPz3N2lqW2iqLk8 vbim3AvUn9ZJI130BCE+uZZRlX1c6uimZ6OoY/VUpduI/9M0sajnszahNh+/B84i8/1t pMIXCV/ShUrctSG/c5BaLwdo7ZJ1hKe/oyPOKNddEK2PZzZrxOjdJINgSiTQrWpVm2L8 VVYNCn+457u078wG+NXeMd2d6VkIkHNSaFbRcjgcF/7SrApAcy2gMym/17kFbNwoei8K 4nE1VAnAI8ImdYI236E1MKnfnHAYiZpHZVnZ2RmGx2WDmAuNOBO0wmqad4gFDTWfIh2J tVww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id; bh=pZ/zwfYxj+ywyblg2W8gT3fPKT/I25PrX23fzbPqd4c=; b=gVco2uqph3Bqv5ORfY3xqhfLu2pmgxUj9WwsGrViSQ+kpGSJLADPmIFrsDjtG+nuDQ mpzS8iPtgYL94ezJvvsobX3+PQ3YO/dOXBFuuzaYXxMyr9Kp6O80hyHuPcScOrSCEjI6 +6aBi71edirTsofscD4H2aLxLXeobMoltIogldnbeeEaLBrp/taRIHrpwXVcPn22n88O XyT2poiGLOLn85gLiWdhz1WBf8b7zDCYhac9kds4kKYs6aOV/zgpAntBAJk0la5KuNAz iFwRjKKCf9Ks01V5nTnRB4B6umnk3/FmQpDazdbJB3aA+6altIyS2O/mwvfWztho2smC Aviw== X-Gm-Message-State: AOAM530VF+BlGj8ul7XE0I5UICbfCgnKcoMN2MVBGSAZpTaMJUqTQSw4 H7c7wsQjv0KvnvJZ0qzwF5lIGYI2FtiqkA== X-Google-Smtp-Source: ABdhPJxFg3nIbibmT+wwq1itcVvxxkQ5WItV25Fm+5kRxnxN2nh0+3kSpmDqX8MXiadrd0HLrOF/1A== X-Received: by 2002:a17:906:a145:b0:6ae:e45d:15b6 with SMTP id bu5-20020a170906a14500b006aee45d15b6mr11250667ejb.714.1645318386072; Sat, 19 Feb 2022 16:53:06 -0800 (PST) Received: from e28887faee29.8.8.8.8 ([91.224.238.83]) by smtp.gmail.com with ESMTPSA id gj7sm3605326ejc.90.2022.02.19.16.53.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Feb 2022 16:53:05 -0800 (PST) From: Nejc Galof To: libcamera-devel@lists.libcamera.org Date: Sun, 20 Feb 2022 01:52:57 +0100 Message-Id: <20220220005257.30480-1-galof.nejc@gmail.com> X-Mailer: git-send-email 2.17.1 Subject: [libcamera-devel] [PATCH] cam: Use structured bindings in range-based for loops 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Use structured bindings range-based for loops for better readability. Reviewed-by: Laurent Pinchart Signed-off-by: Nejc Galof Reviewed-by: Kieran Bingham --- src/cam/camera_session.cpp | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/src/cam/camera_session.cpp b/src/cam/camera_session.cpp index 1bf460fa..0428b538 100644 --- a/src/cam/camera_session.cpp +++ b/src/cam/camera_session.cpp @@ -120,10 +120,7 @@ CameraSession::~CameraSession() void CameraSession::listControls() const { - for (const auto &ctrl : camera_->controls()) { - const ControlId *id = ctrl.first; - const ControlInfo &info = ctrl.second; - + for (const auto &[id, info] : camera_->controls()) { std::cout << "Control: " << id->name() << ": " << info.toString() << std::endl; } @@ -131,9 +128,8 @@ void CameraSession::listControls() const void CameraSession::listProperties() const { - for (const auto &prop : camera_->properties()) { - const ControlId *id = properties::properties.at(prop.first); - const ControlValue &value = prop.second; + for (const auto &[key, value] : camera_->properties()) { + const ControlId *id = properties::properties.at(key); std::cout << "Property: " << id->name() << " = " << value.toString() << std::endl; @@ -374,10 +370,7 @@ void CameraSession::processRequest(Request *request) << std::setw(6) << std::setfill('0') << ts / 1000 % 1000000 << " (" << std::fixed << std::setprecision(2) << fps << " fps)"; - for (auto it = buffers.begin(); it != buffers.end(); ++it) { - const Stream *stream = it->first; - FrameBuffer *buffer = it->second; - + for (const auto &[stream, buffer] : buffers) { const FrameMetadata &metadata = buffer->metadata(); info << " " << streamNames_[stream] @@ -401,10 +394,10 @@ void CameraSession::processRequest(Request *request) if (printMetadata_) { const ControlList &requestMetadata = request->metadata(); - for (const auto &ctrl : requestMetadata) { - const ControlId *id = controls::controls.at(ctrl.first); + for (const auto &[key, value] : requestMetadata) { + const ControlId *id = controls::controls.at(key); std::cout << "\t" << id->name() << " = " - << ctrl.second.toString() << std::endl; + << value.toString() << std::endl; } }