OpenNI 1.5.7
XnCppWrapper.h
Go to the documentation of this file.
1 /*****************************************************************************
2 * *
3 * OpenNI 1.x Alpha *
4 * Copyright (C) 2012 PrimeSense Ltd. *
5 * *
6 * This file is part of OpenNI. *
7 * *
8 * Licensed under the Apache License, Version 2.0 (the "License"); *
9 * you may not use this file except in compliance with the License. *
10 * You may obtain a copy of the License at *
11 * *
12 * http://www.apache.org/licenses/LICENSE-2.0 *
13 * *
14 * Unless required by applicable law or agreed to in writing, software *
15 * distributed under the License is distributed on an "AS IS" BASIS, *
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
17 * See the License for the specific language governing permissions and *
18 * limitations under the License. *
19 * *
20 *****************************************************************************/
21 #ifndef __XN_CPP_WRAPPER_H__
22 #define __XN_CPP_WRAPPER_H__
23 
24 //---------------------------------------------------------------------------
25 // Includes
26 //---------------------------------------------------------------------------
27 #include <XnOpenNI.h>
28 #include <XnCodecIDs.h>
29 
30 //---------------------------------------------------------------------------
31 // Types
32 //---------------------------------------------------------------------------
33 namespace xn
34 {
35  //---------------------------------------------------------------------------
36  // Forward Declarations
37  //---------------------------------------------------------------------------
38  class ProductionNode;
39  class EnumerationErrors;
40  class NodeInfo;
41  class NodeInfoList;
42  class Context;
43  class Query;
44  class Generator;
45 
71  //---------------------------------------------------------------------------
72  // Types
73  //---------------------------------------------------------------------------
74 
100  typedef void (XN_CALLBACK_TYPE* StateChangedHandler)(ProductionNode& node, void* pCookie);
101 
102  //---------------------------------------------------------------------------
103  // Internal stuff
104  //---------------------------------------------------------------------------
105  typedef XnStatus (*_XnRegisterStateChangeFuncPtr)(XnNodeHandle hNode, XnStateChangedHandler handler, void* pCookie, XnCallbackHandle* phCallback);
106  typedef void (*_XnUnregisterStateChangeFuncPtr)(XnNodeHandle hNode, XnCallbackHandle hCallback);
107 
108  static XnStatus _RegisterToStateChange(_XnRegisterStateChangeFuncPtr xnFunc, XnNodeHandle hNode, StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback);
109  static void _UnregisterFromStateChange(_XnUnregisterStateChangeFuncPtr xnFunc, XnNodeHandle hNode, XnCallbackHandle hCallback);
110 
111  //---------------------------------------------------------------------------
112  // Some Utilities
113  //---------------------------------------------------------------------------
118  class Version
119  {
120  public:
121  Version(const XnVersion& version) : m_version(version) {}
122  Version(XnUInt8 nMajor, XnUInt8 nMinor, XnUInt16 nMaintenance, XnUInt32 nBuild)
123  {
124  m_version.nMajor = nMajor;
125  m_version.nMinor = nMinor;
126  m_version.nMaintenance = nMaintenance;
127  m_version.nBuild = nBuild;
128  }
129 
130  bool operator==(const Version& other) const
131  {
132  return (xnVersionCompare(&m_version, &other.m_version) == 0);
133  }
134  bool operator!=(const Version& other) const
135  {
136  return (xnVersionCompare(&m_version, &other.m_version) != 0);
137  }
138  bool operator<(const Version& other) const
139  {
140  return (xnVersionCompare(&m_version, &other.m_version) < 0);
141  }
142  bool operator<=(const Version& other) const
143  {
144  return (xnVersionCompare(&m_version, &other.m_version) <= 0);
145  }
146  bool operator>(const Version& other) const
147  {
148  return (xnVersionCompare(&m_version, &other.m_version) > 0);
149  }
150  bool operator>=(const Version& other) const
151  {
152  return (xnVersionCompare(&m_version, &other.m_version) >= 0);
153  }
154 
155  static Version Current()
156  {
157  XnVersion version;
158  xnGetVersion(&version);
159  return Version(version);
160  }
161 
162  XnUInt8 Major() const { return m_version.nMajor; }
163  XnUInt8 Minor() const { return m_version.nMinor; }
164  XnUInt16 Maintenance() const { return m_version.nMaintenance; }
165  XnUInt32 Build() const { return m_version.nBuild; }
166 
167  XnUInt8& Major() { return m_version.nMajor; }
168  XnUInt8& Minor() { return m_version.nMinor; }
169  XnUInt16& Maintenance() { return m_version.nMaintenance; }
170  XnUInt32& Build() { return m_version.nBuild; }
171 
172  const XnVersion* GetUnderlying() const { return &m_version; }
173  XnVersion* GetUnderlying() { return &m_version; }
174 
175  private:
176  XnVersion m_version;
177  };
178 
179  //---------------------------------------------------------------------------
180  // Meta Data
181  //---------------------------------------------------------------------------
182 
198  {
199  public:
205  inline OutputMetaData(const XnUInt8** ppData) : m_ppData(ppData), m_nAllocatedSize(0), m_pAllocatedData(NULL)
206  {
207  xnOSMemSet(&m_output, 0, sizeof(XnOutputMetaData));
208  }
209 
213  virtual ~OutputMetaData() { Free(); }
214 
218  inline XnUInt64 Timestamp() const { return m_output.nTimestamp; }
219 
223  inline XnUInt64& Timestamp() { return m_output.nTimestamp; }
224 
229  inline XnUInt32 FrameID() const { return m_output.nFrameID; }
230 
235  inline XnUInt32& FrameID() { return m_output.nFrameID; }
236 
245  inline XnUInt32 DataSize() const { return m_output.nDataSize; }
246 
255  inline XnUInt32& DataSize() { return m_output.nDataSize; }
256 
261  inline XnBool IsDataNew() const { return m_output.bIsNew; }
262 
267  inline XnBool& IsDataNew() { return m_output.bIsNew; }
268 
272  inline const XnOutputMetaData* GetUnderlying() const { return &m_output; }
276  inline XnOutputMetaData* GetUnderlying() { return &m_output; }
277 
282  inline const XnUInt8* Data() const { return *m_ppData; }
287  inline const XnUInt8*& Data() { return *m_ppData; }
288 
292  inline XnUInt8* WritableData()
293  {
295  return m_pAllocatedData;
296  }
297 
306  XnStatus AllocateData(XnUInt32 nBytes)
307  {
308  if (nBytes > m_nAllocatedSize)
309  {
310  // reallocate
311  XnUInt8* pData = (XnUInt8*)xnOSMallocAligned(nBytes, XN_DEFAULT_MEM_ALIGN);
312  XN_VALIDATE_ALLOC_PTR(pData);
313 
314  // allocation succeeded, replace
315  Free();
316  m_pAllocatedData = pData;
317  m_nAllocatedSize = nBytes;
318  }
319 
320  DataSize() = nBytes;
321  *m_ppData = m_pAllocatedData;
322 
323  return XN_STATUS_OK;
324  }
325 
329  void Free()
330  {
331  if (m_nAllocatedSize != 0)
332  {
334  m_pAllocatedData = NULL;
335  m_nAllocatedSize = 0;
336  }
337  }
338 
344  {
345  XnStatus nRetVal = XN_STATUS_OK;
346 
347  // check data isn't already writable
348  if (Data() != m_pAllocatedData || DataSize() > m_nAllocatedSize)
349  {
350  const XnUInt8* pOrigData = *m_ppData;
351 
352  nRetVal = AllocateData(DataSize());
353  XN_IS_STATUS_OK(nRetVal);
354 
355  if (pOrigData != NULL)
356  {
357  xnOSMemCopy(m_pAllocatedData, pOrigData, DataSize());
358  }
359  else
360  {
362  }
363  }
364 
365  return (XN_STATUS_OK);
366  }
367 
368  protected:
370 
371  private:
372  XnOutputMetaData m_output;
373 
374  const XnUInt8** m_ppData;
375  XnUInt32 m_nAllocatedSize;
376  };
377 
391  {
392  public:
399  inline MapMetaData(XnPixelFormat format, const XnUInt8** ppData) : OutputMetaData(ppData)
400  {
401  xnOSMemSet(&m_map, 0, sizeof(XnMapMetaData));
403  m_map.PixelFormat = format;
404  }
405 
411  inline XnUInt32 XRes() const { return m_map.Res.X; }
417  inline XnUInt32& XRes() { return m_map.Res.X; }
418 
424  inline XnUInt32 YRes() const { return m_map.Res.Y; }
430  inline XnUInt32& YRes() { return m_map.Res.Y; }
431 
440  inline XnUInt32 XOffset() const { return m_map.Offset.X; }
449  inline XnUInt32& XOffset() { return m_map.Offset.X; }
450 
459  inline XnUInt32 YOffset() const { return m_map.Offset.Y; }
468  inline XnUInt32& YOffset() { return m_map.Offset.Y; }
469 
474  inline XnUInt32 FullXRes() const { return m_map.FullRes.X; }
475 
476 
481  inline XnUInt32& FullXRes() { return m_map.FullRes.X; }
482 
486  inline XnUInt32 FullYRes() const { return m_map.FullRes.Y; }
490  inline XnUInt32& FullYRes() { return m_map.FullRes.Y; }
491 
495  inline XnUInt32 FPS() const { return m_map.nFPS; }
499  inline XnUInt32& FPS() { return m_map.nFPS; }
500 
504  inline XnPixelFormat PixelFormat() const { return m_map.PixelFormat; }
505 
509  inline const XnMapMetaData* GetUnderlying() const { return &m_map; }
513  inline XnMapMetaData* GetUnderlying() { return &m_map; }
514 
518  inline XnUInt32 BytesPerPixel() const
519  {
520  switch (PixelFormat())
521  {
523  return sizeof(XnRGB24Pixel);
525  return sizeof(XnYUV422DoublePixel)/2;
527  return sizeof(XnGrayscale8Pixel);
529  return sizeof(XnGrayscale16Pixel);
531  return 2;
532  default:
533  XN_ASSERT(FALSE);
534  return 0;
535  }
536  }
537 
544  XnStatus AllocateData(XnUInt32 nXRes, XnUInt32 nYRes)
545  {
546  XnStatus nRetVal = XN_STATUS_OK;
547 
548  XnUInt32 nSize = nXRes * nYRes * BytesPerPixel();
549  nRetVal = OutputMetaData::AllocateData(nSize);
550  XN_IS_STATUS_OK(nRetVal);
551 
552  FullXRes() = XRes() = nXRes;
553  FullYRes() = YRes() = nYRes;
554  XOffset() = YOffset() = 0;
555 
556  return (XN_STATUS_OK);
557  }
558 
567  XnStatus ReAdjust(XnUInt32 nXRes, XnUInt32 nYRes, const XnUInt8* pExternalBuffer)
568  {
569  XnStatus nRetVal = XN_STATUS_OK;
570 
571  if (pExternalBuffer == NULL)
572  {
573  nRetVal = AllocateData(nXRes, nYRes);
574  XN_IS_STATUS_OK(nRetVal);
575  }
576  else
577  {
578  FullXRes() = XRes() = nXRes;
579  FullYRes() = YRes() = nYRes;
580  XOffset() = YOffset() = 0;
581  Data() = pExternalBuffer;
582  DataSize() = nXRes * nYRes * BytesPerPixel();
583  }
584 
585  return (XN_STATUS_OK);
586  }
587 
588  protected:
590 
591  private:
592  // block copy ctor and assignment operator
593  MapMetaData& operator=(const MapMetaData&);
594  inline MapMetaData(const MapMetaData& other);
595 
596  // Members
597  XnMapMetaData m_map;
598  };
599 
607  template<class _pixelType>
608  class Map
609  {
610  public:
611  inline Map(_pixelType*& pData, XnUInt32& nXRes, XnUInt32 &nYRes) :
612  m_pData(pData), m_nXRes(nXRes), m_nYRes(nYRes)
613  {}
614 
622  inline XnUInt32 XRes() const { return m_nXRes; }
630  inline XnUInt32 YRes() const { return m_nYRes; }
631 
643  inline const _pixelType& operator[](XnUInt32 nIndex) const
644  {
645  XN_ASSERT(nIndex < (m_nXRes * m_nYRes));
646  return m_pData[nIndex];
647  }
659  inline _pixelType& operator[](XnUInt32 nIndex)
660  {
661  XN_ASSERT(nIndex < (m_nXRes *m_nYRes));
662  return m_pData[nIndex];
663  }
664 
673  inline const _pixelType& operator()(XnUInt32 x, XnUInt32 y) const
674  {
675  XN_ASSERT(x < m_nXRes && y < m_nYRes);
676  return m_pData[y*m_nXRes + x];
677  }
686  inline _pixelType& operator()(XnUInt32 x, XnUInt32 y)
687  {
688  XN_ASSERT(x < m_nXRes && y < m_nYRes);
689  return m_pData[y*m_nXRes + x];
690  }
691 
692  private:
693  /* block copy ctor and assignment operator */
694  Map(const Map& other);
695  Map& operator=(const Map&);
696 
697  _pixelType*& m_pData;
698  XnUInt32& m_nXRes;
699  XnUInt32& m_nYRes;
700  };
701 
753  class DepthMetaData : public MapMetaData
754  {
755  public:
759  inline DepthMetaData() :
760  MapMetaData(XN_PIXEL_FORMAT_GRAYSCALE_16_BIT, (const XnUInt8**)&m_depth.pData),
761  m_depthMap(const_cast<XnDepthPixel*&>(m_depth.pData), MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y),
762  m_writableDepthMap((XnDepthPixel*&)m_pAllocatedData, MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y)
763  {
764  xnOSMemSet(&m_depth, 0, sizeof(XnDepthMetaData));
765  m_depth.pMap = MapMetaData::GetUnderlying();
766  }
767 
775  inline void InitFrom(const DepthMetaData& other)
776  {
777  xnCopyDepthMetaData(&m_depth, &other.m_depth);
778  }
779 
790  inline XnStatus InitFrom(const DepthMetaData& other, XnUInt32 nXRes, XnUInt32 nYRes, const XnDepthPixel* pExternalBuffer)
791  {
792  InitFrom(other);
793  return ReAdjust(nXRes, nYRes, pExternalBuffer);
794  }
795 
803  {
804  // copy props
805  InitFrom(other);
806  // and make a copy of the data (this will allocate and copy data)
807  return MakeDataWritable();
808  }
809 
813  XnStatus ReAdjust(XnUInt32 nXRes, XnUInt32 nYRes, const XnDepthPixel* pExternalBuffer = NULL)
814  {
815  return MapMetaData::ReAdjust(nXRes, nYRes, (const XnUInt8*)pExternalBuffer);
816  }
817 
823  inline XnDepthPixel ZRes() const { return m_depth.nZRes; }
829  inline XnDepthPixel& ZRes() { return m_depth.nZRes; }
830 
843  inline const XnDepthPixel* Data() const { return (const XnDepthPixel*)MapMetaData::Data(); }
856  inline const XnDepthPixel*& Data() { return (const XnDepthPixel*&)MapMetaData::Data(); }
857 
858 
863 
867  inline const xn::DepthMap& DepthMap() const { return m_depthMap; }
872  {
874  return m_writableDepthMap;
875  }
876 
882  inline const XnDepthPixel& operator[](XnUInt32 nIndex) const
883  {
884  XN_ASSERT(nIndex < (XRes()*YRes()));
885  return Data()[nIndex];
886  }
887 
894  inline const XnDepthPixel& operator()(XnUInt32 x, XnUInt32 y) const
895  {
896  XN_ASSERT(x < XRes() && y < YRes());
897  return Data()[y*XRes() + x];
898  }
899 
903  inline const XnDepthMetaData* GetUnderlying() const { return &m_depth; }
907  inline XnDepthMetaData* GetUnderlying() { return &m_depth; }
908 
909  private:
910  // block copy ctor and assignment operator (because we can't return errors in those)
911  DepthMetaData(const DepthMetaData& other);
912  DepthMetaData& operator=(const DepthMetaData&);
913 
914  XnDepthMetaData m_depth;
915  const xn::DepthMap m_depthMap;
916  xn::DepthMap m_writableDepthMap;
917  };
918 
945  class ImageMetaData : public MapMetaData
946  {
947  public:
948  inline ImageMetaData() :
949  MapMetaData(XN_PIXEL_FORMAT_RGB24, &m_image.pData),
950  m_imageMap(const_cast<XnUInt8*&>(m_image.pData), MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y),
951  m_writableImageMap((XnUInt8*&)m_pAllocatedData, MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y),
952  m_rgb24Map((XnRGB24Pixel*&)m_image.pData, MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y),
953  m_writableRgb24Map((XnRGB24Pixel*&)m_pAllocatedData, MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y),
954  m_gray16Map((XnGrayscale16Pixel*&)m_image.pData, MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y),
955  m_writableGray16Map((XnGrayscale16Pixel*&)m_pAllocatedData, MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y),
956  m_gray8Map((XnGrayscale8Pixel*&)m_image.pData, MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y),
957  m_writableGray8Map((XnGrayscale8Pixel*&)m_pAllocatedData, MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y)
958  {
959  xnOSMemSet(&m_image, 0, sizeof(XnImageMetaData));
960  m_image.pMap = MapMetaData::GetUnderlying();
961  }
962 
970  inline void InitFrom(const ImageMetaData& other)
971  {
972  xnCopyImageMetaData(&m_image, &other.m_image);
973  }
974 
986  inline XnStatus InitFrom(const ImageMetaData& other, XnUInt32 nXRes, XnUInt32 nYRes, XnPixelFormat format, const XnUInt8* pExternalBuffer)
987  {
988  InitFrom(other);
989  XnStatus nRetVal = ReAdjust(nXRes, nYRes, format, pExternalBuffer);
990  XN_IS_STATUS_OK(nRetVal);
991  PixelFormat() = format;
992  return XN_STATUS_OK;
993  }
994 
1002  inline XnStatus AllocateData(XnUInt32 nXRes, XnUInt32 nYRes, XnPixelFormat format)
1003  {
1004  XnPixelFormat origFormat = PixelFormat();
1005  PixelFormat() = format;
1006  XnStatus nRetVal = MapMetaData::AllocateData(nXRes, nYRes);
1007  if (nRetVal != XN_STATUS_OK)
1008  {
1009  PixelFormat() = origFormat;
1010  return (nRetVal);
1011  }
1012 
1013  return XN_STATUS_OK;
1014  }
1015 
1021  inline XnStatus CopyFrom(const ImageMetaData& other)
1022  {
1023  // copy props
1024  xnCopyImageMetaData(&m_image, &other.m_image);
1025  // and make a copy of the data (this will allocate and copy data)
1026  return MakeDataWritable();
1027  }
1028 
1038  XnStatus ReAdjust(XnUInt32 nXRes, XnUInt32 nYRes, XnPixelFormat format, const XnUInt8* pExternalBuffer = NULL)
1039  {
1040  XnPixelFormat origFormat = PixelFormat();
1041  PixelFormat() = format;
1042  XnStatus nRetVal = MapMetaData::ReAdjust(nXRes, nYRes, pExternalBuffer);
1043  if (nRetVal != XN_STATUS_OK)
1044  {
1045  PixelFormat() = origFormat;
1046  return (nRetVal);
1047  }
1048 
1049  return XN_STATUS_OK;
1050  }
1051 
1074 
1078  inline XnUInt8* WritableData() { return MapMetaData::WritableData(); }
1079 
1084  inline const XnRGB24Pixel* RGB24Data() const { return (const XnRGB24Pixel*)MapMetaData::Data(); }
1089  inline const XnRGB24Pixel*& RGB24Data() { return (const XnRGB24Pixel*&)MapMetaData::Data(); }
1094 
1100  inline const XnYUV422DoublePixel* YUV422Data() const { return (const XnYUV422DoublePixel*)MapMetaData::Data(); }
1111 
1116  inline const XnGrayscale8Pixel* Grayscale8Data() const { return (const XnGrayscale8Pixel*)MapMetaData::Data(); }
1126 
1131  inline const XnGrayscale16Pixel* Grayscale16Data() const { return (const XnGrayscale16Pixel*)MapMetaData::Data(); }
1141 
1145  inline const xn::ImageMap& ImageMap() const { return m_imageMap; }
1149  inline xn::ImageMap& WritableImageMap() { MakeDataWritable(); return m_writableImageMap; }
1150 
1156  inline const xn::RGB24Map& RGB24Map() const { return m_rgb24Map; }
1160  inline xn::RGB24Map& WritableRGB24Map() { MakeDataWritable(); return m_writableRgb24Map; }
1161 
1165  inline const xn::Grayscale8Map& Grayscale8Map() const { return m_gray8Map; }
1169  inline xn::Grayscale8Map& WritableGrayscale8Map() { MakeDataWritable(); return m_writableGray8Map; }
1170 
1175  inline const xn::Grayscale16Map& Grayscale16Map() const { return m_gray16Map; }
1179  inline xn::Grayscale16Map& WritableGrayscale16Map() { MakeDataWritable(); return m_writableGray16Map; }
1180 
1184  inline const XnImageMetaData* GetUnderlying() const { return &m_image; }
1188  inline XnImageMetaData* GetUnderlying() { return &m_image; }
1189 
1190  private:
1191  // block copy ctor and assignment operator
1192  ImageMetaData(const ImageMetaData& other);
1193  ImageMetaData& operator=(const ImageMetaData&);
1194 
1195  XnImageMetaData m_image;
1196  const xn::ImageMap m_imageMap;
1197  xn::ImageMap m_writableImageMap;
1198  const xn::RGB24Map m_rgb24Map;
1199  xn::RGB24Map m_writableRgb24Map;
1200  const xn::Grayscale16Map m_gray16Map;
1201  xn::Grayscale16Map m_writableGray16Map;
1202  const xn::Grayscale8Map m_gray8Map;
1203  xn::Grayscale8Map m_writableGray8Map;
1204  };
1205 
1215  class IRMetaData : public MapMetaData
1216  {
1217  public:
1218  inline IRMetaData() :
1219  MapMetaData(XN_PIXEL_FORMAT_GRAYSCALE_16_BIT, (const XnUInt8**)&m_ir.pData),
1220  m_irMap(const_cast<XnIRPixel*&>(m_ir.pData), MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y),
1221  m_writableIRMap((XnIRPixel*&)m_pAllocatedData, MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y)
1222  {
1223  xnOSMemSet(&m_ir, 0, sizeof(XnIRMetaData));
1225  }
1226 
1234  inline void InitFrom(const IRMetaData& other)
1235  {
1236  xnCopyIRMetaData(&m_ir, &other.m_ir);
1237  }
1238 
1248  inline XnStatus InitFrom(const IRMetaData& other, XnUInt32 nXRes, XnUInt32 nYRes, const XnIRPixel* pExternalBuffer)
1249  {
1250  InitFrom(other);
1251  return ReAdjust(nXRes, nYRes, pExternalBuffer);
1252  }
1253 
1260  {
1261  // copy props
1262  xnCopyIRMetaData(&m_ir, &other.m_ir);
1263  // and make a copy of the data (this will allocate and copy data)
1264  return MakeDataWritable();
1265  }
1266 
1270  XnStatus ReAdjust(XnUInt32 nXRes, XnUInt32 nYRes, const XnIRPixel* pExternalBuffer = NULL)
1271  {
1272  return MapMetaData::ReAdjust(nXRes, nYRes, (const XnUInt8*)pExternalBuffer);
1273  }
1274 
1287  inline const XnIRPixel* Data() const { return (const XnIRPixel*)MapMetaData::Data(); }
1300  inline const XnIRPixel*& Data() { return (const XnIRPixel*&)MapMetaData::Data(); }
1305 
1311  inline const XnIRPixel& operator[](XnUInt32 nIndex) const
1312  {
1313  XN_ASSERT(nIndex < (XRes()*YRes()));
1314  return Data()[nIndex];
1315  }
1316 
1323  inline const XnIRPixel& operator()(XnUInt32 x, XnUInt32 y) const
1324  {
1325  XN_ASSERT(x < XRes() && y < YRes());
1326  return Data()[y*XRes() + x];
1327  }
1328 
1337  inline const xn::IRMap& IRMap() const { return m_irMap; }
1346  inline xn::IRMap& WritableIRMap() { MakeDataWritable(); return m_writableIRMap; }
1347 
1351  inline const XnIRMetaData* GetUnderlying() const { return &m_ir; }
1355  inline XnIRMetaData* GetUnderlying() { return &m_ir; }
1356 
1357  private:
1358  // block copy ctor and assignment operator
1359  IRMetaData(const IRMetaData& other);
1360  IRMetaData& operator=(const IRMetaData&);
1361 
1362  XnIRMetaData m_ir;
1363  const xn::IRMap m_irMap;
1364  xn::IRMap m_writableIRMap;
1365  };
1366 
1374  {
1375  public:
1376  XN_PRAGMA_START_DISABLED_WARNING_SECTION(XN_UNALIGNED_ADDRESS_WARNING_ID);
1377  inline AudioMetaData() : OutputMetaData(&m_audio.pData)
1378  {
1379  xnOSMemSet(&m_audio, 0, sizeof(XnAudioMetaData));
1381  }
1382 
1384 
1392  inline void InitFrom(const AudioMetaData& other)
1393  {
1394  xnCopyAudioMetaData(&m_audio, &other.m_audio);
1395  }
1396 
1400  inline XnUInt8 NumberOfChannels() const { return m_audio.Wave.nChannels; }
1404  inline XnUInt8& NumberOfChannels() { return m_audio.Wave.nChannels; }
1405 
1409  inline XnUInt32 SampleRate() const { return m_audio.Wave.nSampleRate; }
1413  inline XnUInt32& SampleRate() { return m_audio.Wave.nSampleRate; }
1414 
1418  inline XnUInt16 BitsPerSample() const { return m_audio.Wave.nBitsPerSample; }
1422  inline XnUInt16& BitsPerSample() { return m_audio.Wave.nBitsPerSample; }
1423 
1427  inline const XnAudioMetaData* GetUnderlying() const { return &m_audio; }
1431  inline XnAudioMetaData* GetUnderlying() { return &m_audio; }
1432 
1433  private:
1434  // block copy ctor and assignment operator
1435  AudioMetaData(const AudioMetaData& other);
1436  AudioMetaData& operator=(const AudioMetaData&);
1437 
1438  XnAudioMetaData m_audio;
1439  };
1440 
1450  {
1451  public:
1452  inline SceneMetaData() :
1453  MapMetaData(XN_PIXEL_FORMAT_GRAYSCALE_16_BIT, (const XnUInt8**)&m_scene.pData),
1454  m_labelMap(const_cast<XnLabel*&>(m_scene.pData), MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y),
1455  m_writableLabelMap((XnLabel*&)m_pAllocatedData, MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y)
1456  {
1457  xnOSMemSet(&m_scene, 0, sizeof(XnSceneMetaData));
1458  m_scene.pMap = MapMetaData::GetUnderlying();
1459  }
1460 
1468  inline void InitFrom(const SceneMetaData& other)
1469  {
1470  xnCopySceneMetaData(&m_scene, &other.m_scene);
1471  }
1472 
1482  inline XnStatus InitFrom(const SceneMetaData& other, XnUInt32 nXRes, XnUInt32 nYRes, const XnLabel* pExternalBuffer)
1483  {
1484  InitFrom(other);
1485  return ReAdjust(nXRes, nYRes, pExternalBuffer);
1486  }
1487 
1494  {
1495  // copy props
1496  xnCopySceneMetaData(&m_scene, &other.m_scene);
1497  // and make a copy of the data (this will allocate and copy data)
1498  return MakeDataWritable();
1499  }
1500 
1504  XnStatus ReAdjust(XnUInt32 nXRes, XnUInt32 nYRes, const XnLabel* pExternalBuffer = NULL)
1505  {
1506  return MapMetaData::ReAdjust(nXRes, nYRes, (const XnUInt8*)pExternalBuffer);
1507  }
1508 
1522  inline const XnLabel* Data() const { return (const XnLabel*)MapMetaData::Data(); }
1536  inline const XnLabel*& Data() { return (const XnLabel*&)MapMetaData::Data(); }
1537 
1542 
1546  inline const xn::LabelMap& LabelMap() const { return m_labelMap; }
1550  inline xn::LabelMap& WritableLabelMap() { MakeDataWritable(); return m_writableLabelMap; }
1551 
1562  inline const XnLabel& operator[](XnUInt32 nIndex) const
1563  {
1564  XN_ASSERT(nIndex < (XRes()*YRes()));
1565  return Data()[nIndex];
1566  }
1567 
1579  inline const XnLabel& operator()(XnUInt32 x, XnUInt32 y) const
1580  {
1581  XN_ASSERT(x < XRes() && y < YRes());
1582  return (*this)[y*XRes() + x];
1583  }
1584 
1588  inline const XnSceneMetaData* GetUnderlying() const { return &m_scene; }
1592  inline XnSceneMetaData* GetUnderlying() { return &m_scene; }
1593 
1594  private:
1595  // block copy ctor and assignment operator
1596  SceneMetaData(const SceneMetaData& other);
1597  SceneMetaData& operator=(const SceneMetaData&);
1598 
1599  XnSceneMetaData m_scene;
1600  const xn::LabelMap m_labelMap;
1601  xn::LabelMap m_writableLabelMap;
1602  };
1603 
1604  //---------------------------------------------------------------------------
1605  // NodeWrapper
1606  //---------------------------------------------------------------------------
1607 
1628  {
1629  public:
1630  friend class Context;
1631 
1637  inline NodeWrapper(XnNodeHandle hNode) : m_hNode(NULL), m_hShuttingDownCallback(NULL)
1638  {
1639  SetHandle(hNode);
1640  }
1641 
1642  inline NodeWrapper(const NodeWrapper& other) : m_hNode(NULL), m_hShuttingDownCallback(NULL)
1643  {
1644  SetHandle(other.GetHandle());
1645  }
1646 
1647  inline NodeWrapper& operator=(const NodeWrapper& other)
1648  {
1649  SetHandle(other.GetHandle());
1650  return *this;
1651  }
1652 
1653  inline ~NodeWrapper()
1654  {
1655  SetHandle(NULL);
1656  }
1657 
1658  inline operator XnNodeHandle() const { return GetHandle(); }
1659 
1663  inline XnNodeHandle GetHandle() const { return m_hNode; }
1664 
1670  inline XnBool operator==(const NodeWrapper& other)
1671  {
1672  return (GetHandle() == other.GetHandle());
1673  }
1674 
1680  inline XnBool operator!=(const NodeWrapper& other)
1681  {
1682  return (GetHandle() != other.GetHandle());
1683  }
1684 
1698  inline XnBool IsValid() const { return (GetHandle() != NULL); }
1699 
1700  /*
1701  * @brief Gets the instance name of a node. Unless the application made a specific
1702  * request for a specific name, the name will be of the form: "Depth1", "Image2", etc.
1703  */
1704  const XnChar* GetName() const {return xnGetNodeName(GetHandle()); }
1705 
1711 
1716  inline void Release()
1717  {
1718  SetHandle(NULL);
1719  }
1720 
1721 
1725  inline void SetHandle(XnNodeHandle hNode)
1726  {
1727  if (m_hNode == hNode)
1728  {
1729  // Optimization: do nothing
1730  return;
1731  }
1732 
1733  // check currently held node. If we're holding a node, release it
1734  if (m_hNode != NULL)
1735  {
1736  XnContext* pContext = xnGetRefContextFromNodeHandle(m_hNode);
1737  xnContextUnregisterFromShutdown(pContext, m_hShuttingDownCallback);
1738  xnContextRelease(pContext);
1739  xnProductionNodeRelease(m_hNode);
1740  }
1741 
1742  // check new node handle, if it points to a node, add ref to it
1743  if (hNode != NULL)
1744  {
1745  XnStatus nRetVal = xnProductionNodeAddRef(hNode);
1746  XN_ASSERT(nRetVal == XN_STATUS_OK);
1747  XN_REFERENCE_VARIABLE(nRetVal);
1748 
1749  XnContext* pContext = xnGetRefContextFromNodeHandle(hNode);
1750 
1751  nRetVal = xnContextRegisterForShutdown(pContext, ContextShuttingDownCallback, this, &m_hShuttingDownCallback);
1752  XN_ASSERT(nRetVal == XN_STATUS_OK);
1753 
1754  xnContextRelease(pContext);
1755  }
1756 
1757  m_hNode = hNode;
1758  }
1759 
1760  inline void TakeOwnership(XnNodeHandle hNode)
1761  {
1762  SetHandle(hNode);
1763 
1764  if (hNode != NULL)
1765  {
1766  xnProductionNodeRelease(hNode);
1767  }
1768  }
1769 
1771  inline XnStatus XN_API_DEPRECATED("Please use AddRef() instead.") Ref() { return AddRef(); }
1772  inline void XN_API_DEPRECATED("Please use Release() instead.") Unref() { Release(); }
1775  private:
1776  XnNodeHandle m_hNode;
1777  XnCallbackHandle m_hShuttingDownCallback;
1778 
1779  static void XN_CALLBACK_TYPE ContextShuttingDownCallback(XnContext* /*pContext*/, void* pCookie)
1780  {
1781  NodeWrapper* pThis = (NodeWrapper*)pCookie;
1782  pThis->m_hNode = NULL;
1783  }
1784  };
1785 
1786  //---------------------------------------------------------------------------
1787  // Node Info
1788  //---------------------------------------------------------------------------
1789 
1801  class NodeInfo
1802  {
1803  public:
1809  NodeInfo(XnNodeInfo* pInfo) : m_pNeededNodes(NULL), m_bOwnerOfNode(FALSE)
1810  {
1811  SetUnderlyingObject(pInfo);
1812  }
1813 
1819  NodeInfo(const NodeInfo& other) : m_pNeededNodes(NULL), m_bOwnerOfNode(FALSE)
1820  {
1821  SetUnderlyingObject(other.m_pInfo);
1822  }
1823 
1828  {
1829  SetUnderlyingObject(NULL);
1830  }
1831 
1837  inline NodeInfo& operator=(const NodeInfo& other)
1838  {
1839  SetUnderlyingObject(other.m_pInfo);
1840  return *this;
1841  }
1842 
1846  inline operator XnNodeInfo*()
1847  {
1848  return m_pInfo;
1849  }
1850 
1856  inline XnStatus SetInstanceName(const XnChar* strName)
1857  {
1858  return xnNodeInfoSetInstanceName(m_pInfo, strName);
1859  }
1860 
1875  {
1876  return *xnNodeInfoGetDescription(m_pInfo);
1877  }
1878 
1890  inline const XnChar* GetInstanceName() const
1891  {
1892  return xnNodeInfoGetInstanceName(m_pInfo);
1893  }
1894 
1906  inline const XnChar* GetCreationInfo() const
1907  {
1908  return xnNodeInfoGetCreationInfo(m_pInfo);
1909  }
1910 
1911  /*
1912  * @brief Gets the list of dependant nodes for this node alternative.
1913  * These are any other node alternatives that the node is dependant on.
1914  */
1915  inline NodeInfoList& GetNeededNodes() const;
1916 
1924  inline XnStatus GetInstance(ProductionNode& node) const;
1925 
1930  inline const void* GetAdditionalData() const
1931  {
1932  return xnNodeInfoGetAdditionalData(m_pInfo);
1933  }
1934 
1939  inline XnStatus GetTreeStringRepresentation(XnChar* csResultBuffer, XnUInt32 nBufferSize) const
1940  {
1941  return xnNodeInfoGetTreeStringRepresentation(m_pInfo, csResultBuffer, nBufferSize);
1942  }
1943 
1944  private:
1945  inline void SetUnderlyingObject(XnNodeInfo* pInfo);
1946 
1947  XnNodeInfo* m_pInfo;
1948  mutable NodeInfoList* m_pNeededNodes;
1949  XnBool m_bOwnerOfNode; // backwards compatibility
1950  friend class Context;
1951  };
1952 
1953  //---------------------------------------------------------------------------
1954  // Query
1955  //---------------------------------------------------------------------------
1956 
1975  class Query
1976  {
1977  public:
1978  inline Query() : m_bAllocated(TRUE)
1979  {
1980  xnNodeQueryAllocate(&m_pQuery);
1981  }
1982 
1983  inline Query(XnNodeQuery* pNodeQuery) : m_bAllocated(FALSE), m_pQuery(pNodeQuery)
1984  {
1985  }
1986 
1988  {
1989  if (m_bAllocated)
1990  {
1991  xnNodeQueryFree(m_pQuery);
1992  }
1993  }
1994 
1998  inline const XnNodeQuery* GetUnderlyingObject() const { return m_pQuery; }
1999  inline XnNodeQuery* GetUnderlyingObject() { return m_pQuery; }
2000 
2005  inline XnStatus SetVendor(const XnChar* strVendor)
2006  {
2007  return xnNodeQuerySetVendor(m_pQuery, strVendor);
2008  }
2009 
2018  inline XnStatus SetName(const XnChar* strName)
2019  {
2020  return xnNodeQuerySetName(m_pQuery, strName);
2021  }
2022 
2026  inline XnStatus SetMinVersion(const XnVersion& minVersion)
2027  {
2028  return xnNodeQuerySetMinVersion(m_pQuery, &minVersion);
2029  }
2030 
2034  inline XnStatus SetMinVersion(const Version& minVersion)
2035  {
2036  return xnNodeQuerySetMinVersion(m_pQuery, minVersion.GetUnderlying());
2037  }
2038 
2042  inline XnStatus SetMaxVersion(const XnVersion& maxVersion)
2043  {
2044  return xnNodeQuerySetMaxVersion(m_pQuery, &maxVersion);
2045  }
2046 
2050  inline XnStatus SetMaxVersion(const Version& maxVersion)
2051  {
2052  return xnNodeQuerySetMaxVersion(m_pQuery, maxVersion.GetUnderlying());
2053  }
2054 
2067  inline XnStatus AddSupportedCapability(const XnChar* strNeededCapability)
2068  {
2069  return xnNodeQueryAddSupportedCapability(m_pQuery, strNeededCapability);
2070  }
2071 
2083  {
2084  return xnNodeQueryAddSupportedMapOutputMode(m_pQuery, &MapOutputMode);
2085  }
2086 
2091  inline XnStatus SetSupportedMinUserPositions(const XnUInt32 nCount)
2092  {
2093  return xnNodeQuerySetSupportedMinUserPositions(m_pQuery, nCount);
2094  }
2095 
2107  inline XnStatus SetExistingNodeOnly(XnBool bExistingNode)
2108  {
2109  return xnNodeQuerySetExistingNodeOnly(m_pQuery, bExistingNode);
2110  }
2111 
2116  inline XnStatus AddNeededNode(const XnChar* strInstanceName)
2117  {
2118  return xnNodeQueryAddNeededNode(m_pQuery, strInstanceName);
2119  }
2120 
2125  inline XnStatus SetCreationInfo(const XnChar* strCreationInfo)
2126  {
2127  return xnNodeQuerySetCreationInfo(m_pQuery, strCreationInfo);
2128  }
2129 
2130  private:
2131  XnNodeQuery* m_pQuery;
2132  XnBool m_bAllocated;
2133  };
2134 
2135  //---------------------------------------------------------------------------
2136  // Node Info List
2137  //---------------------------------------------------------------------------
2138 
2144  {
2145  public:
2149  class Iterator
2150  {
2151  public:
2152  friend class NodeInfoList;
2153 
2166  XnBool operator==(const Iterator& other) const
2167  {
2168  return m_it.pCurrent == other.m_it.pCurrent;
2169  }
2170 
2177  XnBool operator!=(const Iterator& other) const
2178  {
2179  return m_it.pCurrent != other.m_it.pCurrent;
2180  }
2181 
2187  {
2188  UpdateInternalObject(xnNodeInfoListGetNext(m_it));
2189  return *this;
2190  }
2191 
2196  inline Iterator operator++(int)
2197  {
2198  XnNodeInfoListIterator curr = m_it;
2199  UpdateInternalObject(xnNodeInfoListGetNext(m_it));
2200  return Iterator(curr);
2201  }
2202 
2207  {
2208  UpdateInternalObject(xnNodeInfoListGetPrevious(m_it));
2209  return *this;
2210  }
2211 
2215  inline Iterator operator--(int)
2216  {
2217  XnNodeInfoListIterator curr = m_it;
2218  UpdateInternalObject(xnNodeInfoListGetPrevious(m_it));
2219  return Iterator(curr);
2220  }
2221 
2226  {
2227  return m_Info;
2228  }
2229 
2230  private:
2231  inline Iterator(XnNodeInfoListIterator it) : m_Info(NULL)
2232  {
2233  UpdateInternalObject(it);
2234  }
2235 
2236  inline void UpdateInternalObject(XnNodeInfoListIterator it)
2237  {
2238  m_it = it;
2240  {
2241  XnNodeInfo* pInfo = xnNodeInfoListGetCurrent(it);
2242  m_Info = NodeInfo(pInfo);
2243  }
2244  else
2245  {
2246  m_Info = NodeInfo(NULL);
2247  }
2248  }
2249 
2250  NodeInfo m_Info;
2252  };
2253 
2257  inline NodeInfoList()
2258  {
2259  xnNodeInfoListAllocate(&m_pList);
2260  m_bAllocated = TRUE;
2261  }
2262 
2269  inline NodeInfoList(XnNodeInfoList* pList) : m_pList(pList), m_bAllocated(FALSE) {}
2270 
2271  inline ~NodeInfoList()
2272  {
2273  FreeImpl();
2274  }
2275 
2279  inline XnNodeInfoList* GetUnderlyingObject() const { return m_pList; }
2280 
2288  {
2289  FreeImpl();
2290  m_pList = pList;
2291  m_bAllocated = TRUE;
2292  }
2293 
2298  inline XnStatus Add(XnProductionNodeDescription& description, const XnChar* strCreationInfo, NodeInfoList* pNeededNodes)
2299  {
2300  XnNodeInfoList* pList = (pNeededNodes == NULL) ? NULL : pNeededNodes->GetUnderlyingObject();
2301  return xnNodeInfoListAdd(m_pList, &description, strCreationInfo, pList);
2302  }
2303 
2308  inline XnStatus AddEx(XnProductionNodeDescription& description, const XnChar* strCreationInfo, NodeInfoList* pNeededNodes, const void* pAdditionalData, XnFreeHandler pFreeHandler)
2309  {
2310  XnNodeInfoList* pList = (pNeededNodes == NULL) ? NULL : pNeededNodes->GetUnderlyingObject();
2311  return xnNodeInfoListAddEx(m_pList, &description, strCreationInfo, pList, pAdditionalData, pFreeHandler);
2312  }
2313 
2318  inline XnStatus AddNode(NodeInfo& info)
2319  {
2320  return xnNodeInfoListAddNode(m_pList, info);
2321  }
2322 
2328  {
2329  return xnNodeInfoListAddNodeFromList(m_pList, it.m_it);
2330  }
2331 
2336  inline Iterator Begin() const
2337  {
2338  return Iterator(xnNodeInfoListGetFirst(m_pList));
2339  }
2340 
2345  inline Iterator End() const
2346  {
2347  XnNodeInfoListIterator it = { NULL };
2348  return Iterator(it);
2349  }
2350 
2355  inline Iterator RBegin() const
2356  {
2357  return Iterator(xnNodeInfoListGetLast(m_pList));
2358  }
2359 
2364  inline Iterator REnd() const
2365  {
2366  XnNodeInfoListIterator it = { NULL };
2367  return Iterator(it);
2368  }
2369 
2375  {
2376  return xnNodeInfoListRemove(m_pList, it.m_it);
2377  }
2378 
2383  inline XnStatus Clear()
2384  {
2385  return xnNodeInfoListClear(m_pList);
2386  }
2387 
2393  {
2394  return xnNodeInfoListAppend(m_pList, other.GetUnderlyingObject());
2395  }
2396 
2400  inline XnBool IsEmpty()
2401  {
2402  return xnNodeInfoListIsEmpty(m_pList);
2403  }
2404 
2409  inline XnStatus FilterList(Context& context, Query& query);
2410 
2411  private:
2412  inline void FreeImpl()
2413  {
2414  if (m_bAllocated)
2415  {
2416  xnNodeInfoListFree(m_pList);
2417  m_bAllocated = FALSE;
2418  m_pList = NULL;
2419  }
2420  }
2421 
2422  XnNodeInfoList* m_pList;
2423  XnBool m_bAllocated;
2424  };
2425 
2426  //---------------------------------------------------------------------------
2427  // Production Nodes Functionality
2428  //---------------------------------------------------------------------------
2429 
2434  class Capability : public NodeWrapper
2435  {
2436  public:
2443  Capability(const NodeWrapper& node) : NodeWrapper(node) {}
2444  };
2445 
2480  {
2481  public:
2489 
2493  inline XnStatus GetErrorState() const
2494  {
2495  return xnGetNodeErrorState(GetHandle());
2496  }
2497 
2508  {
2509  return _RegisterToStateChange(xnRegisterToNodeErrorStateChange, GetHandle(), handler, pCookie, hCallback);
2510  }
2511 
2520  {
2521  _UnregisterFromStateChange(xnUnregisterFromNodeErrorStateChange, GetHandle(), hCallback);
2522  }
2523  };
2524 
2531  {
2532  public:
2539  GeneralIntCapability(XnNodeHandle hNode, const XnChar* strCap) : Capability(hNode), m_strCap(strCap) {}
2540  GeneralIntCapability(const NodeWrapper& node, const XnChar* strCap) : Capability(node), m_strCap(strCap) {}
2541 
2546  inline void GetRange(XnInt32& nMin, XnInt32& nMax, XnInt32& nStep, XnInt32& nDefault, XnBool& bIsAutoSupported) const
2547  {
2548  xnGetGeneralIntRange(GetHandle(), m_strCap, &nMin, &nMax, &nStep, &nDefault, &bIsAutoSupported);
2549  }
2550 
2555  inline XnInt32 Get()
2556  {
2557  XnInt32 nValue;
2558  xnGetGeneralIntValue(GetHandle(), m_strCap, &nValue);
2559  return nValue;
2560  }
2561 
2566  inline XnStatus Set(XnInt32 nValue)
2567  {
2568  return xnSetGeneralIntValue(GetHandle(), m_strCap, nValue);
2569  }
2570 
2580  XnStatus RegisterToValueChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback);
2581 
2590 
2591  private:
2592  const XnChar* m_strCap;
2593  };
2594 
2631  {
2632  public:
2638  inline ProductionNode(XnNodeHandle hNode = NULL) : NodeWrapper(hNode) {}
2639  inline ProductionNode(const NodeWrapper& other) : NodeWrapper(other) {}
2640 
2649  inline NodeInfo GetInfo() const { return NodeInfo(xnGetNodeInfo(GetHandle())); }
2650 
2656  {
2657  return xnAddNeededNode(GetHandle(), needed.GetHandle());
2658  }
2659 
2665  {
2666  return xnRemoveNeededNode(GetHandle(), needed.GetHandle());
2667  }
2668 
2680  inline void GetContext(Context& context) const;
2681 
2691  inline Context GetContext() const;
2692 
2704  inline XnBool IsCapabilitySupported(const XnChar* strCapabilityName) const
2705  {
2706  return xnIsCapabilitySupported(GetHandle(), strCapabilityName);
2707  }
2708 
2713  inline XnStatus SetIntProperty(const XnChar* strName, XnUInt64 nValue)
2714  {
2715  return xnSetIntProperty(GetHandle(), strName, nValue);
2716  }
2717 
2722  inline XnStatus SetRealProperty(const XnChar* strName, XnDouble dValue)
2723  {
2724  return xnSetRealProperty(GetHandle(), strName, dValue);
2725  }
2726 
2731  inline XnStatus SetStringProperty(const XnChar* strName, const XnChar* strValue)
2732  {
2733  return xnSetStringProperty(GetHandle(), strName, strValue);
2734  }
2735 
2740  inline XnStatus SetGeneralProperty(const XnChar* strName, XnUInt32 nBufferSize, const void* pBuffer)
2741  {
2742  return xnSetGeneralProperty(GetHandle(), strName, nBufferSize, pBuffer);
2743  }
2744 
2749  inline XnStatus GetIntProperty(const XnChar* strName, XnUInt64& nValue) const
2750  {
2751  return xnGetIntProperty(GetHandle(), strName, &nValue);
2752  }
2753 
2758  inline XnStatus GetRealProperty(const XnChar* strName, XnDouble &dValue) const
2759  {
2760  return xnGetRealProperty(GetHandle(), strName, &dValue);
2761  }
2762 
2767  inline XnStatus GetStringProperty(const XnChar* strName, XnChar* csValue, XnUInt32 nBufSize) const
2768  {
2769  return xnGetStringProperty(GetHandle(), strName, csValue, nBufSize);
2770  }
2771 
2776  inline XnStatus GetGeneralProperty(const XnChar* strName, XnUInt32 nBufferSize, void* pBuffer) const
2777  {
2778  return xnGetGeneralProperty(GetHandle(), strName, nBufferSize, pBuffer);
2779  }
2780 
2786  {
2787  return xnLockNodeForChanges(GetHandle(), phLock);
2788  }
2789 
2794  inline void UnlockForChanges(XnLockHandle hLock)
2795  {
2797  }
2798 
2804  {
2805  return xnLockedNodeStartChanges(GetHandle(), hLock);
2806  }
2807 
2813  {
2815  }
2816 
2826  {
2827  return ErrorStateCapability(GetHandle());
2828  }
2829 
2839  {
2840  return ErrorStateCapability(GetHandle());
2841  }
2842 
2854  inline GeneralIntCapability GetGeneralIntCap(const XnChar* strCapability)
2855  {
2856  return GeneralIntCapability(GetHandle(), strCapability);
2857  }
2858  };
2859 
2870  {
2871  public:
2879 
2889  inline XnStatus GetDeviceName(XnChar* strBuffer, XnUInt32 nBufferSize)
2890  {
2891  return xnGetDeviceName(GetHandle(), strBuffer, &nBufferSize);
2892  }
2893 
2903  inline XnStatus GetVendorSpecificData(XnChar* strBuffer, XnUInt32 nBufferSize)
2904  {
2905  return xnGetVendorSpecificData(GetHandle(), strBuffer, &nBufferSize);
2906  }
2907 
2917  inline XnStatus GetSerialNumber(XnChar* strBuffer, XnUInt32 nBufferSize)
2918  {
2919  return xnGetSerialNumber(GetHandle(), strBuffer, &nBufferSize);
2920  }
2921  };
2922 
2936  class Device : public ProductionNode
2937  {
2938  public:
2939  inline Device(XnNodeHandle hNode = NULL) : ProductionNode(hNode) {}
2940  inline Device(const NodeWrapper& other) : ProductionNode(other) {}
2941 
2950  inline XnStatus Create(Context& context, Query* pQuery = NULL, EnumerationErrors* pErrors = NULL);
2951 
2966  {
2968  }
2969  };
2970 
3019  {
3020  public:
3021  inline MirrorCapability(XnNodeHandle hNode) : Capability(hNode) {}
3022  MirrorCapability(const NodeWrapper& node) : Capability(node) {}
3023 
3030  inline XnStatus SetMirror(XnBool bMirror)
3031  {
3032  return xnSetMirror(GetHandle(), bMirror);
3033  }
3034 
3038  inline XnBool IsMirrored() const
3039  {
3040  return xnIsMirrored(GetHandle());
3041  }
3042 
3052  inline XnStatus RegisterToMirrorChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
3053  {
3054  return _RegisterToStateChange(xnRegisterToMirrorChange, GetHandle(), handler, pCookie, hCallback);
3055  }
3056 
3065  {
3066  _UnregisterFromStateChange(xnUnregisterFromMirrorChange, GetHandle(), hCallback);
3067  }
3068  };
3069 
3103  {
3104  public:
3107 
3122  inline XnBool IsViewPointSupported(ProductionNode& otherNode) const
3123  {
3124  return xnIsViewPointSupported(GetHandle(), otherNode.GetHandle());
3125  }
3126 
3135  {
3136  return xnSetViewPoint(GetHandle(), otherNode.GetHandle());
3137  }
3138 
3143  {
3144  return xnResetViewPoint(GetHandle());
3145  }
3146 
3154  inline XnBool IsViewPointAs(ProductionNode& otherNode) const
3155  {
3156  return xnIsViewPointAs(GetHandle(), otherNode.GetHandle());
3157  }
3158 
3168  inline XnStatus RegisterToViewPointChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
3169  {
3170  return _RegisterToStateChange(xnRegisterToViewPointChange, GetHandle(), handler, pCookie, hCallback);
3171  }
3172 
3181  {
3182  _UnregisterFromStateChange(xnUnregisterFromViewPointChange, GetHandle(), hCallback);
3183  }
3184 
3196  XnStatus GetPixelCoordinatesInViewPoint(ProductionNode& other, XnUInt32 x, XnUInt32 y, XnUInt32& altX, XnUInt32& altY)
3197  {
3198  return xnGetPixelCoordinatesInViewPoint(GetHandle(), other.GetHandle(), x, y, &altX, &altY);
3199  }
3200  };
3201 
3224  {
3225  public:
3226  inline FrameSyncCapability(XnNodeHandle hNode) : Capability(hNode) {}
3228 
3237  inline XnBool CanFrameSyncWith(Generator& other) const;
3238 
3245  inline XnStatus FrameSyncWith(Generator& other);
3246 
3251  inline XnStatus StopFrameSyncWith(Generator& other);
3252 
3259  inline XnBool IsFrameSyncedWith(Generator& other) const;
3260 
3270  inline XnStatus RegisterToFrameSyncChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
3271  {
3272  return _RegisterToStateChange(xnRegisterToFrameSyncChange, GetHandle(), handler, pCookie, hCallback);
3273  }
3274 
3283  {
3284  _UnregisterFromStateChange(xnUnregisterFromFrameSyncChange, GetHandle(), hCallback);
3285  }
3286  };
3287 
3340  class Generator : public ProductionNode
3341  {
3342  public:
3348  inline Generator(XnNodeHandle hNode = NULL) : ProductionNode(hNode) {}
3349  inline Generator(const NodeWrapper& other) : ProductionNode(other) {}
3350 
3371  {
3372  return xnStartGenerating(GetHandle());
3373  }
3374 
3378  inline XnBool IsGenerating() const
3379  {
3380  return xnIsGenerating(GetHandle());
3381  }
3382 
3392  {
3393  return xnStopGenerating(GetHandle());
3394  }
3395 
3410  {
3411  return _RegisterToStateChange(xnRegisterToGenerationRunningChange, GetHandle(), handler, pCookie, hCallback);
3412  }
3413 
3422  {
3423  _UnregisterFromStateChange(xnUnregisterFromGenerationRunningChange, GetHandle(), hCallback);
3424  }
3425 
3440  {
3441  return _RegisterToStateChange(xnRegisterToNewDataAvailable, GetHandle(), handler, pCookie, hCallback);
3442  }
3443 
3452  {
3453  _UnregisterFromStateChange(xnUnregisterFromNewDataAvailable, GetHandle(), hCallback);
3454  }
3455 
3464  inline XnBool IsNewDataAvailable(XnUInt64* pnTimestamp = NULL) const
3465  {
3466  return xnIsNewDataAvailable(GetHandle(), pnTimestamp);
3467  }
3468 
3488  {
3489  return xnWaitAndUpdateData(GetHandle());
3490  }
3491 
3496  inline XnBool IsDataNew() const
3497  {
3498  return xnIsDataNew(GetHandle());
3499  }
3500 
3518  inline const void* GetData()
3519  {
3520  return xnGetData(GetHandle());
3521  }
3522 
3536  inline XnUInt32 GetDataSize() const
3537  {
3538  return xnGetDataSize(GetHandle());
3539  }
3540 
3554  inline XnUInt64 GetTimestamp() const
3555  {
3556  return xnGetTimestamp(GetHandle());
3557  }
3558 
3571  inline XnUInt32 GetFrameID() const
3572  {
3573  return xnGetFrameID(GetHandle());
3574  }
3575 
3584  inline const MirrorCapability GetMirrorCap() const
3585  {
3586  return MirrorCapability(GetHandle());
3587  }
3588 
3598  {
3599  return MirrorCapability(GetHandle());
3600  }
3601 
3613  {
3615  }
3616 
3628  {
3630  }
3631 
3642  {
3643  return FrameSyncCapability(GetHandle());
3644  }
3645 
3656  {
3657  return FrameSyncCapability(GetHandle());
3658  }
3659  };
3660 
3705  class Recorder : public ProductionNode
3706  {
3707  public:
3713  inline Recorder(XnNodeHandle hNode = NULL) : ProductionNode(hNode) {}
3714  inline Recorder(const NodeWrapper& other) : ProductionNode(other) {}
3715 
3723  inline XnStatus Create(Context& context, const XnChar* strFormatName = NULL);
3724 
3733  inline XnStatus SetDestination(XnRecordMedium destType, const XnChar* strDest)
3734  {
3735  return xnSetRecorderDestination(GetHandle(), destType, strDest);
3736  }
3737 
3747  inline XnStatus GetDestination(XnRecordMedium& destType, XnChar* strDest, XnUInt32 nBufSize)
3748  {
3749  return xnGetRecorderDestination(GetHandle(), &destType, strDest, nBufSize);
3750  }
3751 
3762  {
3763  return xnAddNodeToRecording(GetHandle(), Node.GetHandle(), compression);
3764  }
3765 
3773  {
3774  return xnRemoveNodeFromRecording(GetHandle(), Node.GetHandle());
3775  }
3776 
3789  inline XnStatus Record()
3790  {
3791  return xnRecord(GetHandle());
3792  }
3793  };
3794 
3822  class Player : public ProductionNode
3823  {
3824  public:
3830  inline Player(XnNodeHandle hNode = NULL) : ProductionNode(hNode) {}
3831  inline Player(const NodeWrapper& other) : ProductionNode(other) {}
3832 
3841  inline XnStatus Create(Context& context, const XnChar* strFormatName);
3842 
3843 
3858  inline XnStatus SetRepeat(XnBool bRepeat)
3859  {
3860  return xnSetPlayerRepeat(GetHandle(), bRepeat);
3861  }
3862 
3867  inline XnStatus SetSource(XnRecordMedium sourceType, const XnChar* strSource)
3868  {
3869  return xnSetPlayerSource(GetHandle(), sourceType, strSource);
3870  }
3871 
3880  inline XnStatus GetSource(XnRecordMedium &sourceType, XnChar* strSource, XnUInt32 nBufSize) const
3881  {
3882  return xnGetPlayerSource(GetHandle(), &sourceType, strSource, nBufSize);
3883  }
3884 
3890  {
3891  return xnPlayerReadNext(GetHandle());
3892  }
3893 
3918  inline XnStatus SeekToTimeStamp(XnInt64 nTimeOffset, XnPlayerSeekOrigin origin)
3919  {
3920  return xnSeekPlayerToTimeStamp(GetHandle(), nTimeOffset, origin);
3921  }
3922 
3947  inline XnStatus SeekToFrame(const XnChar* strNodeName, XnInt32 nFrameOffset, XnPlayerSeekOrigin origin)
3948  {
3949  return xnSeekPlayerToFrame(GetHandle(), strNodeName, nFrameOffset, origin);
3950  }
3951 
3957  inline XnStatus TellTimestamp(XnUInt64& nTimestamp) const
3958  {
3959  return xnTellPlayerTimestamp(GetHandle(), &nTimestamp);
3960  }
3961 
3974  inline XnStatus TellFrame(const XnChar* strNodeName, XnUInt32& nFrame) const
3975  {
3976  return xnTellPlayerFrame(GetHandle(), strNodeName, &nFrame);
3977  }
3978 
3986  inline XnStatus GetNumFrames(const XnChar* strNodeName, XnUInt32& nFrames) const
3987  {
3988  return xnGetPlayerNumFrames(GetHandle(), strNodeName, &nFrames);
3989  }
3990 
3995  inline const XnChar* GetSupportedFormat() const
3996  {
3998  }
3999 
4005  {
4006  XnNodeInfoList* pList;
4007  XnStatus nRetVal = xnEnumeratePlayerNodes(GetHandle(), &pList);
4008  XN_IS_STATUS_OK(nRetVal);
4009 
4010  list.ReplaceUnderlyingObject(pList);
4011 
4012  return (XN_STATUS_OK);
4013  }
4014 
4023  inline XnBool IsEOF() const
4024  {
4025  return xnIsPlayerAtEOF(GetHandle());
4026  }
4027 
4038  {
4039  return _RegisterToStateChange(xnRegisterToEndOfFileReached, GetHandle(), handler, pCookie, hCallback);
4040  }
4041 
4050  {
4051  _UnregisterFromStateChange(xnUnregisterFromEndOfFileReached, GetHandle(), hCallback);
4052  }
4053 
4072  inline XnStatus SetPlaybackSpeed(XnDouble dSpeed)
4073  {
4074  return xnSetPlaybackSpeed(GetHandle(), dSpeed);
4075  }
4076 
4081  inline XnDouble GetPlaybackSpeed() const
4082  {
4083  return xnGetPlaybackSpeed(GetHandle());
4084  }
4085  };
4086 
4115  {
4116  public:
4122  inline CroppingCapability(XnNodeHandle hNode) : Capability(hNode) {}
4124 
4134  inline XnStatus SetCropping(const XnCropping& Cropping)
4135  {
4136  return xnSetCropping(GetHandle(), &Cropping);
4137  }
4138 
4149  inline XnStatus GetCropping(XnCropping& Cropping) const
4150  {
4151  return xnGetCropping(GetHandle(), &Cropping);
4152  }
4153 
4163  inline XnStatus RegisterToCroppingChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
4164  {
4165  return _RegisterToStateChange(xnRegisterToCroppingChange, GetHandle(), handler, pCookie, hCallback);
4166  }
4167 
4176  {
4177  _UnregisterFromStateChange(xnUnregisterFromCroppingChange, GetHandle(), hCallback);
4178  }
4179  };
4180 
4190  {
4191  public:
4199 
4205  {
4206  return xnSetPowerLineFrequency(GetHandle(), nFrequency);
4207  }
4208 
4214  {
4216  }
4217 
4228  {
4229  return _RegisterToStateChange(xnRegisterToPowerLineFrequencyChange, GetHandle(), handler, pCookie, hCallback);
4230  }
4231 
4240  {
4241  _UnregisterFromStateChange(xnUnregisterFromPowerLineFrequencyChange, GetHandle(), hCallback);
4242  }
4243  };
4244 
4268  class MapGenerator : public Generator
4269  {
4270  public:
4276  inline MapGenerator(XnNodeHandle hNode = NULL) : Generator(hNode) {}
4277  inline MapGenerator(const NodeWrapper& other) : Generator(other) {}
4278 
4286  inline XnUInt32 GetSupportedMapOutputModesCount() const
4287  {
4289  }
4290 
4301  inline XnStatus GetSupportedMapOutputModes(XnMapOutputMode* aModes, XnUInt32& nCount) const
4302  {
4303  return xnGetSupportedMapOutputModes(GetHandle(), aModes, &nCount);
4304  }
4305 
4319  inline XnStatus SetMapOutputMode(const XnMapOutputMode& OutputMode)
4320  {
4321  return xnSetMapOutputMode(GetHandle(), &OutputMode);
4322  }
4323 
4341  inline XnStatus GetMapOutputMode(XnMapOutputMode &OutputMode) const
4342  {
4343  return xnGetMapOutputMode(GetHandle(), &OutputMode);
4344  }
4345 
4354  inline XnUInt32 GetBytesPerPixel() const
4355  {
4356  return xnGetBytesPerPixel(GetHandle());
4357  }
4358 
4369  {
4370  return _RegisterToStateChange(xnRegisterToMapOutputModeChange, GetHandle(), handler, pCookie, hCallback);
4371  }
4372 
4381  {
4382  _UnregisterFromStateChange(xnUnregisterFromMapOutputModeChange, GetHandle(), hCallback);
4383  }
4384 
4393  inline const CroppingCapability GetCroppingCap() const
4394  {
4395  return CroppingCapability(GetHandle());
4396  }
4397 
4407  {
4408  return CroppingCapability(GetHandle());
4409  }
4410 
4417  {
4419  }
4420 
4427  {
4429  }
4430 
4437  {
4439  }
4440 
4447  {
4449  }
4450 
4457  {
4459  }
4460 
4467  {
4469  }
4470 
4477  {
4479  }
4480 
4487  {
4489  }
4490 
4497  {
4499  }
4500 
4507  {
4509  }
4510 
4517  {
4519  }
4520 
4527  {
4529  }
4530 
4537  {
4539  }
4540 
4547  {
4549  }
4550 
4557  {
4559  }
4560 
4561 
4568  {
4570  }
4571 
4578  {
4580  }
4581 
4588  {
4590  }
4591 
4598  {
4599  return AntiFlickerCapability(GetHandle());
4600  }
4601  };
4602 
4612  {
4613  public:
4619  inline UserPositionCapability(XnNodeHandle hNode = NULL) : Capability(hNode) {}
4621 
4626  inline XnUInt32 GetSupportedUserPositionsCount() const
4627  {
4629  }
4630 
4635  inline XnStatus SetUserPosition(XnUInt32 nIndex, const XnBoundingBox3D& Position)
4636  {
4637  return xnSetUserPosition(GetHandle(), nIndex, &Position);
4638  }
4639 
4644  inline XnStatus GetUserPosition(XnUInt32 nIndex, XnBoundingBox3D& Position) const
4645  {
4646  return xnGetUserPosition(GetHandle(), nIndex, &Position);
4647  }
4648 
4659  {
4660  return _RegisterToStateChange(xnRegisterToUserPositionChange, GetHandle(), handler, pCookie, hCallback);
4661  }
4662 
4671  {
4672  _UnregisterFromStateChange(xnUnregisterFromUserPositionChange, GetHandle(), hCallback);
4673  }
4674  };
4675 
4721  {
4722  public:
4728  inline DepthGenerator(XnNodeHandle hNode = NULL) : MapGenerator(hNode) {}
4729  inline DepthGenerator(const NodeWrapper& other) : MapGenerator(other) {}
4730 
4738  inline XnStatus Create(Context& context, Query* pQuery = NULL, EnumerationErrors* pErrors = NULL);
4739 
4756  inline void GetMetaData(DepthMetaData& metaData) const
4757  {
4759  }
4760 
4765  inline const XnDepthPixel* GetDepthMap() const
4766  {
4767  return xnGetDepthMap(GetHandle());
4768  }
4769 
4780  {
4781  return xnGetDeviceMaxDepth(GetHandle());
4782  }
4783 
4803  {
4804  return xnGetDepthFieldOfView(GetHandle(), &FOV);
4805  }
4806 
4817  {
4818  return _RegisterToStateChange(xnRegisterToDepthFieldOfViewChange, GetHandle(), handler, pCookie, hCallback);
4819  }
4820 
4829  {
4830  _UnregisterFromStateChange(xnUnregisterFromDepthFieldOfViewChange, GetHandle(), hCallback);
4831  }
4832 
4842  inline XnStatus ConvertProjectiveToRealWorld(XnUInt32 nCount, const XnPoint3D aProjective[], XnPoint3D aRealWorld[]) const
4843  {
4844  return xnConvertProjectiveToRealWorld(GetHandle(), nCount, aProjective, aRealWorld);
4845  }
4846 
4856  inline XnStatus ConvertRealWorldToProjective(XnUInt32 nCount, const XnPoint3D aRealWorld[], XnPoint3D aProjective[]) const
4857  {
4858  return xnConvertRealWorldToProjective(GetHandle(), nCount, aRealWorld, aProjective);
4859  }
4860 
4867  {
4869  }
4870 
4877  {
4879  }
4880  };
4881 
4887  {
4888  public:
4894  inline MockDepthGenerator(XnNodeHandle hNode = NULL) : DepthGenerator(hNode) {}
4895  inline MockDepthGenerator(const NodeWrapper& other) : DepthGenerator(other) {}
4896 
4903  XnStatus Create(Context& context, const XnChar* strName = NULL);
4904 
4912  XnStatus CreateBasedOn(DepthGenerator& other, const XnChar* strName = NULL);
4913 
4918  inline XnStatus SetData(XnUInt32 nFrameID, XnUInt64 nTimestamp, XnUInt32 nDataSize, const XnDepthPixel* pDepthMap)
4919  {
4920  return xnMockDepthSetData(GetHandle(), nFrameID, nTimestamp, nDataSize, pDepthMap);
4921  }
4922 
4931  inline XnStatus SetData(const DepthMetaData& depthMD, XnUInt32 nFrameID, XnUInt64 nTimestamp)
4932  {
4933  return SetData(nFrameID, nTimestamp, depthMD.DataSize(), depthMD.Data());
4934  }
4935 
4941  inline XnStatus SetData(const DepthMetaData& depthMD)
4942  {
4943  return SetData(depthMD, depthMD.FrameID(), depthMD.Timestamp());
4944  }
4945  };
4946 
4966  {
4967  public:
4973  inline ImageGenerator(XnNodeHandle hNode = NULL) : MapGenerator(hNode) {}
4974  inline ImageGenerator(const NodeWrapper& other) : MapGenerator(other) {}
4975 
4981  inline XnStatus Create(Context& context, Query* pQuery = NULL, EnumerationErrors* pErrors = NULL);
4982 
4999  inline void GetMetaData(ImageMetaData& metaData) const
5000  {
5002  }
5003 
5008  inline const XnRGB24Pixel* GetRGB24ImageMap() const
5009  {
5010  return xnGetRGB24ImageMap(GetHandle());
5011  }
5012 
5018  {
5019  return xnGetYUV422ImageMap(GetHandle());
5020  }
5021 
5027  {
5029  }
5030 
5036  {
5038  }
5039 
5044  inline const XnUInt8* GetImageMap() const
5045  {
5046  return xnGetImageMap(GetHandle());
5047  }
5048 
5059  inline XnBool IsPixelFormatSupported(XnPixelFormat Format) const
5060  {
5061  return xnIsPixelFormatSupported(GetHandle(), Format);
5062  }
5063 
5082  {
5083  return xnSetPixelFormat(GetHandle(), Format);
5084  }
5085 
5097  {
5098  return xnGetPixelFormat(GetHandle());
5099  }
5100 
5111  {
5112  return _RegisterToStateChange(xnRegisterToPixelFormatChange, GetHandle(), handler, pCookie, hCallback);
5113  }
5114 
5123  {
5124  _UnregisterFromStateChange(xnUnregisterFromPixelFormatChange, GetHandle(), hCallback);
5125  }
5126  };
5127 
5133  {
5134  public:
5140  inline MockImageGenerator(XnNodeHandle hNode = NULL) : ImageGenerator(hNode) {}
5141  inline MockImageGenerator(const NodeWrapper& other) : ImageGenerator(other) {}
5142 
5149  XnStatus Create(Context& context, const XnChar* strName = NULL);
5150 
5158  XnStatus CreateBasedOn(ImageGenerator& other, const XnChar* strName = NULL);
5159 
5164  inline XnStatus SetData(XnUInt32 nFrameID, XnUInt64 nTimestamp, XnUInt32 nDataSize, const XnUInt8* pImageMap)
5165  {
5166  return xnMockImageSetData(GetHandle(), nFrameID, nTimestamp, nDataSize, pImageMap);
5167  }
5168 
5177  inline XnStatus SetData(const ImageMetaData& imageMD, XnUInt32 nFrameID, XnUInt64 nTimestamp)
5178  {
5179  return SetData(nFrameID, nTimestamp, imageMD.DataSize(), imageMD.Data());
5180  }
5181 
5187  inline XnStatus SetData(const ImageMetaData& imageMD)
5188  {
5189  return SetData(imageMD, imageMD.FrameID(), imageMD.Timestamp());
5190  }
5191  };
5192 
5201  class IRGenerator : public MapGenerator
5202  {
5203  public:
5209  inline IRGenerator(XnNodeHandle hNode = NULL) : MapGenerator(hNode) {}
5210  inline IRGenerator(const NodeWrapper& other) : MapGenerator(other) {}
5211 
5218  inline XnStatus Create(Context& context, Query* pQuery = NULL, EnumerationErrors* pErrors = NULL);
5219 
5236  inline void GetMetaData(IRMetaData& metaData) const
5237  {
5238  xnGetIRMetaData(GetHandle(), metaData.GetUnderlying());
5239  }
5240 
5244  inline const XnIRPixel* GetIRMap() const
5245  {
5246  return xnGetIRMap(GetHandle());
5247  }
5248  };
5249 
5255  {
5256  public:
5262  inline MockIRGenerator(XnNodeHandle hNode = NULL) : IRGenerator(hNode) {}
5263  inline MockIRGenerator(const NodeWrapper& other) : IRGenerator(other) {}
5264 
5271  XnStatus Create(Context& context, const XnChar* strName = NULL);
5278  XnStatus CreateBasedOn(IRGenerator& other, const XnChar* strName = NULL);
5279 
5284  inline XnStatus SetData(XnUInt32 nFrameID, XnUInt64 nTimestamp, XnUInt32 nDataSize, const XnIRPixel* pIRMap)
5285  {
5286  return xnMockIRSetData(GetHandle(), nFrameID, nTimestamp, nDataSize, pIRMap);
5287  }
5288 
5297  inline XnStatus SetData(const IRMetaData& irMD, XnUInt32 nFrameID, XnUInt64 nTimestamp)
5298  {
5299  return SetData(nFrameID, nTimestamp, irMD.DataSize(), irMD.Data());
5300  }
5301 
5307  inline XnStatus SetData(const IRMetaData& irMD)
5308  {
5309  return SetData(irMD, irMD.FrameID(), irMD.Timestamp());
5310  }
5311  };
5312 
5381  {
5382  public:
5388  inline GestureGenerator(XnNodeHandle hNode = NULL) : Generator(hNode) {}
5389  inline GestureGenerator(const NodeWrapper& other) : Generator(other) {}
5390 
5404  inline XnStatus Create(Context& context, Query* pQuery = NULL, EnumerationErrors* pErrors = NULL);
5405 
5419  inline XnStatus AddGesture(const XnChar* strGesture, XnBoundingBox3D* pArea)
5420  {
5421  return xnAddGesture(GetHandle(), strGesture, pArea);
5422  }
5423 
5431  inline XnStatus RemoveGesture(const XnChar* strGesture)
5432  {
5433  return xnRemoveGesture(GetHandle(), strGesture);
5434  }
5435 
5444  inline XnStatus GetAllActiveGestures(XnChar** astrGestures, XnUInt32 nNameLength, XnUInt16& nGestures) const
5445  {
5446  return xnGetAllActiveGestures(GetHandle(), astrGestures, nNameLength, &nGestures);
5447  }
5448 
5453  inline XnUInt16 GetNumberOfAvailableGestures() const
5454  {
5456  }
5457 
5466  inline XnStatus EnumerateAllGestures(XnChar** astrGestures, XnUInt32 nNameLength, XnUInt16& nGestures) const
5467  {
5468  return xnEnumerateAllGestures(GetHandle(), astrGestures, nNameLength, &nGestures);
5469  }
5470 
5476  inline XnBool IsGestureAvailable(const XnChar* strGesture) const
5477  {
5478  return xnIsGestureAvailable(GetHandle(), strGesture);
5479  }
5480 
5485  inline XnBool IsGestureProgressSupported(const XnChar* strGesture) const
5486  {
5487  return xnIsGestureProgressSupported(GetHandle(), strGesture);
5488  }
5489 
5511  typedef void (XN_CALLBACK_TYPE* GestureRecognized)(GestureGenerator& generator, const XnChar* strGesture, const XnPoint3D* pIDPosition, const XnPoint3D* pEndPosition, void* pCookie);
5512 
5539  typedef void (XN_CALLBACK_TYPE* GestureProgress)(GestureGenerator& generator, const XnChar* strGesture, const XnPoint3D* pPosition, XnFloat fProgress, void* pCookie);
5540 
5552  XnStatus RegisterGestureCallbacks(GestureRecognized RecognizedCB, GestureProgress ProgressCB, void* pCookie, XnCallbackHandle& hCallback)
5553  {
5554  XnStatus nRetVal = XN_STATUS_OK;
5555 
5556  GestureCookie* pGestureCookie;
5557  XN_VALIDATE_ALLOC(pGestureCookie, GestureCookie);
5558  pGestureCookie->recognizedHandler = RecognizedCB;
5559  pGestureCookie->progressHandler = ProgressCB;
5560  pGestureCookie->pUserCookie = pCookie;
5561 
5562  nRetVal = xnRegisterGestureCallbacks(GetHandle(), GestureRecognizedCallback, GestureProgressCallback, pGestureCookie, &pGestureCookie->hCallback);
5563  if (nRetVal != XN_STATUS_OK)
5564  {
5565  xnOSFree(pGestureCookie);
5566  return (nRetVal);
5567  }
5568 
5569  hCallback = pGestureCookie;
5570 
5571  return (XN_STATUS_OK);
5572  }
5573 
5582  {
5583  GestureCookie* pGestureCookie = (GestureCookie*)hCallback;
5584  xnUnregisterGestureCallbacks(GetHandle(), pGestureCookie->hCallback);
5585  xnOSFree(pGestureCookie);
5586  }
5587 
5597  inline XnStatus RegisterToGestureChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
5598  {
5599  return _RegisterToStateChange(xnRegisterToGestureChange, GetHandle(), handler, pCookie, hCallback);
5600  }
5601 
5610  {
5611  _UnregisterFromStateChange(xnUnregisterFromGestureChange, GetHandle(), hCallback);
5612  }
5613 
5641  typedef void (XN_CALLBACK_TYPE* GestureIntermediateStageCompleted)(GestureGenerator& generator, const XnChar* strGesture, const XnPoint3D* pPosition, void* pCookie);
5642 
5653  {
5654  XnStatus nRetVal = XN_STATUS_OK;
5655 
5656  GestureIntermediateStageCompletedCookie* pGestureCookie;
5657  XN_VALIDATE_ALLOC(pGestureCookie, GestureIntermediateStageCompletedCookie);
5658  pGestureCookie->handler = handler;
5659  pGestureCookie->pUserCookie = pCookie;
5660 
5661  nRetVal = xnRegisterToGestureIntermediateStageCompleted(GetHandle(), GestureIntermediateStageCompletedCallback, pGestureCookie, &pGestureCookie->hCallback);
5662  if (nRetVal != XN_STATUS_OK)
5663  {
5664  xnOSFree(pGestureCookie);
5665  return (nRetVal);
5666  }
5667 
5668  hCallback = pGestureCookie;
5669 
5670  return (XN_STATUS_OK);
5671  }
5672 
5681  {
5682  GestureIntermediateStageCompletedCookie* pGestureCookie = (GestureIntermediateStageCompletedCookie*)hCallback;
5683  xnUnregisterFromGestureIntermediateStageCompleted(GetHandle(), pGestureCookie->hCallback);
5684  xnOSFree(pGestureCookie);
5685  }
5686 
5705  typedef void (XN_CALLBACK_TYPE* GestureReadyForNextIntermediateStage)(GestureGenerator& generator, const XnChar* strGesture, const XnPoint3D* pPosition, void* pCookie);
5706 
5717  {
5718  XnStatus nRetVal = XN_STATUS_OK;
5719 
5720  GestureReadyForNextIntermediateStageCookie* pGestureCookie;
5721  XN_VALIDATE_ALLOC(pGestureCookie, GestureReadyForNextIntermediateStageCookie);
5722  pGestureCookie->handler = handler;
5723  pGestureCookie->pUserCookie = pCookie;
5724 
5725  nRetVal = xnRegisterToGestureReadyForNextIntermediateStage(GetHandle(), GestureReadyForNextIntermediateStageCallback, pGestureCookie, &pGestureCookie->hCallback);
5726  if (nRetVal != XN_STATUS_OK)
5727  {
5728  xnOSFree(pGestureCookie);
5729  return (nRetVal);
5730  }
5731 
5732  hCallback = pGestureCookie;
5733 
5734  return (XN_STATUS_OK);
5735  }
5736 
5745  {
5746  GestureReadyForNextIntermediateStageCookie* pGestureCookie = (GestureReadyForNextIntermediateStageCookie*)hCallback;
5748  xnOSFree(pGestureCookie);
5749  }
5750 
5752  inline XnStatus XN_API_DEPRECATED("Use GetAllActiveGestures() instead") GetActiveGestures(XnChar*& astrGestures, XnUInt16& nGestures) const
5753  {
5754  return xnGetActiveGestures(GetHandle(), &astrGestures, &nGestures);
5755  }
5756  inline XnStatus XN_API_DEPRECATED("Use EnumerateAllGestures() instead") EnumerateGestures(XnChar*& astrGestures, XnUInt16& nGestures) const
5757  {
5758  return xnEnumerateGestures(GetHandle(), &astrGestures, &nGestures);
5759  }
5762  private:
5763  typedef struct GestureCookie
5764  {
5765  GestureRecognized recognizedHandler;
5766  GestureProgress progressHandler;
5767  void* pUserCookie;
5768  XnCallbackHandle hCallback;
5769  } GestureCookie;
5770 
5771  static void XN_CALLBACK_TYPE GestureRecognizedCallback(XnNodeHandle hNode, const XnChar* strGesture, const XnPoint3D* pIDPosition, const XnPoint3D* pEndPosition, void* pCookie)
5772  {
5773  GestureCookie* pGestureCookie = (GestureCookie*)pCookie;
5774  GestureGenerator gen(hNode);
5775  if (pGestureCookie->recognizedHandler != NULL)
5776  {
5777  pGestureCookie->recognizedHandler(gen, strGesture, pIDPosition, pEndPosition, pGestureCookie->pUserCookie);
5778  }
5779  }
5780 
5781  static void XN_CALLBACK_TYPE GestureProgressCallback(XnNodeHandle hNode, const XnChar* strGesture, const XnPoint3D* pPosition, XnFloat fProgress, void* pCookie)
5782  {
5783  GestureCookie* pGestureCookie = (GestureCookie*)pCookie;
5784  GestureGenerator gen(hNode);
5785  if (pGestureCookie->progressHandler != NULL)
5786  {
5787  pGestureCookie->progressHandler(gen, strGesture, pPosition, fProgress, pGestureCookie->pUserCookie);
5788  }
5789  }
5790 
5791  typedef struct GestureIntermediateStageCompletedCookie
5792  {
5794  void* pUserCookie;
5795  XnCallbackHandle hCallback;
5796  } GestureIntermediateStageCompletedCookie;
5797 
5798  static void XN_CALLBACK_TYPE GestureIntermediateStageCompletedCallback(XnNodeHandle hNode, const XnChar* strGesture, const XnPoint3D* pPosition, void* pCookie)
5799  {
5800  GestureIntermediateStageCompletedCookie* pGestureCookie = (GestureIntermediateStageCompletedCookie*)pCookie;
5801  GestureGenerator gen(hNode);
5802  if (pGestureCookie->handler != NULL)
5803  {
5804  pGestureCookie->handler(gen, strGesture, pPosition, pGestureCookie->pUserCookie);
5805  }
5806  }
5807 
5808  typedef struct GestureReadyForNextIntermediateStageCookie
5809  {
5811  void* pUserCookie;
5812  XnCallbackHandle hCallback;
5813  } GestureReadyForNextIntermediateStageCookie;
5814 
5815  static void XN_CALLBACK_TYPE GestureReadyForNextIntermediateStageCallback(XnNodeHandle hNode, const XnChar* strGesture, const XnPoint3D* pPosition, void* pCookie)
5816  {
5817  GestureReadyForNextIntermediateStageCookie* pGestureCookie = (GestureReadyForNextIntermediateStageCookie*)pCookie;
5818  GestureGenerator gen(hNode);
5819  if (pGestureCookie->handler != NULL)
5820  {
5821  pGestureCookie->handler(gen, strGesture, pPosition, pGestureCookie->pUserCookie);
5822  }
5823  }
5824  };
5825 
5845  {
5846  public:
5852  inline SceneAnalyzer(XnNodeHandle hNode = NULL) : MapGenerator(hNode) {}
5853  inline SceneAnalyzer(const NodeWrapper& other) : MapGenerator(other) {}
5854 
5862  inline XnStatus Create(Context& context, Query* pQuery = NULL, EnumerationErrors* pErrors = NULL);
5863 
5864 
5884  inline void GetMetaData(SceneMetaData& metaData) const
5885  {
5887  }
5888 
5893  inline const XnLabel* GetLabelMap() const
5894  {
5895  return xnGetLabelMap(GetHandle());
5896  }
5897 
5903  inline XnStatus GetFloor(XnPlane3D& Plane) const
5904  {
5905  return xnGetFloor(GetHandle(), &Plane);
5906  }
5907  };
5908 
5917  {
5918  public:
5926 
5937  typedef void (XN_CALLBACK_TYPE* HandTouchingFOVEdge)(HandTouchingFOVEdgeCapability& touchingfov, XnUserID user, const XnPoint3D* pPosition, XnFloat fTime, XnDirection eDir, void* pCookie);
5938 
5949  {
5950  XnStatus nRetVal = XN_STATUS_OK;
5951 
5952  HandTouchingFOVEdgeCookie* pHandCookie;
5953  XN_VALIDATE_ALLOC(pHandCookie, HandTouchingFOVEdgeCookie);
5954  pHandCookie->handler = handler;
5955  pHandCookie->pUserCookie = pCookie;
5956 
5957  nRetVal = xnRegisterToHandTouchingFOVEdge(GetHandle(), HandTouchingFOVEdgeCB, pHandCookie, &pHandCookie->hCallback);
5958  if (nRetVal != XN_STATUS_OK)
5959  {
5960  xnOSFree(pHandCookie);
5961  return (nRetVal);
5962  }
5963 
5964  hCallback = pHandCookie;
5965 
5966  return (XN_STATUS_OK);
5967  }
5968 
5977  {
5978  HandTouchingFOVEdgeCookie* pHandCookie = (HandTouchingFOVEdgeCookie*)hCallback;
5979  xnUnregisterFromHandTouchingFOVEdge(GetHandle(), pHandCookie->hCallback);
5980  xnOSFree(pHandCookie);
5981  }
5982  private:
5983  typedef struct HandTouchingFOVEdgeCookie
5984  {
5985  HandTouchingFOVEdge handler;
5986  void* pUserCookie;
5987  XnCallbackHandle hCallback;
5988  } HandTouchingFOVEdgeCookie;
5989 
5990  static void XN_CALLBACK_TYPE HandTouchingFOVEdgeCB(XnNodeHandle hNode, XnUserID user, const XnPoint3D* pPosition, XnFloat fTime, XnDirection eDir, void* pCookie)
5991  {
5992  HandTouchingFOVEdgeCookie* pHandCookie = (HandTouchingFOVEdgeCookie*)pCookie;
5993  HandTouchingFOVEdgeCapability cap(hNode);
5994  if (pHandCookie->handler != NULL)
5995  {
5996  pHandCookie->handler(cap, user, pPosition, fTime, eDir, pHandCookie->pUserCookie);
5997  }
5998  }
5999 
6000  };
6001 
6089  class HandsGenerator : public Generator
6090  {
6091  public:
6097  inline HandsGenerator(XnNodeHandle hNode = NULL) : Generator(hNode) {}
6098  inline HandsGenerator(const NodeWrapper& other) : Generator(other) {}
6099 
6107  inline XnStatus Create(Context& context, Query* pQuery = NULL, EnumerationErrors* pErrors = NULL);
6108 
6124  typedef void (XN_CALLBACK_TYPE* HandCreate)(HandsGenerator& generator, XnUserID user, const XnPoint3D* pPosition, XnFloat fTime, void* pCookie);
6125 
6142  typedef void (XN_CALLBACK_TYPE* HandUpdate)(HandsGenerator& generator, XnUserID user, const XnPoint3D* pPosition, XnFloat fTime, void* pCookie);
6143 
6157  typedef void (XN_CALLBACK_TYPE* HandDestroy)(HandsGenerator& generator, XnUserID user, XnFloat fTime, void* pCookie);
6158 
6171  inline XnStatus RegisterHandCallbacks(HandCreate CreateCB, HandUpdate UpdateCB, HandDestroy DestroyCB, void* pCookie, XnCallbackHandle& hCallback)
6172  {
6173  XnStatus nRetVal = XN_STATUS_OK;
6174 
6175  HandCookie* pHandCookie;
6176  XN_VALIDATE_ALLOC(pHandCookie, HandCookie);
6177  pHandCookie->createHandler = CreateCB;
6178  pHandCookie->updateHandler = UpdateCB;
6179  pHandCookie->destroyHandler = DestroyCB;
6180  pHandCookie->pUserCookie = pCookie;
6181 
6182  nRetVal = xnRegisterHandCallbacks(GetHandle(), HandCreateCB, HandUpdateCB, HandDestroyCB, pHandCookie, &pHandCookie->hCallback);
6183  if (nRetVal != XN_STATUS_OK)
6184  {
6185  xnOSFree(pHandCookie);
6186  return (nRetVal);
6187  }
6188 
6189  hCallback = pHandCookie;
6190 
6191  return (XN_STATUS_OK);
6192  }
6193 
6202  {
6203  HandCookie* pHandCookie = (HandCookie*)hCallback;
6204  xnUnregisterHandCallbacks(GetHandle(), pHandCookie->hCallback);
6205  xnOSFree(pHandCookie);
6206  }
6207 
6222  {
6223  return xnStopTracking(GetHandle(), user);
6224  }
6225 
6235  {
6236  return xnStopTrackingAll(GetHandle());
6237  }
6238 
6255  inline XnStatus StartTracking(const XnPoint3D& ptPosition)
6256  {
6257  return xnStartTracking(GetHandle(), &ptPosition);
6258  }
6259 
6276  inline XnStatus SetSmoothing(XnFloat fSmoothingFactor)
6277  {
6278  return xnSetTrackingSmoothing(GetHandle(), fSmoothingFactor);
6279  }
6280 
6289  {
6291  }
6292 
6301  {
6303  }
6304 
6305  private:
6306  typedef struct HandCookie
6307  {
6308  HandCreate createHandler;
6309  HandUpdate updateHandler;
6310  HandDestroy destroyHandler;
6311  void* pUserCookie;
6312  XnCallbackHandle hCallback;
6313  } HandCookie;
6314 
6315  static void XN_CALLBACK_TYPE HandCreateCB(XnNodeHandle hNode, XnUserID user, const XnPoint3D* pPosition, XnFloat fTime, void* pCookie)
6316  {
6317  HandCookie* pHandCookie = (HandCookie*)pCookie;
6318  HandsGenerator gen(hNode);
6319  if (pHandCookie->createHandler != NULL)
6320  {
6321  pHandCookie->createHandler(gen, user, pPosition, fTime, pHandCookie->pUserCookie);
6322  }
6323  }
6324  static void XN_CALLBACK_TYPE HandUpdateCB(XnNodeHandle hNode, XnUserID user, const XnPoint3D* pPosition, XnFloat fTime, void* pCookie)
6325  {
6326  HandCookie* pHandCookie = (HandCookie*)pCookie;
6327  HandsGenerator gen(hNode);
6328  if (pHandCookie->updateHandler != NULL)
6329  {
6330  pHandCookie->updateHandler(gen, user, pPosition, fTime, pHandCookie->pUserCookie);
6331  }
6332  }
6333  static void XN_CALLBACK_TYPE HandDestroyCB(XnNodeHandle hNode, XnUserID user, XnFloat fTime, void* pCookie)
6334  {
6335  HandCookie* pHandCookie = (HandCookie*)pCookie;
6336  HandsGenerator gen(hNode);
6337  if (pHandCookie->destroyHandler != NULL)
6338  {
6339  pHandCookie->destroyHandler(gen, user, fTime, pHandCookie->pUserCookie);
6340  }
6341  }
6342  };
6343 
6401  {
6402  public:
6408  inline SkeletonCapability(XnNodeHandle hNode) : Capability(hNode) {}
6410 
6416  inline XnBool IsJointAvailable(XnSkeletonJoint eJoint) const
6417  {
6418  return xnIsJointAvailable(GetHandle(), eJoint);
6419  }
6420 
6426  inline XnBool IsProfileAvailable(XnSkeletonProfile eProfile) const
6427  {
6428  return xnIsProfileAvailable(GetHandle(), eProfile);
6429  }
6430 
6462  {
6463  return xnSetSkeletonProfile(GetHandle(), eProfile);
6464  }
6465 
6489  inline XnStatus SetJointActive(XnSkeletonJoint eJoint, XnBool bState)
6490  {
6491  return xnSetJointActive(GetHandle(), eJoint, bState);
6492  }
6493 
6499  inline XnBool IsJointActive(XnSkeletonJoint eJoint) const
6500  {
6501  return xnIsJointActive(GetHandle(), eJoint);
6502  }
6503 
6514  {
6515  return _RegisterToStateChange(xnRegisterToJointConfigurationChange, GetHandle(), handler, pCookie, hCallback);
6516  }
6517 
6526  {
6527  _UnregisterFromStateChange(xnUnregisterFromJointConfigurationChange, GetHandle(), hCallback);
6528  }
6529 
6534  inline XnStatus EnumerateActiveJoints(XnSkeletonJoint* pJoints, XnUInt16& nJoints) const
6535  {
6536  return xnEnumerateActiveJoints(GetHandle(), pJoints, &nJoints);
6537  }
6538 
6548  {
6549  return xnGetSkeletonJoint(GetHandle(), user, eJoint, &Joint);
6550  }
6551 
6574  {
6575  return xnGetSkeletonJointPosition(GetHandle(), user, eJoint, &Joint);
6576  }
6577 
6586  {
6587  return xnGetSkeletonJointOrientation(GetHandle(), user, eJoint, &Joint);
6588  }
6589 
6600  inline XnBool IsTracking(XnUserID user) const
6601  {
6602  return xnIsSkeletonTracking(GetHandle(), user);
6603  }
6604 
6615  inline XnBool IsCalibrated(XnUserID user) const
6616  {
6617  return xnIsSkeletonCalibrated(GetHandle(), user);
6618  }
6619 
6630  inline XnBool IsCalibrating(XnUserID user) const
6631  {
6632  return xnIsSkeletonCalibrating(GetHandle(), user);
6633  }
6634 
6659  inline XnStatus RequestCalibration(XnUserID user, XnBool bForce)
6660  {
6661  return xnRequestSkeletonCalibration(GetHandle(), user, bForce);
6662  }
6663 
6674  {
6675  return xnAbortSkeletonCalibration(GetHandle(), user);
6676  }
6677 
6696  inline XnStatus SaveCalibrationDataToFile(XnUserID user, const XnChar* strFileName)
6697  {
6698  return xnSaveSkeletonCalibrationDataToFile(GetHandle(), user, strFileName);
6699  }
6700 
6707  inline XnStatus LoadCalibrationDataFromFile(XnUserID user, const XnChar* strFileName)
6708  {
6709  return xnLoadSkeletonCalibrationDataFromFile(GetHandle(), user, strFileName);
6710  }
6711 
6723  inline XnStatus SaveCalibrationData(XnUserID user, XnUInt32 nSlot)
6724  {
6725  return xnSaveSkeletonCalibrationData(GetHandle(), user, nSlot);
6726  }
6727 
6734  inline XnStatus LoadCalibrationData(XnUserID user, XnUInt32 nSlot)
6735  {
6736  return xnLoadSkeletonCalibrationData(GetHandle(), user, nSlot);
6737  }
6738 
6744  inline XnStatus ClearCalibrationData(XnUInt32 nSlot)
6745  {
6746  return xnClearSkeletonCalibrationData(GetHandle(), nSlot);
6747  }
6748 
6754  inline XnBool IsCalibrationData(XnUInt32 nSlot) const
6755  {
6756  return xnIsSkeletonCalibrationData(GetHandle(), nSlot);
6757  }
6758 
6774  {
6775  return xnStartSkeletonTracking(GetHandle(), user);
6776  }
6777 
6783  {
6784  return xnStopSkeletonTracking(GetHandle(), user);
6785  }
6786 
6795  inline XnStatus Reset(XnUserID user)
6796  {
6797  return xnResetSkeleton(GetHandle(), user);
6798  }
6799 
6808  inline XnBool NeedPoseForCalibration() const
6809  {
6811  }
6812 
6825  inline XnStatus GetCalibrationPose(XnChar* strPose) const
6826  {
6827  return xnGetSkeletonCalibrationPose(GetHandle(), strPose);
6828  }
6829 
6842  inline XnStatus SetSmoothing(XnFloat fSmoothingFactor)
6843  {
6844  return xnSetSkeletonSmoothing(GetHandle(), fSmoothingFactor);
6845  }
6846 
6868  typedef void (XN_CALLBACK_TYPE* CalibrationStart)(SkeletonCapability& skeleton, XnUserID user, void* pCookie);
6869 
6887  typedef void (XN_CALLBACK_TYPE* CalibrationEnd)(SkeletonCapability& skeleton, XnUserID user, XnBool bSuccess, void* pCookie);
6888 
6900  inline XnStatus RegisterToCalibrationStart(CalibrationStart handler, void* pCookie, XnCallbackHandle& hCallback)
6901  {
6902  XnStatus nRetVal = XN_STATUS_OK;
6903  CalibrationStartCookie* pCalibrationCookie;
6904  XN_VALIDATE_ALLOC(pCalibrationCookie, CalibrationStartCookie);
6905  pCalibrationCookie->handler = handler;
6906  pCalibrationCookie->pUserCookie = pCookie;
6907  nRetVal = xnRegisterToCalibrationStart(GetHandle(), CalibrationStartCallback, pCalibrationCookie, &pCalibrationCookie->hCallback);
6908  if (nRetVal != XN_STATUS_OK)
6909  {
6910  xnOSFree(pCalibrationCookie);
6911  return nRetVal;
6912  }
6913  hCallback = pCalibrationCookie;
6914  return XN_STATUS_OK;
6915  }
6916 
6928  {
6929  CalibrationStartCookie* pCalibrationCookie = (CalibrationStartCookie*)hCallback;
6930  xnUnregisterFromCalibrationStart(GetHandle(), pCalibrationCookie->hCallback);
6931  xnOSFree(pCalibrationCookie);
6932  return XN_STATUS_OK;
6933  }
6934 
6956  typedef void (XN_CALLBACK_TYPE* CalibrationInProgress)(SkeletonCapability& skeleton, XnUserID user, XnCalibrationStatus calibrationError, void* pCookie);
6957 
6968  {
6969  XnStatus nRetVal = XN_STATUS_OK;
6970 
6971  CalibrationInProgressCookie* pSkeletonCookie;
6972  XN_VALIDATE_ALLOC(pSkeletonCookie, CalibrationInProgressCookie);
6973  pSkeletonCookie->handler = handler;
6974  pSkeletonCookie->pUserCookie = pCookie;
6975 
6976  nRetVal = xnRegisterToCalibrationInProgress(GetHandle(), CalibrationInProgressCallback, pSkeletonCookie, &pSkeletonCookie->hCallback);
6977  if (nRetVal != XN_STATUS_OK)
6978  {
6979  xnOSFree(pSkeletonCookie);
6980  return (nRetVal);
6981  }
6982 
6983  hCallback = pSkeletonCookie;
6984 
6985  return (XN_STATUS_OK);
6986  }
6987 
6996  {
6997  CalibrationInProgressCookie* pSkeletonCookie = (CalibrationInProgressCookie*)hCallback;
6998  xnUnregisterFromCalibrationInProgress(GetHandle(), pSkeletonCookie->hCallback);
6999  xnOSFree(pSkeletonCookie);
7000  }
7001 
7019  typedef void (XN_CALLBACK_TYPE* CalibrationComplete)(SkeletonCapability& skeleton, XnUserID user, XnCalibrationStatus calibrationError, void* pCookie);
7020 
7031  {
7032  XnStatus nRetVal = XN_STATUS_OK;
7033 
7034  CalibrationCompleteCookie* pSkeletonCookie;
7035  XN_VALIDATE_ALLOC(pSkeletonCookie, CalibrationCompleteCookie);
7036  pSkeletonCookie->handler = handler;
7037  pSkeletonCookie->pUserCookie = pCookie;
7038 
7039  nRetVal = xnRegisterToCalibrationComplete(GetHandle(), CalibrationCompleteCallback, pSkeletonCookie, &pSkeletonCookie->hCallback);
7040  if (nRetVal != XN_STATUS_OK)
7041  {
7042  xnOSFree(pSkeletonCookie);
7043  return (nRetVal);
7044  }
7045 
7046  hCallback = pSkeletonCookie;
7047 
7048  return (XN_STATUS_OK);
7049  }
7050 
7059  {
7060  CalibrationCompleteCookie* pSkeletonCookie = (CalibrationCompleteCookie*)hCallback;
7061  xnUnregisterFromCalibrationComplete(GetHandle(), pSkeletonCookie->hCallback);
7062  xnOSFree(pSkeletonCookie);
7063  }
7064 
7066  XN_API_DEPRECATED("Use the overload with one argument - the bState parameter is useless")
7067  inline XnBool IsJointActive(XnSkeletonJoint eJoint, XnBool /*bState*/) const
7068  {
7069  return xnIsJointActive(GetHandle(), eJoint);
7070  }
7071 
7072  inline XnStatus XN_API_DEPRECATED("Please use RegisterToCalibrationStart/Complete") RegisterCalibrationCallbacks(CalibrationStart CalibrationStartCB, CalibrationEnd CalibrationEndCB, void* pCookie, XnCallbackHandle& hCallback)
7073  {
7074  XnStatus nRetVal = XN_STATUS_OK;
7075 
7076  SkeletonCookie* pSkeletonCookie;
7077  XN_VALIDATE_ALLOC(pSkeletonCookie, SkeletonCookie);
7078  pSkeletonCookie->startHandler = CalibrationStartCB;
7079  pSkeletonCookie->endHandler = CalibrationEndCB;
7080  pSkeletonCookie->pUserCookie = pCookie;
7081 
7082 #pragma warning (push)
7083 #pragma warning (disable: XN_DEPRECATED_WARNING_IDS)
7084  nRetVal = xnRegisterCalibrationCallbacks(GetHandle(), CalibrationStartBundleCallback, CalibrationEndBundleCallback, pSkeletonCookie, &pSkeletonCookie->hCallback);
7085 #pragma warning (pop)
7086  if (nRetVal != XN_STATUS_OK)
7087  {
7088  xnOSFree(pSkeletonCookie);
7089  return (nRetVal);
7090  }
7091 
7092  hCallback = pSkeletonCookie;
7093 
7094  return (XN_STATUS_OK);
7095  }
7096 
7097  inline void XN_API_DEPRECATED("Please use UnregisterFromCalibrationStart/Complete") UnregisterCalibrationCallbacks(XnCallbackHandle hCallback)
7098  {
7099  SkeletonCookie* pSkeletonCookie = (SkeletonCookie*)hCallback;
7100 #pragma warning (push)
7101 #pragma warning (disable: XN_DEPRECATED_WARNING_IDS)
7102  xnUnregisterCalibrationCallbacks(GetHandle(), pSkeletonCookie->hCallback);
7103 #pragma warning (pop)
7104  xnOSFree(pSkeletonCookie);
7105  }
7108 private:
7109  typedef struct SkeletonCookie
7110  {
7111  CalibrationStart startHandler;
7112  CalibrationEnd endHandler;
7113  void* pUserCookie;
7114  XnCallbackHandle hCallback;
7115  } SkeletonCookie;
7116 
7117  static void XN_CALLBACK_TYPE CalibrationStartBundleCallback(XnNodeHandle hNode, XnUserID user, void* pCookie)
7118  {
7119  SkeletonCookie* pSkeletonCookie = (SkeletonCookie*)pCookie;
7120  SkeletonCapability cap(hNode);
7121  if (pSkeletonCookie->startHandler != NULL)
7122  {
7123  pSkeletonCookie->startHandler(cap, user, pSkeletonCookie->pUserCookie);
7124  }
7125  }
7126 
7127  static void XN_CALLBACK_TYPE CalibrationEndBundleCallback(XnNodeHandle hNode, XnUserID user, XnBool bSuccess, void* pCookie)
7128  {
7129  SkeletonCookie* pSkeletonCookie = (SkeletonCookie*)pCookie;
7130  SkeletonCapability cap(hNode);
7131  if (pSkeletonCookie->endHandler != NULL)
7132  {
7133  pSkeletonCookie->endHandler(cap, user, bSuccess, pSkeletonCookie->pUserCookie);
7134  }
7135  }
7136 
7137  typedef struct CalibrationStartCookie
7138  {
7139  CalibrationStart handler;
7140  void* pUserCookie;
7141  XnCallbackHandle hCallback;
7142  } CalibrationStartCookie;
7143 
7144  static void XN_CALLBACK_TYPE CalibrationStartCallback(XnNodeHandle hNode, XnUserID user, void* pCookie)
7145  {
7146  CalibrationStartCookie* pCalibrationCookie = (CalibrationStartCookie*)pCookie;
7147  SkeletonCapability cap(hNode);
7148  if (pCalibrationCookie->handler != NULL)
7149  {
7150  pCalibrationCookie->handler(cap, user, pCalibrationCookie->pUserCookie);
7151  }
7152  }
7153 
7154  typedef struct CalibrationInProgressCookie
7155  {
7156  CalibrationInProgress handler;
7157  void* pUserCookie;
7158  XnCallbackHandle hCallback;
7159  } CalibrationInProgressCookie;
7160 
7161  static void XN_CALLBACK_TYPE CalibrationInProgressCallback(XnNodeHandle hNode, XnUserID user, XnCalibrationStatus calibrationError, void* pCookie)
7162  {
7163  CalibrationInProgressCookie* pSkeletonCookie = (CalibrationInProgressCookie*)pCookie;
7164  SkeletonCapability cap(hNode);
7165  if (pSkeletonCookie->handler != NULL)
7166  {
7167  pSkeletonCookie->handler(cap, user, calibrationError, pSkeletonCookie->pUserCookie);
7168  }
7169  }
7170 
7171  typedef struct CalibrationCompleteCookie
7172  {
7173  CalibrationComplete handler;
7174  void* pUserCookie;
7175  XnCallbackHandle hCallback;
7176  } CalibrationCompleteCookie;
7177 
7178  static void XN_CALLBACK_TYPE CalibrationCompleteCallback(XnNodeHandle hNode, XnUserID user, XnCalibrationStatus calibrationError, void* pCookie)
7179  {
7180  CalibrationCompleteCookie* pSkeletonCookie = (CalibrationCompleteCookie*)pCookie;
7181  SkeletonCapability cap(hNode);
7182  if (pSkeletonCookie->handler != NULL)
7183  {
7184  pSkeletonCookie->handler(cap, user, calibrationError, pSkeletonCookie->pUserCookie);
7185  }
7186  }
7187  };
7188 
7211  {
7212  public:
7220 
7234  typedef void (XN_CALLBACK_TYPE* PoseDetection)(PoseDetectionCapability& pose, const XnChar* strPose, XnUserID user, void* pCookie);
7235 
7245  inline XnUInt32 GetNumberOfPoses() const
7246  {
7247  return xnGetNumberOfPoses(GetHandle());
7248  }
7249 
7262  inline XnStatus GetAllAvailablePoses(XnChar** pstrPoses, XnUInt32 nNameLength, XnUInt32& nPoses) const
7263  {
7264  return xnGetAllAvailablePoses(GetHandle(), pstrPoses, nNameLength, &nPoses);
7265  }
7266 
7267  inline XnBool IsPoseSupported(const XnChar* strPose)
7268  {
7269  return xnIsPoseSupported(GetHandle(), strPose);
7270  }
7271 
7272  inline XnStatus GetPoseStatus(XnUserID userID, const XnChar* poseName, XnUInt64& poseTime, XnPoseDetectionStatus& eStatus, XnPoseDetectionState& eState)
7273  {
7274  return xnGetPoseStatus(GetHandle(), userID, poseName, &poseTime, &eStatus, &eState);
7275  }
7276 
7292  inline XnStatus StartPoseDetection(const XnChar* strPose, XnUserID user)
7293  {
7294  return xnStartPoseDetection(GetHandle(), strPose, user);
7295  }
7296 
7309  {
7310  return xnStopPoseDetection(GetHandle(), user);
7311  }
7312 
7316  inline XnStatus StopSinglePoseDetection(XnUserID user, const XnChar* strPose)
7317  {
7318  return xnStopSinglePoseDetection(GetHandle(), user, strPose);
7319  }
7320 
7330  inline XnStatus RegisterToPoseDetected(PoseDetection handler, void* pCookie, XnCallbackHandle& hCallback)
7331  {
7332  XnStatus nRetVal = XN_STATUS_OK;
7333  PoseDetectionCookie* pPoseCookie;
7334  XN_VALIDATE_ALLOC(pPoseCookie, PoseDetectionCookie);
7335  pPoseCookie->handler = handler;
7336  pPoseCookie->pPoseCookie = pCookie;
7337 
7338  nRetVal = xnRegisterToPoseDetected(GetHandle(), PoseDetectionCallback, pPoseCookie, &pPoseCookie->hCallback);
7339  if (nRetVal != XN_STATUS_OK)
7340  {
7341  xnOSFree(pPoseCookie);
7342  return nRetVal;
7343  }
7344  hCallback = pPoseCookie;
7345  return XN_STATUS_OK;
7346  }
7347 
7357  inline XnStatus RegisterToOutOfPose(PoseDetection handler, void* pCookie, XnCallbackHandle& hCallback)
7358  {
7359  XnStatus nRetVal = XN_STATUS_OK;
7360  PoseDetectionCookie* pPoseCookie;
7361  XN_VALIDATE_ALLOC(pPoseCookie, PoseDetectionCookie);
7362  pPoseCookie->handler = handler;
7363  pPoseCookie->pPoseCookie = pCookie;
7364 
7365  nRetVal = xnRegisterToOutOfPose(GetHandle(), PoseDetectionCallback, pPoseCookie, &pPoseCookie->hCallback);
7366  if (nRetVal != XN_STATUS_OK)
7367  {
7368  xnOSFree(pPoseCookie);
7369  return nRetVal;
7370  }
7371  hCallback = pPoseCookie;
7372  return XN_STATUS_OK;
7373  }
7382  {
7383  PoseDetectionCookie* pPoseCookie = (PoseDetectionCookie*)hCallback;
7384  xnUnregisterFromPoseDetected(GetHandle(), pPoseCookie->hCallback);
7385  xnOSFree(pPoseCookie);
7386  }
7395  {
7396  PoseDetectionCookie* pPoseCookie = (PoseDetectionCookie*)hCallback;
7397  xnUnregisterFromOutOfPose(GetHandle(), pPoseCookie->hCallback);
7398  xnOSFree(pPoseCookie);
7399  }
7400 
7423  typedef void (XN_CALLBACK_TYPE* PoseInProgress)(PoseDetectionCapability& pose, const XnChar* strPose, XnUserID user, XnPoseDetectionStatus poseError, void* pCookie);
7424 
7441  inline XnStatus RegisterToPoseInProgress(PoseInProgress handler, void* pCookie, XnCallbackHandle& hCallback)
7442  {
7443  XnStatus nRetVal = XN_STATUS_OK;
7444 
7445  PoseInProgressCookie* pPoseCookie;
7446  XN_VALIDATE_ALLOC(pPoseCookie, PoseInProgressCookie);
7447  pPoseCookie->handler = handler;
7448  pPoseCookie->pPoseCookie = pCookie;
7449 
7450  nRetVal = xnRegisterToPoseDetectionInProgress(GetHandle(), PoseDetectionInProgressCallback, pPoseCookie, &pPoseCookie->hCallback);
7451  if (nRetVal != XN_STATUS_OK)
7452  {
7453  xnOSFree(pPoseCookie);
7454  return (nRetVal);
7455  }
7456 
7457  hCallback = pPoseCookie;
7458 
7459  return (XN_STATUS_OK);
7460  }
7461 
7470  {
7471  PoseInProgressCookie* pPoseCookie = (PoseInProgressCookie*)hCallback;
7472  xnUnregisterFromPoseDetectionInProgress(GetHandle(), pPoseCookie->hCallback);
7473  xnOSFree(pPoseCookie);
7474  }
7475 
7477  inline XnStatus XN_API_DEPRECATED("Use GetAllAvailablePoses() instead") GetAvailablePoses(XnChar** pstrPoses, XnUInt32& nPoses) const
7478  {
7479  return xnGetAvailablePoses(GetHandle(), pstrPoses, &nPoses);
7480  }
7481 
7482  inline XnStatus XN_API_DEPRECATED("Please use RegisterToPoseDetected/RegisterToOutOfPose instead") RegisterToPoseCallbacks(PoseDetection PoseStartCB, PoseDetection PoseEndCB, void* pCookie, XnCallbackHandle& hCallback)
7483  {
7484  XnStatus nRetVal = XN_STATUS_OK;
7485 
7486  PoseCookie* pPoseCookie;
7487  XN_VALIDATE_ALLOC(pPoseCookie, PoseCookie);
7488  pPoseCookie->startHandler = PoseStartCB;
7489  pPoseCookie->endHandler = PoseEndCB;
7490  pPoseCookie->pPoseCookie = pCookie;
7491 
7492 #pragma warning (push)
7493 #pragma warning (disable: XN_DEPRECATED_WARNING_IDS)
7494  nRetVal = xnRegisterToPoseCallbacks(GetHandle(), PoseDetectionStartBundleCallback, PoseDetectionStartEndBundleCallback, pPoseCookie, &pPoseCookie->hCallback);
7495 #pragma warning (pop)
7496  if (nRetVal != XN_STATUS_OK)
7497  {
7498  xnOSFree(pPoseCookie);
7499  return (nRetVal);
7500  }
7501 
7502  hCallback = pPoseCookie;
7503 
7504  return (XN_STATUS_OK);
7505  }
7506 
7507  inline void XN_API_DEPRECATED("Please use UnregisterFromPoseDetected/UnregisterFromOutOfPose instead") UnregisterFromPoseCallbacks(XnCallbackHandle hCallback)
7508  {
7509  PoseCookie* pPoseCookie = (PoseCookie*)hCallback;
7510 #pragma warning (push)
7511 #pragma warning (disable: XN_DEPRECATED_WARNING_IDS)
7512  xnUnregisterFromPoseCallbacks(GetHandle(), pPoseCookie->hCallback);
7513 #pragma warning (pop)
7514  xnOSFree(pPoseCookie);
7515  }
7518 private:
7519  typedef struct PoseCookie
7520  {
7521  PoseDetection startHandler;
7522  PoseDetection endHandler;
7523  void* pPoseCookie;
7524  XnCallbackHandle hCallback;
7525  } PoseCookie;
7526 
7527  static void XN_CALLBACK_TYPE PoseDetectionStartBundleCallback(XnNodeHandle hNode, const XnChar* strPose, XnUserID user, void* pCookie)
7528  {
7529  PoseCookie* pPoseCookie = (PoseCookie*)pCookie;
7530  PoseDetectionCapability cap(hNode);
7531  if (pPoseCookie->startHandler != NULL)
7532  {
7533  pPoseCookie->startHandler(cap, strPose, user, pPoseCookie->pPoseCookie);
7534  }
7535  }
7536 
7537  static void XN_CALLBACK_TYPE PoseDetectionStartEndBundleCallback(XnNodeHandle hNode, const XnChar* strPose, XnUserID user, void* pCookie)
7538  {
7539  PoseCookie* pPoseCookie = (PoseCookie*)pCookie;
7540  PoseDetectionCapability cap(hNode);
7541  if (pPoseCookie->endHandler != NULL)
7542  {
7543  pPoseCookie->endHandler(cap, strPose, user, pPoseCookie->pPoseCookie);
7544  }
7545  }
7546  typedef struct PoseDetectionCookie
7547  {
7548  PoseDetection handler;
7549  void* pPoseCookie;
7550  XnCallbackHandle hCallback;
7551  } PoseDetectionCookie;
7552  static void XN_CALLBACK_TYPE PoseDetectionCallback(XnNodeHandle hNode, const XnChar* strPose, XnUserID user, void* pCookie)
7553  {
7554  PoseDetectionCookie* pPoseDetectionCookie = (PoseDetectionCookie*)pCookie;
7555  PoseDetectionCapability cap(hNode);
7556  if (pPoseDetectionCookie->handler != NULL)
7557  {
7558  pPoseDetectionCookie->handler(cap, strPose, user, pPoseDetectionCookie->pPoseCookie);
7559  }
7560  }
7561 
7562  typedef struct PoseInProgressCookie
7563  {
7564  PoseInProgress handler;
7565  void* pPoseCookie;
7566  XnCallbackHandle hCallback;
7567  } PoseInProgressCookie;
7568 
7569  static void XN_CALLBACK_TYPE PoseDetectionInProgressCallback(XnNodeHandle hNode, const XnChar* strPose, XnUserID user, XnPoseDetectionStatus poseErrors, void* pCookie)
7570  {
7571  PoseInProgressCookie* pPoseCookie = (PoseInProgressCookie*)pCookie;
7572  PoseDetectionCapability cap(hNode);
7573  if (pPoseCookie->handler != NULL)
7574  {
7575  pPoseCookie->handler(cap, strPose, user, poseErrors, pPoseCookie->pPoseCookie);
7576  }
7577  }
7578  };
7579 
7691  class UserGenerator : public Generator
7692  {
7693  public:
7699  inline UserGenerator(XnNodeHandle hNode = NULL) : Generator(hNode) {}
7700  inline UserGenerator(const NodeWrapper& other) : Generator(other) {}
7701 
7709  inline XnStatus Create(Context& context, Query* pQuery = NULL, EnumerationErrors* pErrors = NULL);
7710 
7723  typedef void (XN_CALLBACK_TYPE* UserHandler)(UserGenerator& generator, XnUserID user, void* pCookie);
7724 
7732  inline XnUInt16 GetNumberOfUsers() const
7733  {
7734  return xnGetNumberOfUsers(GetHandle());
7735  }
7736 
7759  inline XnStatus GetUsers(XnUserID aUsers[], XnUInt16& nUsers) const
7760  {
7761  return xnGetUsers(GetHandle(), aUsers, &nUsers);
7762  }
7763 
7783  inline XnStatus GetCoM(XnUserID user, XnPoint3D& com) const
7784  {
7785  return xnGetUserCoM(GetHandle(), user, &com);
7786  }
7787 
7804  {
7805  return xnGetUserPixels(GetHandle(), user, smd.GetUnderlying());
7806  }
7807 
7818  inline XnStatus RegisterUserCallbacks(UserHandler NewUserCB, UserHandler LostUserCB, void* pCookie, XnCallbackHandle& hCallback)
7819  {
7820  XnStatus nRetVal = XN_STATUS_OK;
7821 
7822  UserCookie* pUserCookie;
7823  XN_VALIDATE_ALLOC(pUserCookie, UserCookie);
7824  pUserCookie->newHandler = NewUserCB;
7825  pUserCookie->lostHandler = LostUserCB;
7826  pUserCookie->pUserCookie = pCookie;
7827 
7828  nRetVal = xnRegisterUserCallbacks(GetHandle(), NewUserCallback, LostUserCallback, pUserCookie, &pUserCookie->hCallback);
7829  if (nRetVal != XN_STATUS_OK)
7830  {
7831  xnOSFree(pUserCookie);
7832  return (nRetVal);
7833  }
7834 
7835  hCallback = pUserCookie;
7836 
7837  return (XN_STATUS_OK);
7838  }
7839 
7848  {
7849  UserCookie* pUserCookie = (UserCookie*)hCallback;
7850  xnUnregisterUserCallbacks(GetHandle(), pUserCookie->hCallback);
7851  xnOSFree(pUserCookie);
7852  }
7853 
7865  inline const SkeletonCapability GetSkeletonCap() const
7866  {
7867  return SkeletonCapability(GetHandle());
7868  }
7869 
7882  {
7883  return SkeletonCapability(GetHandle());
7884  }
7885 
7897  {
7899  }
7900 
7912  {
7914  }
7915 
7925  inline XnStatus RegisterToUserExit(UserHandler handler, void* pCookie, XnCallbackHandle& hCallback)
7926  {
7927  XnStatus nRetVal = XN_STATUS_OK;
7928 
7929  UserSingleCookie* pUserCookie;
7930  XN_VALIDATE_ALLOC(pUserCookie, UserSingleCookie);
7931  pUserCookie->handler = handler;
7932  pUserCookie->pUserCookie = pCookie;
7933 
7934  nRetVal = xnRegisterToUserExit(GetHandle(), UserSingleCallback, pUserCookie, &pUserCookie->hCallback);
7935  if (nRetVal != XN_STATUS_OK)
7936  {
7937  xnOSFree(pUserCookie);
7938  return (nRetVal);
7939  }
7940 
7941  hCallback = pUserCookie;
7942 
7943  return (XN_STATUS_OK);
7944  }
7945 
7954  {
7955  UserSingleCookie* pUserCookie = (UserSingleCookie*)hCallback;
7956  xnUnregisterFromUserExit(GetHandle(), pUserCookie->hCallback);
7957  xnOSFree(pUserCookie);
7958  }
7959 
7969  inline XnStatus RegisterToUserReEnter(UserHandler handler, void* pCookie, XnCallbackHandle& hCallback)
7970  {
7971  XnStatus nRetVal = XN_STATUS_OK;
7972 
7973  UserSingleCookie* pUserCookie;
7974  XN_VALIDATE_ALLOC(pUserCookie, UserSingleCookie);
7975  pUserCookie->handler = handler;
7976  pUserCookie->pUserCookie = pCookie;
7977 
7978  nRetVal = xnRegisterToUserReEnter(GetHandle(), UserSingleCallback, pUserCookie, &pUserCookie->hCallback);
7979  if (nRetVal != XN_STATUS_OK)
7980  {
7981  xnOSFree(pUserCookie);
7982  return (nRetVal);
7983  }
7984 
7985  hCallback = pUserCookie;
7986 
7987  return (XN_STATUS_OK);
7988  }
7989 
7998  {
7999  UserSingleCookie* pUserCookie = (UserSingleCookie*)hCallback;
8000  xnUnregisterFromUserReEnter(GetHandle(), pUserCookie->hCallback);
8001  xnOSFree(pUserCookie);
8002  }
8003 
8004  private:
8005  typedef struct UserCookie
8006  {
8007  UserHandler newHandler;
8008  UserHandler lostHandler;
8009  void* pUserCookie;
8010  XnCallbackHandle hCallback;
8011  } UserCookie;
8012 
8013  static void XN_CALLBACK_TYPE NewUserCallback(XnNodeHandle hNode, XnUserID user, void* pCookie)
8014  {
8015  UserCookie* pUserCookie = (UserCookie*)pCookie;
8016  UserGenerator gen(hNode);
8017  if (pUserCookie->newHandler != NULL)
8018  {
8019  pUserCookie->newHandler(gen, user, pUserCookie->pUserCookie);
8020  }
8021  }
8022 
8023  static void XN_CALLBACK_TYPE LostUserCallback(XnNodeHandle hNode, XnUserID user, void* pCookie)
8024  {
8025  UserCookie* pUserCookie = (UserCookie*)pCookie;
8026  UserGenerator gen(hNode);
8027  if (pUserCookie->lostHandler != NULL)
8028  {
8029  pUserCookie->lostHandler(gen, user, pUserCookie->pUserCookie);
8030  }
8031  }
8032 
8033  typedef struct UserSingleCookie
8034  {
8035  UserHandler handler;
8036  void* pUserCookie;
8037  XnCallbackHandle hCallback;
8038  } UserSingleCookie;
8039 
8040  static void XN_CALLBACK_TYPE UserSingleCallback(XnNodeHandle hNode, XnUserID user, void* pCookie)
8041  {
8042  UserSingleCookie* pUserCookie = (UserSingleCookie*)pCookie;
8043  UserGenerator gen(hNode);
8044  if (pUserCookie->handler != NULL)
8045  {
8046  pUserCookie->handler(gen, user, pUserCookie->pUserCookie);
8047  }
8048  }
8049  };
8050 
8064  class AudioGenerator : public Generator
8065  {
8066  public:
8072  inline AudioGenerator(XnNodeHandle hNode = NULL) : Generator(hNode) {}
8073  inline AudioGenerator(const NodeWrapper& other) : Generator(other) {}
8074 
8082  inline XnStatus Create(Context& context, Query* pQuery = NULL, EnumerationErrors* pErrors = NULL);
8083 
8100  inline void GetMetaData(AudioMetaData& metaData) const
8101  {
8103  }
8104 
8109  inline const XnUChar* GetAudioBuffer() const
8110  {
8111  return xnGetAudioBuffer(GetHandle());
8112  }
8113 
8117  inline XnUInt32 GetSupportedWaveOutputModesCount() const
8118  {
8120  }
8121 
8128  inline XnStatus GetSupportedWaveOutputModes(XnWaveOutputMode* aSupportedModes, XnUInt32& nCount) const
8129  {
8130  return xnGetSupportedWaveOutputModes(GetHandle(), aSupportedModes, &nCount);
8131  }
8132 
8144  inline XnStatus SetWaveOutputMode(const XnWaveOutputMode& OutputMode)
8145  {
8146  return xnSetWaveOutputMode(GetHandle(), &OutputMode);
8147  }
8148 
8160  inline XnStatus GetWaveOutputMode(XnWaveOutputMode& OutputMode) const
8161  {
8162  return xnGetWaveOutputMode(GetHandle(), &OutputMode);
8163  }
8164 
8175  {
8176  return _RegisterToStateChange(xnRegisterToWaveOutputModeChanges, GetHandle(), handler, pCookie, hCallback);
8177  }
8178 
8187  {
8188  _UnregisterFromStateChange(xnUnregisterFromWaveOutputModeChanges, GetHandle(), hCallback);
8189  }
8190  };
8191 
8197  {
8198  public:
8204  inline MockAudioGenerator(XnNodeHandle hNode = NULL) : AudioGenerator(hNode) {}
8205  inline MockAudioGenerator(const NodeWrapper& other) : AudioGenerator(other) {}
8206 
8213  XnStatus Create(Context& context, const XnChar* strName = NULL);
8214 
8222  XnStatus CreateBasedOn(AudioGenerator& other, const XnChar* strName = NULL);
8223 
8228  inline XnStatus SetData(XnUInt32 nFrameID, XnUInt64 nTimestamp, XnUInt32 nDataSize, const XnUInt8* pAudioBuffer)
8229  {
8230  return xnMockAudioSetData(GetHandle(), nFrameID, nTimestamp, nDataSize, pAudioBuffer);
8231  }
8232 
8241  inline XnStatus SetData(const AudioMetaData& audioMD, XnUInt32 nFrameID, XnUInt64 nTimestamp)
8242  {
8243  return SetData(nFrameID, nTimestamp, audioMD.DataSize(), audioMD.Data());
8244  }
8245 
8251  inline XnStatus SetData(const AudioMetaData& audioMD)
8252  {
8253  return SetData(audioMD, audioMD.FrameID(), audioMD.Timestamp());
8254  }
8255  };
8256 
8261  {
8262  public:
8263  MockRawGenerator(XnNodeHandle hNode = NULL) : Generator(hNode) {}
8264  MockRawGenerator(const NodeWrapper& other) : Generator(other) {}
8265 
8266  inline XnStatus Create(Context& context, const XnChar* strName = NULL);
8267 
8268  inline XnStatus SetData(XnUInt32 nFrameID, XnUInt64 nTimestamp, XnUInt32 nDataSize, const void* pData)
8269  {
8270  return xnMockRawSetData(GetHandle(), nFrameID, nTimestamp, nDataSize, pData);
8271  }
8272 
8273  };
8274 
8279  class Codec : public ProductionNode
8280  {
8281  public:
8287  inline Codec(XnNodeHandle hNode = NULL) : ProductionNode(hNode) {}
8288  inline Codec(const NodeWrapper& other) : ProductionNode(other) {}
8289 
8294  inline XnStatus Create(Context& context, XnCodecID codecID, ProductionNode& initializerNode);
8295 
8300  inline XnCodecID GetCodecID() const
8301  {
8302  return xnGetCodecID(GetHandle());
8303  }
8304 
8309  inline XnStatus EncodeData(const void* pSrc, XnUInt32 nSrcSize, void* pDst, XnUInt32 nDstSize, XnUInt* pnBytesWritten) const
8310  {
8311  return xnEncodeData(GetHandle(), pSrc, nSrcSize, pDst, nDstSize, pnBytesWritten);
8312  }
8313 
8318  inline XnStatus DecodeData(const void* pSrc, XnUInt32 nSrcSize, void* pDst, XnUInt32 nDstSize, XnUInt* pnBytesWritten) const
8319  {
8320  return xnDecodeData(GetHandle(), pSrc, nSrcSize, pDst, nDstSize, pnBytesWritten);
8321  }
8322  };
8323 
8358  {
8359  public:
8365  inline ScriptNode(XnNodeHandle hNode = NULL) : ProductionNode(hNode) {}
8366  inline ScriptNode(const NodeWrapper& other) : ProductionNode(other) {}
8367 
8368  inline XnStatus Create(Context& context, const XnChar* strFormat);
8369 
8370  inline const XnChar* GetSupportedFormat()
8371  {
8373  }
8374 
8380  inline XnStatus LoadScriptFromFile(const XnChar* strFileName)
8381  {
8382  return xnLoadScriptFromFile(GetHandle(), strFileName);
8383  }
8384 
8390  inline XnStatus LoadScriptFromString(const XnChar* strScript)
8391  {
8392  return xnLoadScriptFromString(GetHandle(), strScript);
8393  }
8394 
8406  inline XnStatus Run(EnumerationErrors* pErrors);
8407  };
8408 
8409  //---------------------------------------------------------------------------
8410  // EnumerationErrors
8411  //---------------------------------------------------------------------------
8433  {
8434  public:
8438  inline EnumerationErrors() : m_bAllocated(TRUE), m_pErrors(NULL) { xnEnumerationErrorsAllocate(&m_pErrors); }
8439 
8447  inline EnumerationErrors(XnEnumerationErrors* pErrors, XnBool bOwn = FALSE) : m_bAllocated(bOwn), m_pErrors(pErrors) {}
8448 
8453 
8457  class Iterator
8458  {
8459  public:
8460  friend class EnumerationErrors;
8461 
8467  XnBool operator==(const Iterator& other) const
8468  {
8469  return m_it == other.m_it;
8470  }
8471 
8477  XnBool operator!=(const Iterator& other) const
8478  {
8479  return m_it != other.m_it;
8480  }
8481 
8487  {
8488  m_it = xnEnumerationErrorsGetNext(m_it);
8489  return *this;
8490  }
8491 
8496  inline Iterator operator++(int)
8497  {
8498  return Iterator(xnEnumerationErrorsGetNext(m_it));
8499  }
8500 
8510 
8516 
8517  private:
8518  inline Iterator(XnEnumerationErrorsIterator it) : m_it(it) {}
8519 
8521  };
8522 
8531  inline Iterator Begin() const { return Iterator(xnEnumerationErrorsGetFirst(m_pErrors)); }
8532 
8541  inline Iterator End() const { return Iterator(NULL); }
8542 
8551  inline XnStatus ToString(XnChar* csBuffer, XnUInt32 nSize)
8552  {
8553  return xnEnumerationErrorsToString(m_pErrors, csBuffer, nSize);
8554  }
8555 
8560  inline void Free()
8561  {
8562  if (m_bAllocated)
8563  {
8564  xnEnumerationErrorsFree(m_pErrors);
8565  m_pErrors = NULL;
8566  m_bAllocated = FALSE;
8567  }
8568  }
8569 
8573  inline XnEnumerationErrors* GetUnderlying() { return m_pErrors; }
8574 
8575  private:
8576  XnEnumerationErrors* m_pErrors;
8577  XnBool m_bAllocated;
8578  };
8579 
8580  //---------------------------------------------------------------------------
8581  // Context
8582  //---------------------------------------------------------------------------
8583 
8619  class Context
8620  {
8621  public:
8636  typedef void (XN_CALLBACK_TYPE* NodeCreationHandler)(Context& context, ProductionNode& createdNode, void* pCookie);
8637 
8652  typedef void (XN_CALLBACK_TYPE* NodeDestructionHandler)(Context& context, const XnChar* strDestroyedNodeName, void* pCookie);
8653 
8657  inline Context() : m_pContext(NULL), m_bUsingDeprecatedAPI(FALSE), m_bAllocated(FALSE), m_hShuttingDownCallback(NULL) {}
8658 
8664  inline Context(XnContext* pContext) : m_pContext(NULL), m_bUsingDeprecatedAPI(FALSE), m_bAllocated(FALSE), m_hShuttingDownCallback(NULL)
8665  {
8666  SetHandle(pContext);
8667  }
8668 
8675  inline Context(const Context& other) : m_pContext(NULL), m_bUsingDeprecatedAPI(FALSE), m_bAllocated(FALSE), m_hShuttingDownCallback(NULL)
8676  {
8677  SetHandle(other.m_pContext);
8678  }
8679 
8684  {
8685  SetHandle(NULL);
8686  }
8687 
8688  inline Context& operator=(const Context& other)
8689  {
8690  SetHandle(other.m_pContext);
8691  return *this;
8692  }
8693 
8697  inline XnContext* GetUnderlyingObject() const { return m_pContext; }
8698 
8704  inline XnBool operator==(const Context& other)
8705  {
8706  return (GetUnderlyingObject() == other.GetUnderlyingObject());
8707  }
8708 
8714  inline XnBool operator!=(const Context& other)
8715  {
8716  return (GetUnderlyingObject() != other.GetUnderlyingObject());
8717  }
8718 
8733  inline XnStatus Init()
8734  {
8735  XnContext* pContext = NULL;
8736  XnStatus nRetVal = xnInit(&pContext);
8737  XN_IS_STATUS_OK(nRetVal);
8738 
8739  TakeOwnership(pContext);
8740  m_bAllocated = TRUE;
8741 
8742  return (XN_STATUS_OK);
8743  }
8744 
8760  inline XnStatus RunXmlScript(const XnChar* strScript, ScriptNode& scriptNode, EnumerationErrors* pErrors = NULL)
8761  {
8762  XnStatus nRetVal = XN_STATUS_OK;
8763 
8764  XnNodeHandle hScriptNode;
8765  nRetVal = xnContextRunXmlScriptEx(m_pContext, strScript, pErrors == NULL ? NULL : pErrors->GetUnderlying(), &hScriptNode);
8766  XN_IS_STATUS_OK(nRetVal);
8767 
8768  scriptNode.TakeOwnership(hScriptNode);
8769 
8770  return (XN_STATUS_OK);
8771  }
8772 
8788  inline XnStatus RunXmlScriptFromFile(const XnChar* strFileName, ScriptNode& scriptNode, EnumerationErrors* pErrors = NULL)
8789  {
8790  XnStatus nRetVal = XN_STATUS_OK;
8791 
8792  XnNodeHandle hScriptNode;
8793  nRetVal = xnContextRunXmlScriptFromFileEx(m_pContext, strFileName, pErrors == NULL ? NULL : pErrors->GetUnderlying(), &hScriptNode);
8794  XN_IS_STATUS_OK(nRetVal);
8795 
8796  scriptNode.TakeOwnership(hScriptNode);
8797 
8798  return (XN_STATUS_OK);
8799  }
8800 
8816  inline XnStatus InitFromXmlFile(const XnChar* strFileName, ScriptNode& scriptNode, EnumerationErrors* pErrors = NULL)
8817  {
8818  XnContext* pContext = NULL;
8819 
8820  XnNodeHandle hScriptNode;
8821  XnStatus nRetVal = xnInitFromXmlFileEx(strFileName, &pContext, pErrors == NULL ? NULL : pErrors->GetUnderlying(), &hScriptNode);
8822  XN_IS_STATUS_OK(nRetVal);
8823 
8824  scriptNode.TakeOwnership(hScriptNode);
8825  TakeOwnership(pContext);
8826  m_bAllocated = TRUE;
8827 
8828  return (XN_STATUS_OK);
8829  }
8830 
8847  inline XnStatus OpenFileRecording(const XnChar* strFileName, ProductionNode& playerNode)
8848  {
8849  XnStatus nRetVal = XN_STATUS_OK;
8850 
8851  XnNodeHandle hPlayer;
8852  nRetVal = xnContextOpenFileRecordingEx(m_pContext, strFileName, &hPlayer);
8853  XN_IS_STATUS_OK(nRetVal);
8854 
8855  playerNode.TakeOwnership(hPlayer);
8856 
8857  return (XN_STATUS_OK);
8858  }
8859 
8864  inline XnStatus CreateMockNode(XnProductionNodeType type, const XnChar* strName, ProductionNode& mockNode)
8865  {
8866  XnStatus nRetVal = XN_STATUS_OK;
8867 
8868  XnNodeHandle hMockNode;
8869  nRetVal = xnCreateMockNode(m_pContext, type, strName, &hMockNode);
8870  XN_IS_STATUS_OK(nRetVal);
8871 
8872  mockNode.TakeOwnership(hMockNode);
8873 
8874  return (XN_STATUS_OK);
8875  }
8876 
8881  inline XnStatus CreateMockNodeBasedOn(ProductionNode& originalNode, const XnChar* strName, ProductionNode& mockNode)
8882  {
8883  XnStatus nRetVal = XN_STATUS_OK;
8884 
8885  XnNodeHandle hMockNode;
8886  nRetVal = xnCreateMockNodeBasedOn(m_pContext, originalNode, strName, &hMockNode);
8887  XN_IS_STATUS_OK(nRetVal);
8888 
8889  mockNode.TakeOwnership(hMockNode);
8890 
8891  return (XN_STATUS_OK);
8892  }
8893 
8898  inline XnStatus CreateCodec(XnCodecID codecID, ProductionNode& initializerNode, Codec& codec)
8899  {
8900  XnStatus nRetVal = XN_STATUS_OK;
8901 
8902  XnNodeHandle hCodec;
8903  nRetVal = xnCreateCodec(m_pContext, codecID, initializerNode.GetHandle(), &hCodec);
8904  XN_IS_STATUS_OK(nRetVal);
8905 
8906  codec.TakeOwnership(hCodec);
8907 
8908  return (XN_STATUS_OK);
8909  }
8910 
8915  inline XnStatus AddRef()
8916  {
8917  return xnContextAddRef(m_pContext);
8918  }
8919 
8924  inline void Release()
8925  {
8926  SetHandle(NULL);
8927  }
8928 
8929 
8934  inline XnStatus AddLicense(const XnLicense& License)
8935  {
8936  return xnAddLicense(m_pContext, &License);
8937  }
8938 
8943  inline XnStatus EnumerateLicenses(XnLicense*& aLicenses, XnUInt32& nCount) const
8944  {
8945  return xnEnumerateLicenses(m_pContext, &aLicenses, &nCount);
8946  }
8947 
8952  inline static void FreeLicensesList(XnLicense aLicenses[])
8953  {
8954  xnFreeLicensesList(aLicenses);
8955  }
8956 
8977  XnStatus EnumerateProductionTrees(XnProductionNodeType Type, const Query* pQuery, NodeInfoList& TreesList, EnumerationErrors* pErrors = NULL) const
8978  {
8979  XnStatus nRetVal = XN_STATUS_OK;
8980 
8981  const XnNodeQuery* pInternalQuery = (pQuery != NULL) ? pQuery->GetUnderlyingObject() : NULL;
8982 
8983  XnNodeInfoList* pList = NULL;
8984  nRetVal = xnEnumerateProductionTrees(m_pContext, Type, pInternalQuery, &pList, pErrors == NULL ? NULL : pErrors->GetUnderlying());
8985  XN_IS_STATUS_OK(nRetVal);
8986 
8987  TreesList.ReplaceUnderlyingObject(pList);
8988 
8989  return (XN_STATUS_OK);
8990  }
8991 
9025  {
9026  XnStatus nRetVal = XN_STATUS_OK;
9027 
9028  XnNodeQuery* pInternalQuery = (pQuery != NULL) ? pQuery->GetUnderlyingObject() : NULL;
9029 
9030  XnNodeHandle hNode;
9031  nRetVal = xnCreateAnyProductionTree(m_pContext, type, pInternalQuery, &hNode, pErrors == NULL ? NULL : pErrors->GetUnderlying());
9032  XN_IS_STATUS_OK(nRetVal);
9033 
9034  node.TakeOwnership(hNode);
9035 
9036  return (XN_STATUS_OK);
9037  }
9038 
9056  {
9057  XnStatus nRetVal = XN_STATUS_OK;
9058 
9059  XnNodeHandle hNode;
9060  nRetVal = xnCreateProductionTree(m_pContext, Tree, &hNode);
9061  XN_IS_STATUS_OK(nRetVal);
9062 
9063  node.TakeOwnership(hNode);
9064 
9065  return (XN_STATUS_OK);
9066  }
9067 
9077  {
9078  XnNodeInfoList* pList;
9079  XnStatus nRetVal = xnEnumerateExistingNodes(m_pContext, &pList);
9080  XN_IS_STATUS_OK(nRetVal);
9081 
9082  list.ReplaceUnderlyingObject(pList);
9083 
9084  return (XN_STATUS_OK);
9085  }
9086 
9106  {
9107  XnNodeInfoList* pList;
9108  XnStatus nRetVal = xnEnumerateExistingNodesByType(m_pContext, type, &pList);
9109  XN_IS_STATUS_OK(nRetVal);
9110 
9111  list.ReplaceUnderlyingObject(pList);
9112 
9113  return (XN_STATUS_OK);
9114  }
9115 
9135  {
9136  XnStatus nRetVal = XN_STATUS_OK;
9137 
9138  XnNodeHandle hNode;
9139  nRetVal = xnFindExistingRefNodeByType(m_pContext, type, &hNode);
9140  XN_IS_STATUS_OK(nRetVal);
9141 
9142  node.TakeOwnership(hNode);
9143 
9144  return (XN_STATUS_OK);
9145  }
9146 
9151  XnStatus GetProductionNodeByName(const XnChar* strInstanceName, ProductionNode& node) const
9152  {
9153  XnStatus nRetVal = XN_STATUS_OK;
9154 
9155  XnNodeHandle hNode;
9156  nRetVal = xnGetRefNodeHandleByName(m_pContext, strInstanceName, &hNode);
9157  XN_IS_STATUS_OK(nRetVal);
9158 
9159  node.TakeOwnership(hNode);
9160 
9161  return (XN_STATUS_OK);
9162  }
9163 
9168  XnStatus GetProductionNodeInfoByName(const XnChar* strInstanceName, NodeInfo& nodeInfo) const
9169  {
9170  XnStatus nRetVal = XN_STATUS_OK;
9171 
9172  XnNodeHandle hNode;
9173  nRetVal = xnGetRefNodeHandleByName(m_pContext, strInstanceName, &hNode);
9174  XN_IS_STATUS_OK(nRetVal);
9175 
9176  xnProductionNodeRelease(hNode);
9177 
9178  nodeInfo = NodeInfo(xnGetNodeInfo(hNode));
9179 
9180  return (XN_STATUS_OK);
9181  }
9182 
9188  {
9189  return xnStartGeneratingAll(m_pContext);
9190  }
9191 
9196  {
9197  return xnStopGeneratingAll(m_pContext);
9198  }
9199 
9209  inline XnStatus SetGlobalMirror(XnBool bMirror)
9210  {
9211  return xnSetGlobalMirror(m_pContext, bMirror);
9212  }
9213 
9218  inline XnBool GetGlobalMirror()
9219  {
9220  return xnGetGlobalMirror(m_pContext);
9221  }
9222 
9228  {
9229  return xnGetGlobalErrorState(m_pContext);
9230  }
9231 
9242  {
9243  return xnRegisterToGlobalErrorStateChange(m_pContext, handler, pCookie, &hCallback);
9244  }
9245 
9254  {
9255  xnUnregisterFromGlobalErrorStateChange(m_pContext, hCallback);
9256  }
9257 
9267  inline XnStatus RegisterToNodeCreation(NodeCreationHandler handler, void* pCookie, XnCallbackHandle& hCallback)
9268  {
9269  XnStatus nRetVal = XN_STATUS_OK;
9270 
9271  NodeCreationCookie* pCreationCookie;
9272  XN_VALIDATE_ALLOC(pCreationCookie, NodeCreationCookie);
9273  pCreationCookie->pFunc = handler;
9274  pCreationCookie->pCookie = pCookie;
9275 
9276  nRetVal = xnRegisterToNodeCreation(m_pContext, NodeCreationCallback, pCreationCookie, &pCreationCookie->hUnderlyingCallback);
9277  XN_IS_STATUS_OK(nRetVal);
9278 
9279  hCallback = pCreationCookie;
9280 
9281  return XN_STATUS_OK;
9282  }
9283 
9292  {
9293  NodeCreationCookie* pCreationCookie = (NodeCreationCookie*)hCallback;
9294  xnUnregisterFromNodeCreation(m_pContext, pCreationCookie->hUnderlyingCallback);
9295  xnOSFree(pCreationCookie);
9296  }
9297 
9308  {
9309  XnStatus nRetVal = XN_STATUS_OK;
9310 
9311  NodeDestructionCookie* pDestructionCookie;
9312  XN_VALIDATE_ALLOC(pDestructionCookie, NodeDestructionCookie);
9313  pDestructionCookie->pFunc = handler;
9314  pDestructionCookie->pCookie = pCookie;
9315 
9316  nRetVal = xnRegisterToNodeDestruction(m_pContext, NodeDestructionCallback, pDestructionCookie, &pDestructionCookie->hUnderlyingCallback);
9317  XN_IS_STATUS_OK(nRetVal);
9318 
9319  hCallback = pDestructionCookie;
9320 
9321  return XN_STATUS_OK;
9322  }
9323 
9332  {
9333  NodeDestructionCookie* pDestructionCookie = (NodeDestructionCookie*)hCallback;
9334  xnUnregisterFromNodeDestruction(m_pContext, pDestructionCookie->hUnderlyingCallback);
9335  xnOSFree(pDestructionCookie);
9336  }
9337 
9372  {
9373  return xnWaitAndUpdateAll(m_pContext);
9374  }
9375 
9411  {
9412  return xnWaitAnyUpdateAll(m_pContext);
9413  }
9414 
9446  {
9447  return xnWaitOneUpdateAll(m_pContext, node.GetHandle());
9448  }
9449 
9472  {
9473  return xnWaitNoneUpdateAll(m_pContext);
9474  }
9475 
9480  inline XnStatus AutoEnumerateOverSingleInput(NodeInfoList& List, XnProductionNodeDescription& description, const XnChar* strCreationInfo, XnProductionNodeType InputType, EnumerationErrors* pErrors, Query* pQuery = NULL) const
9481  {
9482  return xnAutoEnumerateOverSingleInput(m_pContext, List.GetUnderlyingObject(), &description, strCreationInfo, InputType, pErrors == NULL ? NULL : pErrors->GetUnderlying(), pQuery == NULL ? NULL : pQuery->GetUnderlyingObject());
9483  }
9484 
9488  inline void SetHandle(XnContext* pContext)
9489  {
9490  if (m_pContext == pContext)
9491  {
9492  return;
9493  }
9494 
9495  if (m_pContext != NULL)
9496  {
9497  if (m_bUsingDeprecatedAPI && m_bAllocated)
9498  {
9499  // Backwards compatibility: call shutdown instead of release, to make old programs get the
9500  // exact same behavior they used to have.
9501  xnForceShutdown(m_pContext);
9502  }
9503  else
9504  {
9505  xnContextUnregisterFromShutdown(m_pContext, m_hShuttingDownCallback);
9506  xnContextRelease(m_pContext);
9507  }
9508  }
9509 
9510  if (pContext != NULL)
9511  {
9512  XnStatus nRetVal = xnContextAddRef(pContext);
9513  XN_ASSERT(nRetVal == XN_STATUS_OK);
9514  XN_REFERENCE_VARIABLE(nRetVal);
9515 
9516  nRetVal = xnContextRegisterForShutdown(pContext, ContextShuttingDownCallback, this, &m_hShuttingDownCallback);
9517  XN_ASSERT(nRetVal == XN_STATUS_OK);
9518  }
9519 
9520  m_pContext = pContext;
9521  }
9522 
9523  inline void TakeOwnership(XnContext* pContext)
9524  {
9525  SetHandle(pContext);
9526 
9527  if (pContext != NULL)
9528  {
9529  xnContextRelease(pContext);
9530  }
9531  }
9532 
9534  inline XnStatus XN_API_DEPRECATED("Use other overload!") RunXmlScript(const XnChar* strScript, EnumerationErrors* pErrors = NULL)
9535  {
9536  m_bUsingDeprecatedAPI = TRUE;
9537  #pragma warning (push)
9538  #pragma warning (disable: XN_DEPRECATED_WARNING_IDS)
9539  return xnContextRunXmlScript(m_pContext, strScript, pErrors == NULL ? NULL : pErrors->GetUnderlying());
9540  #pragma warning (pop)
9541  }
9542 
9543  inline XnStatus XN_API_DEPRECATED("Use other overload!") RunXmlScriptFromFile(const XnChar* strFileName, EnumerationErrors* pErrors = NULL)
9544  {
9545  m_bUsingDeprecatedAPI = TRUE;
9546  #pragma warning (push)
9547  #pragma warning (disable: XN_DEPRECATED_WARNING_IDS)
9548  return xnContextRunXmlScriptFromFile(m_pContext, strFileName, pErrors == NULL ? NULL : pErrors->GetUnderlying());
9549  #pragma warning (pop)
9550  }
9551 
9552  inline XnStatus XN_API_DEPRECATED("Use other overload!") InitFromXmlFile(const XnChar* strFileName, EnumerationErrors* pErrors = NULL)
9553  {
9554  XnContext* pContext = NULL;
9555  m_bUsingDeprecatedAPI = TRUE;
9556 
9557  #pragma warning (push)
9558  #pragma warning (disable: XN_DEPRECATED_WARNING_IDS)
9559  XnStatus nRetVal = xnInitFromXmlFile(strFileName, &pContext, pErrors == NULL ? NULL : pErrors->GetUnderlying());
9560  #pragma warning (pop)
9561  XN_IS_STATUS_OK(nRetVal);
9562 
9563  TakeOwnership(pContext);
9564  m_bAllocated = TRUE;
9565 
9566  return (XN_STATUS_OK);
9567  }
9568 
9569  inline XnStatus XN_API_DEPRECATED("Use other overload!") OpenFileRecording(const XnChar* strFileName)
9570  {
9571  m_bUsingDeprecatedAPI = TRUE;
9572  #pragma warning (push)
9573  #pragma warning (disable: XN_DEPRECATED_WARNING_IDS)
9574  return xnContextOpenFileRecording(m_pContext, strFileName);
9575  #pragma warning (pop)
9576  }
9577 
9578  inline void XN_API_DEPRECATED("You may use Release() instead, or count on dtor") Shutdown()
9579  {
9580  if (m_pContext != NULL)
9581  {
9582  #pragma warning (push)
9583  #pragma warning (disable: XN_DEPRECATED_WARNING_IDS)
9584  xnShutdown(m_pContext);
9585  #pragma warning (pop)
9586  m_pContext = NULL;
9587  }
9588  }
9589 
9590  XnStatus XN_API_DEPRECATED("Please use other overload") CreateProductionTree(NodeInfo& Tree)
9591  {
9592  XnStatus nRetVal = XN_STATUS_OK;
9593 
9594  XnNodeHandle hNode;
9595  nRetVal = xnCreateProductionTree(m_pContext, Tree, &hNode);
9596  XN_IS_STATUS_OK(nRetVal);
9597 
9598  Tree.m_bOwnerOfNode = TRUE;
9599 
9600  return (XN_STATUS_OK);
9601  }
9604  private:
9605  typedef struct NodeCreationCookie
9606  {
9607  NodeCreationHandler pFunc;
9608  void* pCookie;
9609  XnCallbackHandle hUnderlyingCallback;
9610  } NodeCreationCookie;
9611 
9612  typedef struct NodeDestructionCookie
9613  {
9614  NodeDestructionHandler pFunc;
9615  void* pCookie;
9616  XnCallbackHandle hUnderlyingCallback;
9617  } NodeDestructionCookie;
9618 
9619  static void XN_CALLBACK_TYPE NodeCreationCallback(XnContext* pContext, XnNodeHandle hCreatedNode, void* pCookie)
9620  {
9621  NodeCreationCookie* pNodeCreationCookie = (NodeCreationCookie*)pCookie;
9622  Context context(pContext);
9623  ProductionNode createdNode(hCreatedNode);
9624  pNodeCreationCookie->pFunc(context, createdNode, pNodeCreationCookie->pCookie);
9625  }
9626 
9627  static void XN_CALLBACK_TYPE NodeDestructionCallback(XnContext* pContext, const XnChar* strDestroyedNodeName, void* pCookie)
9628  {
9629  NodeDestructionCookie* pNodeCreationCookie = (NodeDestructionCookie*)pCookie;
9630  Context context(pContext);
9631  pNodeCreationCookie->pFunc(context, strDestroyedNodeName, pNodeCreationCookie->pCookie);
9632  }
9633 
9634  static void XN_CALLBACK_TYPE ContextShuttingDownCallback(XnContext* /*pContext*/, void* pCookie)
9635  {
9636  Context* pThis = (Context*)pCookie;
9637  pThis->m_pContext = NULL;
9638  }
9639 
9640  XnContext* m_pContext;
9641  XnBool m_bUsingDeprecatedAPI;
9642  XnBool m_bAllocated;
9643  XnCallbackHandle m_hShuttingDownCallback;
9644  };
9645 
9651  {
9652  public:
9658  inline Resolution(XnResolution res) : m_Res(res)
9659  {
9660  m_nXRes = xnResolutionGetXRes(res);
9661  m_nYRes = xnResolutionGetYRes(res);
9662  m_strName = xnResolutionGetName(res);
9663  }
9664 
9671  inline Resolution(XnUInt32 xRes, XnUInt32 yRes) : m_nXRes(xRes), m_nYRes(yRes)
9672  {
9673  m_Res = xnResolutionGetFromXYRes(xRes, yRes);
9674  m_strName = xnResolutionGetName(m_Res);
9675  }
9676 
9682  inline Resolution(const XnChar* strName)
9683  {
9684  m_Res = xnResolutionGetFromName(strName);
9685  m_nXRes = xnResolutionGetXRes(m_Res);
9686  m_nYRes = xnResolutionGetYRes(m_Res);
9687  m_strName = xnResolutionGetName(m_Res);
9688  }
9689 
9693  inline XnResolution GetResolution() const { return m_Res; }
9697  inline XnUInt32 GetXResolution() const { return m_nXRes; }
9701  inline XnUInt32 GetYResolution() const { return m_nYRes; }
9705  inline const XnChar* GetName() const { return m_strName; }
9706 
9707  private:
9708  XnResolution m_Res;
9709  XnUInt32 m_nXRes;
9710  XnUInt32 m_nYRes;
9711  const XnChar* m_strName;
9712  };
9713 
9714  //---------------------------------------------------------------------------
9715  // Functions Implementation
9716  //---------------------------------------------------------------------------
9718  {
9719  return xnNodeQueryFilterList(context.GetUnderlyingObject(), query.GetUnderlyingObject(), m_pList);
9720  }
9721 
9722  inline void ProductionNode::GetContext(Context& context) const
9723  {
9725  }
9726 
9728  {
9730  Context result(pContext);
9731  xnContextRelease(pContext);
9732  return result;
9733  }
9734 
9736  {
9737  if (m_pNeededNodes == NULL)
9738  {
9739  XnNodeInfoList* pList = xnNodeInfoGetNeededNodes(m_pInfo);
9740  m_pNeededNodes = XN_NEW(NodeInfoList, pList);
9741  }
9742 
9743  return *m_pNeededNodes;
9744  }
9745 
9746  inline void NodeInfo::SetUnderlyingObject(XnNodeInfo* pInfo)
9747  {
9748  if (m_pNeededNodes != NULL)
9749  {
9750  XN_DELETE(m_pNeededNodes);
9751  }
9752 
9753  m_bOwnerOfNode = FALSE;
9754  m_pInfo = pInfo;
9755  m_pNeededNodes = NULL;
9756  }
9757 
9759  {
9760  return xnCanFrameSyncWith(GetHandle(), other.GetHandle());
9761  }
9762 
9764  {
9765  return xnFrameSyncWith(GetHandle(), other.GetHandle());
9766  }
9767 
9769  {
9770  return xnStopFrameSyncWith(GetHandle(), other.GetHandle());
9771  }
9772 
9774  {
9775  return xnIsFrameSyncedWith(GetHandle(), other.GetHandle());
9776  }
9777 
9779  {
9780  if (m_pInfo == NULL)
9781  {
9782  return XN_STATUS_INVALID_OPERATION;
9783  }
9784 
9785  XnNodeHandle hNode = xnNodeInfoGetRefHandle(m_pInfo);
9786  node.TakeOwnership(hNode);
9787 
9788  if (m_bOwnerOfNode)
9789  {
9790  xnProductionNodeRelease(hNode);
9791  }
9792 
9793  return (XN_STATUS_OK);
9794  }
9795 
9796  //---------------------------------------------------------------------------
9797  // Node creation functions
9798  //---------------------------------------------------------------------------
9799 
9800  inline XnStatus Device::Create(Context& context, Query* pQuery/*=NULL*/, EnumerationErrors* pErrors/*=NULL*/)
9801  {
9802  XnNodeHandle hNode;
9803  XnStatus nRetVal = xnCreateDevice(context.GetUnderlyingObject(), &hNode, pQuery == NULL ? NULL : pQuery->GetUnderlyingObject(), pErrors == NULL ? NULL : pErrors->GetUnderlying());
9804  XN_IS_STATUS_OK(nRetVal);
9805  TakeOwnership(hNode);
9806  return (XN_STATUS_OK);
9807  }
9808 
9809  inline XnStatus Recorder::Create(Context& context, const XnChar* strFormatName /*= NULL*/)
9810  {
9811  XnNodeHandle hNode;
9812  XnStatus nRetVal = xnCreateRecorder(context.GetUnderlyingObject(), strFormatName, &hNode);
9813  XN_IS_STATUS_OK(nRetVal);
9814  TakeOwnership(hNode);
9815  return (XN_STATUS_OK);
9816  }
9817 
9818  inline XnStatus Player::Create(Context& context, const XnChar* strFormatName)
9819  {
9820  XnNodeHandle hNode;
9821  XnStatus nRetVal = xnCreatePlayer(context.GetUnderlyingObject(), strFormatName, &hNode);
9822  XN_IS_STATUS_OK(nRetVal);
9823  TakeOwnership(hNode);
9824  return (XN_STATUS_OK);
9825  }
9826 
9827  inline XnStatus DepthGenerator::Create(Context& context, Query* pQuery/*=NULL*/, EnumerationErrors* pErrors/*=NULL*/)
9828  {
9829  XnNodeHandle hNode;
9830  XnStatus nRetVal = xnCreateDepthGenerator(context.GetUnderlyingObject(), &hNode, pQuery == NULL ? NULL : pQuery->GetUnderlyingObject(), pErrors == NULL ? NULL : pErrors->GetUnderlying());
9831  XN_IS_STATUS_OK(nRetVal);
9832  TakeOwnership(hNode);
9833  return (XN_STATUS_OK);
9834  }
9835 
9836  inline XnStatus MockDepthGenerator::Create(Context& context, const XnChar* strName /* = NULL */)
9837  {
9838  XnNodeHandle hNode;
9839  XnStatus nRetVal = xnCreateMockNode(context.GetUnderlyingObject(), XN_NODE_TYPE_DEPTH, strName, &hNode);
9840  XN_IS_STATUS_OK(nRetVal);
9841  TakeOwnership(hNode);
9842  return (XN_STATUS_OK);
9843  }
9844 
9845  inline XnStatus MockDepthGenerator::CreateBasedOn(DepthGenerator& other, const XnChar* strName /* = NULL */)
9846  {
9847  Context context;
9848  other.GetContext(context);
9849  XnNodeHandle hNode;
9850  XnStatus nRetVal = xnCreateMockNodeBasedOn(context.GetUnderlyingObject(), other.GetHandle(), strName, &hNode);
9851  XN_IS_STATUS_OK(nRetVal);
9852  TakeOwnership(hNode);
9853  return (XN_STATUS_OK);
9854  }
9855 
9856  inline XnStatus ImageGenerator::Create(Context& context, Query* pQuery/*=NULL*/, EnumerationErrors* pErrors/*=NULL*/)
9857  {
9858  XnNodeHandle hNode;
9859  XnStatus nRetVal = xnCreateImageGenerator(context.GetUnderlyingObject(), &hNode, pQuery == NULL ? NULL : pQuery->GetUnderlyingObject(), pErrors == NULL ? NULL : pErrors->GetUnderlying());
9860  XN_IS_STATUS_OK(nRetVal);
9861  TakeOwnership(hNode);
9862  return (XN_STATUS_OK);
9863  }
9864 
9865  inline XnStatus MockImageGenerator::Create(Context& context, const XnChar* strName /* = NULL */)
9866  {
9867  XnNodeHandle hNode;
9868  XnStatus nRetVal = xnCreateMockNode(context.GetUnderlyingObject(), XN_NODE_TYPE_IMAGE, strName, &hNode);
9869  XN_IS_STATUS_OK(nRetVal);
9870  TakeOwnership(hNode);
9871  return (XN_STATUS_OK);
9872  }
9873 
9874  inline XnStatus MockImageGenerator::CreateBasedOn(ImageGenerator& other, const XnChar* strName /* = NULL */)
9875  {
9876  Context context;
9877  other.GetContext(context);
9878  XnNodeHandle hNode;
9879  XnStatus nRetVal = xnCreateMockNodeBasedOn(context.GetUnderlyingObject(), other.GetHandle(), strName, &hNode);
9880  XN_IS_STATUS_OK(nRetVal);
9881  TakeOwnership(hNode);
9882  return (XN_STATUS_OK);
9883  }
9884 
9885  inline XnStatus IRGenerator::Create(Context& context, Query* pQuery/*=NULL*/, EnumerationErrors* pErrors/*=NULL*/)
9886  {
9887  XnNodeHandle hNode;
9888  XnStatus nRetVal = xnCreateIRGenerator(context.GetUnderlyingObject(), &hNode, pQuery == NULL ? NULL : pQuery->GetUnderlyingObject(), pErrors == NULL ? NULL : pErrors->GetUnderlying());
9889  XN_IS_STATUS_OK(nRetVal);
9890  TakeOwnership(hNode);
9891  return (XN_STATUS_OK);
9892  }
9893 
9894  inline XnStatus MockIRGenerator::Create(Context& context, const XnChar* strName /* = NULL */)
9895  {
9896  XnNodeHandle hNode;
9897  XnStatus nRetVal = xnCreateMockNode(context.GetUnderlyingObject(), XN_NODE_TYPE_IR, strName, &hNode);
9898  XN_IS_STATUS_OK(nRetVal);
9899  TakeOwnership(hNode);
9900  return (XN_STATUS_OK);
9901  }
9902 
9903  inline XnStatus MockIRGenerator::CreateBasedOn(IRGenerator& other, const XnChar* strName /* = NULL */)
9904  {
9905  Context context;
9906  other.GetContext(context);
9907  XnNodeHandle hNode;
9908  XnStatus nRetVal = xnCreateMockNodeBasedOn(context.GetUnderlyingObject(), other.GetHandle(), strName, &hNode);
9909  XN_IS_STATUS_OK(nRetVal);
9910  TakeOwnership(hNode);
9911  return (XN_STATUS_OK);
9912  }
9913 
9914  inline XnStatus GestureGenerator::Create(Context& context, Query* pQuery/*=NULL*/, EnumerationErrors* pErrors/*=NULL*/)
9915  {
9916  XnNodeHandle hNode;
9917  XnStatus nRetVal = xnCreateGestureGenerator(context.GetUnderlyingObject(), &hNode, pQuery == NULL ? NULL : pQuery->GetUnderlyingObject(), pErrors == NULL ? NULL : pErrors->GetUnderlying());
9918  XN_IS_STATUS_OK(nRetVal);
9919  TakeOwnership(hNode);
9920  return (XN_STATUS_OK);
9921  }
9922 
9923  inline XnStatus SceneAnalyzer::Create(Context& context, Query* pQuery/*=NULL*/, EnumerationErrors* pErrors/*=NULL*/)
9924  {
9925  //You're creating a scene!
9926  XnNodeHandle hNode;
9927  XnStatus nRetVal = xnCreateSceneAnalyzer(context.GetUnderlyingObject(), &hNode, pQuery == NULL ? NULL : pQuery->GetUnderlyingObject(), pErrors == NULL ? NULL : pErrors->GetUnderlying());
9928  XN_IS_STATUS_OK(nRetVal);
9929  TakeOwnership(hNode);
9930  return (XN_STATUS_OK);
9931  }
9932 
9933  inline XnStatus HandsGenerator::Create(Context& context, Query* pQuery/*=NULL*/, EnumerationErrors* pErrors/*=NULL*/)
9934  {
9935  XnNodeHandle hNode;
9936  XnStatus nRetVal = xnCreateHandsGenerator(context.GetUnderlyingObject(), &hNode, pQuery == NULL ? NULL : pQuery->GetUnderlyingObject(), pErrors == NULL ? NULL : pErrors->GetUnderlying());
9937  XN_IS_STATUS_OK(nRetVal);
9938  TakeOwnership(hNode);
9939  return (XN_STATUS_OK);
9940  }
9941 
9942  inline XnStatus UserGenerator::Create(Context& context, Query* pQuery/*=NULL*/, EnumerationErrors* pErrors/*=NULL*/)
9943  {
9944  XnNodeHandle hNode;
9945  XnStatus nRetVal = xnCreateUserGenerator(context.GetUnderlyingObject(), &hNode, pQuery == NULL ? NULL : pQuery->GetUnderlyingObject(), pErrors == NULL ? NULL : pErrors->GetUnderlying());
9946  XN_IS_STATUS_OK(nRetVal);
9947  TakeOwnership(hNode);
9948  return (XN_STATUS_OK);
9949  }
9950 
9951  inline XnStatus AudioGenerator::Create(Context& context, Query* pQuery/*=NULL*/, EnumerationErrors* pErrors/*=NULL*/)
9952  {
9953  XnNodeHandle hNode;
9954  XnStatus nRetVal = xnCreateAudioGenerator(context.GetUnderlyingObject(), &hNode, pQuery == NULL ? NULL : pQuery->GetUnderlyingObject(), pErrors == NULL ? NULL : pErrors->GetUnderlying());
9955  XN_IS_STATUS_OK(nRetVal);
9956  TakeOwnership(hNode);
9957  return (XN_STATUS_OK);
9958  }
9959 
9960  inline XnStatus MockAudioGenerator::Create(Context& context, const XnChar* strName /* = NULL */)
9961  {
9962  XnNodeHandle hNode;
9963  XnStatus nRetVal = xnCreateMockNode(context.GetUnderlyingObject(), XN_NODE_TYPE_AUDIO, strName, &hNode);
9964  XN_IS_STATUS_OK(nRetVal);
9965  TakeOwnership(hNode);
9966  return (XN_STATUS_OK);
9967  }
9968 
9969  inline XnStatus MockAudioGenerator::CreateBasedOn(AudioGenerator& other, const XnChar* strName /* = NULL */)
9970  {
9971  Context context;
9972  other.GetContext(context);
9973  XnNodeHandle hNode;
9974  XnStatus nRetVal = xnCreateMockNodeBasedOn(context.GetUnderlyingObject(), other.GetHandle(), strName, &hNode);
9975  XN_IS_STATUS_OK(nRetVal);
9976  TakeOwnership(hNode);
9977  return (XN_STATUS_OK);
9978  }
9979 
9980  inline XnStatus MockRawGenerator::Create(Context& context, const XnChar* strName /*= NULL*/)
9981  {
9982  XnNodeHandle hNode;
9983  XnStatus nRetVal = xnCreateMockNode(context.GetUnderlyingObject(), XN_NODE_TYPE_GENERATOR, strName, &hNode);
9984  XN_IS_STATUS_OK(nRetVal);
9985  TakeOwnership(hNode);
9986  return (XN_STATUS_OK);
9987  }
9988 
9989  inline XnStatus Codec::Create(Context& context, XnCodecID codecID, ProductionNode& initializerNode)
9990  {
9991  XnNodeHandle hNode;
9992  XnStatus nRetVal = xnCreateCodec(context.GetUnderlyingObject(), codecID, initializerNode.GetHandle(), &hNode);
9993  XN_IS_STATUS_OK(nRetVal);
9994  TakeOwnership(hNode);
9995  return (XN_STATUS_OK);
9996  }
9997 
9999  {
10000  return xnScriptNodeRun(GetHandle(), pErrors == NULL ? NULL : pErrors->GetUnderlying());
10001  }
10002 
10003  inline XnStatus ScriptNode::Create(Context& context, const XnChar* strFormat)
10004  {
10005  XnNodeHandle hNode;
10006  XnStatus nRetVal = xnCreateScriptNode(context.GetUnderlyingObject(), strFormat, &hNode);
10007  XN_IS_STATUS_OK(nRetVal);
10008  TakeOwnership(hNode);
10009  return (XN_STATUS_OK);
10010  }
10011 
10012  //---------------------------------------------------------------------------
10013  // Global Helper Functions
10014  //---------------------------------------------------------------------------
10015 
10016  inline void XN_API_DEPRECATED("Use xn::Version::Current() instead") GetVersion(XnVersion& Version)
10017  {
10018  xnGetVersion(&Version);
10019  }
10020 
10021  //---------------------------------------------------------------------------
10022  // Internal Helper Classes and Functions
10023  //---------------------------------------------------------------------------
10024 
10026  {
10027  public:
10028  StateChangedCallbackTranslator(StateChangedHandler handler, void* pCookie) : m_UserHandler(handler), m_pUserCookie(pCookie), m_hCallback(NULL) {}
10029 
10030  XnStatus Register(_XnRegisterStateChangeFuncPtr xnFunc, XnNodeHandle hNode)
10031  {
10032  return xnFunc(hNode, StateChangedCallback, this, &m_hCallback);
10033  }
10034 
10035  void Unregister(_XnUnregisterStateChangeFuncPtr xnFunc, XnNodeHandle hNode)
10036  {
10037  xnFunc(hNode, m_hCallback);
10038  }
10039 
10040  static XnStatus RegisterToUnderlying(_XnRegisterStateChangeFuncPtr xnFunc, XnNodeHandle hNode, StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
10041  {
10042  XnStatus nRetVal = XN_STATUS_OK;
10043 
10045  XN_VALIDATE_NEW(pTrans, StateChangedCallbackTranslator, handler, pCookie);
10046 
10047  nRetVal = pTrans->Register(xnFunc, hNode);
10048  if (nRetVal != XN_STATUS_OK)
10049  {
10050  XN_DELETE(pTrans);
10051  return (nRetVal);
10052  }
10053 
10054  hCallback = pTrans;
10055 
10056  return (XN_STATUS_OK);
10057  }
10058 
10059  static XnStatus UnregisterFromUnderlying(_XnUnregisterStateChangeFuncPtr xnFunc, XnNodeHandle hNode, XnCallbackHandle hCallback)
10060  {
10062  pTrans->Unregister(xnFunc, hNode);
10063  XN_DELETE(pTrans);
10064  return XN_STATUS_OK;
10065  }
10066 
10067  private:
10068  friend class GeneralIntCapability;
10069 
10070  typedef struct StateChangeCookie
10071  {
10072  StateChangedHandler userHandler;
10073  void* pUserCookie;
10074  XnCallbackHandle hCallback;
10075  } StateChangeCookie;
10076 
10077  static void XN_CALLBACK_TYPE StateChangedCallback(XnNodeHandle hNode, void* pCookie)
10078  {
10080  ProductionNode node(hNode);
10081  pTrans->m_UserHandler(node, pTrans->m_pUserCookie);
10082  }
10083 
10084  StateChangedHandler m_UserHandler;
10085  void* m_pUserCookie;
10086  XnCallbackHandle m_hCallback;
10087  };
10088 
10089  static XnStatus _RegisterToStateChange(_XnRegisterStateChangeFuncPtr xnFunc, XnNodeHandle hNode, StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
10090  {
10091  return StateChangedCallbackTranslator::RegisterToUnderlying(xnFunc, hNode, handler, pCookie, hCallback);
10092  }
10093 
10094  static void _UnregisterFromStateChange(_XnUnregisterStateChangeFuncPtr xnFunc, XnNodeHandle hNode, XnCallbackHandle hCallback)
10095  {
10097  }
10098 
10100  {
10101  XnStatus nRetVal = XN_STATUS_OK;
10102 
10104  XN_VALIDATE_NEW(pTrans, StateChangedCallbackTranslator, handler, pCookie);
10105 
10106  nRetVal = xnRegisterToGeneralIntValueChange(GetHandle(), m_strCap, pTrans->StateChangedCallback, pTrans, &pTrans->m_hCallback);
10107  if (nRetVal != XN_STATUS_OK)
10108  {
10109  XN_DELETE(pTrans);
10110  return (nRetVal);
10111  }
10112 
10113  hCallback = pTrans;
10114 
10115  return (XN_STATUS_OK);
10116  }
10117 
10119  {
10121  xnUnregisterFromGeneralIntValueChange(GetHandle(), m_strCap, pTrans->m_hCallback);
10122  XN_DELETE(pTrans);
10123  }
10124 };
10125 
10126 #endif // __XN_CPP_WRAPPER_H__