From patchwork Mon Jun 8 23:28:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 3998 X-Patchwork-Delegate: jacopo@jmondi.org Return-Path: Received: from relay10.mail.gandi.net (relay10.mail.gandi.net [217.70.178.230]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E219461687 for ; Tue, 9 Jun 2020 01:25:26 +0200 (CEST) Received: from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101]) (Authenticated sender: jacopo@jmondi.org) by relay10.mail.gandi.net (Postfix) with ESMTPSA id 2D81C240004; Mon, 8 Jun 2020 23:25:25 +0000 (UTC) From: Jacopo Mondi 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 Subject: [libcamera-devel] [PATCH v2 3/6] libcamera: formats: Make ImageFormats iterable 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-List-Received-Date: Mon, 08 Jun 2020 23:25:27 -0000 Make ImageFormats an iterable class by exposing the type definitions for forward iterators and begin() and end() function from the internal formats map. Signed-off-by: Jacopo Mondi --- include/libcamera/internal/formats.h | 8 +++++++ src/libcamera/formats.cpp | 36 ++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/include/libcamera/internal/formats.h b/include/libcamera/internal/formats.h index 5668f3744c5d..cb840014cbd7 100644 --- a/include/libcamera/internal/formats.h +++ b/include/libcamera/internal/formats.h @@ -22,6 +22,14 @@ template class ImageFormats { public: + using iterator = typename std::map>::iterator; + using const_iterator = typename std::map>::const_iterator; + + iterator begin() { return data_.begin(); } + const_iterator begin() const { return data_.begin(); } + iterator end() { return data_.end(); } + const_iterator end() const { return data_.end(); } + int addFormat(T format, const std::vector &sizes); bool isEmpty() const; diff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp index 62fd46686d7d..fe50b9aaa1f2 100644 --- a/src/libcamera/formats.cpp +++ b/src/libcamera/formats.cpp @@ -34,6 +34,42 @@ LOG_DEFINE_CATEGORY(Formats) * Sizes are stored as a list of SizeRange. */ +/** + * \typedef ImageFormats::iterator + * \brief Iterator for the formats map + */ + +/** + * \typedef ImageFormats::const_iterator + * \brief Const iterator for the formats map + */ + +/** + * \fn iterator ImageFormats::begin() + * \brief Retrieve an iterator to the first element in the formats map + * \return An iterator to the first format map + */ + +/** + * \fn const_iterator ImageFormats::begin() const + * \brief Retrieve an const iterator to the first element in the formats map + * \return A const iterator to the first format map + */ + +/** + * \fn iterator ImageFormats::end() + * \brief Retrieve an iterator pointing to the past-the-end element in the + * formats map + * \return An iterator to the element following the last format + */ + +/** + * \fn const_iterator ImageFormats::end() const + * \brief Retrieve a const iterator pointing to the past-the-end element in the + * formats map + * \return A const iterator to the element following the last format + */ + /** * \brief Add a format and corresponding sizes to the description * \param[in] format Pixel format or media bus code to describe