Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 122 lines (111 sloc) 4.764 kb
43c256b Ziv Hendel first version
OpenNI authored
1 /*****************************************************************************
2 * *
3 * OpenNI 1.0 Alpha *
4 * Copyright (C) 2010 PrimeSense Ltd. *
5 * *
6 * This file is part of OpenNI. *
7 * *
8 * OpenNI is free software: you can redistribute it and/or modify *
9 * it under the terms of the GNU Lesser General Public License as published *
10 * by the Free Software Foundation, either version 3 of the License, or *
11 * (at your option) any later version. *
12 * *
13 * OpenNI is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16 * GNU Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public License *
19 * along with OpenNI. If not, see <http://www.gnu.org/licenses/>. *
20 * *
21 *****************************************************************************/
22
23
24
25
26 #ifndef _XN_DATA_TYPES_H_
27 #define _XN_DATA_TYPES_H_
28
29 //---------------------------------------------------------------------------
30 // Includes
31 //---------------------------------------------------------------------------
32 #include "XnOS.h"
33
34 //---------------------------------------------------------------------------
35 // Types
36 //---------------------------------------------------------------------------
37 /**
38 * The value type for all general data structures
39 */
40 typedef void* XnValue;
41
42 /**
43 * Declares a translator from @a Type to XnValue, with a name @a ClassName. The class is declared
44 * with the @a decl declspec.
45 */
46 #define XN_DECLARE_DEFAULT_VALUE_TRANSLATOR_DECL(decl, Type, ClassName) \
47 class decl ClassName \
48 { \
49 public: \
50 static XnValue CreateValueCopy(Type const& orig) \
51 { \
52 if (sizeof(Type) > sizeof(XnValue)) \
53 { \
54 Type* pNew = XN_NEW(Type, orig); \
55 return (XnValue)pNew; \
56 } \
57 else \
58 { \
59 XnValue result = 0; \
60 xnOSMemCopy(&result, &orig, sizeof(Type)); \
61 return result; \
62 } \
63 } \
64 static void FreeValue(XnValue& Value) \
65 { \
66 if (sizeof(Type) > sizeof(XnValue)) \
67 { \
68 Type* p = (Type*)Value; \
69 XN_DELETE(p); \
70 } \
71 } \
72 static XnValue GetAsValue(Type const& orig) \
73 { \
74 if (sizeof(Type) > sizeof(XnValue)) \
75 { \
76 return (XnValue)&orig; \
77 } \
78 else \
79 { \
80 XnValue result = 0; \
81 xnOSMemCopy(&result, &orig, sizeof(Type)); \
82 return result; \
83 } \
84 } \
85 static Type const& GetFromValue(const XnValue& Value) \
86 { \
87 if (sizeof(Type) > sizeof(XnValue)) \
88 { \
89 Type const* p = (Type const*)Value; \
90 return *p; \
91 } \
92 else \
93 { \
94 Type const* p = (Type const*)&Value; \
95 return *p; \
96 } \
97 } \
98 static Type& GetFromValue(XnValue& Value) \
99 { \
100 if (sizeof(Type) > sizeof(XnValue)) \
101 { \
102 Type* p = (Type*)Value; \
103 return *p; \
104 } \
105 else \
106 { \
107 Type* p = (Type*)&Value; \
108 return *p; \
109 } \
110 } \
111 };
112
113 /**
114 * Declares a translator from @a Type to XnValue, with a name @a ClassName.
115 */
116 #define XN_DECLARE_DEFAULT_VALUE_TRANSLATOR(Type, ClassName) \
117 XN_DECLARE_DEFAULT_VALUE_TRANSLATOR_DECL(, Type, ClassName)
118
119 #define XN_DEFAULT_TRANSLATOR_NAME(ClassName) ClassName ## Translator
120
121 #endif // _XN_DATA_TYPES_H_
Something went wrong with that request. Please try again.