OpenNI 1.5.4
|
XnDataTypes.h
Go to the documentation of this file.
00001 /**************************************************************************** 00002 * * 00003 * OpenNI 1.x 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 XN_PRAGMA_START_DISABLED_WARNING_SECTION(XN_CONDITION_IS_CONST_WARNING_ID) \ 00047 \ 00048 static XnValue CreateValueCopy(Type const& orig) \ 00049 { \ 00050 if (sizeof(Type) > sizeof(XnValue)) \ 00051 { \ 00052 Type* pNew = XN_NEW(Type, orig); \ 00053 return (XnValue)pNew; \ 00054 } \ 00055 else \ 00056 { \ 00057 XnValue result = 0; \ 00058 xnOSMemCopy(&result, &orig, sizeof(Type)); \ 00059 return result; \ 00060 } \ 00061 } \ 00062 static void FreeValue(XnValue& Value) \ 00063 { \ 00064 if (sizeof(Type) > sizeof(XnValue)) \ 00065 { \ 00066 Type* p = (Type*)Value; \ 00067 XN_DELETE(p); \ 00068 } \ 00069 } \ 00070 static XnValue GetAsValue(Type const& orig) \ 00071 { \ 00072 if (sizeof(Type) > sizeof(XnValue)) \ 00073 { \ 00074 return (XnValue)&orig; \ 00075 } \ 00076 else \ 00077 { \ 00078 XnValue result = 0; \ 00079 xnOSMemCopy(&result, &orig, sizeof(Type)); \ 00080 return result; \ 00081 } \ 00082 } \ 00083 static Type const& GetFromValue(const XnValue& Value) \ 00084 { \ 00085 if (sizeof(Type) > sizeof(XnValue)) \ 00086 { \ 00087 Type const* p = (Type const*)Value; \ 00088 return *p; \ 00089 } \ 00090 else \ 00091 { \ 00092 Type const* p = (Type const*)&Value; \ 00093 return *p; \ 00094 } \ 00095 } \ 00096 static Type& GetFromValue(XnValue& Value) \ 00097 { \ 00098 if (sizeof(Type) > sizeof(XnValue)) \ 00099 { \ 00100 Type* p = (Type*)Value; \ 00101 return *p; \ 00102 } \ 00103 else \ 00104 { \ 00105 Type* p = (Type*)&Value; \ 00106 return *p; \ 00107 } \ 00108 } \ 00109 XN_PRAGMA_STOP_DISABLED_WARNING_SECTION \ 00110 }; 00111 00115 #define XN_DECLARE_DEFAULT_VALUE_TRANSLATOR(Type, ClassName) \ 00116 XN_DECLARE_DEFAULT_VALUE_TRANSLATOR_DECL(, Type, ClassName) 00117 00118 #define XN_DEFAULT_TRANSLATOR_NAME(ClassName) ClassName ## Translator 00119 00120 #endif // _XN_DATA_TYPES_H_
Generated on Wed May 16 2012 10:16:05 for OpenNI 1.5.4 by 1.7.5.1