OpenNI 1.5.4
XnCppWrapper.h
Go to the documentation of this file.
1 /****************************************************************************
2 * *
3 * OpenNI 1.x Alpha *
4 * Copyright (C) 2011 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 #ifndef __XN_CPP_WRAPPER_H__
23 #define __XN_CPP_WRAPPER_H__
24 
25 //---------------------------------------------------------------------------
26 // Includes
27 //---------------------------------------------------------------------------
28 #include <XnOpenNI.h>
29 #include <XnCodecIDs.h>
30 
31 //---------------------------------------------------------------------------
32 // Types
33 //---------------------------------------------------------------------------
34 namespace xn
35 {
36  //---------------------------------------------------------------------------
37  // Forward Declarations
38  //---------------------------------------------------------------------------
39  class ProductionNode;
40  class EnumerationErrors;
41  class NodeInfo;
42  class NodeInfoList;
43  class Context;
44  class Query;
45  class Generator;
46 
72  //---------------------------------------------------------------------------
73  // Types
74  //---------------------------------------------------------------------------
75 
101  typedef void (XN_CALLBACK_TYPE* StateChangedHandler)(ProductionNode& node, void* pCookie);
102 
103  //---------------------------------------------------------------------------
104  // Internal stuff
105  //---------------------------------------------------------------------------
106  typedef XnStatus (*_XnRegisterStateChangeFuncPtr)(XnNodeHandle hNode, XnStateChangedHandler handler, void* pCookie, XnCallbackHandle* phCallback);
107  typedef void (*_XnUnregisterStateChangeFuncPtr)(XnNodeHandle hNode, XnCallbackHandle hCallback);
108 
109  static XnStatus _RegisterToStateChange(_XnRegisterStateChangeFuncPtr xnFunc, XnNodeHandle hNode, StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback);
110  static void _UnregisterFromStateChange(_XnUnregisterStateChangeFuncPtr xnFunc, XnNodeHandle hNode, XnCallbackHandle hCallback);
111 
112  //---------------------------------------------------------------------------
113  // Some Utilities
114  //---------------------------------------------------------------------------
119  class Version
120  {
121  public:
122  Version(const XnVersion& version) : m_version(version) {}
123  Version(XnUInt8 nMajor, XnUInt8 nMinor, XnUInt16 nMaintenance, XnUInt32 nBuild)
124  {
125  m_version.nMajor = nMajor;
126  m_version.nMinor = nMinor;
127  m_version.nMaintenance = nMaintenance;
128  m_version.nBuild = nBuild;
129  }
130 
131  bool operator==(const Version& other) const
132  {
133  return (xnVersionCompare(&m_version, &other.m_version) == 0);
134  }
135  bool operator!=(const Version& other) const
136  {
137  return (xnVersionCompare(&m_version, &other.m_version) != 0);
138  }
139  bool operator<(const Version& other) const
140  {
141  return (xnVersionCompare(&m_version, &other.m_version) < 0);
142  }
143  bool operator<=(const Version& other) const
144  {
145  return (xnVersionCompare(&m_version, &other.m_version) <= 0);
146  }
147  bool operator>(const Version& other) const
148  {
149  return (xnVersionCompare(&m_version, &other.m_version) > 0);
150  }
151  bool operator>=(const Version& other) const
152  {
153  return (xnVersionCompare(&m_version, &other.m_version) >= 0);
154  }
155 
156  static Version Current()
157  {
158  XnVersion version;
159  xnGetVersion(&version);
160  return Version(version);
161  }
162 
163  XnUInt8 Major() const { return m_version.nMajor; }
164  XnUInt8 Minor() const { return m_version.nMinor; }
165  XnUInt16 Maintenance() const { return m_version.nMaintenance; }
166  XnUInt32 Build() const { return m_version.nBuild; }
167 
168  XnUInt8& Major() { return m_version.nMajor; }
169  XnUInt8& Minor() { return m_version.nMinor; }
170  XnUInt16& Maintenance() { return m_version.nMaintenance; }
171  XnUInt32& Build() { return m_version.nBuild; }
172 
173  const XnVersion* GetUnderlying() const { return &m_version; }
174  XnVersion* GetUnderlying() { return &m_version; }
175 
176  private:
177  XnVersion m_version;
178  };
179 
180  //---------------------------------------------------------------------------
181  // Meta Data
182  //---------------------------------------------------------------------------
183 
199  {
200  public:
206  inline OutputMetaData(const XnUInt8** ppData) : m_ppData(ppData), m_nAllocatedSize(0), m_pAllocatedData(NULL)
207  {
208  xnOSMemSet(&m_output, 0, sizeof(XnOutputMetaData));
209  }
210 
214  virtual ~OutputMetaData() { Free(); }
215 
219  inline XnUInt64 Timestamp() const { return m_output.nTimestamp; }
220 
224  inline XnUInt64& Timestamp() { return m_output.nTimestamp; }
225 
230  inline XnUInt32 FrameID() const { return m_output.nFrameID; }
231 
236  inline XnUInt32& FrameID() { return m_output.nFrameID; }
237 
246  inline XnUInt32 DataSize() const { return m_output.nDataSize; }
247 
256  inline XnUInt32& DataSize() { return m_output.nDataSize; }
257 
262  inline XnBool IsDataNew() const { return m_output.bIsNew; }
263 
268  inline XnBool& IsDataNew() { return m_output.bIsNew; }
269 
273  inline const XnOutputMetaData* GetUnderlying() const { return &m_output; }
277  inline XnOutputMetaData* GetUnderlying() { return &m_output; }
278 
283  inline const XnUInt8* Data() const { return *m_ppData; }
288  inline const XnUInt8*& Data() { return *m_ppData; }
289 
293  inline XnUInt8* WritableData()
294  {
296  return m_pAllocatedData;
297  }
298 
307  XnStatus AllocateData(XnUInt32 nBytes)
308  {
309  if (nBytes > m_nAllocatedSize)
310  {
311  // reallocate
312  XnUInt8* pData = (XnUInt8*)xnOSMallocAligned(nBytes, XN_DEFAULT_MEM_ALIGN);
313  XN_VALIDATE_ALLOC_PTR(pData);
314 
315  // allocation succeeded, replace
316  Free();
317  m_pAllocatedData = pData;
318  m_nAllocatedSize = nBytes;
319  }
320 
321  DataSize() = nBytes;
322  *m_ppData = m_pAllocatedData;
323 
324  return XN_STATUS_OK;
325  }
326 
330  void Free()
331  {
332  if (m_nAllocatedSize != 0)
333  {
335  m_pAllocatedData = NULL;
336  m_nAllocatedSize = 0;
337  }
338  }
339 
345  {
346  XnStatus nRetVal = XN_STATUS_OK;
347 
348  // check data isn't already writable
349  if (Data() != m_pAllocatedData || DataSize() > m_nAllocatedSize)
350  {
351  const XnUInt8* pOrigData = *m_ppData;
352 
353  nRetVal = AllocateData(DataSize());
354  XN_IS_STATUS_OK(nRetVal);
355 
356  if (pOrigData != NULL)
357  {
358  xnOSMemCopy(m_pAllocatedData, pOrigData, DataSize());
359  }
360  else
361  {
363  }
364  }
365 
366  return (XN_STATUS_OK);
367  }
368 
369  protected:
371 
372  private:
373  XnOutputMetaData m_output;
374 
375  const XnUInt8** m_ppData;
376  XnUInt32 m_nAllocatedSize;
377  };
378 
392  {
393  public:
400  inline MapMetaData(XnPixelFormat format, const XnUInt8** ppData) : OutputMetaData(ppData)
401  {
402  xnOSMemSet(&m_map, 0, sizeof(XnMapMetaData));
404  m_map.PixelFormat = format;
405  }
406 
412  inline XnUInt32 XRes() const { return m_map.Res.X; }
418  inline XnUInt32& XRes() { return m_map.Res.X; }
419 
425  inline XnUInt32 YRes() const { return m_map.Res.Y; }
431  inline XnUInt32& YRes() { return m_map.Res.Y; }
432 
441  inline XnUInt32 XOffset() const { return m_map.Offset.X; }
450  inline XnUInt32& XOffset() { return m_map.Offset.X; }
451 
460  inline XnUInt32 YOffset() const { return m_map.Offset.Y; }
469  inline XnUInt32& YOffset() { return m_map.Offset.Y; }
470 
475  inline XnUInt32 FullXRes() const { return m_map.FullRes.X; }
476 
477 
482  inline XnUInt32& FullXRes() { return m_map.FullRes.X; }
483 
487  inline XnUInt32 FullYRes() const { return m_map.FullRes.Y; }
491  inline XnUInt32& FullYRes() { return m_map.FullRes.Y; }
492 
496  inline XnUInt32 FPS() const { return m_map.nFPS; }
500  inline XnUInt32& FPS() { return m_map.nFPS; }
501 
505  inline XnPixelFormat PixelFormat() const { return m_map.PixelFormat; }
506 
510  inline const XnMapMetaData* GetUnderlying() const { return &m_map; }
514  inline XnMapMetaData* GetUnderlying() { return &m_map; }
515 
519  inline XnUInt32 BytesPerPixel() const
520  {
521  switch (PixelFormat())
522  {
524  return sizeof(XnRGB24Pixel);
526  return sizeof(XnYUV422DoublePixel)/2;
528  return sizeof(XnGrayscale8Pixel);
530  return sizeof(XnGrayscale16Pixel);
532  return 2;
533  default:
534  XN_ASSERT(FALSE);
535  return 0;
536  }
537  }
538 
545  XnStatus AllocateData(XnUInt32 nXRes, XnUInt32 nYRes)
546  {
547  XnStatus nRetVal = XN_STATUS_OK;
548 
549  XnUInt32 nSize = nXRes * nYRes * BytesPerPixel();
550  nRetVal = OutputMetaData::AllocateData(nSize);
551  XN_IS_STATUS_OK(nRetVal);
552 
553  FullXRes() = XRes() = nXRes;
554  FullYRes() = YRes() = nYRes;
555  XOffset() = YOffset() = 0;
556 
557  return (XN_STATUS_OK);
558  }
559 
568  XnStatus ReAdjust(XnUInt32 nXRes, XnUInt32 nYRes, const XnUInt8* pExternalBuffer)
569  {
570  XnStatus nRetVal = XN_STATUS_OK;
571 
572  if (pExternalBuffer == NULL)
573  {
574  nRetVal = AllocateData(nXRes, nYRes);
575  XN_IS_STATUS_OK(nRetVal);
576  }
577  else
578  {
579  FullXRes() = XRes() = nXRes;
580  FullYRes() = YRes() = nYRes;
581  XOffset() = YOffset() = 0;
582  Data() = pExternalBuffer;
583  DataSize() = nXRes * nYRes * BytesPerPixel();
584  }
585 
586  return (XN_STATUS_OK);
587  }
588 
589  protected:
591 
592  private:
593  // block copy ctor and assignment operator
594  MapMetaData& operator=(const MapMetaData&);
595  inline MapMetaData(const MapMetaData& other);
596 
597  // Members
598  XnMapMetaData m_map;
599  };
600 
608  template<class _pixelType>
609  class Map
610  {
611  public:
612  inline Map(_pixelType*& pData, XnUInt32& nXRes, XnUInt32 &nYRes) :
613  m_pData(pData), m_nXRes(nXRes), m_nYRes(nYRes)
614  {}
615 
623  inline XnUInt32 XRes() const { return m_nXRes; }
631  inline XnUInt32 YRes() const { return m_nYRes; }
632 
644  inline const _pixelType& operator[](XnUInt32 nIndex) const
645  {
646  XN_ASSERT(nIndex < (m_nXRes * m_nYRes));
647  return m_pData[nIndex];
648  }
660  inline _pixelType& operator[](XnUInt32 nIndex)
661  {
662  XN_ASSERT(nIndex < (m_nXRes *m_nYRes));
663  return m_pData[nIndex];
664  }
665 
674  inline const _pixelType& operator()(XnUInt32 x, XnUInt32 y) const
675  {
676  XN_ASSERT(x < m_nXRes && y < m_nYRes);
677  return m_pData[y*m_nXRes + x];
678  }
687  inline _pixelType& operator()(XnUInt32 x, XnUInt32 y)
688  {
689  XN_ASSERT(x < m_nXRes && y < m_nYRes);
690  return m_pData[y*m_nXRes + x];
691  }
692 
693  private:
694  /* block copy ctor and assignment operator */
695  Map(const Map& other);
696  Map& operator=(const Map&);
697 
698  _pixelType*& m_pData;
699  XnUInt32& m_nXRes;
700  XnUInt32& m_nYRes;
701  };
702 
754  class DepthMetaData : public MapMetaData
755  {
756  public:
760  inline DepthMetaData() :
761  MapMetaData(XN_PIXEL_FORMAT_GRAYSCALE_16_BIT, (const XnUInt8**)&m_depth.pData),
762  m_depthMap(const_cast<XnDepthPixel*&>(m_depth.pData), MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y),
763  m_writableDepthMap((XnDepthPixel*&)m_pAllocatedData, MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y)
764  {
765  xnOSMemSet(&m_depth, 0, sizeof(XnDepthMetaData));
766  m_depth.pMap = MapMetaData::GetUnderlying();
767  }
768 
776  inline void InitFrom(const DepthMetaData& other)
777  {
778  xnCopyDepthMetaData(&m_depth, &other.m_depth);
779  }
780 
791  inline XnStatus InitFrom(const DepthMetaData& other, XnUInt32 nXRes, XnUInt32 nYRes, const XnDepthPixel* pExternalBuffer)
792  {
793  InitFrom(other);
794  return ReAdjust(nXRes, nYRes, pExternalBuffer);
795  }
796 
804  {
805  // copy props
806  InitFrom(other);
807  // and make a copy of the data (this will allocate and copy data)
808  return MakeDataWritable();
809  }
810 
814  XnStatus ReAdjust(XnUInt32 nXRes, XnUInt32 nYRes, const XnDepthPixel* pExternalBuffer = NULL)
815  {
816  return MapMetaData::ReAdjust(nXRes, nYRes, (const XnUInt8*)pExternalBuffer);
817  }
818 
824  inline XnDepthPixel ZRes() const { return m_depth.nZRes; }
830  inline XnDepthPixel& ZRes() { return m_depth.nZRes; }
831 
844  inline const XnDepthPixel* Data() const { return (const XnDepthPixel*)MapMetaData::Data(); }
857  inline const XnDepthPixel*& Data() { return (const XnDepthPixel*&)MapMetaData::Data(); }
858 
859 
864 
868  inline const xn::DepthMap& DepthMap() const { return m_depthMap; }
873  {
875  return m_writableDepthMap;
876  }
877 
883  inline const XnDepthPixel& operator[](XnUInt32 nIndex) const
884  {
885  XN_ASSERT(nIndex < (XRes()*YRes()));
886  return Data()[nIndex];
887  }
888 
895  inline const XnDepthPixel& operator()(XnUInt32 x, XnUInt32 y) const
896  {
897  XN_ASSERT(x < XRes() && y < YRes());
898  return Data()[y*XRes() + x];
899  }
900 
904  inline const XnDepthMetaData* GetUnderlying() const { return &m_depth; }
908  inline XnDepthMetaData* GetUnderlying() { return &m_depth; }
909 
910  private:
911  // block copy ctor and assignment operator (because we can't return errors in those)
912  DepthMetaData(const DepthMetaData& other);
913  DepthMetaData& operator=(const DepthMetaData&);
914 
915  XnDepthMetaData m_depth;
916  const xn::DepthMap m_depthMap;
917  xn::DepthMap m_writableDepthMap;
918  };
919 
946  class ImageMetaData : public MapMetaData
947  {
948  public:
949  inline ImageMetaData() :
950  MapMetaData(XN_PIXEL_FORMAT_RGB24, &m_image.pData),
951  m_imageMap(const_cast<XnUInt8*&>(m_image.pData), MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y),
952  m_writableImageMap((XnUInt8*&)m_pAllocatedData, MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y),
953  m_rgb24Map((XnRGB24Pixel*&)m_image.pData, MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y),
954  m_writableRgb24Map((XnRGB24Pixel*&)m_pAllocatedData, MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y),
955  m_gray16Map((XnGrayscale16Pixel*&)m_image.pData, MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y),
956  m_writableGray16Map((XnGrayscale16Pixel*&)m_pAllocatedData, MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y),
957  m_gray8Map((XnGrayscale8Pixel*&)m_image.pData, MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y),
958  m_writableGray8Map((XnGrayscale8Pixel*&)m_pAllocatedData, MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y)
959  {
960  xnOSMemSet(&m_image, 0, sizeof(XnImageMetaData));
961  m_image.pMap = MapMetaData::GetUnderlying();
962  }
963 
971  inline void InitFrom(const ImageMetaData& other)
972  {
973  xnCopyImageMetaData(&m_image, &other.m_image);
974  }
975 
987  inline XnStatus InitFrom(const ImageMetaData& other, XnUInt32 nXRes, XnUInt32 nYRes, XnPixelFormat format, const XnUInt8* pExternalBuffer)
988  {
989  InitFrom(other);
990  XnStatus nRetVal = ReAdjust(nXRes, nYRes, format, pExternalBuffer);
991  XN_IS_STATUS_OK(nRetVal);
992  PixelFormat() = format;
993  return XN_STATUS_OK;
994  }
995 
1003  inline XnStatus AllocateData(XnUInt32 nXRes, XnUInt32 nYRes, XnPixelFormat format)
1004  {
1005  XnPixelFormat origFormat = PixelFormat();
1006  PixelFormat() = format;
1007  XnStatus nRetVal = MapMetaData::AllocateData(nXRes, nYRes);
1008  if (nRetVal != XN_STATUS_OK)
1009  {
1010  PixelFormat() = origFormat;
1011  return (nRetVal);
1012  }
1013 
1014  return XN_STATUS_OK;
1015  }
1016 
1022  inline XnStatus CopyFrom(const ImageMetaData& other)
1023  {
1024  // copy props
1025  xnCopyImageMetaData(&m_image, &other.m_image);
1026  // and make a copy of the data (this will allocate and copy data)
1027  return MakeDataWritable();
1028  }
1029 
1039  XnStatus ReAdjust(XnUInt32 nXRes, XnUInt32 nYRes, XnPixelFormat format, const XnUInt8* pExternalBuffer = NULL)
1040  {
1041  XnPixelFormat origFormat = PixelFormat();
1042  PixelFormat() = format;
1043  XnStatus nRetVal = MapMetaData::ReAdjust(nXRes, nYRes, pExternalBuffer);
1044  if (nRetVal != XN_STATUS_OK)
1045  {
1046  PixelFormat() = origFormat;
1047  return (nRetVal);
1048  }
1049 
1050  return XN_STATUS_OK;
1051  }
1052 
1075 
1079  inline XnUInt8* WritableData() { return MapMetaData::WritableData(); }
1080 
1085  inline const XnRGB24Pixel* RGB24Data() const { return (const XnRGB24Pixel*)MapMetaData::Data(); }
1090  inline const XnRGB24Pixel*& RGB24Data() { return (const XnRGB24Pixel*&)MapMetaData::Data(); }
1095 
1101  inline const XnYUV422DoublePixel* YUV422Data() const { return (const XnYUV422DoublePixel*)MapMetaData::Data(); }
1112 
1117  inline const XnGrayscale8Pixel* Grayscale8Data() const { return (const XnGrayscale8Pixel*)MapMetaData::Data(); }
1127 
1132  inline const XnGrayscale16Pixel* Grayscale16Data() const { return (const XnGrayscale16Pixel*)MapMetaData::Data(); }
1142 
1146  inline const xn::ImageMap& ImageMap() const { return m_imageMap; }
1150  inline xn::ImageMap& WritableImageMap() { MakeDataWritable(); return m_writableImageMap; }
1151 
1157  inline const xn::RGB24Map& RGB24Map() const { return m_rgb24Map; }
1161  inline xn::RGB24Map& WritableRGB24Map() { MakeDataWritable(); return m_writableRgb24Map; }
1162 
1166  inline const xn::Grayscale8Map& Grayscale8Map() const { return m_gray8Map; }
1170  inline xn::Grayscale8Map& WritableGrayscale8Map() { MakeDataWritable(); return m_writableGray8Map; }
1171 
1176  inline const xn::Grayscale16Map& Grayscale16Map() const { return m_gray16Map; }
1180  inline xn::Grayscale16Map& WritableGrayscale16Map() { MakeDataWritable(); return m_writableGray16Map; }
1181 
1185  inline const XnImageMetaData* GetUnderlying() const { return &m_image; }
1189  inline XnImageMetaData* GetUnderlying() { return &m_image; }
1190 
1191  private:
1192  // block copy ctor and assignment operator
1193  ImageMetaData(const ImageMetaData& other);
1194  ImageMetaData& operator=(const ImageMetaData&);
1195 
1196  XnImageMetaData m_image;
1197  const xn::ImageMap m_imageMap;
1198  xn::ImageMap m_writableImageMap;
1199  const xn::RGB24Map m_rgb24Map;
1200  xn::RGB24Map m_writableRgb24Map;
1201  const xn::Grayscale16Map m_gray16Map;
1202  xn::Grayscale16Map m_writableGray16Map;
1203  const xn::Grayscale8Map m_gray8Map;
1204  xn::Grayscale8Map m_writableGray8Map;
1205  };
1206 
1216  class IRMetaData : public MapMetaData
1217  {
1218  public:
1219  inline IRMetaData() :
1220  MapMetaData(XN_PIXEL_FORMAT_GRAYSCALE_16_BIT, (const XnUInt8**)&m_ir.pData),
1221  m_irMap(const_cast<XnIRPixel*&>(m_ir.pData), MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y),
1222  m_writableIRMap((XnIRPixel*&)m_pAllocatedData, MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y)
1223  {
1224  xnOSMemSet(&m_ir, 0, sizeof(XnIRMetaData));
1226  }
1227 
1235  inline void InitFrom(const IRMetaData& other)
1236  {
1237  xnCopyIRMetaData(&m_ir, &other.m_ir);
1238  }
1239 
1249  inline XnStatus InitFrom(const IRMetaData& other, XnUInt32 nXRes, XnUInt32 nYRes, const XnIRPixel* pExternalBuffer)
1250  {
1251  InitFrom(other);
1252  return ReAdjust(nXRes, nYRes, pExternalBuffer);
1253  }
1254 
1261  {
1262  // copy props
1263  xnCopyIRMetaData(&m_ir, &other.m_ir);
1264  // and make a copy of the data (this will allocate and copy data)
1265  return MakeDataWritable();
1266  }
1267 
1271  XnStatus ReAdjust(XnUInt32 nXRes, XnUInt32 nYRes, const XnIRPixel* pExternalBuffer = NULL)
1272  {
1273  return MapMetaData::ReAdjust(nXRes, nYRes, (const XnUInt8*)pExternalBuffer);
1274  }
1275 
1288  inline const XnIRPixel* Data() const { return (const XnIRPixel*)MapMetaData::Data(); }
1301  inline const XnIRPixel*& Data() { return (const XnIRPixel*&)MapMetaData::Data(); }
1306 
1312  inline const XnIRPixel& operator[](XnUInt32 nIndex) const
1313  {
1314  XN_ASSERT(nIndex < (XRes()*YRes()));
1315  return Data()[nIndex];
1316  }
1317 
1324  inline const XnIRPixel& operator()(XnUInt32 x, XnUInt32 y) const
1325  {
1326  XN_ASSERT(x < XRes() && y < YRes());
1327  return Data()[y*XRes() + x];
1328  }
1329 
1338  inline const xn::IRMap& IRMap() const { return m_irMap; }
1347  inline xn::IRMap& WritableIRMap() { MakeDataWritable(); return m_writableIRMap; }
1348 
1352  inline const XnIRMetaData* GetUnderlying() const { return &m_ir; }
1356  inline XnIRMetaData* GetUnderlying() { return &m_ir; }
1357 
1358  private:
1359  // block copy ctor and assignment operator
1360  IRMetaData(const IRMetaData& other);
1361  IRMetaData& operator=(const IRMetaData&);
1362 
1363  XnIRMetaData m_ir;
1364  const xn::IRMap m_irMap;
1365  xn::IRMap m_writableIRMap;
1366  };
1367 
1375  {
1376  public:
1377  XN_PRAGMA_START_DISABLED_WARNING_SECTION(XN_UNALIGNED_ADDRESS_WARNING_ID);
1378  inline AudioMetaData() : OutputMetaData(&m_audio.pData)
1379  {
1380  xnOSMemSet(&m_audio, 0, sizeof(XnAudioMetaData));
1382  }
1383 
1385 
1393  inline void InitFrom(const AudioMetaData& other)
1394  {
1395  xnCopyAudioMetaData(&m_audio, &other.m_audio);
1396  }
1397 
1401  inline XnUInt8 NumberOfChannels() const { return m_audio.Wave.nChannels; }
1405  inline XnUInt8& NumberOfChannels() { return m_audio.Wave.nChannels; }
1406 
1410  inline XnUInt32 SampleRate() const { return m_audio.Wave.nSampleRate; }
1414  inline XnUInt32& SampleRate() { return m_audio.Wave.nSampleRate; }
1415 
1419  inline XnUInt16 BitsPerSample() const { return m_audio.Wave.nBitsPerSample; }
1423  inline XnUInt16& BitsPerSample() { return m_audio.Wave.nBitsPerSample; }
1424 
1428  inline const XnAudioMetaData* GetUnderlying() const { return &m_audio; }
1432  inline XnAudioMetaData* GetUnderlying() { return &m_audio; }
1433 
1434  private:
1435  // block copy ctor and assignment operator
1436  AudioMetaData(const AudioMetaData& other);
1437  AudioMetaData& operator=(const AudioMetaData&);
1438 
1439  XnAudioMetaData m_audio;
1440  };
1441 
1451  {
1452  public:
1453  inline SceneMetaData() :
1454  MapMetaData(XN_PIXEL_FORMAT_GRAYSCALE_16_BIT, (const XnUInt8**)&m_scene.pData),
1455  m_labelMap(const_cast<XnLabel*&>(m_scene.pData), MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y),
1456  m_writableLabelMap((XnLabel*&)m_pAllocatedData, MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y)
1457  {
1458  xnOSMemSet(&m_scene, 0, sizeof(XnSceneMetaData));
1459  m_scene.pMap = MapMetaData::GetUnderlying();
1460  }
1461 
1469  inline void InitFrom(const SceneMetaData& other)
1470  {
1471  xnCopySceneMetaData(&m_scene, &other.m_scene);
1472  }
1473 
1483  inline XnStatus InitFrom(const SceneMetaData& other, XnUInt32 nXRes, XnUInt32 nYRes, const XnLabel* pExternalBuffer)
1484  {
1485  InitFrom(other);
1486  return ReAdjust(nXRes, nYRes, pExternalBuffer);
1487  }
1488 
1495  {
1496  // copy props
1497  xnCopySceneMetaData(&m_scene, &other.m_scene);
1498  // and make a copy of the data (this will allocate and copy data)
1499  return MakeDataWritable();
1500  }
1501 
1505  XnStatus ReAdjust(XnUInt32 nXRes, XnUInt32 nYRes, const XnLabel* pExternalBuffer = NULL)
1506  {
1507  return MapMetaData::ReAdjust(nXRes, nYRes, (const XnUInt8*)pExternalBuffer);
1508  }
1509 
1523  inline const XnLabel* Data() const { return (const XnLabel*)MapMetaData::Data(); }
1537  inline const XnLabel*& Data() { return (const XnLabel*&)MapMetaData::Data(); }
1538 
1543 
1547  inline const xn::LabelMap& LabelMap() const { return m_labelMap; }
1551  inline xn::LabelMap& WritableLabelMap() { MakeDataWritable(); return m_writableLabelMap; }
1552 
1563  inline const XnLabel& operator[](XnUInt32 nIndex) const
1564  {
1565  XN_ASSERT(nIndex < (XRes()*YRes()));
1566  return Data()[nIndex];
1567  }
1568 
1580  inline const XnLabel& operator()(XnUInt32 x, XnUInt32 y) const
1581  {
1582  XN_ASSERT(x < XRes() && y < YRes());
1583  return (*this)[y*XRes() + x];
1584  }
1585 
1589  inline const XnSceneMetaData* GetUnderlying() const { return &m_scene; }
1593  inline XnSceneMetaData* GetUnderlying() { return &m_scene; }
1594 
1595  private:
1596  // block copy ctor and assignment operator
1597  SceneMetaData(const SceneMetaData& other);
1598  SceneMetaData& operator=(const SceneMetaData&);
1599 
1600  XnSceneMetaData m_scene;
1601  const xn::LabelMap m_labelMap;
1602  xn::LabelMap m_writableLabelMap;
1603  };
1604 
1605  //---------------------------------------------------------------------------
1606  // NodeWrapper
1607  //---------------------------------------------------------------------------
1608 
1629  {
1630  public:
1631  friend class Context;
1632 
1638  inline NodeWrapper(XnNodeHandle hNode) : m_hNode(NULL), m_hShuttingDownCallback(NULL)
1639  {
1640  SetHandle(hNode);
1641  }
1642 
1643  inline NodeWrapper(const NodeWrapper& other) : m_hNode(NULL), m_hShuttingDownCallback(NULL)
1644  {
1645  SetHandle(other.GetHandle());
1646  }
1647 
1648  inline NodeWrapper& operator=(const NodeWrapper& other)
1649  {
1650  SetHandle(other.GetHandle());
1651  return *this;
1652  }
1653 
1654  inline ~NodeWrapper()
1655  {
1656  SetHandle(NULL);
1657  }
1658 
1659  inline operator XnNodeHandle() const { return GetHandle(); }
1660 
1664  inline XnNodeHandle GetHandle() const { return m_hNode; }
1665 
1671  inline XnBool operator==(const NodeWrapper& other)
1672  {
1673  return (GetHandle() == other.GetHandle());
1674  }
1675 
1681  inline XnBool operator!=(const NodeWrapper& other)
1682  {
1683  return (GetHandle() != other.GetHandle());
1684  }
1685 
1699  inline XnBool IsValid() const { return (GetHandle() != NULL); }
1700 
1701  /*
1702  * @brief Gets the instance name of a node. Unless the application made a specific
1703  * request for a specific name, the name will be of the form: "Depth1", "Image2", etc.
1704  */
1705  const XnChar* GetName() const {return xnGetNodeName(GetHandle()); }
1706 
1712 
1717  inline void Release()
1718  {
1719  SetHandle(NULL);
1720  }
1721 
1722 
1726  inline void SetHandle(XnNodeHandle hNode)
1727  {
1728  if (m_hNode == hNode)
1729  {
1730  // Optimization: do nothing
1731  return;
1732  }
1733 
1734  // check currently held node. If we're holding a node, release it
1735  if (m_hNode != NULL)
1736  {
1737  XnContext* pContext = xnGetRefContextFromNodeHandle(m_hNode);
1738  xnContextUnregisterFromShutdown(pContext, m_hShuttingDownCallback);
1739  xnContextRelease(pContext);
1740  xnProductionNodeRelease(m_hNode);
1741  }
1742 
1743  // check new node handle, if it points to a node, add ref to it
1744  if (hNode != NULL)
1745  {
1746  XnStatus nRetVal = xnProductionNodeAddRef(hNode);
1747  XN_ASSERT(nRetVal == XN_STATUS_OK);
1748  XN_REFERENCE_VARIABLE(nRetVal);
1749 
1750  XnContext* pContext = xnGetRefContextFromNodeHandle(hNode);
1751 
1752  nRetVal = xnContextRegisterForShutdown(pContext, ContextShuttingDownCallback, this, &m_hShuttingDownCallback);
1753  XN_ASSERT(nRetVal == XN_STATUS_OK);
1754 
1755  xnContextRelease(pContext);
1756  }
1757 
1758  m_hNode = hNode;
1759  }
1760 
1761  inline void TakeOwnership(XnNodeHandle hNode)
1762  {
1763  SetHandle(hNode);
1764 
1765  if (hNode != NULL)
1766  {
1767  xnProductionNodeRelease(hNode);
1768  }
1769  }
1770 
1772  inline XnStatus XN_API_DEPRECATED("Please use AddRef() instead.") Ref() { return AddRef(); }
1773  inline void XN_API_DEPRECATED("Please use Release() instead.") Unref() { Release(); }
1776  private:
1777  XnNodeHandle m_hNode;
1778  XnCallbackHandle m_hShuttingDownCallback;
1779 
1780  static void XN_CALLBACK_TYPE ContextShuttingDownCallback(XnContext* /*pContext*/, void* pCookie)
1781  {
1782  NodeWrapper* pThis = (NodeWrapper*)pCookie;
1783  pThis->m_hNode = NULL;
1784  }
1785  };
1786 
1787  //---------------------------------------------------------------------------
1788  // Node Info
1789  //---------------------------------------------------------------------------
1790 
1802  class NodeInfo
1803  {
1804  public:
1810  NodeInfo(XnNodeInfo* pInfo) : m_pNeededNodes(NULL), m_bOwnerOfNode(FALSE)
1811  {
1812  SetUnderlyingObject(pInfo);
1813  }
1814 
1820  NodeInfo(const NodeInfo& other) : m_pNeededNodes(NULL), m_bOwnerOfNode(FALSE)
1821  {
1822  SetUnderlyingObject(other.m_pInfo);
1823  }
1824 
1829  {
1830  SetUnderlyingObject(NULL);
1831  }
1832 
1838  inline NodeInfo& operator=(const NodeInfo& other)
1839  {
1840  SetUnderlyingObject(other.m_pInfo);
1841  return *this;
1842  }
1843 
1847  inline operator XnNodeInfo*()
1848  {
1849  return m_pInfo;
1850  }
1851 
1857  inline XnStatus SetInstanceName(const XnChar* strName)
1858  {
1859  return xnNodeInfoSetInstanceName(m_pInfo, strName);
1860  }
1861 
1876  {
1877  return *xnNodeInfoGetDescription(m_pInfo);
1878  }
1879 
1891  inline const XnChar* GetInstanceName() const
1892  {
1893  return xnNodeInfoGetInstanceName(m_pInfo);
1894  }
1895 
1907  inline const XnChar* GetCreationInfo() const
1908  {
1909  return xnNodeInfoGetCreationInfo(m_pInfo);
1910  }
1911 
1912  /*
1913  * @brief Gets the list of dependant nodes for this node alternative.
1914  * These are any other node alternatives that the node is dependant on.
1915  */
1916  inline NodeInfoList& GetNeededNodes() const;
1917 
1925  inline XnStatus GetInstance(ProductionNode& node) const;
1926 
1931  inline const void* GetAdditionalData() const
1932  {
1933  return xnNodeInfoGetAdditionalData(m_pInfo);
1934  }
1935 
1940  inline XnStatus GetTreeStringRepresentation(XnChar* csResultBuffer, XnUInt32 nBufferSize) const
1941  {
1942  return xnNodeInfoGetTreeStringRepresentation(m_pInfo, csResultBuffer, nBufferSize);
1943  }
1944 
1945  private:
1946  inline void SetUnderlyingObject(XnNodeInfo* pInfo);
1947 
1948  XnNodeInfo* m_pInfo;
1949  mutable NodeInfoList* m_pNeededNodes;
1950  XnBool m_bOwnerOfNode; // backwards compatibility
1951  friend class Context;
1952  };
1953 
1954  //---------------------------------------------------------------------------
1955  // Query
1956  //---------------------------------------------------------------------------
1957 
1976  class Query
1977  {
1978  public:
1979  inline Query() : m_bAllocated(TRUE)
1980  {
1981  xnNodeQueryAllocate(&m_pQuery);
1982  }
1983 
1984  inline Query(XnNodeQuery* pNodeQuery) : m_bAllocated(FALSE), m_pQuery(pNodeQuery)
1985  {
1986  }
1987 
1989  {
1990  if (m_bAllocated)
1991  {
1992  xnNodeQueryFree(m_pQuery);
1993  }
1994  }
1995 
1999  inline const XnNodeQuery* GetUnderlyingObject() const { return m_pQuery; }
2000  inline XnNodeQuery* GetUnderlyingObject() { return m_pQuery; }
2001 
2006  inline XnStatus SetVendor(const XnChar* strVendor)
2007  {
2008  return xnNodeQuerySetVendor(m_pQuery, strVendor);
2009  }
2010 
2019  inline XnStatus SetName(const XnChar* strName)
2020  {
2021  return xnNodeQuerySetName(m_pQuery, strName);
2022  }
2023 
2027  inline XnStatus SetMinVersion(const XnVersion& minVersion)
2028  {
2029  return xnNodeQuerySetMinVersion(m_pQuery, &minVersion);
2030  }
2031 
2035  inline XnStatus SetMinVersion(const Version& minVersion)
2036  {
2037  return xnNodeQuerySetMinVersion(m_pQuery, minVersion.GetUnderlying());
2038  }
2039 
2043  inline XnStatus SetMaxVersion(const XnVersion& maxVersion)
2044  {
2045  return xnNodeQuerySetMaxVersion(m_pQuery, &maxVersion);
2046  }
2047 
2051  inline XnStatus SetMaxVersion(const Version& maxVersion)
2052  {
2053  return xnNodeQuerySetMaxVersion(m_pQuery, maxVersion.GetUnderlying());
2054  }
2055 
2068  inline XnStatus AddSupportedCapability(const XnChar* strNeededCapability)
2069  {
2070  return xnNodeQueryAddSupportedCapability(m_pQuery, strNeededCapability);
2071  }
2072 
2084  {
2085  return xnNodeQueryAddSupportedMapOutputMode(m_pQuery, &MapOutputMode);
2086  }
2087 
2092  inline XnStatus SetSupportedMinUserPositions(const XnUInt32 nCount)
2093  {
2094  return xnNodeQuerySetSupportedMinUserPositions(m_pQuery, nCount);
2095  }
2096 
2108  inline XnStatus SetExistingNodeOnly(XnBool bExistingNode)
2109  {
2110  return xnNodeQuerySetExistingNodeOnly(m_pQuery, bExistingNode);
2111  }
2112 
2117  inline XnStatus AddNeededNode(const XnChar* strInstanceName)
2118  {
2119  return xnNodeQueryAddNeededNode(m_pQuery, strInstanceName);
2120  }
2121 
2126  inline XnStatus SetCreationInfo(const XnChar* strCreationInfo)
2127  {
2128  return xnNodeQuerySetCreationInfo(m_pQuery, strCreationInfo);
2129  }
2130 
2131  private:
2132  XnNodeQuery* m_pQuery;
2133  XnBool m_bAllocated;
2134  };
2135 
2136  //---------------------------------------------------------------------------
2137  // Node Info List
2138  //---------------------------------------------------------------------------
2139 
2145  {
2146  public:
2150  class Iterator
2151  {
2152  public:
2153  friend class NodeInfoList;
2154 
2167  XnBool operator==(const Iterator& other) const
2168  {
2169  return m_it.pCurrent == other.m_it.pCurrent;
2170  }
2171 
2178  XnBool operator!=(const Iterator& other) const
2179  {
2180  return m_it.pCurrent != other.m_it.pCurrent;
2181  }
2182 
2188  {
2189  UpdateInternalObject(xnNodeInfoListGetNext(m_it));
2190  return *this;
2191  }
2192 
2197  inline Iterator operator++(int)
2198  {
2199  XnNodeInfoListIterator curr = m_it;
2200  UpdateInternalObject(xnNodeInfoListGetNext(m_it));
2201  return Iterator(curr);
2202  }
2203 
2208  {
2209  UpdateInternalObject(xnNodeInfoListGetPrevious(m_it));
2210  return *this;
2211  }
2212 
2216  inline Iterator operator--(int)
2217  {
2218  XnNodeInfoListIterator curr = m_it;
2219  UpdateInternalObject(xnNodeInfoListGetPrevious(m_it));
2220  return Iterator(curr);
2221  }
2222 
2227  {
2228  return m_Info;
2229  }
2230 
2231  private:
2232  inline Iterator(XnNodeInfoListIterator it) : m_Info(NULL)
2233  {
2234  UpdateInternalObject(it);
2235  }
2236 
2237  inline void UpdateInternalObject(XnNodeInfoListIterator it)
2238  {
2239  m_it = it;
2241  {
2242  XnNodeInfo* pInfo = xnNodeInfoListGetCurrent(it);
2243  m_Info = NodeInfo(pInfo);
2244  }
2245  else
2246  {
2247  m_Info = NodeInfo(NULL);
2248  }
2249  }
2250 
2251  NodeInfo m_Info;
2253  };
2254 
2258  inline NodeInfoList()
2259  {
2260  xnNodeInfoListAllocate(&m_pList);
2261  m_bAllocated = TRUE;
2262  }
2263 
2270  inline NodeInfoList(XnNodeInfoList* pList) : m_pList(pList), m_bAllocated(FALSE) {}
2271 
2272  inline ~NodeInfoList()
2273  {
2274  FreeImpl();
2275  }
2276 
2280  inline XnNodeInfoList* GetUnderlyingObject() const { return m_pList; }
2281 
2289  {
2290  FreeImpl();
2291  m_pList = pList;
2292  m_bAllocated = TRUE;
2293  }
2294 
2299  inline XnStatus Add(XnProductionNodeDescription& description, const XnChar* strCreationInfo, NodeInfoList* pNeededNodes)
2300  {
2301  XnNodeInfoList* pList = (pNeededNodes == NULL) ? NULL : pNeededNodes->GetUnderlyingObject();
2302  return xnNodeInfoListAdd(m_pList, &description, strCreationInfo, pList);
2303  }
2304 
2309  inline XnStatus AddEx(XnProductionNodeDescription& description, const XnChar* strCreationInfo, NodeInfoList* pNeededNodes, const void* pAdditionalData, XnFreeHandler pFreeHandler)
2310  {
2311  XnNodeInfoList* pList = (pNeededNodes == NULL) ? NULL : pNeededNodes->GetUnderlyingObject();
2312  return xnNodeInfoListAddEx(m_pList, &description, strCreationInfo, pList, pAdditionalData, pFreeHandler);
2313  }
2314 
2319  inline XnStatus AddNode(NodeInfo& info)
2320  {
2321  return xnNodeInfoListAddNode(m_pList, info);
2322  }
2323 
2329  {
2330  return xnNodeInfoListAddNodeFromList(m_pList, it.m_it);
2331  }
2332 
2337  inline Iterator Begin() const
2338  {
2339  return Iterator(xnNodeInfoListGetFirst(m_pList));
2340  }
2341 
2346  inline Iterator End() const
2347  {
2348  XnNodeInfoListIterator it = { NULL };
2349  return Iterator(it);
2350  }
2351 
2356  inline Iterator RBegin() const
2357  {
2358  return Iterator(xnNodeInfoListGetLast(m_pList));
2359  }
2360 
2365  inline Iterator REnd() const
2366  {
2367  XnNodeInfoListIterator it = { NULL };
2368  return Iterator(it);
2369  }
2370 
2376  {
2377  return xnNodeInfoListRemove(m_pList, it.m_it);
2378  }
2379 
2384  inline XnStatus Clear()
2385  {
2386  return xnNodeInfoListClear(m_pList);
2387  }
2388 
2394  {
2395  return xnNodeInfoListAppend(m_pList, other.GetUnderlyingObject());
2396  }
2397 
2401  inline XnBool IsEmpty()
2402  {
2403  return xnNodeInfoListIsEmpty(m_pList);
2404  }
2405 
2410  inline XnStatus FilterList(Context& context, Query& query);
2411 
2412  private:
2413  inline void FreeImpl()
2414  {
2415  if (m_bAllocated)
2416  {
2417  xnNodeInfoListFree(m_pList);
2418  m_bAllocated = FALSE;
2419  m_pList = NULL;
2420  }
2421  }
2422 
2423  XnNodeInfoList* m_pList;
2424  XnBool m_bAllocated;
2425  };
2426 
2427  //---------------------------------------------------------------------------
2428  // Production Nodes Functionality
2429  //---------------------------------------------------------------------------
2430 
2435  class Capability : public NodeWrapper
2436  {
2437  public:
2444  Capability(const NodeWrapper& node) : NodeWrapper(node) {}
2445  };
2446 
2481  {
2482  public:
2490 
2494  inline XnStatus GetErrorState() const
2495  {
2496  return xnGetNodeErrorState(GetHandle());
2497  }
2498 
2509  {
2510  return _RegisterToStateChange(xnRegisterToNodeErrorStateChange, GetHandle(), handler, pCookie, hCallback);
2511  }
2512 
2521  {
2522  _UnregisterFromStateChange(xnUnregisterFromNodeErrorStateChange, GetHandle(), hCallback);
2523  }
2524  };
2525 
2532  {
2533  public:
2540  GeneralIntCapability(XnNodeHandle hNode, const XnChar* strCap) : Capability(hNode), m_strCap(strCap) {}
2541  GeneralIntCapability(const NodeWrapper& node, const XnChar* strCap) : Capability(node), m_strCap(strCap) {}
2542 
2547  inline void GetRange(XnInt32& nMin, XnInt32& nMax, XnInt32& nStep, XnInt32& nDefault, XnBool& bIsAutoSupported) const
2548  {
2549  xnGetGeneralIntRange(GetHandle(), m_strCap, &nMin, &nMax, &nStep, &nDefault, &bIsAutoSupported);
2550  }
2551 
2556  inline XnInt32 Get()
2557  {
2558  XnInt32 nValue;
2559  xnGetGeneralIntValue(GetHandle(), m_strCap, &nValue);
2560  return nValue;
2561  }
2562 
2567  inline XnStatus Set(XnInt32 nValue)
2568  {
2569  return xnSetGeneralIntValue(GetHandle(), m_strCap, nValue);
2570  }
2571 
2581  XnStatus RegisterToValueChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback);
2582 
2591 
2592  private:
2593  const XnChar* m_strCap;
2594  };
2595 
2632  {
2633  public:
2639  inline ProductionNode(XnNodeHandle hNode = NULL) : NodeWrapper(hNode) {}
2640  inline ProductionNode(const NodeWrapper& other) : NodeWrapper(other) {}
2641 
2650  inline NodeInfo GetInfo() const { return NodeInfo(xnGetNodeInfo(GetHandle())); }
2651 
2657  {
2658  return xnAddNeededNode(GetHandle(), needed.GetHandle());
2659  }
2660 
2666  {
2667  return xnRemoveNeededNode(GetHandle(), needed.GetHandle());
2668  }
2669 
2681  inline void GetContext(Context& context) const;
2682 
2692  inline Context GetContext() const;
2693 
2705  inline XnBool IsCapabilitySupported(const XnChar* strCapabilityName) const
2706  {
2707  return xnIsCapabilitySupported(GetHandle(), strCapabilityName);
2708  }
2709 
2714  inline XnStatus SetIntProperty(const XnChar* strName, XnUInt64 nValue)
2715  {
2716  return xnSetIntProperty(GetHandle(), strName, nValue);
2717  }
2718 
2723  inline XnStatus SetRealProperty(const XnChar* strName, XnDouble dValue)
2724  {
2725  return xnSetRealProperty(GetHandle(), strName, dValue);
2726  }
2727 
2732  inline XnStatus SetStringProperty(const XnChar* strName, const XnChar* strValue)
2733  {
2734  return xnSetStringProperty(GetHandle(), strName, strValue);
2735  }
2736 
2741  inline XnStatus SetGeneralProperty(const XnChar* strName, XnUInt32 nBufferSize, const void* pBuffer)
2742  {
2743  return xnSetGeneralProperty(GetHandle(), strName, nBufferSize, pBuffer);
2744  }
2745 
2750  inline XnStatus GetIntProperty(const XnChar* strName, XnUInt64& nValue) const
2751  {
2752  return xnGetIntProperty(GetHandle(), strName, &nValue);
2753  }
2754 
2759  inline XnStatus GetRealProperty(const XnChar* strName, XnDouble &dValue) const
2760  {
2761  return xnGetRealProperty(GetHandle(), strName, &dValue);
2762  }
2763 
2768  inline XnStatus GetStringProperty(const XnChar* strName, XnChar* csValue, XnUInt32 nBufSize) const
2769  {
2770  return xnGetStringProperty(GetHandle(), strName, csValue, nBufSize);
2771  }
2772 
2777  inline XnStatus GetGeneralProperty(const XnChar* strName, XnUInt32 nBufferSize, void* pBuffer) const
2778  {
2779  return xnGetGeneralProperty(GetHandle(), strName, nBufferSize, pBuffer);
2780  }
2781 
2787  {
2788  return xnLockNodeForChanges(GetHandle(), phLock);
2789  }
2790 
2795  inline void UnlockForChanges(XnLockHandle hLock)
2796  {
2798  }
2799 
2805  {
2806  return xnLockedNodeStartChanges(GetHandle(), hLock);
2807  }
2808 
2814  {
2816  }
2817 
2827  {
2828  return ErrorStateCapability(GetHandle());
2829  }
2830 
2840  {
2841  return ErrorStateCapability(GetHandle());
2842  }
2843 
2855  inline GeneralIntCapability GetGeneralIntCap(const XnChar* strCapability)
2856  {
2857  return GeneralIntCapability(GetHandle(), strCapability);
2858  }
2859  };
2860 
2871  {
2872  public:
2880 
2890  inline XnStatus GetDeviceName(XnChar* strBuffer, XnUInt32 nBufferSize)
2891  {
2892  return xnGetDeviceName(GetHandle(), strBuffer, &nBufferSize);
2893  }
2894 
2904  inline XnStatus GetVendorSpecificData(XnChar* strBuffer, XnUInt32 nBufferSize)
2905  {
2906  return xnGetVendorSpecificData(GetHandle(), strBuffer, &nBufferSize);
2907  }
2908 
2918  inline XnStatus GetSerialNumber(XnChar* strBuffer, XnUInt32 nBufferSize)
2919  {
2920  return xnGetSerialNumber(GetHandle(), strBuffer, &nBufferSize);
2921  }
2922  };
2923 
2937  class Device : public ProductionNode
2938  {
2939  public:
2940  inline Device(XnNodeHandle hNode = NULL) : ProductionNode(hNode) {}
2941  inline Device(const NodeWrapper& other) : ProductionNode(other) {}
2942 
2951  inline XnStatus Create(Context& context, Query* pQuery = NULL, EnumerationErrors* pErrors = NULL);
2952 
2967  {
2969  }
2970  };
2971 
3020  {
3021  public:
3022  inline MirrorCapability(XnNodeHandle hNode) : Capability(hNode) {}
3023  MirrorCapability(const NodeWrapper& node) : Capability(node) {}
3024 
3031  inline XnStatus SetMirror(XnBool bMirror)
3032  {
3033  return xnSetMirror(GetHandle(), bMirror);
3034  }
3035 
3039  inline XnBool IsMirrored() const
3040  {
3041  return xnIsMirrored(GetHandle());
3042  }
3043 
3053  inline XnStatus RegisterToMirrorChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
3054  {
3055  return _RegisterToStateChange(xnRegisterToMirrorChange, GetHandle(), handler, pCookie, hCallback);
3056  }
3057 
3066  {
3067  _UnregisterFromStateChange(xnUnregisterFromMirrorChange, GetHandle(), hCallback);
3068  }
3069  };
3070 
3104  {
3105  public:
3108 
3123  inline XnBool IsViewPointSupported(ProductionNode& otherNode) const
3124  {
3125  return xnIsViewPointSupported(GetHandle(), otherNode.GetHandle());
3126  }
3127 
3136  {
3137  return xnSetViewPoint(GetHandle(), otherNode.GetHandle());
3138  }
3139 
3144  {
3145  return xnResetViewPoint(GetHandle());
3146  }
3147 
3155  inline XnBool IsViewPointAs(ProductionNode& otherNode) const
3156  {
3157  return xnIsViewPointAs(GetHandle(), otherNode.GetHandle());
3158  }
3159 
3169  inline XnStatus RegisterToViewPointChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
3170  {
3171  return _RegisterToStateChange(xnRegisterToViewPointChange, GetHandle(), handler, pCookie, hCallback);
3172  }
3173 
3182  {
3183  _UnregisterFromStateChange(xnUnregisterFromViewPointChange, GetHandle(), hCallback);
3184  }
3185  };
3186 
3209  {
3210  public:
3211  inline FrameSyncCapability(XnNodeHandle hNode) : Capability(hNode) {}
3213 
3222  inline XnBool CanFrameSyncWith(Generator& other) const;
3223 
3230  inline XnStatus FrameSyncWith(Generator& other);
3231 
3236  inline XnStatus StopFrameSyncWith(Generator& other);
3237 
3244  inline XnBool IsFrameSyncedWith(Generator& other) const;
3245 
3255  inline XnStatus RegisterToFrameSyncChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
3256  {
3257  return _RegisterToStateChange(xnRegisterToFrameSyncChange, GetHandle(), handler, pCookie, hCallback);
3258  }
3259 
3268  {
3269  _UnregisterFromStateChange(xnUnregisterFromFrameSyncChange, GetHandle(), hCallback);
3270  }
3271  };
3272 
3325  class Generator : public ProductionNode
3326  {
3327  public:
3333  inline Generator(XnNodeHandle hNode = NULL) : ProductionNode(hNode) {}
3334  inline Generator(const NodeWrapper& other) : ProductionNode(other) {}
3335 
3356  {
3357  return xnStartGenerating(GetHandle());
3358  }
3359 
3363  inline XnBool IsGenerating() const
3364  {
3365  return xnIsGenerating(GetHandle());
3366  }
3367 
3377  {
3378  return xnStopGenerating(GetHandle());
3379  }
3380 
3395  {
3396  return _RegisterToStateChange(xnRegisterToGenerationRunningChange, GetHandle(), handler, pCookie, hCallback);
3397  }
3398 
3407  {
3408  _UnregisterFromStateChange(xnUnregisterFromGenerationRunningChange, GetHandle(), hCallback);
3409  }
3410 
3425  {
3426  return _RegisterToStateChange(xnRegisterToNewDataAvailable, GetHandle(), handler, pCookie, hCallback);
3427  }
3428 
3437  {
3438  _UnregisterFromStateChange(xnUnregisterFromNewDataAvailable, GetHandle(), hCallback);
3439  }
3440 
3449  inline XnBool IsNewDataAvailable(XnUInt64* pnTimestamp = NULL) const
3450  {
3451  return xnIsNewDataAvailable(GetHandle(), pnTimestamp);
3452  }
3453 
3473  {
3474  return xnWaitAndUpdateData(GetHandle());
3475  }
3476 
3481  inline XnBool IsDataNew() const
3482  {
3483  return xnIsDataNew(GetHandle());
3484  }
3485 
3503  inline const void* GetData()
3504  {
3505  return xnGetData(GetHandle());
3506  }
3507 
3521  inline XnUInt32 GetDataSize() const
3522  {
3523  return xnGetDataSize(GetHandle());
3524  }
3525 
3539  inline XnUInt64 GetTimestamp() const
3540  {
3541  return xnGetTimestamp(GetHandle());
3542  }
3543 
3556  inline XnUInt32 GetFrameID() const
3557  {
3558  return xnGetFrameID(GetHandle());
3559  }
3560 
3569  inline const MirrorCapability GetMirrorCap() const
3570  {
3571  return MirrorCapability(GetHandle());
3572  }
3573 
3583  {
3584  return MirrorCapability(GetHandle());
3585  }
3586 
3598  {
3600  }
3601 
3613  {
3615  }
3616 
3627  {
3628  return FrameSyncCapability(GetHandle());
3629  }
3630 
3641  {
3642  return FrameSyncCapability(GetHandle());
3643  }
3644  };
3645 
3690  class Recorder : public ProductionNode
3691  {
3692  public:
3698  inline Recorder(XnNodeHandle hNode = NULL) : ProductionNode(hNode) {}
3699  inline Recorder(const NodeWrapper& other) : ProductionNode(other) {}
3700 
3708  inline XnStatus Create(Context& context, const XnChar* strFormatName = NULL);
3709 
3718  inline XnStatus SetDestination(XnRecordMedium destType, const XnChar* strDest)
3719  {
3720  return xnSetRecorderDestination(GetHandle(), destType, strDest);
3721  }
3722 
3732  inline XnStatus GetDestination(XnRecordMedium& destType, XnChar* strDest, XnUInt32 nBufSize)
3733  {
3734  return xnGetRecorderDestination(GetHandle(), &destType, strDest, nBufSize);
3735  }
3736 
3747  {
3748  return xnAddNodeToRecording(GetHandle(), Node.GetHandle(), compression);
3749  }
3750 
3758  {
3759  return xnRemoveNodeFromRecording(GetHandle(), Node.GetHandle());
3760  }
3761 
3774  inline XnStatus Record()
3775  {
3776  return xnRecord(GetHandle());
3777  }
3778  };
3779 
3807  class Player : public ProductionNode
3808  {
3809  public:
3815  inline Player(XnNodeHandle hNode = NULL) : ProductionNode(hNode) {}
3816  inline Player(const NodeWrapper& other) : ProductionNode(other) {}
3817 
3826  inline XnStatus Create(Context& context, const XnChar* strFormatName);
3827 
3828 
3843  inline XnStatus SetRepeat(XnBool bRepeat)
3844  {
3845  return xnSetPlayerRepeat(GetHandle(), bRepeat);
3846  }
3847 
3852  inline XnStatus SetSource(XnRecordMedium sourceType, const XnChar* strSource)
3853  {
3854  return xnSetPlayerSource(GetHandle(), sourceType, strSource);
3855  }
3856 
3865  inline XnStatus GetSource(XnRecordMedium &sourceType, XnChar* strSource, XnUInt32 nBufSize) const
3866  {
3867  return xnGetPlayerSource(GetHandle(), &sourceType, strSource, nBufSize);
3868  }
3869 
3875  {
3876  return xnPlayerReadNext(GetHandle());
3877  }
3878 
3903  inline XnStatus SeekToTimeStamp(XnInt64 nTimeOffset, XnPlayerSeekOrigin origin)
3904  {
3905  return xnSeekPlayerToTimeStamp(GetHandle(), nTimeOffset, origin);
3906  }
3907 
3932  inline XnStatus SeekToFrame(const XnChar* strNodeName, XnInt32 nFrameOffset, XnPlayerSeekOrigin origin)
3933  {
3934  return xnSeekPlayerToFrame(GetHandle(), strNodeName, nFrameOffset, origin);
3935  }
3936 
3942  inline XnStatus TellTimestamp(XnUInt64& nTimestamp) const
3943  {
3944  return xnTellPlayerTimestamp(GetHandle(), &nTimestamp);
3945  }
3946 
3959  inline XnStatus TellFrame(const XnChar* strNodeName, XnUInt32& nFrame) const
3960  {
3961  return xnTellPlayerFrame(GetHandle(), strNodeName, &nFrame);
3962  }
3963 
3971  inline XnStatus GetNumFrames(const XnChar* strNodeName, XnUInt32& nFrames) const
3972  {
3973  return xnGetPlayerNumFrames(GetHandle(), strNodeName, &nFrames);
3974  }
3975 
3980  inline const XnChar* GetSupportedFormat() const
3981  {
3983  }
3984 
3990  {
3991  XnNodeInfoList* pList;
3992  XnStatus nRetVal = xnEnumeratePlayerNodes(GetHandle(), &pList);
3993  XN_IS_STATUS_OK(nRetVal);
3994 
3995  list.ReplaceUnderlyingObject(pList);
3996 
3997  return (XN_STATUS_OK);
3998  }
3999 
4008  inline XnBool IsEOF() const
4009  {
4010  return xnIsPlayerAtEOF(GetHandle());
4011  }
4012 
4023  {
4024  return _RegisterToStateChange(xnRegisterToEndOfFileReached, GetHandle(), handler, pCookie, hCallback);
4025  }
4026 
4035  {
4036  _UnregisterFromStateChange(xnUnregisterFromEndOfFileReached, GetHandle(), hCallback);
4037  }
4038 
4057  inline XnStatus SetPlaybackSpeed(XnDouble dSpeed)
4058  {
4059  return xnSetPlaybackSpeed(GetHandle(), dSpeed);
4060  }
4061 
4066  inline XnDouble GetPlaybackSpeed() const
4067  {
4068  return xnGetPlaybackSpeed(GetHandle());
4069  }
4070  };
4071 
4100  {
4101  public:
4107  inline CroppingCapability(XnNodeHandle hNode) : Capability(hNode) {}
4109 
4119  inline XnStatus SetCropping(const XnCropping& Cropping)
4120  {
4121  return xnSetCropping(GetHandle(), &Cropping);
4122  }
4123 
4134  inline XnStatus GetCropping(XnCropping& Cropping) const
4135  {
4136  return xnGetCropping(GetHandle(), &Cropping);
4137  }
4138 
4148  inline XnStatus RegisterToCroppingChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
4149  {
4150  return _RegisterToStateChange(xnRegisterToCroppingChange, GetHandle(), handler, pCookie, hCallback);
4151  }
4152 
4161  {
4162  _UnregisterFromStateChange(xnUnregisterFromCroppingChange, GetHandle(), hCallback);
4163  }
4164  };
4165 
4175  {
4176  public:
4184 
4190  {
4191  return xnSetPowerLineFrequency(GetHandle(), nFrequency);
4192  }
4193 
4199  {
4201  }
4202 
4213  {
4214  return _RegisterToStateChange(xnRegisterToPowerLineFrequencyChange, GetHandle(), handler, pCookie, hCallback);
4215  }
4216 
4225  {
4226  _UnregisterFromStateChange(xnUnregisterFromPowerLineFrequencyChange, GetHandle(), hCallback);
4227  }
4228  };
4229 
4253  class MapGenerator : public Generator
4254  {
4255  public:
4261  inline MapGenerator(XnNodeHandle hNode = NULL) : Generator(hNode) {}
4262  inline MapGenerator(const NodeWrapper& other) : Generator(other) {}
4263 
4271  inline XnUInt32 GetSupportedMapOutputModesCount() const
4272  {
4274  }
4275 
4286  inline XnStatus GetSupportedMapOutputModes(XnMapOutputMode* aModes, XnUInt32& nCount) const
4287  {
4288  return xnGetSupportedMapOutputModes(GetHandle(), aModes, &nCount);
4289  }
4290 
4304  inline XnStatus SetMapOutputMode(const XnMapOutputMode& OutputMode)
4305  {
4306  return xnSetMapOutputMode(GetHandle(), &OutputMode);
4307  }
4308 
4326  inline XnStatus GetMapOutputMode(XnMapOutputMode &OutputMode) const
4327  {
4328  return xnGetMapOutputMode(GetHandle(), &OutputMode);
4329  }
4330 
4339  inline XnUInt32 GetBytesPerPixel() const
4340  {
4341  return xnGetBytesPerPixel(GetHandle());
4342  }
4343 
4354  {
4355  return _RegisterToStateChange(xnRegisterToMapOutputModeChange, GetHandle(), handler, pCookie, hCallback);
4356  }
4357 
4366  {
4367  _UnregisterFromStateChange(xnUnregisterFromMapOutputModeChange, GetHandle(), hCallback);
4368  }
4369 
4378  inline const CroppingCapability GetCroppingCap() const
4379  {
4380  return CroppingCapability(GetHandle());
4381  }
4382 
4392  {
4393  return CroppingCapability(GetHandle());
4394  }
4395 
4402  {
4404  }
4405 
4412  {
4414  }
4415 
4422  {
4424  }
4425 
4432  {
4434  }
4435 
4442  {
4444  }
4445 
4452  {
4454  }
4455 
4462  {
4464  }
4465 
4472  {
4474  }
4475 
4482  {
4484  }
4485 
4492  {
4494  }
4495 
4502  {
4504  }
4505 
4512  {
4514  }
4515 
4522  {
4524  }
4525 
4532  {
4534  }
4535 
4542  {
4544  }
4545 
4552  {
4554  }
4555 
4562  {
4564  }
4565 
4572  {
4573  return AntiFlickerCapability(GetHandle());
4574  }
4575  };
4576 
4586  {
4587  public:
4593  inline UserPositionCapability(XnNodeHandle hNode = NULL) : Capability(hNode) {}
4595 
4600  inline XnUInt32 GetSupportedUserPositionsCount() const
4601  {
4603  }
4604 
4609  inline XnStatus SetUserPosition(XnUInt32 nIndex, const XnBoundingBox3D& Position)
4610  {
4611  return xnSetUserPosition(GetHandle(), nIndex, &Position);
4612  }
4613 
4618  inline XnStatus GetUserPosition(XnUInt32 nIndex, XnBoundingBox3D& Position) const
4619  {
4620  return xnGetUserPosition(GetHandle(), nIndex, &Position);
4621  }
4622 
4633  {
4634  return _RegisterToStateChange(xnRegisterToUserPositionChange, GetHandle(), handler, pCookie, hCallback);
4635  }
4636 
4645  {
4646  _UnregisterFromStateChange(xnUnregisterFromUserPositionChange, GetHandle(), hCallback);
4647  }
4648  };
4649 
4695  {
4696  public:
4702  inline DepthGenerator(XnNodeHandle hNode = NULL) : MapGenerator(hNode) {}
4703  inline DepthGenerator(const NodeWrapper& other) : MapGenerator(other) {}
4704 
4712  inline XnStatus Create(Context& context, Query* pQuery = NULL, EnumerationErrors* pErrors = NULL);
4713 
4730  inline void GetMetaData(DepthMetaData& metaData) const
4731  {
4733  }
4734 
4739  inline const XnDepthPixel* GetDepthMap() const
4740  {
4741  return xnGetDepthMap(GetHandle());
4742  }
4743 
4754  {
4755  return xnGetDeviceMaxDepth(GetHandle());
4756  }
4757 
4777  {
4778  return xnGetDepthFieldOfView(GetHandle(), &FOV);
4779  }
4780 
4791  {
4792  return _RegisterToStateChange(xnRegisterToDepthFieldOfViewChange, GetHandle(), handler, pCookie, hCallback);
4793  }
4794 
4803  {
4804  _UnregisterFromStateChange(xnUnregisterFromDepthFieldOfViewChange, GetHandle(), hCallback);
4805  }
4806 
4816  inline XnStatus ConvertProjectiveToRealWorld(XnUInt32 nCount, const XnPoint3D aProjective[], XnPoint3D aRealWorld[]) const
4817  {
4818  return xnConvertProjectiveToRealWorld(GetHandle(), nCount, aProjective, aRealWorld);
4819  }
4820 
4830  inline XnStatus ConvertRealWorldToProjective(XnUInt32 nCount, const XnPoint3D aRealWorld[], XnPoint3D aProjective[]) const
4831  {
4832  return xnConvertRealWorldToProjective(GetHandle(), nCount, aRealWorld, aProjective);
4833  }
4834 
4841  {
4843  }
4844 
4851  {
4853  }
4854  };
4855 
4861  {
4862  public:
4868  inline MockDepthGenerator(XnNodeHandle hNode = NULL) : DepthGenerator(hNode) {}
4869  inline MockDepthGenerator(const NodeWrapper& other) : DepthGenerator(other) {}
4870 
4877  XnStatus Create(Context& context, const XnChar* strName = NULL);
4878 
4886  XnStatus CreateBasedOn(DepthGenerator& other, const XnChar* strName = NULL);
4887 
4892  inline XnStatus SetData(XnUInt32 nFrameID, XnUInt64 nTimestamp, XnUInt32 nDataSize, const XnDepthPixel* pDepthMap)
4893  {
4894  return xnMockDepthSetData(GetHandle(), nFrameID, nTimestamp, nDataSize, pDepthMap);
4895  }
4896 
4905  inline XnStatus SetData(const DepthMetaData& depthMD, XnUInt32 nFrameID, XnUInt64 nTimestamp)
4906  {
4907  return SetData(nFrameID, nTimestamp, depthMD.DataSize(), depthMD.Data());
4908  }
4909 
4915  inline XnStatus SetData(const DepthMetaData& depthMD)
4916  {
4917  return SetData(depthMD, depthMD.FrameID(), depthMD.Timestamp());
4918  }
4919  };
4920 
4940  {
4941  public:
4947  inline ImageGenerator(XnNodeHandle hNode = NULL) : MapGenerator(hNode) {}
4948  inline ImageGenerator(const NodeWrapper& other) : MapGenerator(other) {}
4949 
4955  inline XnStatus Create(Context& context, Query* pQuery = NULL, EnumerationErrors* pErrors = NULL);
4956 
4973  inline void GetMetaData(ImageMetaData& metaData) const
4974  {
4976  }
4977 
4982  inline const XnRGB24Pixel* GetRGB24ImageMap() const
4983  {
4984  return xnGetRGB24ImageMap(GetHandle());
4985  }
4986 
4992  {
4993  return xnGetYUV422ImageMap(GetHandle());
4994  }
4995 
5001  {
5003  }
5004 
5010  {
5012  }
5013 
5018  inline const XnUInt8* GetImageMap() const
5019  {
5020  return xnGetImageMap(GetHandle());
5021  }
5022 
5033  inline XnBool IsPixelFormatSupported(XnPixelFormat Format) const
5034  {
5035  return xnIsPixelFormatSupported(GetHandle(), Format);
5036  }
5037 
5056  {
5057  return xnSetPixelFormat(GetHandle(), Format);
5058  }
5059 
5071  {
5072  return xnGetPixelFormat(GetHandle());
5073  }
5074 
5085  {
5086  return _RegisterToStateChange(xnRegisterToPixelFormatChange, GetHandle(), handler, pCookie, hCallback);
5087  }
5088 
5097  {
5098  _UnregisterFromStateChange(xnUnregisterFromPixelFormatChange, GetHandle(), hCallback);
5099  }
5100  };
5101 
5107  {
5108  public:
5114  inline MockImageGenerator(XnNodeHandle hNode = NULL) : ImageGenerator(hNode) {}
5115  inline MockImageGenerator(const NodeWrapper& other) : ImageGenerator(other) {}
5116 
5123  XnStatus Create(Context& context, const XnChar* strName = NULL);
5124 
5132  XnStatus CreateBasedOn(ImageGenerator& other, const XnChar* strName = NULL);
5133 
5138  inline XnStatus SetData(XnUInt32 nFrameID, XnUInt64 nTimestamp, XnUInt32 nDataSize, const XnUInt8* pImageMap)
5139  {
5140  return xnMockImageSetData(GetHandle(), nFrameID, nTimestamp, nDataSize, pImageMap);
5141  }
5142 
5151  inline XnStatus SetData(const ImageMetaData& imageMD, XnUInt32 nFrameID, XnUInt64 nTimestamp)
5152  {
5153  return SetData(nFrameID, nTimestamp, imageMD.DataSize(), imageMD.Data());
5154  }
5155 
5161  inline XnStatus SetData(const ImageMetaData& imageMD)
5162  {
5163  return SetData(imageMD, imageMD.FrameID(), imageMD.Timestamp());
5164  }
5165  };
5166 
5175  class IRGenerator : public MapGenerator
5176  {
5177  public:
5183  inline IRGenerator(XnNodeHandle hNode = NULL) : MapGenerator(hNode) {}
5184  inline IRGenerator(const NodeWrapper& other) : MapGenerator(other) {}
5185 
5192  inline XnStatus Create(Context& context, Query* pQuery = NULL, EnumerationErrors* pErrors = NULL);
5193 
5210  inline void GetMetaData(IRMetaData& metaData) const
5211  {
5212  xnGetIRMetaData(GetHandle(), metaData.GetUnderlying());
5213  }
5214 
5218  inline const XnIRPixel* GetIRMap() const
5219  {
5220  return xnGetIRMap(GetHandle());
5221  }
5222  };
5223 
5229  {
5230  public:
5236  inline MockIRGenerator(XnNodeHandle hNode = NULL) : IRGenerator(hNode) {}
5237  inline MockIRGenerator(const NodeWrapper& other) : IRGenerator(other) {}
5238 
5245  XnStatus Create(Context& context, const XnChar* strName = NULL);
5252  XnStatus CreateBasedOn(IRGenerator& other, const XnChar* strName = NULL);
5253 
5258  inline XnStatus SetData(XnUInt32 nFrameID, XnUInt64 nTimestamp, XnUInt32 nDataSize, const XnIRPixel* pIRMap)
5259  {
5260  return xnMockIRSetData(GetHandle(), nFrameID, nTimestamp, nDataSize, pIRMap);
5261  }
5262 
5271  inline XnStatus SetData(const IRMetaData& irMD, XnUInt32 nFrameID, XnUInt64 nTimestamp)
5272  {
5273  return SetData(nFrameID, nTimestamp, irMD.DataSize(), irMD.Data());
5274  }
5275 
5281  inline XnStatus SetData(const IRMetaData& irMD)
5282  {
5283  return SetData(irMD, irMD.FrameID(), irMD.Timestamp());
5284  }
5285  };
5286 
5355  {
5356  public:
5362  inline GestureGenerator(XnNodeHandle hNode = NULL) : Generator(hNode) {}
5363  inline GestureGenerator(const NodeWrapper& other) : Generator(other) {}
5364 
5378  inline XnStatus Create(Context& context, Query* pQuery = NULL, EnumerationErrors* pErrors = NULL);
5379 
5393  inline XnStatus AddGesture(const XnChar* strGesture, XnBoundingBox3D* pArea)
5394  {
5395  return xnAddGesture(GetHandle(), strGesture, pArea);
5396  }
5397 
5405  inline XnStatus RemoveGesture(const XnChar* strGesture)
5406  {
5407  return xnRemoveGesture(GetHandle(), strGesture);
5408  }
5409 
5418  inline XnStatus GetAllActiveGestures(XnChar** astrGestures, XnUInt32 nNameLength, XnUInt16& nGestures) const
5419  {
5420  return xnGetAllActiveGestures(GetHandle(), astrGestures, nNameLength, &nGestures);
5421  }
5422 
5427  inline XnUInt16 GetNumberOfAvailableGestures() const
5428  {
5430  }
5431 
5440  inline XnStatus EnumerateAllGestures(XnChar** astrGestures, XnUInt32 nNameLength, XnUInt16& nGestures) const
5441  {
5442  return xnEnumerateAllGestures(GetHandle(), astrGestures, nNameLength, &nGestures);
5443  }
5444 
5450  inline XnBool IsGestureAvailable(const XnChar* strGesture) const
5451  {
5452  return xnIsGestureAvailable(GetHandle(), strGesture);
5453  }
5454 
5459  inline XnBool IsGestureProgressSupported(const XnChar* strGesture) const
5460  {
5461  return xnIsGestureProgressSupported(GetHandle(), strGesture);
5462  }
5463 
5485  typedef void (XN_CALLBACK_TYPE* GestureRecognized)(GestureGenerator& generator, const XnChar* strGesture, const XnPoint3D* pIDPosition, const XnPoint3D* pEndPosition, void* pCookie);
5486 
5513  typedef void (XN_CALLBACK_TYPE* GestureProgress)(GestureGenerator& generator, const XnChar* strGesture, const XnPoint3D* pPosition, XnFloat fProgress, void* pCookie);
5514 
5526  XnStatus RegisterGestureCallbacks(GestureRecognized RecognizedCB, GestureProgress ProgressCB, void* pCookie, XnCallbackHandle& hCallback)
5527  {
5528  XnStatus nRetVal = XN_STATUS_OK;
5529 
5530  GestureCookie* pGestureCookie;
5531  XN_VALIDATE_ALLOC(pGestureCookie, GestureCookie);
5532  pGestureCookie->recognizedHandler = RecognizedCB;
5533  pGestureCookie->progressHandler = ProgressCB;
5534  pGestureCookie->pUserCookie = pCookie;
5535 
5536  nRetVal = xnRegisterGestureCallbacks(GetHandle(), GestureRecognizedCallback, GestureProgressCallback, pGestureCookie, &pGestureCookie->hCallback);
5537  if (nRetVal != XN_STATUS_OK)
5538  {
5539  xnOSFree(pGestureCookie);
5540  return (nRetVal);
5541  }
5542 
5543  hCallback = pGestureCookie;
5544 
5545  return (XN_STATUS_OK);
5546  }
5547 
5556  {
5557  GestureCookie* pGestureCookie = (GestureCookie*)hCallback;
5558  xnUnregisterGestureCallbacks(GetHandle(), pGestureCookie->hCallback);
5559  xnOSFree(pGestureCookie);
5560  }
5561 
5571  inline XnStatus RegisterToGestureChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
5572  {
5573  return _RegisterToStateChange(xnRegisterToGestureChange, GetHandle(), handler, pCookie, hCallback);
5574  }
5575 
5584  {
5585  _UnregisterFromStateChange(xnUnregisterFromGestureChange, GetHandle(), hCallback);
5586  }
5587 
5615  typedef void (XN_CALLBACK_TYPE* GestureIntermediateStageCompleted)(GestureGenerator& generator, const XnChar* strGesture, const XnPoint3D* pPosition, void* pCookie);
5616 
5627  {
5628  XnStatus nRetVal = XN_STATUS_OK;
5629 
5630  GestureIntermediateStageCompletedCookie* pGestureCookie;
5631  XN_VALIDATE_ALLOC(pGestureCookie, GestureIntermediateStageCompletedCookie);
5632  pGestureCookie->handler = handler;
5633  pGestureCookie->pUserCookie = pCookie;
5634 
5635  nRetVal = xnRegisterToGestureIntermediateStageCompleted(GetHandle(), GestureIntermediateStageCompletedCallback, pGestureCookie, &pGestureCookie->hCallback);
5636  if (nRetVal != XN_STATUS_OK)
5637  {
5638  xnOSFree(pGestureCookie);
5639  return (nRetVal);
5640  }
5641 
5642  hCallback = pGestureCookie;
5643 
5644  return (XN_STATUS_OK);
5645  }
5646 
5655  {
5656  GestureIntermediateStageCompletedCookie* pGestureCookie = (GestureIntermediateStageCompletedCookie*)hCallback;
5657  xnUnregisterFromGestureIntermediateStageCompleted(GetHandle(), pGestureCookie->hCallback);
5658  xnOSFree(pGestureCookie);
5659  }
5660 
5679  typedef void (XN_CALLBACK_TYPE* GestureReadyForNextIntermediateStage)(GestureGenerator& generator, const XnChar* strGesture, const XnPoint3D* pPosition, void* pCookie);
5680 
5691  {
5692  XnStatus nRetVal = XN_STATUS_OK;
5693 
5694  GestureReadyForNextIntermediateStageCookie* pGestureCookie;
5695  XN_VALIDATE_ALLOC(pGestureCookie, GestureReadyForNextIntermediateStageCookie);
5696  pGestureCookie->handler = handler;
5697  pGestureCookie->pUserCookie = pCookie;
5698 
5699  nRetVal = xnRegisterToGestureReadyForNextIntermediateStage(GetHandle(), GestureReadyForNextIntermediateStageCallback, pGestureCookie, &pGestureCookie->hCallback);
5700  if (nRetVal != XN_STATUS_OK)
5701  {
5702  xnOSFree(pGestureCookie);
5703  return (nRetVal);
5704  }
5705 
5706  hCallback = pGestureCookie;
5707 
5708  return (XN_STATUS_OK);
5709  }
5710 
5719  {
5720  GestureReadyForNextIntermediateStageCookie* pGestureCookie = (GestureReadyForNextIntermediateStageCookie*)hCallback;
5722  xnOSFree(pGestureCookie);
5723  }
5724 
5726  inline XnStatus XN_API_DEPRECATED("Use GetAllActiveGestures() instead") GetActiveGestures(XnChar*& astrGestures, XnUInt16& nGestures) const
5727  {
5728  return xnGetActiveGestures(GetHandle(), &astrGestures, &nGestures);
5729  }
5730  inline XnStatus XN_API_DEPRECATED("Use EnumerateAllGestures() instead") EnumerateGestures(XnChar*& astrGestures, XnUInt16& nGestures) const
5731  {
5732  return xnEnumerateGestures(GetHandle(), &astrGestures, &nGestures);
5733  }
5736  private:
5737  typedef struct GestureCookie
5738  {
5739  GestureRecognized recognizedHandler;
5740  GestureProgress progressHandler;
5741  void* pUserCookie;
5742  XnCallbackHandle hCallback;
5743  } GestureCookie;
5744 
5745  static void XN_CALLBACK_TYPE GestureRecognizedCallback(XnNodeHandle hNode, const XnChar* strGesture, const XnPoint3D* pIDPosition, const XnPoint3D* pEndPosition, void* pCookie)
5746  {
5747  GestureCookie* pGestureCookie = (GestureCookie*)pCookie;
5748  GestureGenerator gen(hNode);
5749  if (pGestureCookie->recognizedHandler != NULL)
5750  {
5751  pGestureCookie->recognizedHandler(gen, strGesture, pIDPosition, pEndPosition, pGestureCookie->pUserCookie);
5752  }
5753  }
5754 
5755  static void XN_CALLBACK_TYPE GestureProgressCallback(XnNodeHandle hNode, const XnChar* strGesture, const XnPoint3D* pPosition, XnFloat fProgress, void* pCookie)
5756  {
5757  GestureCookie* pGestureCookie = (GestureCookie*)pCookie;
5758  GestureGenerator gen(hNode);
5759  if (pGestureCookie->progressHandler != NULL)
5760  {
5761  pGestureCookie->progressHandler(gen, strGesture, pPosition, fProgress, pGestureCookie->pUserCookie);
5762  }
5763  }
5764 
5765  typedef struct GestureIntermediateStageCompletedCookie
5766  {
5768  void* pUserCookie;
5769  XnCallbackHandle hCallback;
5770  } GestureIntermediateStageCompletedCookie;
5771 
5772  static void XN_CALLBACK_TYPE GestureIntermediateStageCompletedCallback(XnNodeHandle hNode, const XnChar* strGesture, const XnPoint3D* pPosition, void* pCookie)
5773  {
5774  GestureIntermediateStageCompletedCookie* pGestureCookie = (GestureIntermediateStageCompletedCookie*)pCookie;
5775  GestureGenerator gen(hNode);
5776  if (pGestureCookie->handler != NULL)
5777  {
5778  pGestureCookie->handler(gen, strGesture, pPosition, pGestureCookie->pUserCookie);
5779  }
5780  }
5781 
5782  typedef struct GestureReadyForNextIntermediateStageCookie
5783  {
5785  void* pUserCookie;
5786  XnCallbackHandle hCallback;
5787  } GestureReadyForNextIntermediateStageCookie;
5788 
5789  static void XN_CALLBACK_TYPE GestureReadyForNextIntermediateStageCallback(XnNodeHandle hNode, const XnChar* strGesture, const XnPoint3D* pPosition, void* pCookie)
5790  {
5791  GestureReadyForNextIntermediateStageCookie* pGestureCookie = (GestureReadyForNextIntermediateStageCookie*)pCookie;
5792  GestureGenerator gen(hNode);
5793  if (pGestureCookie->handler != NULL)
5794  {
5795  pGestureCookie->handler(gen, strGesture, pPosition, pGestureCookie->pUserCookie);
5796  }
5797  }
5798  };
5799 
5819  {
5820  public:
5826  inline SceneAnalyzer(XnNodeHandle hNode = NULL) : MapGenerator(hNode) {}
5827  inline SceneAnalyzer(const NodeWrapper& other) : MapGenerator(other) {}
5828 
5836  inline XnStatus Create(Context& context, Query* pQuery = NULL, EnumerationErrors* pErrors = NULL);
5837 
5838 
5858  inline void GetMetaData(SceneMetaData& metaData) const
5859  {
5861  }
5862 
5867  inline const XnLabel* GetLabelMap() const
5868  {
5869  return xnGetLabelMap(GetHandle());
5870  }
5871 
5877  inline XnStatus GetFloor(XnPlane3D& Plane) const
5878  {
5879  return xnGetFloor(GetHandle(), &Plane);
5880  }
5881  };
5882 
5891  {
5892  public:
5900 
5911  typedef void (XN_CALLBACK_TYPE* HandTouchingFOVEdge)(HandTouchingFOVEdgeCapability& touchingfov, XnUserID user, const XnPoint3D* pPosition, XnFloat fTime, XnDirection eDir, void* pCookie);
5912 
5923  {
5924  XnStatus nRetVal = XN_STATUS_OK;
5925 
5926  HandTouchingFOVEdgeCookie* pHandCookie;
5927  XN_VALIDATE_ALLOC(pHandCookie, HandTouchingFOVEdgeCookie);
5928  pHandCookie->handler = handler;
5929  pHandCookie->pUserCookie = pCookie;
5930 
5931  nRetVal = xnRegisterToHandTouchingFOVEdge(GetHandle(), HandTouchingFOVEdgeCB, pHandCookie, &pHandCookie->hCallback);
5932  if (nRetVal != XN_STATUS_OK)
5933  {
5934  xnOSFree(pHandCookie);
5935  return (nRetVal);
5936  }
5937 
5938  hCallback = pHandCookie;
5939 
5940  return (XN_STATUS_OK);
5941  }
5942 
5951  {
5952  HandTouchingFOVEdgeCookie* pHandCookie = (HandTouchingFOVEdgeCookie*)hCallback;
5953  xnUnregisterFromHandTouchingFOVEdge(GetHandle(), pHandCookie->hCallback);
5954  xnOSFree(pHandCookie);
5955  }
5956  private:
5957  typedef struct HandTouchingFOVEdgeCookie
5958  {
5959  HandTouchingFOVEdge handler;
5960  void* pUserCookie;
5961  XnCallbackHandle hCallback;
5962  } HandTouchingFOVEdgeCookie;
5963 
5964  static void XN_CALLBACK_TYPE HandTouchingFOVEdgeCB(XnNodeHandle hNode, XnUserID user, const XnPoint3D* pPosition, XnFloat fTime, XnDirection eDir, void* pCookie)
5965  {
5966  HandTouchingFOVEdgeCookie* pHandCookie = (HandTouchingFOVEdgeCookie*)pCookie;
5967  HandTouchingFOVEdgeCapability cap(hNode);
5968  if (pHandCookie->handler != NULL)
5969  {
5970  pHandCookie->handler(cap, user, pPosition, fTime, eDir, pHandCookie->pUserCookie);
5971  }
5972  }
5973 
5974  };
5975 
6063  class HandsGenerator : public Generator
6064  {
6065  public:
6071  inline HandsGenerator(XnNodeHandle hNode = NULL) : Generator(hNode) {}
6072  inline HandsGenerator(const NodeWrapper& other) : Generator(other) {}
6073 
6081  inline XnStatus Create(Context& context, Query* pQuery = NULL, EnumerationErrors* pErrors = NULL);
6082 
6098  typedef void (XN_CALLBACK_TYPE* HandCreate)(HandsGenerator& generator, XnUserID user, const XnPoint3D* pPosition, XnFloat fTime, void* pCookie);
6099 
6116  typedef void (XN_CALLBACK_TYPE* HandUpdate)(HandsGenerator& generator, XnUserID user, const XnPoint3D* pPosition, XnFloat fTime, void* pCookie);
6117 
6131  typedef void (XN_CALLBACK_TYPE* HandDestroy)(HandsGenerator& generator, XnUserID user, XnFloat fTime, void* pCookie);
6132 
6145  inline XnStatus RegisterHandCallbacks(HandCreate CreateCB, HandUpdate UpdateCB, HandDestroy DestroyCB, void* pCookie, XnCallbackHandle& hCallback)
6146  {
6147  XnStatus nRetVal = XN_STATUS_OK;
6148 
6149  HandCookie* pHandCookie;
6150  XN_VALIDATE_ALLOC(pHandCookie, HandCookie);
6151  pHandCookie->createHandler = CreateCB;
6152  pHandCookie->updateHandler = UpdateCB;
6153  pHandCookie->destroyHandler = DestroyCB;
6154  pHandCookie->pUserCookie = pCookie;
6155 
6156  nRetVal = xnRegisterHandCallbacks(GetHandle(), HandCreateCB, HandUpdateCB, HandDestroyCB, pHandCookie, &pHandCookie->hCallback);
6157  if (nRetVal != XN_STATUS_OK)
6158  {
6159  xnOSFree(pHandCookie);
6160  return (nRetVal);
6161  }
6162 
6163  hCallback = pHandCookie;
6164 
6165  return (XN_STATUS_OK);
6166  }
6167 
6176  {
6177  HandCookie* pHandCookie = (HandCookie*)hCallback;
6178  xnUnregisterHandCallbacks(GetHandle(), pHandCookie->hCallback);
6179  xnOSFree(pHandCookie);
6180  }
6181 
6196  {
6197  return xnStopTracking(GetHandle(), user);
6198  }
6199 
6209  {
6210  return xnStopTrackingAll(GetHandle());
6211  }
6212 
6229  inline XnStatus StartTracking(const XnPoint3D& ptPosition)
6230  {
6231  return xnStartTracking(GetHandle(), &ptPosition);
6232  }
6233 
6250  inline XnStatus SetSmoothing(XnFloat fSmoothingFactor)
6251  {
6252  return xnSetTrackingSmoothing(GetHandle(), fSmoothingFactor);
6253  }
6254 
6263  {
6265  }
6266 
6275  {
6277  }
6278 
6279  private:
6280  typedef struct HandCookie
6281  {
6282  HandCreate createHandler;
6283  HandUpdate updateHandler;
6284  HandDestroy destroyHandler;
6285  void* pUserCookie;
6286  XnCallbackHandle hCallback;
6287  } HandCookie;
6288 
6289  static void XN_CALLBACK_TYPE HandCreateCB(XnNodeHandle hNode, XnUserID user, const XnPoint3D* pPosition, XnFloat fTime, void* pCookie)
6290  {
6291  HandCookie* pHandCookie = (HandCookie*)pCookie;
6292  HandsGenerator gen(hNode);
6293  if (pHandCookie->createHandler != NULL)
6294  {
6295  pHandCookie->createHandler(gen, user, pPosition, fTime, pHandCookie->pUserCookie);
6296  }
6297  }
6298  static void XN_CALLBACK_TYPE HandUpdateCB(XnNodeHandle hNode, XnUserID user, const XnPoint3D* pPosition, XnFloat fTime, void* pCookie)
6299  {
6300  HandCookie* pHandCookie = (HandCookie*)pCookie;
6301  HandsGenerator gen(hNode);
6302  if (pHandCookie->updateHandler != NULL)
6303  {
6304  pHandCookie->updateHandler(gen, user, pPosition, fTime, pHandCookie->pUserCookie);
6305  }
6306  }
6307  static void XN_CALLBACK_TYPE HandDestroyCB(XnNodeHandle hNode, XnUserID user, XnFloat fTime, void* pCookie)
6308  {
6309  HandCookie* pHandCookie = (HandCookie*)pCookie;
6310  HandsGenerator gen(hNode);
6311  if (pHandCookie->destroyHandler != NULL)
6312  {
6313  pHandCookie->destroyHandler(gen, user, fTime, pHandCookie->pUserCookie);
6314  }
6315  }
6316  };
6317 
6375  {
6376  public:
6382  inline SkeletonCapability(XnNodeHandle hNode) : Capability(hNode) {}
6384 
6390  inline XnBool IsJointAvailable(XnSkeletonJoint eJoint) const
6391  {
6392  return xnIsJointAvailable(GetHandle(), eJoint);
6393  }
6394 
6400  inline XnBool IsProfileAvailable(XnSkeletonProfile eProfile) const
6401  {
6402  return xnIsProfileAvailable(GetHandle(), eProfile);
6403  }
6404 
6436  {
6437  return xnSetSkeletonProfile(GetHandle(), eProfile);
6438  }
6439 
6463  inline XnStatus SetJointActive(XnSkeletonJoint eJoint, XnBool bState)
6464  {
6465  return xnSetJointActive(GetHandle(), eJoint, bState);
6466  }
6467 
6473  inline XnBool IsJointActive(XnSkeletonJoint eJoint) const
6474  {
6475  return xnIsJointActive(GetHandle(), eJoint);
6476  }
6477 
6488  {
6489  return _RegisterToStateChange(xnRegisterToJointConfigurationChange, GetHandle(), handler, pCookie, hCallback);
6490  }
6491 
6500  {
6501  _UnregisterFromStateChange(xnUnregisterFromJointConfigurationChange, GetHandle(), hCallback);
6502  }
6503 
6508  inline XnStatus EnumerateActiveJoints(XnSkeletonJoint* pJoints, XnUInt16& nJoints) const
6509  {
6510  return xnEnumerateActiveJoints(GetHandle(), pJoints, &nJoints);
6511  }
6512 
6522  {
6523  return xnGetSkeletonJoint(GetHandle(), user, eJoint, &Joint);
6524  }
6525 
6548  {
6549  return xnGetSkeletonJointPosition(GetHandle(), user, eJoint, &Joint);
6550  }
6551 
6560  {
6561  return xnGetSkeletonJointOrientation(GetHandle(), user, eJoint, &Joint);
6562  }
6563 
6574  inline XnBool IsTracking(XnUserID user) const
6575  {
6576  return xnIsSkeletonTracking(GetHandle(), user);
6577  }
6578 
6589  inline XnBool IsCalibrated(XnUserID user) const
6590  {
6591  return xnIsSkeletonCalibrated(GetHandle(), user);
6592  }
6593 
6604  inline XnBool IsCalibrating(XnUserID user) const
6605  {
6606  return xnIsSkeletonCalibrating(GetHandle(), user);
6607  }
6608 
6633  inline XnStatus RequestCalibration(XnUserID user, XnBool bForce)
6634  {
6635  return xnRequestSkeletonCalibration(GetHandle(), user, bForce);
6636  }
6637 
6648  {
6649  return xnAbortSkeletonCalibration(GetHandle(), user);
6650  }
6651 
6670  inline XnStatus SaveCalibrationDataToFile(XnUserID user, const XnChar* strFileName)
6671  {
6672  return xnSaveSkeletonCalibrationDataToFile(GetHandle(), user, strFileName);
6673  }
6674 
6681  inline XnStatus LoadCalibrationDataFromFile(XnUserID user, const XnChar* strFileName)
6682  {
6683  return xnLoadSkeletonCalibrationDataFromFile(GetHandle(), user, strFileName);
6684  }
6685 
6697  inline XnStatus SaveCalibrationData(XnUserID user, XnUInt32 nSlot)
6698  {
6699  return xnSaveSkeletonCalibrationData(GetHandle(), user, nSlot);
6700  }
6701 
6708  inline XnStatus LoadCalibrationData(XnUserID user, XnUInt32 nSlot)
6709  {
6710  return xnLoadSkeletonCalibrationData(GetHandle(), user, nSlot);
6711  }
6712 
6718  inline XnStatus ClearCalibrationData(XnUInt32 nSlot)
6719  {
6720  return xnClearSkeletonCalibrationData(GetHandle(), nSlot);
6721  }
6722 
6728  inline XnBool IsCalibrationData(XnUInt32 nSlot) const
6729  {
6730  return xnIsSkeletonCalibrationData(GetHandle(), nSlot);
6731  }
6732 
6748  {
6749  return xnStartSkeletonTracking(GetHandle(), user);
6750  }
6751 
6757  {
6758  return xnStopSkeletonTracking(GetHandle(), user);
6759  }
6760 
6769  inline XnStatus Reset(XnUserID user)
6770  {
6771  return xnResetSkeleton(GetHandle(), user);
6772  }
6773 
6782  inline XnBool NeedPoseForCalibration() const
6783  {
6785  }
6786 
6799  inline XnStatus GetCalibrationPose(XnChar* strPose) const
6800  {
6801  return xnGetSkeletonCalibrationPose(GetHandle(), strPose);
6802  }
6803 
6816  inline XnStatus SetSmoothing(XnFloat fSmoothingFactor)
6817  {
6818  return xnSetSkeletonSmoothing(GetHandle(), fSmoothingFactor);
6819  }
6820 
6842  typedef void (XN_CALLBACK_TYPE* CalibrationStart)(SkeletonCapability& skeleton, XnUserID user, void* pCookie);
6843 
6861  typedef void (XN_CALLBACK_TYPE* CalibrationEnd)(SkeletonCapability& skeleton, XnUserID user, XnBool bSuccess, void* pCookie);
6862 
6874  inline XnStatus RegisterToCalibrationStart(CalibrationStart handler, void* pCookie, XnCallbackHandle& hCallback)
6875  {
6876  XnStatus nRetVal = XN_STATUS_OK;
6877  CalibrationStartCookie* pCalibrationCookie;
6878  XN_VALIDATE_ALLOC(pCalibrationCookie, CalibrationStartCookie);
6879  pCalibrationCookie->handler = handler;
6880  pCalibrationCookie->pUserCookie = pCookie;
6881  nRetVal = xnRegisterToCalibrationStart(GetHandle(), CalibrationStartCallback, pCalibrationCookie, &pCalibrationCookie->hCallback);
6882  if (nRetVal != XN_STATUS_OK)
6883  {
6884  xnOSFree(pCalibrationCookie);
6885  return nRetVal;
6886  }
6887  hCallback = pCalibrationCookie;
6888  return XN_STATUS_OK;
6889  }
6890 
6902  {
6903  CalibrationStartCookie* pCalibrationCookie = (CalibrationStartCookie*)hCallback;
6904  xnUnregisterFromCalibrationStart(GetHandle(), pCalibrationCookie->hCallback);
6905  xnOSFree(pCalibrationCookie);
6906  return XN_STATUS_OK;
6907  }
6908 
6930  typedef void (XN_CALLBACK_TYPE* CalibrationInProgress)(SkeletonCapability& skeleton, XnUserID user, XnCalibrationStatus calibrationError, void* pCookie);
6931 
6942  {
6943  XnStatus nRetVal = XN_STATUS_OK;
6944 
6945  CalibrationInProgressCookie* pSkeletonCookie;
6946  XN_VALIDATE_ALLOC(pSkeletonCookie, CalibrationInProgressCookie);
6947  pSkeletonCookie->handler = handler;
6948  pSkeletonCookie->pUserCookie = pCookie;
6949 
6950  nRetVal = xnRegisterToCalibrationInProgress(GetHandle(), CalibrationInProgressCallback, pSkeletonCookie, &pSkeletonCookie->hCallback);
6951  if (nRetVal != XN_STATUS_OK)
6952  {
6953  xnOSFree(pSkeletonCookie);
6954  return (nRetVal);
6955  }
6956 
6957  hCallback = pSkeletonCookie;
6958 
6959  return (XN_STATUS_OK);
6960  }
6961 
6970  {
6971  CalibrationInProgressCookie* pSkeletonCookie = (CalibrationInProgressCookie*)hCallback;
6972  xnUnregisterFromCalibrationInProgress(GetHandle(), pSkeletonCookie->hCallback);
6973  xnOSFree(pSkeletonCookie);
6974  }
6975 
6993  typedef void (XN_CALLBACK_TYPE* CalibrationComplete)(SkeletonCapability& skeleton, XnUserID user, XnCalibrationStatus calibrationError, void* pCookie);
6994 
7005  {
7006  XnStatus nRetVal = XN_STATUS_OK;
7007 
7008  CalibrationCompleteCookie* pSkeletonCookie;
7009  XN_VALIDATE_ALLOC(pSkeletonCookie, CalibrationCompleteCookie);
7010  pSkeletonCookie->handler = handler;
7011  pSkeletonCookie->pUserCookie = pCookie;
7012 
7013  nRetVal = xnRegisterToCalibrationComplete(GetHandle(), CalibrationCompleteCallback, pSkeletonCookie, &pSkeletonCookie->hCallback);
7014  if (nRetVal != XN_STATUS_OK)
7015  {
7016  xnOSFree(pSkeletonCookie);
7017  return (nRetVal);
7018  }
7019 
7020  hCallback = pSkeletonCookie;
7021 
7022  return (XN_STATUS_OK);
7023  }
7024 
7033  {
7034  CalibrationCompleteCookie* pSkeletonCookie = (CalibrationCompleteCookie*)hCallback;
7035  xnUnregisterFromCalibrationComplete(GetHandle(), pSkeletonCookie->hCallback);
7036  xnOSFree(pSkeletonCookie);
7037  }
7038 
7040  XN_API_DEPRECATED("Use the overload with one argument - the bState parameter is useless")
7041  inline XnBool IsJointActive(XnSkeletonJoint eJoint, XnBool /*bState*/) const
7042  {
7043  return xnIsJointActive(GetHandle(), eJoint);
7044  }
7045 
7046  inline XnStatus XN_API_DEPRECATED("Please use RegisterToCalibrationStart/Complete") RegisterCalibrationCallbacks(CalibrationStart CalibrationStartCB, CalibrationEnd CalibrationEndCB, void* pCookie, XnCallbackHandle& hCallback)
7047  {
7048  XnStatus nRetVal = XN_STATUS_OK;
7049 
7050  SkeletonCookie* pSkeletonCookie;
7051  XN_VALIDATE_ALLOC(pSkeletonCookie, SkeletonCookie);
7052  pSkeletonCookie->startHandler = CalibrationStartCB;
7053  pSkeletonCookie->endHandler = CalibrationEndCB;
7054  pSkeletonCookie->pUserCookie = pCookie;
7055 
7056 #pragma warning (push)
7057 #pragma warning (disable: XN_DEPRECATED_WARNING_IDS)
7058  nRetVal = xnRegisterCalibrationCallbacks(GetHandle(), CalibrationStartBundleCallback, CalibrationEndBundleCallback, pSkeletonCookie, &pSkeletonCookie->hCallback);
7059 #pragma warning (pop)
7060  if (nRetVal != XN_STATUS_OK)
7061  {
7062  xnOSFree(pSkeletonCookie);
7063  return (nRetVal);
7064  }
7065 
7066  hCallback = pSkeletonCookie;
7067 
7068  return (XN_STATUS_OK);
7069  }
7070 
7071  inline void XN_API_DEPRECATED("Please use UnregisterFromCalibrationStart/Complete") UnregisterCalibrationCallbacks(XnCallbackHandle hCallback)
7072  {
7073  SkeletonCookie* pSkeletonCookie = (SkeletonCookie*)hCallback;
7074 #pragma warning (push)
7075 #pragma warning (disable: XN_DEPRECATED_WARNING_IDS)
7076  xnUnregisterCalibrationCallbacks(GetHandle(), pSkeletonCookie->hCallback);
7077 #pragma warning (pop)
7078  xnOSFree(pSkeletonCookie);
7079  }
7082 private:
7083  typedef struct SkeletonCookie
7084  {
7085  CalibrationStart startHandler;
7086  CalibrationEnd endHandler;
7087  void* pUserCookie;
7088  XnCallbackHandle hCallback;
7089  } SkeletonCookie;
7090 
7091  static void XN_CALLBACK_TYPE CalibrationStartBundleCallback(XnNodeHandle hNode, XnUserID user, void* pCookie)
7092  {
7093  SkeletonCookie* pSkeletonCookie = (SkeletonCookie*)pCookie;
7094  SkeletonCapability cap(hNode);
7095  if (pSkeletonCookie->startHandler != NULL)
7096  {
7097  pSkeletonCookie->startHandler(cap, user, pSkeletonCookie->pUserCookie);
7098  }
7099  }
7100 
7101  static void XN_CALLBACK_TYPE CalibrationEndBundleCallback(XnNodeHandle hNode, XnUserID user, XnBool bSuccess, void* pCookie)
7102  {
7103  SkeletonCookie* pSkeletonCookie = (SkeletonCookie*)pCookie;
7104  SkeletonCapability cap(hNode);
7105  if (pSkeletonCookie->endHandler != NULL)
7106  {
7107  pSkeletonCookie->endHandler(cap, user, bSuccess, pSkeletonCookie->pUserCookie);
7108  }
7109  }
7110 
7111  typedef struct CalibrationStartCookie
7112  {
7113  CalibrationStart handler;
7114  void* pUserCookie;
7115  XnCallbackHandle hCallback;
7116  } CalibrationStartCookie;
7117 
7118  static void XN_CALLBACK_TYPE CalibrationStartCallback(XnNodeHandle hNode, XnUserID user, void* pCookie)
7119  {
7120  CalibrationStartCookie* pCalibrationCookie = (CalibrationStartCookie*)pCookie;
7121  SkeletonCapability cap(hNode);
7122  if (pCalibrationCookie->handler != NULL)
7123  {
7124  pCalibrationCookie->handler(cap, user, pCalibrationCookie->pUserCookie);
7125  }
7126  }
7127 
7128  typedef struct CalibrationInProgressCookie
7129  {
7130  CalibrationInProgress handler;
7131  void* pUserCookie;
7132  XnCallbackHandle hCallback;
7133  } CalibrationInProgressCookie;
7134 
7135  static void XN_CALLBACK_TYPE CalibrationInProgressCallback(XnNodeHandle hNode, XnUserID user, XnCalibrationStatus calibrationError, void* pCookie)
7136  {
7137  CalibrationInProgressCookie* pSkeletonCookie = (CalibrationInProgressCookie*)pCookie;
7138  SkeletonCapability cap(hNode);
7139  if (pSkeletonCookie->handler != NULL)
7140  {
7141  pSkeletonCookie->handler(cap, user, calibrationError, pSkeletonCookie->pUserCookie);
7142  }
7143  }
7144 
7145  typedef struct CalibrationCompleteCookie
7146  {
7147  CalibrationComplete handler;
7148  void* pUserCookie;
7149  XnCallbackHandle hCallback;
7150  } CalibrationCompleteCookie;
7151 
7152  static void XN_CALLBACK_TYPE CalibrationCompleteCallback(XnNodeHandle hNode, XnUserID user, XnCalibrationStatus calibrationError, void* pCookie)
7153  {
7154  CalibrationCompleteCookie* pSkeletonCookie = (CalibrationCompleteCookie*)pCookie;
7155  SkeletonCapability cap(hNode);
7156  if (pSkeletonCookie->handler != NULL)
7157  {
7158  pSkeletonCookie->handler(cap, user, calibrationError, pSkeletonCookie->pUserCookie);
7159  }
7160  }
7161  };
7162 
7185  {
7186  public:
7194 
7208  typedef void (XN_CALLBACK_TYPE* PoseDetection)(PoseDetectionCapability& pose, const XnChar* strPose, XnUserID user, void* pCookie);
7209 
7219  inline XnUInt32 GetNumberOfPoses() const
7220  {
7221  return xnGetNumberOfPoses(GetHandle());
7222  }
7223 
7236  inline XnStatus GetAllAvailablePoses(XnChar** pstrPoses, XnUInt32 nNameLength, XnUInt32& nPoses) const
7237  {
7238  return xnGetAllAvailablePoses(GetHandle(), pstrPoses, nNameLength, &nPoses);
7239  }
7240 
7241  inline XnBool IsPoseSupported(const XnChar* strPose)
7242  {
7243  return xnIsPoseSupported(GetHandle(), strPose);
7244  }
7245 
7246  inline XnStatus GetPoseStatus(XnUserID userID, const XnChar* poseName, XnUInt64& poseTime, XnPoseDetectionStatus& eStatus, XnPoseDetectionState& eState)
7247  {
7248  return xnGetPoseStatus(GetHandle(), userID, poseName, &poseTime, &eStatus, &eState);
7249  }
7250 
7266  inline XnStatus StartPoseDetection(const XnChar* strPose, XnUserID user)
7267  {
7268  return xnStartPoseDetection(GetHandle(), strPose, user);
7269  }
7270 
7283  {
7284  return xnStopPoseDetection(GetHandle(), user);
7285  }
7286 
7290  inline XnStatus StopSinglePoseDetection(XnUserID user, const XnChar* strPose)
7291  {
7292  return xnStopSinglePoseDetection(GetHandle(), user, strPose);
7293  }
7294 
7304  inline XnStatus RegisterToPoseDetected(PoseDetection handler, void* pCookie, XnCallbackHandle& hCallback)
7305  {
7306  XnStatus nRetVal = XN_STATUS_OK;
7307  PoseDetectionCookie* pPoseCookie;
7308  XN_VALIDATE_ALLOC(pPoseCookie, PoseDetectionCookie);
7309  pPoseCookie->handler = handler;
7310  pPoseCookie->pPoseCookie = pCookie;
7311 
7312  nRetVal = xnRegisterToPoseDetected(GetHandle(), PoseDetectionCallback, pPoseCookie, &pPoseCookie->hCallback);
7313  if (nRetVal != XN_STATUS_OK)
7314  {
7315  xnOSFree(pPoseCookie);
7316  return nRetVal;
7317  }
7318  hCallback = pPoseCookie;
7319  return XN_STATUS_OK;
7320  }
7321 
7331  inline XnStatus RegisterToOutOfPose(PoseDetection handler, void* pCookie, XnCallbackHandle& hCallback)
7332  {
7333  XnStatus nRetVal = XN_STATUS_OK;
7334  PoseDetectionCookie* pPoseCookie;
7335  XN_VALIDATE_ALLOC(pPoseCookie, PoseDetectionCookie);
7336  pPoseCookie->handler = handler;
7337  pPoseCookie->pPoseCookie = pCookie;
7338 
7339  nRetVal = xnRegisterToOutOfPose(GetHandle(), PoseDetectionCallback, pPoseCookie, &pPoseCookie->hCallback);
7340  if (nRetVal != XN_STATUS_OK)
7341  {
7342  xnOSFree(pPoseCookie);
7343  return nRetVal;
7344  }
7345  hCallback = pPoseCookie;
7346  return XN_STATUS_OK;
7347  }
7356  {
7357  PoseDetectionCookie* pPoseCookie = (PoseDetectionCookie*)hCallback;
7358  xnUnregisterFromPoseDetected(GetHandle(), pPoseCookie->hCallback);
7359  xnOSFree(pPoseCookie);
7360  }
7369  {
7370  PoseDetectionCookie* pPoseCookie = (PoseDetectionCookie*)hCallback;
7371  xnUnregisterFromOutOfPose(GetHandle(), pPoseCookie->hCallback);
7372  xnOSFree(pPoseCookie);
7373  }
7374 
7397  typedef void (XN_CALLBACK_TYPE* PoseInProgress)(PoseDetectionCapability& pose, const XnChar* strPose, XnUserID user, XnPoseDetectionStatus poseError, void* pCookie);
7398 
7415  inline XnStatus RegisterToPoseInProgress(PoseInProgress handler, void* pCookie, XnCallbackHandle& hCallback)
7416  {
7417  XnStatus nRetVal = XN_STATUS_OK;
7418 
7419  PoseInProgressCookie* pPoseCookie;
7420  XN_VALIDATE_ALLOC(pPoseCookie, PoseInProgressCookie);
7421  pPoseCookie->handler = handler;
7422  pPoseCookie->pPoseCookie = pCookie;
7423 
7424  nRetVal = xnRegisterToPoseDetectionInProgress(GetHandle(), PoseDetectionInProgressCallback, pPoseCookie, &pPoseCookie->hCallback);
7425  if (nRetVal != XN_STATUS_OK)
7426  {
7427  xnOSFree(pPoseCookie);
7428  return (nRetVal);
7429  }
7430 
7431  hCallback = pPoseCookie;
7432 
7433  return (XN_STATUS_OK);
7434  }
7435 
7444  {
7445  PoseInProgressCookie* pPoseCookie = (PoseInProgressCookie*)hCallback;
7446  xnUnregisterFromPoseDetectionInProgress(GetHandle(), pPoseCookie->hCallback);
7447  xnOSFree(pPoseCookie);
7448  }
7449 
7451  inline XnStatus XN_API_DEPRECATED("Use GetAllAvailablePoses() instead") GetAvailablePoses(XnChar** pstrPoses, XnUInt32& nPoses) const
7452  {
7453  return xnGetAvailablePoses(GetHandle(), pstrPoses, &nPoses);
7454  }
7455 
7456  inline XnStatus XN_API_DEPRECATED("Please use RegisterToPoseDetected/RegisterToOutOfPose instead") RegisterToPoseCallbacks(PoseDetection PoseStartCB, PoseDetection PoseEndCB, void* pCookie, XnCallbackHandle& hCallback)
7457  {
7458  XnStatus nRetVal = XN_STATUS_OK;
7459 
7460  PoseCookie* pPoseCookie;
7461  XN_VALIDATE_ALLOC(pPoseCookie, PoseCookie);
7462  pPoseCookie->startHandler = PoseStartCB;
7463  pPoseCookie->endHandler = PoseEndCB;
7464  pPoseCookie->pPoseCookie = pCookie;
7465 
7466 #pragma warning (push)
7467 #pragma warning (disable: XN_DEPRECATED_WARNING_IDS)
7468  nRetVal = xnRegisterToPoseCallbacks(GetHandle(), PoseDetectionStartBundleCallback, PoseDetectionStartEndBundleCallback, pPoseCookie, &pPoseCookie->hCallback);
7469 #pragma warning (pop)
7470  if (nRetVal != XN_STATUS_OK)
7471  {
7472  xnOSFree(pPoseCookie);
7473  return (nRetVal);
7474  }
7475 
7476  hCallback = pPoseCookie;
7477 
7478  return (XN_STATUS_OK);
7479  }
7480 
7481  inline void XN_API_DEPRECATED("Please use UnregisterFromPoseDetected/UnregisterFromOutOfPose instead") UnregisterFromPoseCallbacks(XnCallbackHandle hCallback)
7482  {
7483  PoseCookie* pPoseCookie = (PoseCookie*)hCallback;
7484 #pragma warning (push)
7485 #pragma warning (disable: XN_DEPRECATED_WARNING_IDS)
7486  xnUnregisterFromPoseCallbacks(GetHandle(), pPoseCookie->hCallback);
7487 #pragma warning (pop)
7488  xnOSFree(pPoseCookie);
7489  }
7492 private:
7493  typedef struct PoseCookie
7494  {
7495  PoseDetection startHandler;
7496  PoseDetection endHandler;
7497  void* pPoseCookie;
7498  XnCallbackHandle hCallback;
7499  } PoseCookie;
7500 
7501  static void XN_CALLBACK_TYPE PoseDetectionStartBundleCallback(XnNodeHandle hNode, const XnChar* strPose, XnUserID user, void* pCookie)
7502  {
7503  PoseCookie* pPoseCookie = (PoseCookie*)pCookie;
7504  PoseDetectionCapability cap(hNode);
7505  if (pPoseCookie->startHandler != NULL)
7506  {
7507  pPoseCookie->startHandler(cap, strPose, user, pPoseCookie->pPoseCookie);
7508  }
7509  }
7510 
7511  static void XN_CALLBACK_TYPE PoseDetectionStartEndBundleCallback(XnNodeHandle hNode, const XnChar* strPose, XnUserID user, void* pCookie)
7512  {
7513  PoseCookie* pPoseCookie = (PoseCookie*)pCookie;
7514  PoseDetectionCapability cap(hNode);
7515  if (pPoseCookie->endHandler != NULL)
7516  {
7517  pPoseCookie->endHandler(cap, strPose, user, pPoseCookie->pPoseCookie);
7518  }
7519  }
7520  typedef struct PoseDetectionCookie
7521  {
7522  PoseDetection handler;
7523  void* pPoseCookie;
7524  XnCallbackHandle hCallback;
7525  } PoseDetectionCookie;
7526  static void XN_CALLBACK_TYPE PoseDetectionCallback(XnNodeHandle hNode, const XnChar* strPose, XnUserID user, void* pCookie)
7527  {
7528  PoseDetectionCookie* pPoseDetectionCookie = (PoseDetectionCookie*)pCookie;
7529  PoseDetectionCapability cap(hNode);
7530  if (pPoseDetectionCookie->handler != NULL)
7531  {
7532  pPoseDetectionCookie->handler(cap, strPose, user, pPoseDetectionCookie->pPoseCookie);
7533  }
7534  }
7535 
7536  typedef struct PoseInProgressCookie
7537  {
7538  PoseInProgress handler;
7539  void* pPoseCookie;
7540  XnCallbackHandle hCallback;
7541  } PoseInProgressCookie;
7542 
7543  static void XN_CALLBACK_TYPE PoseDetectionInProgressCallback(XnNodeHandle hNode, const XnChar* strPose, XnUserID user, XnPoseDetectionStatus poseErrors, void* pCookie)
7544  {
7545  PoseInProgressCookie* pPoseCookie = (PoseInProgressCookie*)pCookie;
7546  PoseDetectionCapability cap(hNode);
7547  if (pPoseCookie->handler != NULL)
7548  {
7549  pPoseCookie->handler(cap, strPose, user, poseErrors, pPoseCookie->pPoseCookie);
7550  }
7551  }
7552  };
7553 
7665  class UserGenerator : public Generator
7666  {
7667  public:
7673  inline UserGenerator(XnNodeHandle hNode = NULL) : Generator(hNode) {}
7674  inline UserGenerator(const NodeWrapper& other) : Generator(other) {}
7675 
7683  inline XnStatus Create(Context& context, Query* pQuery = NULL, EnumerationErrors* pErrors = NULL);
7684 
7697  typedef void (XN_CALLBACK_TYPE* UserHandler)(UserGenerator& generator, XnUserID user, void* pCookie);
7698 
7706  inline XnUInt16 GetNumberOfUsers() const
7707  {
7708  return xnGetNumberOfUsers(GetHandle());
7709  }
7710 
7733  inline XnStatus GetUsers(XnUserID aUsers[], XnUInt16& nUsers) const
7734  {
7735  return xnGetUsers(GetHandle(), aUsers, &nUsers);
7736  }
7737 
7757  inline XnStatus GetCoM(XnUserID user, XnPoint3D& com) const
7758  {
7759  return xnGetUserCoM(GetHandle(), user, &com);
7760  }
7761 
7778  {
7779  return xnGetUserPixels(GetHandle(), user, smd.GetUnderlying());
7780  }
7781 
7792  inline XnStatus RegisterUserCallbacks(UserHandler NewUserCB, UserHandler LostUserCB, void* pCookie, XnCallbackHandle& hCallback)
7793  {
7794  XnStatus nRetVal = XN_STATUS_OK;
7795 
7796  UserCookie* pUserCookie;
7797  XN_VALIDATE_ALLOC(pUserCookie, UserCookie);
7798  pUserCookie->newHandler = NewUserCB;
7799  pUserCookie->lostHandler = LostUserCB;
7800  pUserCookie->pUserCookie = pCookie;
7801 
7802  nRetVal = xnRegisterUserCallbacks(GetHandle(), NewUserCallback, LostUserCallback, pUserCookie, &pUserCookie->hCallback);
7803  if (nRetVal != XN_STATUS_OK)
7804  {
7805  xnOSFree(pUserCookie);
7806  return (nRetVal);
7807  }
7808 
7809  hCallback = pUserCookie;
7810 
7811  return (XN_STATUS_OK);
7812  }
7813 
7822  {
7823  UserCookie* pUserCookie = (UserCookie*)hCallback;
7824  xnUnregisterUserCallbacks(GetHandle(), pUserCookie->hCallback);
7825  xnOSFree(pUserCookie);
7826  }
7827 
7839  inline const SkeletonCapability GetSkeletonCap() const
7840  {
7841  return SkeletonCapability(GetHandle());
7842  }
7843 
7856  {
7857  return SkeletonCapability(GetHandle());
7858  }
7859 
7871  {
7873  }
7874 
7886  {
7888  }
7889 
7899  inline XnStatus RegisterToUserExit(UserHandler handler, void* pCookie, XnCallbackHandle& hCallback)
7900  {
7901  XnStatus nRetVal = XN_STATUS_OK;
7902 
7903  UserSingleCookie* pUserCookie;
7904  XN_VALIDATE_ALLOC(pUserCookie, UserSingleCookie);
7905  pUserCookie->handler = handler;
7906  pUserCookie->pUserCookie = pCookie;
7907 
7908  nRetVal = xnRegisterToUserExit(GetHandle(), UserSingleCallback, pUserCookie, &pUserCookie->hCallback);
7909  if (nRetVal != XN_STATUS_OK)
7910  {
7911  xnOSFree(pUserCookie);
7912  return (nRetVal);
7913  }
7914 
7915  hCallback = pUserCookie;
7916 
7917  return (XN_STATUS_OK);
7918  }
7919 
7928  {
7929  UserSingleCookie* pUserCookie = (UserSingleCookie*)hCallback;
7930  xnUnregisterFromUserExit(GetHandle(), pUserCookie->hCallback);
7931  xnOSFree(pUserCookie);
7932  }
7933 
7943  inline XnStatus RegisterToUserReEnter(UserHandler handler, void* pCookie, XnCallbackHandle& hCallback)
7944  {
7945  XnStatus nRetVal = XN_STATUS_OK;
7946 
7947  UserSingleCookie* pUserCookie;
7948  XN_VALIDATE_ALLOC(pUserCookie, UserSingleCookie);
7949  pUserCookie->handler = handler;
7950  pUserCookie->pUserCookie = pCookie;
7951 
7952  nRetVal = xnRegisterToUserReEnter(GetHandle(), UserSingleCallback, pUserCookie, &pUserCookie->hCallback);
7953  if (nRetVal != XN_STATUS_OK)
7954  {
7955  xnOSFree(pUserCookie);
7956  return (nRetVal);
7957  }
7958 
7959  hCallback = pUserCookie;
7960 
7961  return (XN_STATUS_OK);
7962  }
7963 
7972  {
7973  UserSingleCookie* pUserCookie = (UserSingleCookie*)hCallback;
7974  xnUnregisterFromUserReEnter(GetHandle(), pUserCookie->hCallback);
7975  xnOSFree(pUserCookie);
7976  }
7977 
7978  private:
7979  typedef struct UserCookie
7980  {
7981  UserHandler newHandler;
7982  UserHandler lostHandler;
7983  void* pUserCookie;
7984  XnCallbackHandle hCallback;
7985  } UserCookie;
7986 
7987  static void XN_CALLBACK_TYPE NewUserCallback(XnNodeHandle hNode, XnUserID user, void* pCookie)
7988  {
7989  UserCookie* pUserCookie = (UserCookie*)pCookie;
7990  UserGenerator gen(hNode);
7991  if (pUserCookie->newHandler != NULL)
7992  {
7993  pUserCookie->newHandler(gen, user, pUserCookie->pUserCookie);
7994  }
7995  }
7996 
7997  static void XN_CALLBACK_TYPE LostUserCallback(XnNodeHandle hNode, XnUserID user, void* pCookie)
7998  {
7999  UserCookie* pUserCookie = (UserCookie*)pCookie;
8000  UserGenerator gen(hNode);
8001  if (pUserCookie->lostHandler != NULL)
8002  {
8003  pUserCookie->lostHandler(gen, user, pUserCookie->pUserCookie);
8004  }
8005  }
8006 
8007  typedef struct UserSingleCookie
8008  {
8009  UserHandler handler;
8010  void* pUserCookie;
8011  XnCallbackHandle hCallback;
8012  } UserSingleCookie;
8013 
8014  static void XN_CALLBACK_TYPE UserSingleCallback(XnNodeHandle hNode, XnUserID user, void* pCookie)
8015  {
8016  UserSingleCookie* pUserCookie = (UserSingleCookie*)pCookie;
8017  UserGenerator gen(hNode);
8018  if (pUserCookie->handler != NULL)
8019  {
8020  pUserCookie->handler(gen, user, pUserCookie->pUserCookie);
8021  }
8022  }
8023  };
8024 
8038  class AudioGenerator : public Generator
8039  {
8040  public:
8046  inline AudioGenerator(XnNodeHandle hNode = NULL) : Generator(hNode) {}
8047  inline AudioGenerator(const NodeWrapper& other) : Generator(other) {}
8048 
8056  inline XnStatus Create(Context& context, Query* pQuery = NULL, EnumerationErrors* pErrors = NULL);
8057 
8074  inline void GetMetaData(AudioMetaData& metaData) const
8075  {
8077  }
8078 
8083  inline const XnUChar* GetAudioBuffer() const
8084  {
8085  return xnGetAudioBuffer(GetHandle());
8086  }
8087 
8091  inline XnUInt32 GetSupportedWaveOutputModesCount() const
8092  {
8094  }
8095 
8102  inline XnStatus GetSupportedWaveOutputModes(XnWaveOutputMode* aSupportedModes, XnUInt32& nCount) const
8103  {
8104  return xnGetSupportedWaveOutputModes(GetHandle(), aSupportedModes, &nCount);
8105  }
8106 
8118  inline XnStatus SetWaveOutputMode(const XnWaveOutputMode& OutputMode)
8119  {
8120  return xnSetWaveOutputMode(GetHandle(), &OutputMode);
8121  }
8122 
8134  inline XnStatus GetWaveOutputMode(XnWaveOutputMode& OutputMode) const
8135  {
8136  return xnGetWaveOutputMode(GetHandle(), &OutputMode);
8137  }
8138 
8149  {
8150  return _RegisterToStateChange(xnRegisterToWaveOutputModeChanges, GetHandle(), handler, pCookie, hCallback);
8151  }
8152 
8161  {
8162  _UnregisterFromStateChange(xnUnregisterFromWaveOutputModeChanges, GetHandle(), hCallback);
8163  }
8164  };
8165 
8171  {
8172  public:
8178  inline MockAudioGenerator(XnNodeHandle hNode = NULL) : AudioGenerator(hNode) {}
8179  inline MockAudioGenerator(const NodeWrapper& other) : AudioGenerator(other) {}
8180 
8187  XnStatus Create(Context& context, const XnChar* strName = NULL);
8188 
8196  XnStatus CreateBasedOn(AudioGenerator& other, const XnChar* strName = NULL);
8197 
8202  inline XnStatus SetData(XnUInt32 nFrameID, XnUInt64 nTimestamp, XnUInt32 nDataSize, const XnUInt8* pAudioBuffer)
8203  {
8204  return xnMockAudioSetData(GetHandle(), nFrameID, nTimestamp, nDataSize, pAudioBuffer);
8205  }
8206 
8215  inline XnStatus SetData(const AudioMetaData& audioMD, XnUInt32 nFrameID, XnUInt64 nTimestamp)
8216  {
8217  return SetData(nFrameID, nTimestamp, audioMD.DataSize(), audioMD.Data());
8218  }
8219 
8225  inline XnStatus SetData(const AudioMetaData& audioMD)
8226  {
8227  return SetData(audioMD, audioMD.FrameID(), audioMD.Timestamp());
8228  }
8229  };
8230 
8235  {
8236  public:
8237  MockRawGenerator(XnNodeHandle hNode = NULL) : Generator(hNode) {}
8238  MockRawGenerator(const NodeWrapper& other) : Generator(other) {}
8239 
8240  inline XnStatus Create(Context& context, const XnChar* strName = NULL);
8241 
8242  inline XnStatus SetData(XnUInt32 nFrameID, XnUInt64 nTimestamp, XnUInt32 nDataSize, const void* pData)
8243  {
8244  return xnMockRawSetData(GetHandle(), nFrameID, nTimestamp, nDataSize, pData);
8245  }
8246 
8247  };
8248 
8253  class Codec : public ProductionNode
8254  {
8255  public:
8261  inline Codec(XnNodeHandle hNode = NULL) : ProductionNode(hNode) {}
8262  inline Codec(const NodeWrapper& other) : ProductionNode(other) {}
8263 
8268  inline XnStatus Create(Context& context, XnCodecID codecID, ProductionNode& initializerNode);
8269 
8274  inline XnCodecID GetCodecID() const
8275  {
8276  return xnGetCodecID(GetHandle());
8277  }
8278 
8283  inline XnStatus EncodeData(const void* pSrc, XnUInt32 nSrcSize, void* pDst, XnUInt32 nDstSize, XnUInt* pnBytesWritten) const
8284  {
8285  return xnEncodeData(GetHandle(), pSrc, nSrcSize, pDst, nDstSize, pnBytesWritten);
8286  }
8287 
8292  inline XnStatus DecodeData(const void* pSrc, XnUInt32 nSrcSize, void* pDst, XnUInt32 nDstSize, XnUInt* pnBytesWritten) const
8293  {
8294  return xnDecodeData(GetHandle(), pSrc, nSrcSize, pDst, nDstSize, pnBytesWritten);
8295  }
8296  };
8297 
8332  {
8333  public:
8339  inline ScriptNode(XnNodeHandle hNode = NULL) : ProductionNode(hNode) {}
8340  inline ScriptNode(const NodeWrapper& other) : ProductionNode(other) {}
8341 
8342  inline XnStatus Create(Context& context, const XnChar* strFormat);
8343 
8344  inline const XnChar* GetSupportedFormat()
8345  {
8347  }
8348 
8354  inline XnStatus LoadScriptFromFile(const XnChar* strFileName)
8355  {
8356  return xnLoadScriptFromFile(GetHandle(), strFileName);
8357  }
8358 
8364  inline XnStatus LoadScriptFromString(const XnChar* strScript)
8365  {
8366  return xnLoadScriptFromString(GetHandle(), strScript);
8367  }
8368 
8380  inline XnStatus Run(EnumerationErrors* pErrors);
8381  };
8382 
8383  //---------------------------------------------------------------------------
8384  // EnumerationErrors
8385  //---------------------------------------------------------------------------
8407  {
8408  public:
8412  inline EnumerationErrors() : m_bAllocated(TRUE), m_pErrors(NULL) { xnEnumerationErrorsAllocate(&m_pErrors); }
8413 
8421  inline EnumerationErrors(XnEnumerationErrors* pErrors, XnBool bOwn = FALSE) : m_bAllocated(bOwn), m_pErrors(pErrors) {}
8422 
8427 
8431  class Iterator
8432  {
8433  public:
8434  friend class EnumerationErrors;
8435 
8441  XnBool operator==(const Iterator& other) const
8442  {
8443  return m_it == other.m_it;
8444  }
8445 
8451  XnBool operator!=(const Iterator& other) const
8452  {
8453  return m_it != other.m_it;
8454  }
8455 
8461  {
8462  m_it = xnEnumerationErrorsGetNext(m_it);
8463  return *this;
8464  }
8465 
8470  inline Iterator operator++(int)
8471  {
8472  return Iterator(xnEnumerationErrorsGetNext(m_it));
8473  }
8474 
8484 
8490 
8491  private:
8492  inline Iterator(XnEnumerationErrorsIterator it) : m_it(it) {}
8493 
8495  };
8496 
8505  inline Iterator Begin() const { return Iterator(xnEnumerationErrorsGetFirst(m_pErrors)); }
8506 
8515  inline Iterator End() const { return Iterator(NULL); }
8516 
8525  inline XnStatus ToString(XnChar* csBuffer, XnUInt32 nSize)
8526  {
8527  return xnEnumerationErrorsToString(m_pErrors, csBuffer, nSize);
8528  }
8529 
8534  inline void Free()
8535  {
8536  if (m_bAllocated)
8537  {
8538  xnEnumerationErrorsFree(m_pErrors);
8539  m_pErrors = NULL;
8540  m_bAllocated = FALSE;
8541  }
8542  }
8543 
8547  inline XnEnumerationErrors* GetUnderlying() { return m_pErrors; }
8548 
8549  private:
8550  XnEnumerationErrors* m_pErrors;
8551  XnBool m_bAllocated;
8552  };
8553 
8554  //---------------------------------------------------------------------------
8555  // Context
8556  //---------------------------------------------------------------------------
8557 
8593  class Context
8594  {
8595  public:
8610  typedef void (XN_CALLBACK_TYPE* NodeCreationHandler)(Context& context, ProductionNode& createdNode, void* pCookie);
8611 
8626  typedef void (XN_CALLBACK_TYPE* NodeDestructionHandler)(Context& context, const XnChar* strDestroyedNodeName, void* pCookie);
8627 
8631  inline Context() : m_pContext(NULL), m_bUsingDeprecatedAPI(FALSE), m_bAllocated(FALSE), m_hShuttingDownCallback(NULL) {}
8632 
8638  inline Context(XnContext* pContext) : m_pContext(NULL), m_bUsingDeprecatedAPI(FALSE), m_bAllocated(FALSE), m_hShuttingDownCallback(NULL)
8639  {
8640  SetHandle(pContext);
8641  }
8642 
8649  inline Context(const Context& other) : m_pContext(NULL), m_bUsingDeprecatedAPI(FALSE), m_bAllocated(FALSE), m_hShuttingDownCallback(NULL)
8650  {
8651  SetHandle(other.m_pContext);
8652  }
8653 
8658  {
8659  SetHandle(NULL);
8660  }
8661 
8662  inline Context& operator=(const Context& other)
8663  {
8664  SetHandle(other.m_pContext);
8665  return *this;
8666  }
8667 
8671  inline XnContext* GetUnderlyingObject() const { return m_pContext; }
8672 
8678  inline XnBool operator==(const Context& other)
8679  {
8680  return (GetUnderlyingObject() == other.GetUnderlyingObject());
8681  }
8682 
8688  inline XnBool operator!=(const Context& other)
8689  {
8690  return (GetUnderlyingObject() != other.GetUnderlyingObject());
8691  }
8692 
8707  inline XnStatus Init()
8708  {
8709  XnContext* pContext = NULL;
8710  XnStatus nRetVal = xnInit(&pContext);
8711  XN_IS_STATUS_OK(nRetVal);
8712 
8713  TakeOwnership(pContext);
8714  m_bAllocated = TRUE;
8715 
8716  return (XN_STATUS_OK);
8717  }
8718 
8734  inline XnStatus RunXmlScript(const XnChar* strScript, ScriptNode& scriptNode, EnumerationErrors* pErrors = NULL)
8735  {
8736  XnStatus nRetVal = XN_STATUS_OK;
8737 
8738  XnNodeHandle hScriptNode;
8739  nRetVal = xnContextRunXmlScriptEx(m_pContext, strScript, pErrors == NULL ? NULL : pErrors->GetUnderlying(), &hScriptNode);
8740  XN_IS_STATUS_OK(nRetVal);
8741 
8742  scriptNode.TakeOwnership(hScriptNode);
8743 
8744  return (XN_STATUS_OK);
8745  }
8746 
8762  inline XnStatus RunXmlScriptFromFile(const XnChar* strFileName, ScriptNode& scriptNode, EnumerationErrors* pErrors = NULL)
8763  {
8764  XnStatus nRetVal = XN_STATUS_OK;
8765 
8766  XnNodeHandle hScriptNode;
8767  nRetVal = xnContextRunXmlScriptFromFileEx(m_pContext, strFileName, pErrors == NULL ? NULL : pErrors->GetUnderlying(), &hScriptNode);
8768  XN_IS_STATUS_OK(nRetVal);
8769 
8770  scriptNode.TakeOwnership(hScriptNode);
8771 
8772  return (XN_STATUS_OK);
8773  }
8774 
8790  inline XnStatus InitFromXmlFile(const XnChar* strFileName, ScriptNode& scriptNode, EnumerationErrors* pErrors = NULL)
8791  {
8792  XnContext* pContext = NULL;
8793 
8794  XnNodeHandle hScriptNode;
8795  XnStatus nRetVal = xnInitFromXmlFileEx(strFileName, &pContext, pErrors == NULL ? NULL : pErrors->GetUnderlying(), &hScriptNode);
8796  XN_IS_STATUS_OK(nRetVal);
8797 
8798  scriptNode.TakeOwnership(hScriptNode);
8799  TakeOwnership(pContext);
8800  m_bAllocated = TRUE;
8801 
8802  return (XN_STATUS_OK);
8803  }
8804 
8821  inline XnStatus OpenFileRecording(const XnChar* strFileName, ProductionNode& playerNode)
8822  {
8823  XnStatus nRetVal = XN_STATUS_OK;
8824 
8825  XnNodeHandle hPlayer;
8826  nRetVal = xnContextOpenFileRecordingEx(m_pContext, strFileName, &hPlayer);
8827  XN_IS_STATUS_OK(nRetVal);
8828 
8829  playerNode.TakeOwnership(hPlayer);
8830 
8831  return (XN_STATUS_OK);
8832  }
8833 
8838  inline XnStatus CreateMockNode(XnProductionNodeType type, const XnChar* strName, ProductionNode& mockNode)
8839  {
8840  XnStatus nRetVal = XN_STATUS_OK;
8841 
8842  XnNodeHandle hMockNode;
8843  nRetVal = xnCreateMockNode(m_pContext, type, strName, &hMockNode);
8844  XN_IS_STATUS_OK(nRetVal);
8845 
8846  mockNode.TakeOwnership(hMockNode);
8847 
8848  return (XN_STATUS_OK);
8849  }
8850 
8855  inline XnStatus CreateMockNodeBasedOn(ProductionNode& originalNode, const XnChar* strName, ProductionNode& mockNode)
8856  {
8857  XnStatus nRetVal = XN_STATUS_OK;
8858 
8859  XnNodeHandle hMockNode;
8860  nRetVal = xnCreateMockNodeBasedOn(m_pContext, originalNode, strName, &hMockNode);
8861  XN_IS_STATUS_OK(nRetVal);
8862 
8863  mockNode.TakeOwnership(hMockNode);
8864 
8865  return (XN_STATUS_OK);
8866  }
8867 
8872  inline XnStatus CreateCodec(XnCodecID codecID, ProductionNode& initializerNode, Codec& codec)
8873  {
8874  XnStatus nRetVal = XN_STATUS_OK;
8875 
8876  XnNodeHandle hCodec;
8877  nRetVal = xnCreateCodec(m_pContext, codecID, initializerNode.GetHandle(), &hCodec);
8878  XN_IS_STATUS_OK(nRetVal);
8879 
8880  codec.TakeOwnership(hCodec);
8881 
8882  return (XN_STATUS_OK);
8883  }
8884 
8889  inline XnStatus AddRef()
8890  {
8891  return xnContextAddRef(m_pContext);
8892  }
8893 
8898  inline void Release()
8899  {
8900  SetHandle(NULL);
8901  }
8902 
8903 
8908  inline XnStatus AddLicense(const XnLicense& License)
8909  {
8910  return xnAddLicense(m_pContext, &License);
8911  }
8912 
8917  inline XnStatus EnumerateLicenses(XnLicense*& aLicenses, XnUInt32& nCount) const
8918  {
8919  return xnEnumerateLicenses(m_pContext, &aLicenses, &nCount);
8920  }
8921 
8926  inline static void FreeLicensesList(XnLicense aLicenses[])
8927  {
8928  xnFreeLicensesList(aLicenses);
8929  }
8930 
8951  XnStatus EnumerateProductionTrees(XnProductionNodeType Type, const Query* pQuery, NodeInfoList& TreesList, EnumerationErrors* pErrors = NULL) const
8952  {
8953  XnStatus nRetVal = XN_STATUS_OK;
8954 
8955  const XnNodeQuery* pInternalQuery = (pQuery != NULL) ? pQuery->GetUnderlyingObject() : NULL;
8956 
8957  XnNodeInfoList* pList = NULL;
8958  nRetVal = xnEnumerateProductionTrees(m_pContext, Type, pInternalQuery, &pList, pErrors == NULL ? NULL : pErrors->GetUnderlying());
8959  XN_IS_STATUS_OK(nRetVal);
8960 
8961  TreesList.ReplaceUnderlyingObject(pList);
8962 
8963  return (XN_STATUS_OK);
8964  }
8965 
8999  {
9000  XnStatus nRetVal = XN_STATUS_OK;
9001 
9002  XnNodeQuery* pInternalQuery = (pQuery != NULL) ? pQuery->GetUnderlyingObject() : NULL;
9003 
9004  XnNodeHandle hNode;
9005  nRetVal = xnCreateAnyProductionTree(m_pContext, type, pInternalQuery, &hNode, pErrors == NULL ? NULL : pErrors->GetUnderlying());
9006  XN_IS_STATUS_OK(nRetVal);
9007 
9008  node.TakeOwnership(hNode);
9009 
9010  return (XN_STATUS_OK);
9011  }
9012 
9030  {
9031  XnStatus nRetVal = XN_STATUS_OK;
9032 
9033  XnNodeHandle hNode;
9034  nRetVal = xnCreateProductionTree(m_pContext, Tree, &hNode);
9035  XN_IS_STATUS_OK(nRetVal);
9036 
9037  node.TakeOwnership(hNode);
9038 
9039  return (XN_STATUS_OK);
9040  }
9041 
9051  {
9052  XnNodeInfoList* pList;
9053  XnStatus nRetVal = xnEnumerateExistingNodes(m_pContext, &pList);
9054  XN_IS_STATUS_OK(nRetVal);
9055 
9056  list.ReplaceUnderlyingObject(pList);
9057 
9058  return (XN_STATUS_OK);
9059  }
9060 
9080  {
9081  XnNodeInfoList* pList;
9082  XnStatus nRetVal = xnEnumerateExistingNodesByType(m_pContext, type, &pList);
9083  XN_IS_STATUS_OK(nRetVal);
9084 
9085  list.ReplaceUnderlyingObject(pList);
9086 
9087  return (XN_STATUS_OK);
9088  }
9089 
9109  {
9110  XnStatus nRetVal = XN_STATUS_OK;
9111 
9112  XnNodeHandle hNode;
9113  nRetVal = xnFindExistingRefNodeByType(m_pContext, type, &hNode);
9114  XN_IS_STATUS_OK(nRetVal);
9115 
9116  node.TakeOwnership(hNode);
9117 
9118  return (XN_STATUS_OK);
9119  }
9120 
9125  XnStatus GetProductionNodeByName(const XnChar* strInstanceName, ProductionNode& node) const
9126  {
9127  XnStatus nRetVal = XN_STATUS_OK;
9128 
9129  XnNodeHandle hNode;
9130  nRetVal = xnGetRefNodeHandleByName(m_pContext, strInstanceName, &hNode);
9131  XN_IS_STATUS_OK(nRetVal);
9132 
9133  node.TakeOwnership(hNode);
9134 
9135  return (XN_STATUS_OK);
9136  }
9137 
9142  XnStatus GetProductionNodeInfoByName(const XnChar* strInstanceName, NodeInfo& nodeInfo) const
9143  {
9144  XnStatus nRetVal = XN_STATUS_OK;
9145 
9146  XnNodeHandle hNode;
9147  nRetVal = xnGetRefNodeHandleByName(m_pContext, strInstanceName, &hNode);
9148  XN_IS_STATUS_OK(nRetVal);
9149 
9150  xnProductionNodeRelease(hNode);
9151 
9152  nodeInfo = NodeInfo(xnGetNodeInfo(hNode));
9153 
9154  return (XN_STATUS_OK);
9155  }
9156 
9162  {
9163  return xnStartGeneratingAll(m_pContext);
9164  }
9165 
9170  {
9171  return xnStopGeneratingAll(m_pContext);
9172  }
9173 
9183  inline XnStatus SetGlobalMirror(XnBool bMirror)
9184  {
9185  return xnSetGlobalMirror(m_pContext, bMirror);
9186  }
9187 
9192  inline XnBool GetGlobalMirror()
9193  {
9194  return xnGetGlobalMirror(m_pContext);
9195  }
9196 
9202  {
9203  return xnGetGlobalErrorState(m_pContext);
9204  }
9205 
9216  {
9217  return xnRegisterToGlobalErrorStateChange(m_pContext, handler, pCookie, &hCallback);
9218  }
9219 
9228  {
9229  xnUnregisterFromGlobalErrorStateChange(m_pContext, hCallback);
9230  }
9231 
9241  inline XnStatus RegisterToNodeCreation(NodeCreationHandler handler, void* pCookie, XnCallbackHandle& hCallback)
9242  {
9243  XnStatus nRetVal = XN_STATUS_OK;
9244 
9245  NodeCreationCookie* pCreationCookie;
9246  XN_VALIDATE_ALLOC(pCreationCookie, NodeCreationCookie);
9247  pCreationCookie->pFunc = handler;
9248  pCreationCookie->pCookie = pCookie;
9249 
9250  nRetVal = xnRegisterToNodeCreation(m_pContext, NodeCreationCallback, pCreationCookie, &pCreationCookie->hUnderlyingCallback);
9251  XN_IS_STATUS_OK(nRetVal);
9252 
9253  hCallback = pCreationCookie;
9254 
9255  return XN_STATUS_OK;
9256  }
9257 
9266  {
9267  NodeCreationCookie* pCreationCookie = (NodeCreationCookie*)hCallback;
9268  xnUnregisterFromNodeCreation(m_pContext, pCreationCookie->hUnderlyingCallback);
9269  xnOSFree(pCreationCookie);
9270  }
9271 
9282  {
9283  XnStatus nRetVal = XN_STATUS_OK;
9284 
9285  NodeDestructionCookie* pDestructionCookie;
9286  XN_VALIDATE_ALLOC(pDestructionCookie, NodeDestructionCookie);
9287  pDestructionCookie->pFunc = handler;
9288  pDestructionCookie->pCookie = pCookie;
9289 
9290  nRetVal = xnRegisterToNodeDestruction(m_pContext, NodeDestructionCallback, pDestructionCookie, &pDestructionCookie->hUnderlyingCallback);
9291  XN_IS_STATUS_OK(nRetVal);
9292 
9293  hCallback = pDestructionCookie;
9294 
9295  return XN_STATUS_OK;
9296  }
9297 
9306  {
9307  NodeDestructionCookie* pDestructionCookie = (NodeDestructionCookie*)hCallback;
9308  xnUnregisterFromNodeDestruction(m_pContext, pDestructionCookie->hUnderlyingCallback);
9309  xnOSFree(pDestructionCookie);
9310  }
9311 
9346  {
9347  return xnWaitAndUpdateAll(m_pContext);
9348  }
9349 
9385  {
9386  return xnWaitAnyUpdateAll(m_pContext);
9387  }
9388 
9420  {
9421  return xnWaitOneUpdateAll(m_pContext, node.GetHandle());
9422  }
9423 
9446  {
9447  return xnWaitNoneUpdateAll(m_pContext);
9448  }
9449 
9454  inline XnStatus AutoEnumerateOverSingleInput(NodeInfoList& List, XnProductionNodeDescription& description, const XnChar* strCreationInfo, XnProductionNodeType InputType, EnumerationErrors* pErrors, Query* pQuery = NULL) const
9455  {
9456  return xnAutoEnumerateOverSingleInput(m_pContext, List.GetUnderlyingObject(), &description, strCreationInfo, InputType, pErrors == NULL ? NULL : pErrors->GetUnderlying(), pQuery == NULL ? NULL : pQuery->GetUnderlyingObject());
9457  }
9458 
9462  inline void SetHandle(XnContext* pContext)
9463  {
9464  if (m_pContext == pContext)
9465  {
9466  return;
9467  }
9468 
9469  if (m_pContext != NULL)
9470  {
9471  if (m_bUsingDeprecatedAPI && m_bAllocated)
9472  {
9473  // Backwards compatibility: call shutdown instead of release, to make old programs get the
9474  // exact same behavior they used to have.
9475  xnForceShutdown(m_pContext);
9476  }
9477  else
9478  {
9479  xnContextUnregisterFromShutdown(m_pContext, m_hShuttingDownCallback);
9480  xnContextRelease(m_pContext);
9481  }
9482  }
9483 
9484  if (pContext != NULL)
9485  {
9486  XnStatus nRetVal = xnContextAddRef(pContext);
9487  XN_ASSERT(nRetVal == XN_STATUS_OK);
9488  XN_REFERENCE_VARIABLE(nRetVal);
9489 
9490  nRetVal = xnContextRegisterForShutdown(pContext, ContextShuttingDownCallback, this, &m_hShuttingDownCallback);
9491  XN_ASSERT(nRetVal == XN_STATUS_OK);
9492  }
9493 
9494  m_pContext = pContext;
9495  }
9496 
9497  inline void TakeOwnership(XnContext* pContext)
9498  {
9499  SetHandle(pContext);
9500 
9501  if (pContext != NULL)
9502  {
9503  xnContextRelease(pContext);
9504  }
9505  }
9506 
9508  inline XnStatus XN_API_DEPRECATED("Use other overload!") RunXmlScript(const XnChar* strScript, EnumerationErrors* pErrors = NULL)
9509  {
9510  m_bUsingDeprecatedAPI = TRUE;
9511  #pragma warning (push)
9512  #pragma warning (disable: XN_DEPRECATED_WARNING_IDS)
9513  return xnContextRunXmlScript(m_pContext, strScript, pErrors == NULL ? NULL : pErrors->GetUnderlying());
9514  #pragma warning (pop)
9515  }
9516 
9517  inline XnStatus XN_API_DEPRECATED("Use other overload!") RunXmlScriptFromFile(const XnChar* strFileName, EnumerationErrors* pErrors = NULL)
9518  {
9519  m_bUsingDeprecatedAPI = TRUE;
9520  #pragma warning (push)
9521  #pragma warning (disable: XN_DEPRECATED_WARNING_IDS)
9522  return xnContextRunXmlScriptFromFile(m_pContext, strFileName, pErrors == NULL ? NULL : pErrors->GetUnderlying());
9523  #pragma warning (pop)
9524  }
9525 
9526  inline XnStatus XN_API_DEPRECATED("Use other overload!") InitFromXmlFile(const XnChar* strFileName, EnumerationErrors* pErrors = NULL)
9527  {
9528  XnContext* pContext = NULL;
9529  m_bUsingDeprecatedAPI = TRUE;
9530 
9531  #pragma warning (push)
9532  #pragma warning (disable: XN_DEPRECATED_WARNING_IDS)
9533  XnStatus nRetVal = xnInitFromXmlFile(strFileName, &pContext, pErrors == NULL ? NULL : pErrors->GetUnderlying());
9534  #pragma warning (pop)
9535  XN_IS_STATUS_OK(nRetVal);
9536 
9537  TakeOwnership(pContext);
9538  m_bAllocated = TRUE;
9539 
9540  return (XN_STATUS_OK);
9541  }
9542 
9543  inline XnStatus XN_API_DEPRECATED("Use other overload!") OpenFileRecording(const XnChar* strFileName)
9544  {
9545  m_bUsingDeprecatedAPI = TRUE;
9546  #pragma warning (push)
9547  #pragma warning (disable: XN_DEPRECATED_WARNING_IDS)
9548  return xnContextOpenFileRecording(m_pContext, strFileName);
9549  #pragma warning (pop)
9550  }
9551 
9552  inline void XN_API_DEPRECATED("You may use Release() instead, or count on dtor") Shutdown()
9553  {
9554  if (m_pContext != NULL)
9555  {
9556  #pragma warning (push)
9557  #pragma warning (disable: XN_DEPRECATED_WARNING_IDS)
9558  xnShutdown(m_pContext);
9559  #pragma warning (pop)
9560  m_pContext = NULL;
9561  }
9562  }
9563 
9564  XnStatus XN_API_DEPRECATED("Please use other overload") CreateProductionTree(NodeInfo& Tree)
9565  {
9566  XnStatus nRetVal = XN_STATUS_OK;
9567 
9568  XnNodeHandle hNode;
9569  nRetVal = xnCreateProductionTree(m_pContext, Tree, &hNode);
9570  XN_IS_STATUS_OK(nRetVal);
9571 
9572  Tree.m_bOwnerOfNode = TRUE;
9573 
9574  return (XN_STATUS_OK);
9575  }
9578  private:
9579  typedef struct NodeCreationCookie
9580  {
9581  NodeCreationHandler pFunc;
9582  void* pCookie;
9583  XnCallbackHandle hUnderlyingCallback;
9584  } NodeCreationCookie;
9585 
9586  typedef struct NodeDestructionCookie
9587  {
9588  NodeDestructionHandler pFunc;
9589  void* pCookie;
9590  XnCallbackHandle hUnderlyingCallback;
9591  } NodeDestructionCookie;
9592 
9593  static void XN_CALLBACK_TYPE NodeCreationCallback(XnContext* pContext, XnNodeHandle hCreatedNode, void* pCookie)
9594  {
9595  NodeCreationCookie* pNodeCreationCookie = (NodeCreationCookie*)pCookie;
9596  Context context(pContext);
9597  ProductionNode createdNode(hCreatedNode);
9598  pNodeCreationCookie->pFunc(context, createdNode, pNodeCreationCookie->pCookie);
9599  }
9600 
9601  static void XN_CALLBACK_TYPE NodeDestructionCallback(XnContext* pContext, const XnChar* strDestroyedNodeName, void* pCookie)
9602  {
9603  NodeDestructionCookie* pNodeCreationCookie = (NodeDestructionCookie*)pCookie;
9604  Context context(pContext);
9605  pNodeCreationCookie->pFunc(context, strDestroyedNodeName, pNodeCreationCookie->pCookie);
9606  }
9607 
9608  static void XN_CALLBACK_TYPE ContextShuttingDownCallback(XnContext* /*pContext*/, void* pCookie)
9609  {
9610  Context* pThis = (Context*)pCookie;
9611  pThis->m_pContext = NULL;
9612  }
9613 
9614  XnContext* m_pContext;
9615  XnBool m_bUsingDeprecatedAPI;
9616  XnBool m_bAllocated;
9617  XnCallbackHandle m_hShuttingDownCallback;
9618  };
9619 
9625  {
9626  public:
9632  inline Resolution(XnResolution res) : m_Res(res)
9633  {
9634  m_nXRes = xnResolutionGetXRes(res);
9635  m_nYRes = xnResolutionGetYRes(res);
9636  m_strName = xnResolutionGetName(res);
9637  }
9638 
9645  inline Resolution(XnUInt32 xRes, XnUInt32 yRes) : m_nXRes(xRes), m_nYRes(yRes)
9646  {
9647  m_Res = xnResolutionGetFromXYRes(xRes, yRes);
9648  m_strName = xnResolutionGetName(m_Res);
9649  }
9650 
9656  inline Resolution(const XnChar* strName)
9657  {
9658  m_Res = xnResolutionGetFromName(strName);
9659  m_nXRes = xnResolutionGetXRes(m_Res);
9660  m_nYRes = xnResolutionGetYRes(m_Res);
9661  m_strName = xnResolutionGetName(m_Res);
9662  }
9663 
9667  inline XnResolution GetResolution() const { return m_Res; }
9671  inline XnUInt32 GetXResolution() const { return m_nXRes; }
9675  inline XnUInt32 GetYResolution() const { return m_nYRes; }
9679  inline const XnChar* GetName() const { return m_strName; }
9680 
9681  private:
9682  XnResolution m_Res;
9683  XnUInt32 m_nXRes;
9684  XnUInt32 m_nYRes;
9685  const XnChar* m_strName;
9686  };
9687 
9688  //---------------------------------------------------------------------------
9689  // Functions Implementation
9690  //---------------------------------------------------------------------------
9692  {
9693  return xnNodeQueryFilterList(context.GetUnderlyingObject(), query.GetUnderlyingObject(), m_pList);
9694  }
9695 
9696  inline void ProductionNode::GetContext(Context& context) const
9697  {
9699  }
9700 
9702  {
9704  Context result(pContext);
9705  xnContextRelease(pContext);
9706  return result;
9707  }
9708 
9710  {
9711  if (m_pNeededNodes == NULL)
9712  {
9713  XnNodeInfoList* pList = xnNodeInfoGetNeededNodes(m_pInfo);
9714  m_pNeededNodes = XN_NEW(NodeInfoList, pList);
9715  }
9716 
9717  return *m_pNeededNodes;
9718  }
9719 
9720  inline void NodeInfo::SetUnderlyingObject(XnNodeInfo* pInfo)
9721  {
9722  if (m_pNeededNodes != NULL)
9723  {
9724  XN_DELETE(m_pNeededNodes);
9725  }
9726 
9727  m_bOwnerOfNode = FALSE;
9728  m_pInfo = pInfo;
9729  m_pNeededNodes = NULL;
9730  }
9731 
9733  {
9734  return xnCanFrameSyncWith(GetHandle(), other.GetHandle());
9735  }
9736 
9738  {
9739  return xnFrameSyncWith(GetHandle(), other.GetHandle());
9740  }
9741 
9743  {
9744  return xnStopFrameSyncWith(GetHandle(), other.GetHandle());
9745  }
9746 
9748  {
9749  return xnIsFrameSyncedWith(GetHandle(), other.GetHandle());
9750  }
9751 
9753  {
9754  if (m_pInfo == NULL)
9755  {
9756  return XN_STATUS_INVALID_OPERATION;
9757  }
9758 
9759  XnNodeHandle hNode = xnNodeInfoGetRefHandle(m_pInfo);
9760  node.TakeOwnership(hNode);
9761 
9762  if (m_bOwnerOfNode)
9763  {
9764  xnProductionNodeRelease(hNode);
9765  }
9766 
9767  return (XN_STATUS_OK);
9768  }
9769 
9770  //---------------------------------------------------------------------------
9771  // Node creation functions
9772  //---------------------------------------------------------------------------
9773 
9774  inline XnStatus Device::Create(Context& context, Query* pQuery/*=NULL*/, EnumerationErrors* pErrors/*=NULL*/)
9775  {
9776  XnNodeHandle hNode;
9777  XnStatus nRetVal = xnCreateDevice(context.GetUnderlyingObject(), &hNode, pQuery == NULL ? NULL : pQuery->GetUnderlyingObject(), pErrors == NULL ? NULL : pErrors->GetUnderlying());
9778  XN_IS_STATUS_OK(nRetVal);
9779  TakeOwnership(hNode);
9780  return (XN_STATUS_OK);
9781  }
9782 
9783  inline XnStatus Recorder::Create(Context& context, const XnChar* strFormatName /*= NULL*/)
9784  {
9785  XnNodeHandle hNode;
9786  XnStatus nRetVal = xnCreateRecorder(context.GetUnderlyingObject(), strFormatName, &hNode);
9787  XN_IS_STATUS_OK(nRetVal);
9788  TakeOwnership(hNode);
9789  return (XN_STATUS_OK);
9790  }
9791 
9792  inline XnStatus Player::Create(Context& context, const XnChar* strFormatName)
9793  {
9794  XnNodeHandle hNode;
9795  XnStatus nRetVal = xnCreatePlayer(context.GetUnderlyingObject(), strFormatName, &hNode);
9796  XN_IS_STATUS_OK(nRetVal);
9797  TakeOwnership(hNode);
9798  return (XN_STATUS_OK);
9799  }
9800 
9801  inline XnStatus DepthGenerator::Create(Context& context, Query* pQuery/*=NULL*/, EnumerationErrors* pErrors/*=NULL*/)
9802  {
9803  XnNodeHandle hNode;
9804  XnStatus nRetVal = xnCreateDepthGenerator(context.GetUnderlyingObject(), &hNode, pQuery == NULL ? NULL : pQuery->GetUnderlyingObject(), pErrors == NULL ? NULL : pErrors->GetUnderlying());
9805  XN_IS_STATUS_OK(nRetVal);
9806  TakeOwnership(hNode);
9807  return (XN_STATUS_OK);
9808  }
9809 
9810  inline XnStatus MockDepthGenerator::Create(Context& context, const XnChar* strName /* = NULL */)
9811  {
9812  XnNodeHandle hNode;
9813  XnStatus nRetVal = xnCreateMockNode(context.GetUnderlyingObject(), XN_NODE_TYPE_DEPTH, strName, &hNode);
9814  XN_IS_STATUS_OK(nRetVal);
9815  TakeOwnership(hNode);
9816  return (XN_STATUS_OK);
9817  }
9818 
9819  inline XnStatus MockDepthGenerator::CreateBasedOn(DepthGenerator& other, const XnChar* strName /* = NULL */)
9820  {
9821  Context context;
9822  other.GetContext(context);
9823  XnNodeHandle hNode;
9824  XnStatus nRetVal = xnCreateMockNodeBasedOn(context.GetUnderlyingObject(), other.GetHandle(), strName, &hNode);
9825  XN_IS_STATUS_OK(nRetVal);
9826  TakeOwnership(hNode);
9827  return (XN_STATUS_OK);
9828  }
9829 
9830  inline XnStatus ImageGenerator::Create(Context& context, Query* pQuery/*=NULL*/, EnumerationErrors* pErrors/*=NULL*/)
9831  {
9832  XnNodeHandle hNode;
9833  XnStatus nRetVal = xnCreateImageGenerator(context.GetUnderlyingObject(), &hNode, pQuery == NULL ? NULL : pQuery->GetUnderlyingObject(), pErrors == NULL ? NULL : pErrors->GetUnderlying());
9834  XN_IS_STATUS_OK(nRetVal);
9835  TakeOwnership(hNode);
9836  return (XN_STATUS_OK);
9837  }
9838 
9839  inline XnStatus MockImageGenerator::Create(Context& context, const XnChar* strName /* = NULL */)
9840  {
9841  XnNodeHandle hNode;
9842  XnStatus nRetVal = xnCreateMockNode(context.GetUnderlyingObject(), XN_NODE_TYPE_IMAGE, strName, &hNode);
9843  XN_IS_STATUS_OK(nRetVal);
9844  TakeOwnership(hNode);
9845  return (XN_STATUS_OK);
9846  }
9847 
9848  inline XnStatus MockImageGenerator::CreateBasedOn(ImageGenerator& other, const XnChar* strName /* = NULL */)
9849  {
9850  Context context;
9851  other.GetContext(context);
9852  XnNodeHandle hNode;
9853  XnStatus nRetVal = xnCreateMockNodeBasedOn(context.GetUnderlyingObject(), other.GetHandle(), strName, &hNode);
9854  XN_IS_STATUS_OK(nRetVal);
9855  TakeOwnership(hNode);
9856  return (XN_STATUS_OK);
9857  }
9858 
9859  inline XnStatus IRGenerator::Create(Context& context, Query* pQuery/*=NULL*/, EnumerationErrors* pErrors/*=NULL*/)
9860  {
9861  XnNodeHandle hNode;
9862  XnStatus nRetVal = xnCreateIRGenerator(context.GetUnderlyingObject(), &hNode, pQuery == NULL ? NULL : pQuery->GetUnderlyingObject(), pErrors == NULL ? NULL : pErrors->GetUnderlying());
9863  XN_IS_STATUS_OK(nRetVal);
9864  TakeOwnership(hNode);
9865  return (XN_STATUS_OK);
9866  }
9867 
9868  inline XnStatus MockIRGenerator::Create(Context& context, const XnChar* strName /* = NULL */)
9869  {
9870  XnNodeHandle hNode;
9871  XnStatus nRetVal = xnCreateMockNode(context.GetUnderlyingObject(), XN_NODE_TYPE_IR, strName, &hNode);
9872  XN_IS_STATUS_OK(nRetVal);
9873  TakeOwnership(hNode);
9874  return (XN_STATUS_OK);
9875  }
9876 
9877  inline XnStatus MockIRGenerator::CreateBasedOn(IRGenerator& other, const XnChar* strName /* = NULL */)
9878  {
9879  Context context;
9880  other.GetContext(context);
9881  XnNodeHandle hNode;
9882  XnStatus nRetVal = xnCreateMockNodeBasedOn(context.GetUnderlyingObject(), other.GetHandle(), strName, &hNode);
9883  XN_IS_STATUS_OK(nRetVal);
9884  TakeOwnership(hNode);
9885  return (XN_STATUS_OK);
9886  }
9887 
9888  inline XnStatus GestureGenerator::Create(Context& context, Query* pQuery/*=NULL*/, EnumerationErrors* pErrors/*=NULL*/)
9889  {
9890  XnNodeHandle hNode;
9891  XnStatus nRetVal = xnCreateGestureGenerator(context.GetUnderlyingObject(), &hNode, pQuery == NULL ? NULL : pQuery->GetUnderlyingObject(), pErrors == NULL ? NULL : pErrors->GetUnderlying());
9892  XN_IS_STATUS_OK(nRetVal);
9893  TakeOwnership(hNode);
9894  return (XN_STATUS_OK);
9895  }
9896 
9897  inline XnStatus SceneAnalyzer::Create(Context& context, Query* pQuery/*=NULL*/, EnumerationErrors* pErrors/*=NULL*/)
9898  {
9899  //You're creating a scene!
9900  XnNodeHandle hNode;
9901  XnStatus nRetVal = xnCreateSceneAnalyzer(context.GetUnderlyingObject(), &hNode, pQuery == NULL ? NULL : pQuery->GetUnderlyingObject(), pErrors == NULL ? NULL : pErrors->GetUnderlying());
9902  XN_IS_STATUS_OK(nRetVal);
9903  TakeOwnership(hNode);
9904  return (XN_STATUS_OK);
9905  }
9906 
9907  inline XnStatus HandsGenerator::Create(Context& context, Query* pQuery/*=NULL*/, EnumerationErrors* pErrors/*=NULL*/)
9908  {
9909  XnNodeHandle hNode;
9910  XnStatus nRetVal = xnCreateHandsGenerator(context.GetUnderlyingObject(), &hNode, pQuery == NULL ? NULL : pQuery->GetUnderlyingObject(), pErrors == NULL ? NULL : pErrors->GetUnderlying());
9911  XN_IS_STATUS_OK(nRetVal);
9912  TakeOwnership(hNode);
9913  return (XN_STATUS_OK);
9914  }
9915 
9916  inline XnStatus UserGenerator::Create(Context& context, Query* pQuery/*=NULL*/, EnumerationErrors* pErrors/*=NULL*/)
9917  {
9918  XnNodeHandle hNode;
9919  XnStatus nRetVal = xnCreateUserGenerator(context.GetUnderlyingObject(), &hNode, pQuery == NULL ? NULL : pQuery->GetUnderlyingObject(), pErrors == NULL ? NULL : pErrors->GetUnderlying());
9920  XN_IS_STATUS_OK(nRetVal);
9921  TakeOwnership(hNode);
9922  return (XN_STATUS_OK);
9923  }
9924 
9925  inline XnStatus AudioGenerator::Create(Context& context, Query* pQuery/*=NULL*/, EnumerationErrors* pErrors/*=NULL*/)
9926  {
9927  XnNodeHandle hNode;
9928  XnStatus nRetVal = xnCreateAudioGenerator(context.GetUnderlyingObject(), &hNode, pQuery == NULL ? NULL : pQuery->GetUnderlyingObject(), pErrors == NULL ? NULL : pErrors->GetUnderlying());
9929  XN_IS_STATUS_OK(nRetVal);
9930  TakeOwnership(hNode);
9931  return (XN_STATUS_OK);
9932  }
9933 
9934  inline XnStatus MockAudioGenerator::Create(Context& context, const XnChar* strName /* = NULL */)
9935  {
9936  XnNodeHandle hNode;
9937  XnStatus nRetVal = xnCreateMockNode(context.GetUnderlyingObject(), XN_NODE_TYPE_AUDIO, strName, &hNode);
9938  XN_IS_STATUS_OK(nRetVal);
9939  TakeOwnership(hNode);
9940  return (XN_STATUS_OK);
9941  }
9942 
9943  inline XnStatus MockAudioGenerator::CreateBasedOn(AudioGenerator& other, const XnChar* strName /* = NULL */)
9944  {
9945  Context context;
9946  other.GetContext(context);
9947  XnNodeHandle hNode;
9948  XnStatus nRetVal = xnCreateMockNodeBasedOn(context.GetUnderlyingObject(), other.GetHandle(), strName, &hNode);
9949  XN_IS_STATUS_OK(nRetVal);
9950  TakeOwnership(hNode);
9951  return (XN_STATUS_OK);
9952  }
9953 
9954  inline XnStatus MockRawGenerator::Create(Context& context, const XnChar* strName /*= NULL*/)
9955  {
9956  XnNodeHandle hNode;
9957  XnStatus nRetVal = xnCreateMockNode(context.GetUnderlyingObject(), XN_NODE_TYPE_GENERATOR, strName, &hNode);
9958  XN_IS_STATUS_OK(nRetVal);
9959  TakeOwnership(hNode);
9960  return (XN_STATUS_OK);
9961  }
9962 
9963  inline XnStatus Codec::Create(Context& context, XnCodecID codecID, ProductionNode& initializerNode)
9964  {
9965  XnNodeHandle hNode;
9966  XnStatus nRetVal = xnCreateCodec(context.GetUnderlyingObject(), codecID, initializerNode.GetHandle(), &hNode);
9967  XN_IS_STATUS_OK(nRetVal);
9968  TakeOwnership(hNode);
9969  return (XN_STATUS_OK);
9970  }
9971 
9973  {
9974  return xnScriptNodeRun(GetHandle(), pErrors == NULL ? NULL : pErrors->GetUnderlying());
9975  }
9976 
9977  inline XnStatus ScriptNode::Create(Context& context, const XnChar* strFormat)
9978  {
9979  XnNodeHandle hNode;
9980  XnStatus nRetVal = xnCreateScriptNode(context.GetUnderlyingObject(), strFormat, &hNode);
9981  XN_IS_STATUS_OK(nRetVal);
9982  TakeOwnership(hNode);
9983  return (XN_STATUS_OK);
9984  }
9985 
9986  //---------------------------------------------------------------------------
9987  // Global Helper Functions
9988  //---------------------------------------------------------------------------
9989 
9990  inline void XN_API_DEPRECATED("Use xn::Version::Current() instead") GetVersion(XnVersion& Version)
9991  {
9992  xnGetVersion(&Version);
9993  }
9994 
9995  //---------------------------------------------------------------------------
9996  // Internal Helper Classes and Functions
9997  //---------------------------------------------------------------------------
9998 
10000  {
10001  public:
10002  StateChangedCallbackTranslator(StateChangedHandler handler, void* pCookie) : m_UserHandler(handler), m_pUserCookie(pCookie), m_hCallback(NULL) {}
10003 
10004  XnStatus Register(_XnRegisterStateChangeFuncPtr xnFunc, XnNodeHandle hNode)
10005  {
10006  return xnFunc(hNode, StateChangedCallback, this, &m_hCallback);
10007  }
10008 
10009  void Unregister(_XnUnregisterStateChangeFuncPtr xnFunc, XnNodeHandle hNode)
10010  {
10011  xnFunc(hNode, m_hCallback);
10012  }
10013 
10014  static XnStatus RegisterToUnderlying(_XnRegisterStateChangeFuncPtr xnFunc, XnNodeHandle hNode, StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
10015  {
10016  XnStatus nRetVal = XN_STATUS_OK;
10017 
10019  XN_VALIDATE_NEW(pTrans, StateChangedCallbackTranslator, handler, pCookie);
10020 
10021  nRetVal = pTrans->Register(xnFunc, hNode);
10022  if (nRetVal != XN_STATUS_OK)
10023  {
10024  XN_DELETE(pTrans);
10025  return (nRetVal);
10026  }
10027 
10028  hCallback = pTrans;
10029 
10030  return (XN_STATUS_OK);
10031  }
10032 
10033  static XnStatus UnregisterFromUnderlying(_XnUnregisterStateChangeFuncPtr xnFunc, XnNodeHandle hNode, XnCallbackHandle hCallback)
10034  {
10036  pTrans->Unregister(xnFunc, hNode);
10037  XN_DELETE(pTrans);
10038  return XN_STATUS_OK;
10039  }
10040 
10041  private:
10042  friend class GeneralIntCapability;
10043 
10044  typedef struct StateChangeCookie
10045  {
10046  StateChangedHandler userHandler;
10047  void* pUserCookie;
10048  XnCallbackHandle hCallback;
10049  } StateChangeCookie;
10050 
10051  static void XN_CALLBACK_TYPE StateChangedCallback(XnNodeHandle hNode, void* pCookie)
10052  {
10054  ProductionNode node(hNode);
10055  pTrans->m_UserHandler(node, pTrans->m_pUserCookie);
10056  }
10057 
10058  StateChangedHandler m_UserHandler;
10059  void* m_pUserCookie;
10060  XnCallbackHandle m_hCallback;
10061  };
10062 
10063  static XnStatus _RegisterToStateChange(_XnRegisterStateChangeFuncPtr xnFunc, XnNodeHandle hNode, StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
10064  {
10065  return StateChangedCallbackTranslator::RegisterToUnderlying(xnFunc, hNode, handler, pCookie, hCallback);
10066  }
10067 
10068  static void _UnregisterFromStateChange(_XnUnregisterStateChangeFuncPtr xnFunc, XnNodeHandle hNode, XnCallbackHandle hCallback)
10069  {
10071  }
10072 
10074  {
10075  XnStatus nRetVal = XN_STATUS_OK;
10076 
10078  XN_VALIDATE_NEW(pTrans, StateChangedCallbackTranslator, handler, pCookie);
10079 
10080  nRetVal = xnRegisterToGeneralIntValueChange(GetHandle(), m_strCap, pTrans->StateChangedCallback, pTrans, &pTrans->m_hCallback);
10081  if (nRetVal != XN_STATUS_OK)
10082  {
10083  XN_DELETE(pTrans);
10084  return (nRetVal);
10085  }
10086 
10087  hCallback = pTrans;
10088 
10089  return (XN_STATUS_OK);
10090  }
10091 
10093  {
10095  xnUnregisterFromGeneralIntValueChange(GetHandle(), m_strCap, pTrans->m_hCallback);
10096  XN_DELETE(pTrans);
10097  }
10098 };
10099 
10100 #endif // __XN_CPP_WRAPPER_H__