From eaa1297df0bc4c6620ccde171dc9dc088109e35e Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Fri, 14 Feb 2020 17:02:18 +0200 Subject: 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 Reviewed-by: Kieran Bingham --- include/libcamera/controls.h | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'include/libcamera/controls.h') diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h index 429f01b0..39e24043 100644 --- a/include/libcamera/controls.h +++ b/include/libcamera/controls.h @@ -8,6 +8,7 @@ #ifndef __LIBCAMERA_CONTROLS_H__ #define __LIBCAMERA_CONTROLS_H__ +#include #include #include @@ -70,9 +71,19 @@ public: } template - T get() const; + T get() const + { + assert(type_ == details::control_type>::value); + + return *reinterpret_cast(&bool_); + } + template - void set(const T &value); + void set(const T &value) + { + type_ = details::control_type>::value; + *reinterpret_cast(&bool_) = value; + } private: ControlType type_; -- cgit v1.2.1