mirror of
https://git.libcamera.org/libcamera/libcamera.git
synced 2025-07-21 15:53:54 +03:00
libcamera: controls: Support accessing controls by numerical ID
The ControlList class has template get() and set() methods to get and set control values. The methods require a reference to a Control instance, which is only available when calling them with a hardcoded control. In order to support usage of ControlList for V4L2 controls, as well as serialisation and deserialisation of ControlList, we need a way to get and set control values based on a control numerical ID. Add new contains(), get() and set() overload methods to do so. As this change prepares the ControlList to be used for other objects than camera, update its documentation accordingly. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Tested-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
This commit is contained in:
parent
576b8aa079
commit
a1c6b2b641
5 changed files with 129 additions and 39 deletions
|
@ -126,7 +126,7 @@ private:
|
|||
using ControlListMap = std::unordered_map<const ControlId *, ControlValue>;
|
||||
|
||||
public:
|
||||
ControlList(ControlValidator *validator = nullptr);
|
||||
ControlList(const ControlIdMap &idmap, ControlValidator *validator = nullptr);
|
||||
|
||||
using iterator = ControlListMap::iterator;
|
||||
using const_iterator = ControlListMap::const_iterator;
|
||||
|
@ -136,11 +136,13 @@ public:
|
|||
const_iterator begin() const { return controls_.begin(); }
|
||||
const_iterator end() const { return controls_.end(); }
|
||||
|
||||
bool contains(const ControlId &id) const;
|
||||
bool empty() const { return controls_.empty(); }
|
||||
std::size_t size() const { return controls_.size(); }
|
||||
void clear() { controls_.clear(); }
|
||||
|
||||
bool contains(const ControlId &id) const;
|
||||
bool contains(unsigned int id) const;
|
||||
|
||||
template<typename T>
|
||||
const T &get(const Control<T> &ctrl) const
|
||||
{
|
||||
|
@ -163,11 +165,15 @@ public:
|
|||
val->set<T>(value);
|
||||
}
|
||||
|
||||
const ControlValue &get(unsigned int id) const;
|
||||
void set(unsigned int id, const ControlValue &value);
|
||||
|
||||
private:
|
||||
const ControlValue *find(const ControlId &id) const;
|
||||
ControlValue *find(const ControlId &id);
|
||||
|
||||
ControlValidator *validator_;
|
||||
const ControlIdMap *idmap_;
|
||||
ControlListMap controls_;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue