00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __NRRO_TYPE_INFO_DOT_H
00021 #define __NRRO_TYPE_INFO_DOT_H
00022
00023 #include "nrro.h"
00024 #include <limits>
00025
00026
00027
00028
00029 class _NrroType {
00030 public:
00031
00032 virtual bool isIntegral() const = 0;
00033
00034 virtual bool isFloat() const = 0;
00035 virtual double min() const = 0;
00036 virtual double max() const = 0;
00037 };
00038
00039 class NrroTypeUnknown : public _NrroType
00040 {
00041 public:
00042 bool isIntegral() const { return false; }
00043 bool isFloat() const { return false; }
00044 double min() const {return std::numeric_limits<double>::quiet_NaN();}
00045 double max() const {return std::numeric_limits<double>::quiet_NaN();}
00046 };
00047
00048 class NrroTypeChar : public _NrroType
00049 {
00050 public:
00051 bool isIntegral() const {return true;}
00052 bool isFloat() const { return false; }
00053 double min() const {return (double)std::numeric_limits<char>::min();}
00054 double max() const {return (double)std::numeric_limits<char>::max();}
00055 };
00056
00057 class NrroTypeUChar : public _NrroType
00058 {
00059 public:
00060 bool isIntegral() const {return true;}
00061 bool isFloat() const { return false; }
00062 double min() const {return (double)std::numeric_limits<unsigned char>::min();}
00063 double max() const {return (double)std::numeric_limits<unsigned char>::max();}
00064 };
00065
00066 class NrroTypeShort : public _NrroType
00067 {
00068 public:
00069 bool isIntegral() const {return true;}
00070 bool isFloat() const { return false; }
00071 double min() const {return (double)std::numeric_limits<short>::min();}
00072 double max() const {return (double)std::numeric_limits<short>::max();}
00073 };
00074
00075 class NrroTypeUShort : public _NrroType
00076 {
00077 public:
00078 bool isIntegral() const {return true;}
00079 bool isFloat() const { return false; }
00080 double min() const {return (double)std::numeric_limits<unsigned short>::min();}
00081 double max() const {return (double)std::numeric_limits<unsigned short>::max();}
00082 };
00083
00084 class NrroTypeInt : public _NrroType
00085 {
00086 public:
00087 bool isIntegral() const {return true;}
00088 bool isFloat() const { return false; }
00089 double min() const {return (double)std::numeric_limits<int>::min();}
00090 double max() const {return (double)std::numeric_limits<int>::max();}
00091 };
00092
00093 class NrroTypeUInt : public _NrroType
00094 {
00095 public:
00096 bool isIntegral() const {return true;}
00097 bool isFloat() const { return false; }
00098 double min() const {return (double)std::numeric_limits<unsigned int>::min();}
00099 double max() const {return (double)std::numeric_limits<unsigned int>::max();}
00100 };
00101
00102 #ifdef _LONGLONG
00103 typedef _LONGLONG longlong;
00104 #else
00105 typedef long long int longlong;
00106 #endif
00107
00108 class NrroTypeLL : public _NrroType
00109 {
00110 public:
00111 bool isIntegral() const {return true;}
00112 bool isFloat() const { return false; }
00113 double min() const {return (double)std::numeric_limits<longlong>::min();}
00114 double max() const {return (double)std::numeric_limits<longlong>::max();}
00115 };
00116
00117 #ifdef _ULONGLONG
00118 typedef _ULONGLONG ulonglong;
00119 #else
00120 typedef unsigned long long int ulonglong;
00121 #endif
00122
00123 class NrroTypeULL : public _NrroType
00124 {
00125 public:
00126 bool isIntegral() const {return true;}
00127 bool isFloat() const { return false; }
00128 double min() const {return (double)std::numeric_limits<ulonglong>::min();}
00129 double max() const {return (double)std::numeric_limits<ulonglong>::max();}
00130 };
00131
00132 class NrroTypeFloat : public _NrroType
00133 {
00134 public:
00135 bool isIntegral() const {return false;}
00136 bool isFloat() const { return true; }
00137 double min() const {return (double)std::numeric_limits<float>::min();}
00138 double max() const {return (double)std::numeric_limits<float>::max();}
00139 };
00140
00141 class NrroTypeDouble : public _NrroType
00142 {
00143 public:
00144 bool isIntegral() const {return false;}
00145 bool isFloat() const { return true; }
00146 double min() const {return (double)std::numeric_limits<double>::min();}
00147 double max() const {return (double)std::numeric_limits<double>::max();}
00148 };
00149
00150
00151
00152
00153
00154
00155
00156 const _NrroType* const NrroType[] = { new NrroTypeUnknown(),
00157 new NrroTypeChar(),
00158 new NrroTypeUChar(),
00159 new NrroTypeShort(),
00160 new NrroTypeUShort(),
00161 new NrroTypeInt(),
00162 new NrroTypeUInt(),
00163 new NrroTypeLL(),
00164 new NrroTypeULL(),
00165 new NrroTypeFloat(),
00166 new NrroTypeDouble(),
00167 new NrroTypeUnknown()
00168 };
00169
00170
00171
00172 template<int T_ENUM>
00173 struct NrroTypesID { };
00174
00175
00176 template<class T>
00177 struct NrroTypesT { };
00178
00179
00180 template<>
00181 struct NrroTypesID<Nrro::CHAR> { typedef char TYPE; };
00182 template<>
00183 struct NrroTypesT<char>
00184 { enum{ID = Nrro::CHAR}; };
00185
00186 template<>
00187 struct NrroTypesID<Nrro::UCHAR> { typedef unsigned char TYPE; };
00188 template<>
00189 struct NrroTypesT<unsigned char>
00190 { enum{ID = Nrro::UCHAR}; };
00191
00192 template<>
00193 struct NrroTypesID<Nrro::SHORT> { typedef short TYPE; };
00194 template<>
00195 struct NrroTypesT<short>
00196 { enum{ID = Nrro::SHORT }; };
00197
00198 template<>
00199 struct NrroTypesID<Nrro::USHORT> { typedef unsigned short TYPE; };
00200 template<>
00201 struct NrroTypesT<unsigned short>
00202 { enum{ID = Nrro::USHORT}; };
00203
00204 template<>
00205 struct NrroTypesID<Nrro::INT> { typedef int TYPE; };
00206 template<>
00207 struct NrroTypesT<int>
00208 { enum{ID = Nrro::INT}; };
00209
00210 template<>
00211 struct NrroTypesID<Nrro::UINT> { typedef unsigned int TYPE; };
00212 template<>
00213 struct NrroTypesT<unsigned int>
00214 { enum{ID = Nrro::UINT}; };
00215
00216 template<>
00217 struct NrroTypesID<Nrro::FLOAT> { typedef float TYPE; };
00218 template<>
00219 struct NrroTypesT<float>
00220 { enum{ID = Nrro::FLOAT}; };
00221
00222 template<>
00223 struct NrroTypesID<Nrro::DOUBLE> { typedef double TYPE; };
00224 template<>
00225 struct NrroTypesT<double>
00226 { enum{ID = Nrro::DOUBLE}; };
00227
00228
00229
00230
00231 #if 0
00232 template<int T_ENUM>
00233 struct _NrroTypeInfoID
00234 {
00235 typedef typename NrroTypesID<T_ENUM>::TYPE TYPE;
00236 static Nrro::NrroIter<TYPE> getBegin(NrroSP n)
00237 { return n->begin<NrroTypesID<T_ENUM>::TYPE>(); }
00238 static Nrro::NrroIter<TYPE> getEnd(NrroSP n)
00239 { return n->end<NrroTypesID<T_ENUM>::TYPE>(); }
00240 };
00241 #endif
00242
00243
00244
00245 #endif
00246
00247