mirror of
https://git.libcamera.org/libcamera/libcamera.git
synced 2025-07-23 00:25:07 +03:00
libcamera: controls: Move ControlValue get() and set() to controls.h
To avoid defining all specializations of ControlValue::get() and ControlValue::set() manually, move the definition of those functions to controls.h and turn them into single template functions. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
parent
300f6e4434
commit
eaa1297df0
2 changed files with 13 additions and 49 deletions
|
@ -8,6 +8,7 @@
|
|||
#ifndef __LIBCAMERA_CONTROLS_H__
|
||||
#define __LIBCAMERA_CONTROLS_H__
|
||||
|
||||
#include <assert.h>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
|
@ -70,9 +71,19 @@ public:
|
|||
}
|
||||
|
||||
template<typename T>
|
||||
T get() const;
|
||||
T get() const
|
||||
{
|
||||
assert(type_ == details::control_type<std::remove_cv_t<T>>::value);
|
||||
|
||||
return *reinterpret_cast<const T *>(&bool_);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void set(const T &value);
|
||||
void set(const T &value)
|
||||
{
|
||||
type_ = details::control_type<std::remove_cv_t<T>>::value;
|
||||
*reinterpret_cast<T *>(&bool_) = value;
|
||||
}
|
||||
|
||||
private:
|
||||
ControlType type_;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue