00001 00026 #ifndef PYCVD_TYPES_HPP 00027 #define PYCVD_TYPES_HPP 00028 00029 namespace PyCVD { 00030 00031 00032 #define DEFINE_NUMPY_TYPE(Type, PyType) \ 00033 template<> struct NumpyType<Type>\ 00034 {\ 00035 static const int num = PyType; \ 00036 static std::string name(){ return #Type;} \ 00037 static char code(){ return PyType##LTR;} \ 00038 } 00039 00040 template<class C> struct NumpyType 00041 { 00042 }; 00043 00044 DEFINE_NUMPY_TYPE(unsigned char , NPY_UBYTE ); 00045 DEFINE_NUMPY_TYPE(char , NPY_BYTE ); 00046 DEFINE_NUMPY_TYPE(short , NPY_SHORT ); 00047 DEFINE_NUMPY_TYPE(unsigned short, NPY_USHORT); 00048 DEFINE_NUMPY_TYPE(int , NPY_INT ); 00049 DEFINE_NUMPY_TYPE(long long , NPY_LONGLONG); 00050 DEFINE_NUMPY_TYPE(unsigned int , NPY_UINT ); 00051 DEFINE_NUMPY_TYPE(float , NPY_FLOAT ); 00052 DEFINE_NUMPY_TYPE(double , NPY_DOUBLE); 00053 00054 struct End{}; 00055 00056 template<class C, class D> struct TypeList 00057 { 00058 typedef C type; 00059 typedef D next; 00060 }; 00061 00062 00063 typedef TypeList<char, 00064 TypeList<unsigned char, 00065 TypeList<short, 00066 TypeList<unsigned short, 00067 TypeList<int, 00068 TypeList<long long, 00069 TypeList<unsigned int, 00070 TypeList<float, 00071 TypeList<double, End> > > > > > > > > CVDTypes; 00072 00073 00074 00075 typedef TypeList<float, 00076 TypeList<double, End> > CVDFloatTypes; 00077 } 00078 00079 #endif