#ifndef CVD_BUILTIN_TRAITS_H_ #define CVD_BUILTIN_TRAITS_H_ #include #include #if defined(CVD_HAVE_TOON) #include #endif namespace CVD { namespace Pixel { //The "Component" class gives us information about the pixel components, //ie how many components there are and whay the type is. //We use a 2 layer thing here so that Component is only properly defined //for builtin types, unless explicitly overridden. template struct component_base { template struct component_base_only_for_basic_types; static const int fail = sizeof(component_base_only_for_basic_types); }; template struct component_base { }; //template ::is_specialized> struct Component; template struct Component { typedef P type; static const size_t count = 1; static const P& get(const P& pixel, size_t) { return pixel; } static P& get(P& pixel, size_t) { return pixel; } }; template struct Component { typedef P type; static const size_t count = I; static const P& get(const P pixel[I], size_t i) { return pixel[i]; } static inline P& get(P pixel[I], size_t i) { return pixel[i]; } }; #if defined(CVD_HAVE_TOON) template struct Component> { typedef P type; static const size_t count = N; static inline const P& get(const TooN::Vector& pixel, size_t i) { return pixel[i]; } static inline P& get(TooN::Vector& pixel, size_t i) { return pixel[i]; } }; template struct Component> { typedef P type; static const size_t count = N * M; static const P& get(const TooN::Matrix& pixel, size_t i) { return pixel[i / M][i % M]; } static inline P& get(TooN::Matrix& pixel, size_t i) { return pixel[i / M][i % M]; } }; #endif } } #endif