![]() |
OpenNI 1.5.7
|
00001 /***************************************************************************** 00002 * * 00003 * OpenNI 1.x Alpha * 00004 * Copyright (C) 2012 PrimeSense Ltd. * 00005 * * 00006 * This file is part of OpenNI. * 00007 * * 00008 * Licensed under the Apache License, Version 2.0 (the "License"); * 00009 * you may not use this file except in compliance with the License. * 00010 * You may obtain a copy of the License at * 00011 * * 00012 * http://www.apache.org/licenses/LICENSE-2.0 * 00013 * * 00014 * Unless required by applicable law or agreed to in writing, software * 00015 * distributed under the License is distributed on an "AS IS" BASIS, * 00016 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * 00017 * See the License for the specific language governing permissions and * 00018 * limitations under the License. * 00019 * * 00020 *****************************************************************************/ 00021 #ifndef _XN_DATA_TYPES_H_ 00022 #define _XN_DATA_TYPES_H_ 00023 00024 //--------------------------------------------------------------------------- 00025 // Includes 00026 //--------------------------------------------------------------------------- 00027 #include "XnOS.h" 00028 00029 //--------------------------------------------------------------------------- 00030 // Types 00031 //--------------------------------------------------------------------------- 00035 typedef void* XnValue; 00036 00041 #define XN_DECLARE_DEFAULT_VALUE_TRANSLATOR_DECL(decl, Type, ClassName) \ 00042 class decl ClassName \ 00043 { \ 00044 public: \ 00045 XN_PRAGMA_START_DISABLED_WARNING_SECTION(XN_CONDITION_IS_CONST_WARNING_ID) \ 00046 \ 00047 static XnValue CreateValueCopy(Type const& orig) \ 00048 { \ 00049 if (sizeof(Type) > sizeof(XnValue)) \ 00050 { \ 00051 Type* pNew = XN_NEW(Type, orig); \ 00052 return (XnValue)pNew; \ 00053 } \ 00054 else \ 00055 { \ 00056 XnValue result = 0; \ 00057 xnOSMemCopy(&result, &orig, sizeof(Type)); \ 00058 return result; \ 00059 } \ 00060 } \ 00061 static void FreeValue(XnValue& Value) \ 00062 { \ 00063 if (sizeof(Type) > sizeof(XnValue)) \ 00064 { \ 00065 Type* p = (Type*)Value; \ 00066 XN_DELETE(p); \ 00067 } \ 00068 } \ 00069 static XnValue GetAsValue(Type const& orig) \ 00070 { \ 00071 if (sizeof(Type) > sizeof(XnValue)) \ 00072 { \ 00073 return (XnValue)&orig; \ 00074 } \ 00075 else \ 00076 { \ 00077 XnValue result = 0; \ 00078 xnOSMemCopy(&result, &orig, sizeof(Type)); \ 00079 return result; \ 00080 } \ 00081 } \ 00082 static Type const& GetFromValue(const XnValue& Value) \ 00083 { \ 00084 if (sizeof(Type) > sizeof(XnValue)) \ 00085 { \ 00086 Type const* p = (Type const*)Value; \ 00087 return *p; \ 00088 } \ 00089 else \ 00090 { \ 00091 Type const* p = (Type const*)&Value; \ 00092 return *p; \ 00093 } \ 00094 } \ 00095 static Type& GetFromValue(XnValue& Value) \ 00096 { \ 00097 if (sizeof(Type) > sizeof(XnValue)) \ 00098 { \ 00099 Type* p = (Type*)Value; \ 00100 return *p; \ 00101 } \ 00102 else \ 00103 { \ 00104 Type* p = (Type*)&Value; \ 00105 return *p; \ 00106 } \ 00107 } \ 00108 XN_PRAGMA_STOP_DISABLED_WARNING_SECTION \ 00109 }; 00110 00114 #define XN_DECLARE_DEFAULT_VALUE_TRANSLATOR(Type, ClassName) \ 00115 XN_DECLARE_DEFAULT_VALUE_TRANSLATOR_DECL(, Type, ClassName) 00116 00117 #define XN_DEFAULT_TRANSLATOR_NAME(ClassName) ClassName ## Translator 00118 00119 #endif // _XN_DATA_TYPES_H_