From patchwork Tue Sep 24 17:24:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 2004 Return-Path: Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C338D62378 for ; Tue, 24 Sep 2019 19:23:31 +0200 (CEST) X-Originating-IP: 213.45.248.89 Received: from uno.homenet.telecomitalia.it (host89-248-dynamic.45-213-r.retail.telecomitalia.it [213.45.248.89]) (Authenticated sender: jacopo@jmondi.org) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id 5B78560005 for ; Tue, 24 Sep 2019 17:23:31 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Tue, 24 Sep 2019 19:24:47 +0200 Message-Id: <20190924172503.30864-6-jacopo@jmondi.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190924172503.30864-1-jacopo@jmondi.org> References: <20190924172503.30864-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 05/21] libcamera: controls: Make ControlInfoMap a class 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: Tue, 24 Sep 2019 17:23:31 -0000 Make a class out of ControlInfoMap to be able to serialize its content. Signed-off-by: Jacopo Mondi --- include/libcamera/controls.h | 24 +++++++++- src/libcamera/controls.cpp | 68 ++++++++++++++++++++++++++++- src/libcamera/pipeline/uvcvideo.cpp | 4 +- src/libcamera/pipeline/vimc.cpp | 4 +- 4 files changed, 92 insertions(+), 8 deletions(-) diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h index 8a7ddc510497..79731c4932ae 100644 --- a/include/libcamera/controls.h +++ b/include/libcamera/controls.h @@ -42,7 +42,29 @@ private: const struct ControlMetadata *meta_; }; -using ControlInfoMap = std::unordered_map; +class ControlInfoMap +{ +private: + using InfoMap = std::unordered_map; + +public: + using iterator = InfoMap::iterator; + using const_iterator = InfoMap::const_iterator; + + iterator begin() { return map_.begin(); } + iterator end() { return map_.end(); } + const_iterator begin() const { return map_.begin(); } + const_iterator end() const { return map_.end(); } + + iterator find(ControlId id) { return map_.find(id); } + const_iterator find(ControlId id) const { return map_.find(id); } + + void emplace(const ControlId id, const DataValue &min, + const DataValue &max); + +private: + InfoMap map_; +}; using ControlValue = DataValue; diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp index ee19eb6dc014..ec7ac7ba9ed6 100644 --- a/src/libcamera/controls.cpp +++ b/src/libcamera/controls.cpp @@ -169,10 +169,76 @@ std::string ControlInfo::toString() const } /** - * \typedef ControlInfoMap + * \class ControlInfoMap * \brief A map of ControlId to ControlInfo */ +/** + * \typedef ControlInfoMap::iterator + * \brief Iterator for the controls contained within the list + */ + +/** + * \typedef ControlInfoMap::const_iterator + * \brief Const iterator for the controls contained within the list + */ + +/** + * \fn iterator ControlInfoMap::begin() + * \brief Retrieve an iterator to the first Control in the list + * \return An iterator to the first Control in the list + */ + +/** + * \fn const_iterator ControlInfoMap::begin() const + * \brief Retrieve a const_iterator to the first Control in the list + * \return A const_iterator to the first Control in the list + */ + +/** + * \fn iterator ControlInfoMap::end() + * \brief Retrieve an iterator pointing to the past-the-end control in the list + * \return An iterator to the element following the last control in the list + */ + +/** + * \fn const_iterator ControlInfoMap::end() const + * \brief Retrieve a const iterator pointing to the past-the-end control in the + * list + * \return A const iterator to the element following the last control in the + * list + */ + +/** + * \fn iterator ControlInfoMap::find(ControlId id) + * \brief Find ControlInfo with \a id + * \param id The control identifier + * \return An interator to the ControlInfo with key \a id or the + * past-the-end iterator if no element with key \a id exists + */ + +/** + * \fn const_iterator ControlInfoMap::find(ControlId id) const + * \brief Find ControlInfo with \a id + * \param id The control identifier + * \return A const interator to the ControlInfo with key \a id or the + * past-the-end iterator if no element with key \a id exists + */ + +/** + * \brief Insert a new element in the map constructed in-place + * \param[in] id The control ID + * \param[in] min The control minimum value + * \param[in] max The control maximum value + */ +void ControlInfoMap::emplace(const ControlId id, const DataValue &min, + const DataValue &max) +{ + map_.emplace(std::piecewise_construct, + std::forward_as_tuple(id), + std::forward_as_tuple(id, min, max)); +} + /** * \typedef ControlValue * \brief A control value stored in the ControlList class diff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp index 8965210550d2..02455d1ac675 100644 --- a/src/libcamera/pipeline/uvcvideo.cpp +++ b/src/libcamera/pipeline/uvcvideo.cpp @@ -374,9 +374,7 @@ int UVCCameraData::init(MediaEntity *entity) continue; } - controlInfo_.emplace(std::piecewise_construct, - std::forward_as_tuple(id), - std::forward_as_tuple(id, info.min(), info.max())); + controlInfo_.emplace(id, info.min(), info.max()); } return 0; diff --git a/src/libcamera/pipeline/vimc.cpp b/src/libcamera/pipeline/vimc.cpp index f26a91f86ec1..5515704df14c 100644 --- a/src/libcamera/pipeline/vimc.cpp +++ b/src/libcamera/pipeline/vimc.cpp @@ -443,9 +443,7 @@ int VimcCameraData::init(MediaDevice *media) continue; } - controlInfo_.emplace(std::piecewise_construct, - std::forward_as_tuple(id), - std::forward_as_tuple(id, info.min(), info.max())); + controlInfo_.emplace(id, info.min(), info.max()); } return 0;