OpenNI 1.0.0
|
00001 /***************************************************************************** 00002 * * 00003 * OpenNI 1.0 Alpha * 00004 * Copyright (C) 2010 PrimeSense Ltd. * 00005 * * 00006 * This file is part of OpenNI. * 00007 * * 00008 * OpenNI is free software: you can redistribute it and/or modify * 00009 * it under the terms of the GNU Lesser General Public License as published * 00010 * by the Free Software Foundation, either version 3 of the License, or * 00011 * (at your option) any later version. * 00012 * * 00013 * OpenNI is distributed in the hope that it will be useful, * 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00016 * GNU Lesser General Public License for more details. * 00017 * * 00018 * You should have received a copy of the GNU Lesser General Public License * 00019 * along with OpenNI. If not, see <http://www.gnu.org/licenses/>. * 00020 * * 00021 *****************************************************************************/ 00022 00023 00024 00025 00026 #ifndef _XN_DATA_TYPES_H_ 00027 #define _XN_DATA_TYPES_H_ 00028 00029 //--------------------------------------------------------------------------- 00030 // Includes 00031 //--------------------------------------------------------------------------- 00032 #include "XnOS.h" 00033 00034 //--------------------------------------------------------------------------- 00035 // Types 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_