[libcamera-devel] [PATCH v3 04/14] libcamera: controls: Construct from values list
Jacopo Mondi
jacopo at jmondi.org
Wed Oct 21 16:36:25 CEST 2020
Add two constructors to the ControlInfo class that allows creating
a class instance from the list of the control supported values with
an optional default value.
Signed-off-by: Jacopo Mondi <jacopo at jmondi.org>
---
include/libcamera/controls.h | 3 +++
src/libcamera/controls.cpp | 31 +++++++++++++++++++++++++++++++
2 files changed, 34 insertions(+)
diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h
index d1f6d4490c35..0099b6329026 100644
--- a/include/libcamera/controls.h
+++ b/include/libcamera/controls.h
@@ -269,6 +269,9 @@ public:
const ControlValue &max = 0,
const ControlValue &def = 0,
const std::vector<ControlValue> &values = {});
+ explicit ControlInfo(const std::vector<ControlValue> &values,
+ const ControlValue &def);
+ explicit ControlInfo(const std::vector<ControlValue> &values);
const ControlValue &min() const { return min_; }
const ControlValue &max() const { return max_; }
diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp
index 61feee37a1b8..389ecd5c519c 100644
--- a/src/libcamera/controls.cpp
+++ b/src/libcamera/controls.cpp
@@ -493,6 +493,37 @@ ControlInfo::ControlInfo(const ControlValue &min,
{
}
+/**
+ * \brief Construct a ControlInfo from the list of supported values and a default
+ * \param[in] values The control supported values
+ * \param[in] def The control default value
+ *
+ * Construct a ControlInfo from a list of supported values. The ControlInfo
+ * minimum and maximum values are assigned to the first and last members of
+ * the values list respectively.
+ */
+ControlInfo::ControlInfo(const std::vector<ControlValue> &values,
+ const ControlValue &def)
+ : def_(def), values_(values)
+{
+ min_ = values_.front();
+ max_ = values_.back();
+}
+
+/**
+ * \brief Construct a ControlInfo from the list of supported values
+ * \param[in] values The control supported values
+ *
+ * Construct a ControlInfo from a list of supported values. The ControlInfo
+ * minimum and maximum values are assigned to the first and last members of
+ * the values list respectively. The ControlInfo default value is set to be
+ * equal to the minimum one.
+ */
+ControlInfo::ControlInfo(const std::vector<ControlValue> &values)
+ : ControlInfo(values, values.front())
+{
+}
+
/**
* \fn ControlInfo::min()
* \brief Retrieve the minimum value of the control
--
2.28.0
More information about the libcamera-devel
mailing list