OpenNI 1.5.7
XnMacros.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_MACROS_H_
22 #define _XN_MACROS_H_
23 
24 //---------------------------------------------------------------------------
25 // Includes
26 //---------------------------------------------------------------------------
27 #include "XnStatusCodes.h"
28 
29 //---------------------------------------------------------------------------
30 // Macros
31 //---------------------------------------------------------------------------
32 
34 #define XN_SETBITMASK(x) (1 << x-1)
35 
37 #define XN_RET_IF_NULL(x, y) \
38  if (x == NULL) \
39  { \
40  return (y); \
41  }
42 
44 #define XN_IS_STATUS_OK_RET(x, y) \
45  if (x != XN_STATUS_OK) \
46  { \
47  return (y); \
48  }
49 
51 #define XN_IS_STATUS_OK_GOCLEANUP_RET(x, y) \
52  if (x != XN_STATUS_OK) \
53  { \
54  x = y; \
55  goto ErrorCleanUp; \
56  }
57 
59 #define XN_IS_STATUS_OK(x) \
60  XN_IS_STATUS_OK_RET(x, x)
61 
62 #define XN_IS_STATUS_OK_ASSERT(x) \
63  if (x != XN_STATUS_OK) \
64  { \
65  XN_ASSERT(FALSE); \
66  return (x); \
67  }
68 
69 
71 #define XN_IS_STATUS_OK_GOCLEANUP(x) \
72  if (x != XN_STATUS_OK) \
73  { \
74  goto ErrorCleanUp; \
75  }
76 
78 #define XN_IS_BOOL_OK_RET(x, y) \
79  if (x != TRUE) \
80  { \
81  return (y); \
82  }
83 
85 #define XN_IS_BOOL_OK_GOCLEANUP_RET(x, y) \
86  if (x != TRUE) \
87  { \
88  goto ErrorCleanUp; \
89  }
90 
92 #define XN_GOCLEANUP_RET(x, y) \
93  x = y; \
94  goto ErrorCleanUp;
95 
97 #define XN_VALIDATE_PTR(x,y) \
98  if (x == NULL) \
99  { \
100  return (y); \
101  }
102 
104 #define XN_CHECK_INPUT_OVERFLOW(x, y) \
105  if (x > y) \
106  { \
107  return (XN_STATUS_INPUT_BUFFER_OVERFLOW); \
108  }
109 
111 #define XN_CHECK_OUTPUT_OVERFLOW(x, y) \
112  if (x > y) \
113  { \
114  return (XN_STATUS_OUTPUT_BUFFER_OVERFLOW); \
115  }
116 
118 #define XN_DISABLE_COPY_AND_ASSIGN(TypeName) \
119  TypeName(const TypeName&); \
120  void operator=(const TypeName&);
121 
124 #define XN_REFERENCE_VARIABLE(x) \
125  ((void)x)
126 
127 #endif //_XN_MACROS_H_