diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2019-10-25 23:48:45 +0300 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2019-11-20 21:47:33 +0200 |
commit | e89c2b22957b9faa2d9521dd8d696ed1cefc7dda (patch) | |
tree | 002950c748e59c9d6200be1cc6e7df3c82e9a4df /include | |
parent | c27b7c103a7d0e8a6ca02b5f6e42372d1ee6993e (diff) |
libcamera: controls: Index ControlList by unsigned int
In preparation for serialization, index the ControlList by unsigned int.
This will allow deserializing a ControlList without requiring external
information.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/libcamera/controls.h | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h index f24dc764..1ecc8fcb 100644 --- a/include/libcamera/controls.h +++ b/include/libcamera/controls.h @@ -78,12 +78,22 @@ private: ControlType type_; }; -static inline bool operator==(const ControlId &lhs, const ControlId &rhs) +static inline bool operator==(unsigned int lhs, const ControlId &rhs) { - return lhs.id() == rhs.id(); + return lhs == rhs.id(); } -static inline bool operator!=(const ControlId &lhs, const ControlId &rhs) +static inline bool operator!=(unsigned int lhs, const ControlId &rhs) +{ + return !(lhs == rhs); +} + +static inline bool operator==(const ControlId &lhs, unsigned int rhs) +{ + return lhs.id() == rhs; +} + +static inline bool operator!=(const ControlId &lhs, unsigned int rhs) { return !(lhs == rhs); } @@ -176,7 +186,7 @@ private: class ControlList { private: - using ControlListMap = std::unordered_map<const ControlId *, ControlValue>; + using ControlListMap = std::unordered_map<unsigned int, ControlValue>; public: ControlList(const ControlIdMap &idmap, ControlValidator *validator = nullptr); @@ -200,7 +210,7 @@ public: template<typename T> const T &get(const Control<T> &ctrl) const { - const ControlValue *val = find(ctrl); + const ControlValue *val = find(ctrl.id()); if (!val) { static T t(0); return t; @@ -212,7 +222,7 @@ public: template<typename T> void set(const Control<T> &ctrl, const T &value) { - ControlValue *val = find(ctrl); + ControlValue *val = find(ctrl.id()); if (!val) return; @@ -223,8 +233,8 @@ public: void set(unsigned int id, const ControlValue &value); private: - const ControlValue *find(const ControlId &id) const; - ControlValue *find(const ControlId &id); + const ControlValue *find(unsigned int id) const; + ControlValue *find(unsigned int id); ControlValidator *validator_; const ControlIdMap *idmap_; |