From c957c8580a30d5940f0d4893497f38e05c7f8e92 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Mon, 14 Oct 2019 01:20:06 +0300 Subject: libcamera: v4l2_controls: Derive V4L2ControlInfoMap from ControlInfoMap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace the std::map<> used as the base type for V4L2ControlInfoMap by ControlInfoMap, which is an alias for an std::unsorted_map<> with the same key and value types. This shortens the code. Signed-off-by: Laurent Pinchart Reviewed-by: Niklas Söderlund Reviewed-by: Jacopo Mondi --- src/libcamera/include/v4l2_controls.h | 38 +++++++++++++++++------------------ src/libcamera/v4l2_controls.cpp | 6 +++--- src/libcamera/v4l2_device.cpp | 2 +- 3 files changed, 23 insertions(+), 23 deletions(-) (limited to 'src/libcamera') diff --git a/src/libcamera/include/v4l2_controls.h b/src/libcamera/include/v4l2_controls.h index 7d3528b0..c427b845 100644 --- a/src/libcamera/include/v4l2_controls.h +++ b/src/libcamera/include/v4l2_controls.h @@ -31,27 +31,27 @@ public: V4L2ControlRange(const struct v4l2_query_ext_ctrl &ctrl); }; -class V4L2ControlInfoMap : private std::map +class V4L2ControlInfoMap : private ControlInfoMap { public: - V4L2ControlInfoMap &operator=(std::map &&info); - - using std::map::key_type; - using std::map::mapped_type; - using std::map::value_type; - using std::map::size_type; - using std::map::iterator; - using std::map::const_iterator; - - using std::map::begin; - using std::map::cbegin; - using std::map::end; - using std::map::cend; - using std::map::at; - using std::map::empty; - using std::map::size; - using std::map::count; - using std::map::find; + V4L2ControlInfoMap &operator=(ControlInfoMap &&info); + + using ControlInfoMap::key_type; + using ControlInfoMap::mapped_type; + using ControlInfoMap::value_type; + using ControlInfoMap::size_type; + using ControlInfoMap::iterator; + using ControlInfoMap::const_iterator; + + using ControlInfoMap::begin; + using ControlInfoMap::cbegin; + using ControlInfoMap::end; + using ControlInfoMap::cend; + using ControlInfoMap::at; + using ControlInfoMap::empty; + using ControlInfoMap::size; + using ControlInfoMap::count; + using ControlInfoMap::find; mapped_type &at(unsigned int key); const mapped_type &at(unsigned int key) const; diff --git a/src/libcamera/v4l2_controls.cpp b/src/libcamera/v4l2_controls.cpp index 63416b9e..33816571 100644 --- a/src/libcamera/v4l2_controls.cpp +++ b/src/libcamera/v4l2_controls.cpp @@ -132,7 +132,7 @@ V4L2ControlRange::V4L2ControlRange(const struct v4l2_query_ext_ctrl &ctrl) */ /** - * \brief Move assignment operator from plain map + * \brief Move assignment operator from a ControlInfoMap * \param[in] info The control info map * * Populate the map by replacing its contents with those of \a info using move @@ -142,9 +142,9 @@ V4L2ControlRange::V4L2ControlRange(const struct v4l2_query_ext_ctrl &ctrl) * * \return The populated V4L2ControlInfoMap */ -V4L2ControlInfoMap &V4L2ControlInfoMap::operator=(std::map &&info) +V4L2ControlInfoMap &V4L2ControlInfoMap::operator=(ControlInfoMap &&info) { - std::map::operator=(std::move(info)); + ControlInfoMap::operator=(std::move(info)); idmap_.clear(); for (const auto &ctrl : *this) diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp index 47999e70..06155eb5 100644 --- a/src/libcamera/v4l2_device.cpp +++ b/src/libcamera/v4l2_device.cpp @@ -342,7 +342,7 @@ int V4L2Device::ioctl(unsigned long request, void *argp) */ void V4L2Device::listControls() { - std::map ctrls; + ControlInfoMap ctrls; struct v4l2_query_ext_ctrl ctrl = {}; /* \todo Add support for menu and compound controls. */ -- cgit v1.2.1