diff --git a/src/libcamera/include/v4l2_controls.h b/src/libcamera/include/v4l2_controls.h index 949ca21cb..8990e755a 100644 --- a/src/libcamera/include/v4l2_controls.h +++ b/src/libcamera/include/v4l2_controls.h @@ -43,7 +43,21 @@ private: ControlRange range_; }; -using V4L2ControlInfoMap = std::map; +class V4L2ControlInfoMap : private std::map +{ +public: + V4L2ControlInfoMap &operator=(std::map &&info); + + 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; +}; class V4L2Control { diff --git a/src/libcamera/v4l2_controls.cpp b/src/libcamera/v4l2_controls.cpp index 3f5f3ff10..3be219979 100644 --- a/src/libcamera/v4l2_controls.cpp +++ b/src/libcamera/v4l2_controls.cpp @@ -156,10 +156,28 @@ V4L2ControlInfo::V4L2ControlInfo(const struct v4l2_query_ext_ctrl &ctrl) */ /** - * \typedef V4L2ControlInfoMap + * \class V4L2ControlInfoMap * \brief A map of control ID to V4L2ControlInfo */ +/** + * \brief Move assignment operator from plain map + * \param[in] info The control info map + * + * Populate the map by replacing its contents with those of \a info using move + * semantics. Upon return the \a info map will be empty. + * + * This is the only supported way to populate a V4L2ControlInfoMap. + * + * \return The populated V4L2ControlInfoMap + */ +V4L2ControlInfoMap &V4L2ControlInfoMap::operator=(std::map &&info) +{ + std::map::operator=(std::move(info)); + + return *this; +} + /** * \class V4L2Control * \brief A V4L2 control value diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp index 8c5998435..1f755f0f3 100644 --- a/src/libcamera/v4l2_device.cpp +++ b/src/libcamera/v4l2_device.cpp @@ -340,6 +340,7 @@ int V4L2Device::ioctl(unsigned long request, void *argp) */ void V4L2Device::listControls() { + std::map ctrls; struct v4l2_query_ext_ctrl ctrl = {}; /* \todo Add support for menu and compound controls. */ @@ -368,10 +369,12 @@ void V4L2Device::listControls() continue; } - controls_.emplace(std::piecewise_construct, - std::forward_as_tuple(ctrl.id), - std::forward_as_tuple(ctrl)); + ctrls.emplace(std::piecewise_construct, + std::forward_as_tuple(ctrl.id), + std::forward_as_tuple(ctrl)); } + + controls_ = std::move(ctrls); } /*