00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00030 #ifndef EXPANDLIB_VARTYPE_NUMERIC_TRAITS_H_INCLUDED
00031 #define EXPANDLIB_VARTYPE_NUMERIC_TRAITS_H_INCLUDED
00032
00033 namespace expander {
00034
00036 template<class NumType>
00037 class expvartype_numeric_traits_normal {
00038 public:
00039 static inline NumType defaultvalue() { return 0; }
00040 static inline NumType validate(const NumType v) { return v; }
00041 };
00042
00044 template<class NumType, const NumType minimum, const NumType maximum>
00045 class expvartype_numeric_traits_limited {
00046 public:
00047 static inline NumType defaultvalue() { return validate(0); }
00048 static inline NumType validate(const NumType v) { return ( v > maximum ? maximum : ( v < minimum ? minimum : v ) ); }
00049 };
00050
00052 template<class NumType, const NumType minimum, const NumType maximum, const NumType defaultval>
00053 class expvartype_numeric_traits_limited_with_default {
00054 public:
00055 static inline NumType defaultvalue() { return defaultval; }
00056 static inline NumType validate(const NumType v) { return ( v > maximum || v < minimum ? defaultval : v ); }
00057 };
00058
00059 }
00060
00061 #endif //EXPANDLIB_VARTYPE_NUMERIC_TRAITS_H_INCLUDED