From 3556ae95ecb049eb7befb4c2115aa1646c5b4daf Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Thu, 27 Feb 2020 01:05:59 +0200 Subject: libcamera: controls: Allow passing an std::initializer list to set() For array controls, the ControlList::set() function takes a value as a type convertible to Span. This allows passing an std::array or an std::vector in addition to an explicit Span, but doesn't accept an std::initializer list as Span has no constructor that takes an initializer list. Callers are thus forced to create temporary objects explicitly, which isn't nice. Fix the issue by providing a ControlList::set() function that takes an std::initializer_list, and convert it to a Span internally. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- include/libcamera/controls.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'include') diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h index 1e24ae30..2102d571 100644 --- a/include/libcamera/controls.h +++ b/include/libcamera/controls.h @@ -335,6 +335,16 @@ public: val->set(value); } + template + void set(const Control &ctrl, const std::initializer_list &value) + { + ControlValue *val = find(ctrl.id()); + if (!val) + return; + + val->set(Span>{ value.begin(), value.size() }); + } + const ControlValue &get(unsigned int id) const; void set(unsigned int id, const ControlValue &value); -- cgit v1.2.1