00001
00004
00005
00006
00007
00008 #ifndef _cel_datatraits_h_
00009 #define _cel_datatraits_h_
00010
00011 #include "cel_types.h"
00012
00013 namespace Celartem
00014 {
00020 enum CopyPolicy
00021 {
00023 noCopy = 0,
00024
00026 byConstructor = 1,
00027
00030 byMemcpy = 2,
00031 };
00032
00039 enum StoragePolicy
00040 {
00042 notToBeStored = 0,
00043
00046 byCopyBytes = 1,
00047
00050 bySwapCopyBytes = 2,
00051
00054 byClassMethods = 3,
00055 };
00056
00076 template<typename T> struct DataTraits
00077 {
00121 static const CopyPolicy copyPolicy = byConstructor;
00122
00133 static const StoragePolicy storagePolicy = notToBeStored;
00134
00140 static const bool isPOD = false;
00141 };
00142
00156 #ifndef DONT_QUALIFY_SPECIALIZED_TEMPLATE
00157 #define CEL_DEFINE_DATATRAITS_EX(inType,inCopyPolicy,inStoragePolicy,isPod) \
00158 template<> struct ::Celartem::DataTraits<inType> { \
00159 static const ::Celartem::CopyPolicy copyPolicy = ::Celartem::inCopyPolicy; \
00160 static const ::Celartem::StoragePolicy storagePolicy = ::Celartem::inStoragePolicy; \
00161 static const bool isPOD = isPod; \
00162 }
00163 #else // DONT_QUALIFY_SPECIALIZED_TEMPLATE
00164 #define CEL_DEFINE_DATATRAITS_EX(inType,inCopyPolicy,inStoragePolicy,isPod) \
00165 template<> struct DataTraits<inType> { \
00166 static const ::Celartem::CopyPolicy copyPolicy = ::Celartem::inCopyPolicy; \
00167 static const ::Celartem::StoragePolicy storagePolicy = ::Celartem::inStoragePolicy; \
00168 static const bool isPOD = isPod; \
00169 }
00170 #endif // DONT_QUALIFY_SPECIALIZED_TEMPLATE
00171
00183 #define CEL_DEFINE_DATATRAITS(inType,inCopyPolicy,inStoragePolicy) \
00184 CEL_DEFINE_DATATRAITS_EX(inType, inCopyPolicy, inStoragePolicy, false)
00185
00192 #define CEL_DEFINE_DATATRAITS_POD(inType) \
00193 CEL_DEFINE_DATATRAITS_EX(inType, byMemcpy, bySwapCopyBytes, true)
00194
00195 CEL_DEFINE_DATATRAITS_POD(char);
00196 CEL_DEFINE_DATATRAITS_POD(signed char);
00197 CEL_DEFINE_DATATRAITS_POD(short);
00198 CEL_DEFINE_DATATRAITS_POD(int);
00199 CEL_DEFINE_DATATRAITS_POD(long);
00200 CEL_DEFINE_DATATRAITS_POD(long long);
00201 CEL_DEFINE_DATATRAITS_POD(unsigned char);
00202 CEL_DEFINE_DATATRAITS_POD(unsigned short);
00203 CEL_DEFINE_DATATRAITS_POD(unsigned int);
00204 CEL_DEFINE_DATATRAITS_POD(unsigned long);
00205 CEL_DEFINE_DATATRAITS_POD(unsigned long long);
00206 CEL_DEFINE_DATATRAITS_POD(float);
00207 CEL_DEFINE_DATATRAITS_POD(double);
00208
00209 }
00210
00211 #endif // _cel_datatraits_h_