{"id":3998,"url":"https://patchwork.libcamera.org/api/1.1/patches/3998/?format=json","web_url":"https://patchwork.libcamera.org/patch/3998/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20200608232844.10150-4-jacopo@jmondi.org>","date":"2020-06-08T23:28:41","name":"[libcamera-devel,v2,3/6] libcamera: formats: Make ImageFormats iterable","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"8f1f5f5a4ef620d35a0da07b187794dd399fad65","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/1.1/people/3/?format=json","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"delegate":{"id":15,"url":"https://patchwork.libcamera.org/api/1.1/users/15/?format=json","username":"jmondi","first_name":"Jacopo","last_name":"Mondi","email":"jacopo@jmondi.org"},"mbox":"https://patchwork.libcamera.org/patch/3998/mbox/","series":[{"id":979,"url":"https://patchwork.libcamera.org/api/1.1/series/979/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=979","date":"2020-06-08T23:28:38","name":"ImageFormats, you again","version":2,"mbox":"https://patchwork.libcamera.org/series/979/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/3998/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/3998/checks/","tags":{},"headers":{"Return-Path":"<jacopo@jmondi.org>","Received":["from relay10.mail.gandi.net (relay10.mail.gandi.net\n\t[217.70.178.230])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id E219461687\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  9 Jun 2020 01:25:26 +0200 (CEST)","from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101])\n\t(Authenticated sender: jacopo@jmondi.org)\n\tby relay10.mail.gandi.net (Postfix) with ESMTPSA id 2D81C240004;\n\tMon,  8 Jun 2020 23:25:25 +0000 (UTC)"],"From":"Jacopo Mondi <jacopo@jmondi.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Tue,  9 Jun 2020 01:28:41 +0200","Message-Id":"<20200608232844.10150-4-jacopo@jmondi.org>","X-Mailer":"git-send-email 2.27.0","In-Reply-To":"<20200608232844.10150-1-jacopo@jmondi.org>","References":"<20200608232844.10150-1-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v2 3/6] libcamera: formats: Make\n\tImageFormats iterable","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>","X-List-Received-Date":"Mon, 08 Jun 2020 23:25:27 -0000"},"content":"Make ImageFormats an iterable class by exposing the type definitions\nfor forward iterators and begin() and end() function from the internal\nformats map.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n include/libcamera/internal/formats.h |  8 +++++++\n src/libcamera/formats.cpp            | 36 ++++++++++++++++++++++++++++\n 2 files changed, 44 insertions(+)","diff":"diff --git a/include/libcamera/internal/formats.h b/include/libcamera/internal/formats.h\nindex 5668f3744c5d..cb840014cbd7 100644\n--- a/include/libcamera/internal/formats.h\n+++ b/include/libcamera/internal/formats.h\n@@ -22,6 +22,14 @@ template<typename T>\n class ImageFormats\n {\n public:\n+\tusing iterator = typename std::map<T, std::vector<SizeRange>>::iterator;\n+\tusing const_iterator = typename std::map<T, std::vector<SizeRange>>::const_iterator;\n+\n+\titerator begin() { return data_.begin(); }\n+\tconst_iterator begin() const { return data_.begin(); }\n+\titerator end() { return data_.end(); }\n+\tconst_iterator end() const { return data_.end(); }\n+\n \tint addFormat(T format, const std::vector<SizeRange> &sizes);\n \n \tbool isEmpty() const;\ndiff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp\nindex 62fd46686d7d..fe50b9aaa1f2 100644\n--- a/src/libcamera/formats.cpp\n+++ b/src/libcamera/formats.cpp\n@@ -34,6 +34,42 @@ LOG_DEFINE_CATEGORY(Formats)\n  * Sizes are stored as a list of SizeRange.\n  */\n \n+/**\n+ * \\typedef ImageFormats::iterator\n+ * \\brief Iterator for the formats map\n+ */\n+\n+/**\n+ * \\typedef ImageFormats::const_iterator\n+ * \\brief Const iterator for the formats map\n+ */\n+\n+/**\n+ * \\fn iterator ImageFormats<T>::begin()\n+ * \\brief Retrieve an iterator to the first element in the formats map\n+ * \\return An iterator to the first format map\n+ */\n+\n+/**\n+ * \\fn const_iterator ImageFormats<T>::begin() const\n+ * \\brief Retrieve an const iterator to the first element in the formats map\n+ * \\return A const iterator to the first format map\n+ */\n+\n+/**\n+ * \\fn iterator ImageFormats<T>::end()\n+ * \\brief Retrieve an iterator pointing to the past-the-end element in the\n+ * formats map\n+ * \\return An iterator to the element following the last format\n+ */\n+\n+/**\n+ * \\fn const_iterator ImageFormats<T>::end() const\n+ * \\brief Retrieve a const iterator pointing to the past-the-end element in the\n+ * formats map\n+ * \\return A const iterator to the element following the last format\n+ */\n+\n /**\n  * \\brief Add a format and corresponding sizes to the description\n  * \\param[in] format Pixel format or media bus code to describe\n","prefixes":["libcamera-devel","v2","3/6"]}