OpenNI 1.3.2
|
00001 /**************************************************************************** 00002 * * 00003 * OpenNI 1.1 Alpha * 00004 * Copyright (C) 2011 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 #ifndef _XN_DATA_TYPES_H_ 00023 #define _XN_DATA_TYPES_H_ 00024 00025 //--------------------------------------------------------------------------- 00026 // Includes 00027 //--------------------------------------------------------------------------- 00028 #include "XnOS.h" 00029 00030 //--------------------------------------------------------------------------- 00031 // Types 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_