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