diff --git a/src/types.hpp b/src/types.hpp index 268bf90c..3fcda9ff 100644 --- a/src/types.hpp +++ b/src/types.hpp @@ -4,6 +4,14 @@ #include #include +#define MAP(T, N) \ + template<> \ + struct ControlTypeMap::value> \ + { \ + using type = T; \ + }; \ + typedef ControlTypeMap::type CT##N; + namespace std { @@ -17,66 +25,12 @@ to_string(const libcamera::ControlType id); template struct ControlTypeMap; -template<> -struct ControlTypeMap -{ - using type = void; -}; - -template<> -struct ControlTypeMap -{ - using type = bool; -}; - -template<> -struct ControlTypeMap -{ - using type = uint8_t; -}; - -template<> -struct ControlTypeMap -{ - using type = int32_t; -}; - -template<> -struct ControlTypeMap -{ - using type = int64_t; -}; - -template<> -struct ControlTypeMap -{ - using type = float; -}; - -template<> -struct ControlTypeMap -{ - using type = std::string; -}; - -template<> -struct ControlTypeMap -{ - using type = libcamera::Rectangle; -}; - -template<> -struct ControlTypeMap -{ - using type = libcamera::Size; -}; - -typedef ControlTypeMap::type CTNone; -typedef ControlTypeMap::type CTBool; -typedef ControlTypeMap::type CTByte; -typedef ControlTypeMap::type CTInteger32; -typedef ControlTypeMap::type CTInteger64; -typedef ControlTypeMap::type CTFloat; -typedef ControlTypeMap::type CTString; -typedef ControlTypeMap::type CTRectangle; -typedef ControlTypeMap::type CTSize; +MAP(void, None); +MAP(bool, Bool); +MAP(uint8_t, Byte); +MAP(int32_t, Integer32); +MAP(int64_t, Integer64); +MAP(float, Float); +MAP(std::string, String); +MAP(libcamera::Rectangle, Rectangle); +MAP(libcamera::Size, Size);