Go to the documentation of this file.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
00026 #ifndef _XN_DATA_TYPES_H_
00027 #define _XN_DATA_TYPES_H_
00028
00029
00030
00031
00032 #include "XnOS.h"
00033
00034
00035
00036
00040 typedef void* XnValue;
00041
00046 #define XN_DECLARE_DEFAULT_VALUE_TRANSLATOR_DECL(decl, Type, ClassName) \
00047 class decl ClassName \
00048 { \
00049 public: \
00050 static XnValue CreateValueCopy(Type const& orig) \
00051 { \
00052 if (sizeof(Type) > sizeof(XnValue)) \
00053 { \
00054 Type* pNew = XN_NEW(Type, orig); \
00055 return (XnValue)pNew; \
00056 } \
00057 else \
00058 { \
00059 XnValue result = 0; \
00060 xnOSMemCopy(&result, &orig, sizeof(Type)); \
00061 return result; \
00062 } \
00063 } \
00064 static void FreeValue(XnValue& Value) \
00065 { \
00066 if (sizeof(Type) > sizeof(XnValue)) \
00067 { \
00068 Type* p = (Type*)Value; \
00069 XN_DELETE(p); \
00070 } \
00071 } \
00072 static XnValue GetAsValue(Type const& orig) \
00073 { \
00074 if (sizeof(Type) > sizeof(XnValue)) \
00075 { \
00076 return (XnValue)&orig; \
00077 } \
00078 else \
00079 { \
00080 XnValue result = 0; \
00081 xnOSMemCopy(&result, &orig, sizeof(Type)); \
00082 return result; \
00083 } \
00084 } \
00085 static Type const& GetFromValue(const XnValue& Value) \
00086 { \
00087 if (sizeof(Type) > sizeof(XnValue)) \
00088 { \
00089 Type const* p = (Type const*)Value; \
00090 return *p; \
00091 } \
00092 else \
00093 { \
00094 Type const* p = (Type const*)&Value; \
00095 return *p; \
00096 } \
00097 } \
00098 static Type& GetFromValue(XnValue& Value) \
00099 { \
00100 if (sizeof(Type) > sizeof(XnValue)) \
00101 { \
00102 Type* p = (Type*)Value; \
00103 return *p; \
00104 } \
00105 else \
00106 { \
00107 Type* p = (Type*)&Value; \
00108 return *p; \
00109 } \
00110 } \
00111 };
00112
00116 #define XN_DECLARE_DEFAULT_VALUE_TRANSLATOR(Type, ClassName) \
00117 XN_DECLARE_DEFAULT_VALUE_TRANSLATOR_DECL(, Type, ClassName)
00118
00119 #define XN_DEFAULT_TRANSLATOR_NAME(ClassName) ClassName ## Translator
00120
00121 #endif // _XN_DATA_TYPES_H_