controls: Add boolean constructors for ControlInfo
It would be convenient to be able to iterate over available boolean values, for example for controls that designate if some function can be enabled/disabled. The current min/max/def constructor is insufficient, as .values() is empty, so the values cannot be easily iterated over, and creating a Span of booleans does not work for the values constructor. Add new constructors to ControlInfo that takes a set of booleans (if both booleans are valid values) plus a default, and another that takes only one boolean (if only one boolean is a valid value). Update the ControlInfo test accordingly. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
#define __LIBCAMERA_CONTROLS_H__
|
||||
|
||||
#include <assert.h>
|
||||
#include <set>
|
||||
#include <stdint.h>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
@@ -272,6 +273,8 @@ public:
|
||||
const ControlValue &def = 0);
|
||||
explicit ControlInfo(Span<const ControlValue> values,
|
||||
const ControlValue &def = {});
|
||||
explicit ControlInfo(std::set<bool> values, bool def);
|
||||
explicit ControlInfo(bool value);
|
||||
|
||||
const ControlValue &min() const { return min_; }
|
||||
const ControlValue &max() const { return max_; }
|
||||
|
||||
Reference in New Issue
Block a user