OpenNI 1.5.7
XnDataTypes.h
Go to the documentation of this file.
1/*****************************************************************************
2* *
3* OpenNI 1.x Alpha *
4* Copyright (C) 2012 PrimeSense Ltd. *
5* *
6* This file is part of OpenNI. *
7* *
8* Licensed under the Apache License, Version 2.0 (the "License"); *
9* you may not use this file except in compliance with the License. *
10* You may obtain a copy of the License at *
11* *
12* http://www.apache.org/licenses/LICENSE-2.0 *
13* *
14* Unless required by applicable law or agreed to in writing, software *
15* distributed under the License is distributed on an "AS IS" BASIS, *
16* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
17* See the License for the specific language governing permissions and *
18* limitations under the License. *
19* *
20*****************************************************************************/
21#ifndef _XN_DATA_TYPES_H_
22#define _XN_DATA_TYPES_H_
23
24//---------------------------------------------------------------------------
25// Includes
26//---------------------------------------------------------------------------
27#include "XnOS.h"
28
29//---------------------------------------------------------------------------
30// Types
31//---------------------------------------------------------------------------
35typedef void* XnValue;
36
41#define XN_DECLARE_DEFAULT_VALUE_TRANSLATOR_DECL(decl, Type, ClassName) \
42 class decl ClassName \
43 { \
44 public: \
45 XN_PRAGMA_START_DISABLED_WARNING_SECTION(XN_CONDITION_IS_CONST_WARNING_ID) \
46 \
47 static XnValue CreateValueCopy(Type const& orig) \
48 { \
49 if (sizeof(Type) > sizeof(XnValue)) \
50 { \
51 Type* pNew = XN_NEW(Type, orig); \
52 return (XnValue)pNew; \
53 } \
54 else \
55 { \
56 XnValue result = 0; \
57 xnOSMemCopy(&result, &orig, sizeof(Type)); \
58 return result; \
59 } \
60 } \
61 static void FreeValue(XnValue& Value) \
62 { \
63 if (sizeof(Type) > sizeof(XnValue)) \
64 { \
65 Type* p = (Type*)Value; \
66 XN_DELETE(p); \
67 } \
68 } \
69 static XnValue GetAsValue(Type const& orig) \
70 { \
71 if (sizeof(Type) > sizeof(XnValue)) \
72 { \
73 return (XnValue)&orig; \
74 } \
75 else \
76 { \
77 XnValue result = 0; \
78 xnOSMemCopy(&result, &orig, sizeof(Type)); \
79 return result; \
80 } \
81 } \
82 static Type const& GetFromValue(const XnValue& Value) \
83 { \
84 if (sizeof(Type) > sizeof(XnValue)) \
85 { \
86 Type const* p = (Type const*)Value; \
87 return *p; \
88 } \
89 else \
90 { \
91 Type const* p = (Type const*)&Value; \
92 return *p; \
93 } \
94 } \
95 static Type& GetFromValue(XnValue& Value) \
96 { \
97 if (sizeof(Type) > sizeof(XnValue)) \
98 { \
99 Type* p = (Type*)Value; \
100 return *p; \
101 } \
102 else \
103 { \
104 Type* p = (Type*)&Value; \
105 return *p; \
106 } \
107 } \
108 XN_PRAGMA_STOP_DISABLED_WARNING_SECTION \
109 };
110
114#define XN_DECLARE_DEFAULT_VALUE_TRANSLATOR(Type, ClassName) \
115 XN_DECLARE_DEFAULT_VALUE_TRANSLATOR_DECL(, Type, ClassName)
116
117#define XN_DEFAULT_TRANSLATOR_NAME(ClassName) ClassName ## Translator
118
119#endif // _XN_DATA_TYPES_H_
void * XnValue
Definition XnDataTypes.h:35