OpenNI 1.3.2
XnCppWrapper.h
Go to the documentation of this file.
00001 /****************************************************************************
00002 *                                                                           *
00003 *  OpenNI 1.1 Alpha                                                         *
00004 *  Copyright (C) 2011 PrimeSense Ltd.                                       *
00005 *                                                                           *
00006 *  This file is part of OpenNI.                                             *
00007 *                                                                           *
00008 *  OpenNI is free software: you can redistribute it and/or modify           *
00009 *  it under the terms of the GNU Lesser General Public License as published *
00010 *  by the Free Software Foundation, either version 3 of the License, or     *
00011 *  (at your option) any later version.                                      *
00012 *                                                                           *
00013 *  OpenNI is distributed in the hope that it will be useful,                *
00014 *  but WITHOUT ANY WARRANTY; without even the implied warranty of           *
00015 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the             *
00016 *  GNU Lesser General Public License for more details.                      *
00017 *                                                                           *
00018 *  You should have received a copy of the GNU Lesser General Public License *
00019 *  along with OpenNI. If not, see <http://www.gnu.org/licenses/>.           *
00020 *                                                                           *
00021 ****************************************************************************/
00022 #ifndef __XN_CPP_WRAPPER_H__
00023 #define __XN_CPP_WRAPPER_H__
00024 
00025 //---------------------------------------------------------------------------
00026 // Includes
00027 //---------------------------------------------------------------------------
00028 #include <XnOpenNI.h>
00029 #include <XnCodecIDs.h>
00030 
00031 //---------------------------------------------------------------------------
00032 // Types
00033 //---------------------------------------------------------------------------
00034 namespace xn
00035 {
00036     //---------------------------------------------------------------------------
00037     // Forward Declarations
00038     //---------------------------------------------------------------------------
00039     class ProductionNode;
00040     class EnumerationErrors;
00041     class NodeInfo;
00042     class NodeInfoList;
00043     class Context;
00044     class Query;
00045     class Generator;
00046 
00052     //---------------------------------------------------------------------------
00053     // Types
00054     //---------------------------------------------------------------------------
00055 
00062     typedef void (XN_CALLBACK_TYPE* StateChangedHandler)(ProductionNode& node, void* pCookie);
00063 
00064     //---------------------------------------------------------------------------
00065     // Internal stuff
00066     //---------------------------------------------------------------------------
00067     typedef XnStatus (*_XnRegisterStateChangeFuncPtr)(XnNodeHandle hNode, XnStateChangedHandler handler, void* pCookie, XnCallbackHandle* phCallback);
00068     typedef void (*_XnUnregisterStateChangeFuncPtr)(XnNodeHandle hNode, XnCallbackHandle hCallback);
00069 
00070     static XnStatus _RegisterToStateChange(_XnRegisterStateChangeFuncPtr xnFunc, XnNodeHandle hNode, StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback);
00071     static void _UnregisterFromStateChange(_XnUnregisterStateChangeFuncPtr xnFunc, XnNodeHandle hNode, XnCallbackHandle hCallback);
00072 
00073     //---------------------------------------------------------------------------
00074     // Some Utilities
00075     //---------------------------------------------------------------------------
00076     class Version
00077     {
00078     public:
00079         Version(const XnVersion& version) : m_version(version) {}
00080         Version(XnUInt8 nMajor, XnUInt8 nMinor, XnUInt16 nMaintenance, XnUInt32 nBuild)
00081         {
00082             m_version.nMajor = nMajor;
00083             m_version.nMinor = nMinor;
00084             m_version.nMaintenance = nMaintenance;
00085             m_version.nBuild = nBuild;
00086         }
00087 
00088         bool operator==(const Version& other) const
00089         {
00090             return (xnVersionCompare(&m_version, &other.m_version) == 0);
00091         }
00092         bool operator!=(const Version& other) const
00093         {
00094             return (xnVersionCompare(&m_version, &other.m_version) != 0);
00095         }
00096         bool operator<(const Version& other) const 
00097         {
00098             return (xnVersionCompare(&m_version, &other.m_version) < 0);
00099         }
00100         bool operator<=(const Version& other) const
00101         {
00102             return (xnVersionCompare(&m_version, &other.m_version) <= 0);
00103         }
00104         bool operator>(const Version& other) const
00105         {
00106             return (xnVersionCompare(&m_version, &other.m_version) > 0);
00107         }
00108         bool operator>=(const Version& other) const
00109         {
00110             return (xnVersionCompare(&m_version, &other.m_version) >= 0);
00111         }
00112     private:
00113         XnVersion m_version;
00114     };
00115 
00116     //---------------------------------------------------------------------------
00117     // Meta Data
00118     //---------------------------------------------------------------------------
00119 
00124     class OutputMetaData
00125     {
00126     public:
00132         inline OutputMetaData(const XnUInt8** ppData) : m_ppData(ppData), m_nAllocatedSize(0), m_pAllocatedData(NULL)
00133         {
00134             xnOSMemSet(&m_output, 0, sizeof(XnOutputMetaData));
00135         }
00136 
00140         virtual ~OutputMetaData() { Free(); }
00141 
00143         inline XnUInt64 Timestamp() const { return m_output.nTimestamp; }
00145         inline XnUInt64& Timestamp() { return m_output.nTimestamp; }
00146 
00148         inline XnUInt32 FrameID() const { return m_output.nFrameID; }
00150         inline XnUInt32& FrameID() { return m_output.nFrameID; }
00151 
00153         inline XnUInt32 DataSize() const { return m_output.nDataSize; }
00155         inline XnUInt32& DataSize() { return m_output.nDataSize; }
00156 
00158         inline XnBool IsDataNew() const { return m_output.bIsNew; }
00160         inline XnBool& IsDataNew() { return m_output.bIsNew; }
00161 
00163         inline const XnOutputMetaData* GetUnderlying() const { return &m_output; }
00165         inline XnOutputMetaData* GetUnderlying() { return &m_output; }
00166 
00168         inline const XnUInt8* Data() const { return *m_ppData; }
00170         inline const XnUInt8*& Data() { return *m_ppData; }
00172         inline XnUInt8* WritableData()
00173         {
00174             MakeDataWritable();
00175             return m_pAllocatedData;
00176         }
00177 
00184         XnStatus AllocateData(XnUInt32 nBytes)
00185         {
00186             if (nBytes > m_nAllocatedSize)
00187             {
00188                 // reallocate
00189                 XnUInt8* pData = (XnUInt8*)xnOSMallocAligned(nBytes, XN_DEFAULT_MEM_ALIGN);
00190                 XN_VALIDATE_ALLOC_PTR(pData);
00191 
00192                 // allocation succeeded, replace
00193                 Free();
00194                 m_pAllocatedData = pData;
00195                 m_nAllocatedSize = nBytes;
00196             }
00197 
00198             DataSize() = nBytes;
00199             *m_ppData = m_pAllocatedData;
00200 
00201             return XN_STATUS_OK;
00202         }
00203 
00207         void Free()
00208         {
00209             if (m_nAllocatedSize != 0)
00210             {
00211                 xnOSFreeAligned(m_pAllocatedData);
00212                 m_pAllocatedData = NULL;
00213                 m_nAllocatedSize = 0;
00214             }
00215         }
00216 
00221         XnStatus MakeDataWritable()
00222         {
00223             XnStatus nRetVal = XN_STATUS_OK;
00224 
00225             // check data isn't already writable
00226             if (Data() != m_pAllocatedData || DataSize() > m_nAllocatedSize)
00227             {
00228                 const XnUInt8* pOrigData = *m_ppData;
00229 
00230                 nRetVal = AllocateData(DataSize());
00231                 XN_IS_STATUS_OK(nRetVal);
00232 
00233                 if (pOrigData != NULL)
00234                 {
00235                     xnOSMemCopy(m_pAllocatedData, pOrigData, DataSize());
00236                 }
00237                 else
00238                 {
00239                     xnOSMemSet(m_pAllocatedData, 0, DataSize());
00240                 }
00241             }
00242 
00243             return (XN_STATUS_OK);
00244         }
00245 
00246     protected:
00247         XnUInt8* m_pAllocatedData;
00248 
00249     private:
00250         XnOutputMetaData m_output;
00251 
00252         const XnUInt8** m_ppData;
00253         XnUInt32 m_nAllocatedSize;
00254     };
00255 
00260     class MapMetaData : public OutputMetaData
00261     {
00262     public:
00269         inline MapMetaData(XnPixelFormat format, const XnUInt8** ppData) : OutputMetaData(ppData)
00270         {
00271             xnOSMemSet(&m_map, 0, sizeof(XnMapMetaData));
00272             m_map.pOutput = OutputMetaData::GetUnderlying();
00273             m_map.PixelFormat = format;
00274         }
00275 
00277         inline XnUInt32 XRes() const { return m_map.Res.X; }
00279         inline XnUInt32& XRes() { return m_map.Res.X; }
00280 
00282         inline XnUInt32 YRes() const { return m_map.Res.Y; }
00284         inline XnUInt32& YRes() { return m_map.Res.Y; }
00285 
00287         inline XnUInt32 XOffset() const { return m_map.Offset.X; }
00289         inline XnUInt32& XOffset() { return m_map.Offset.X; }
00290 
00292         inline XnUInt32 YOffset() const { return m_map.Offset.Y; }
00294         inline XnUInt32& YOffset() { return m_map.Offset.Y; }
00295 
00297         inline XnUInt32 FullXRes() const { return m_map.FullRes.X; }
00299         inline XnUInt32& FullXRes() { return m_map.FullRes.X; }
00300 
00302         inline XnUInt32 FullYRes() const { return m_map.FullRes.Y; }
00304         inline XnUInt32& FullYRes() { return m_map.FullRes.Y; }
00305 
00307         inline XnUInt32 FPS() const { return m_map.nFPS; }
00309         inline XnUInt32& FPS() { return m_map.nFPS; }
00310 
00312         inline XnPixelFormat PixelFormat() const { return m_map.PixelFormat; }
00313 
00315         inline const XnMapMetaData* GetUnderlying() const { return &m_map; }
00317         inline XnMapMetaData* GetUnderlying() { return &m_map; }
00318 
00320         inline XnUInt32 BytesPerPixel() const
00321         {
00322             switch (PixelFormat())
00323             {
00324                 case XN_PIXEL_FORMAT_RGB24:
00325                     return sizeof(XnRGB24Pixel);
00326                 case XN_PIXEL_FORMAT_YUV422:
00327                     return sizeof(XnYUV422DoublePixel)/2;
00328                 case XN_PIXEL_FORMAT_GRAYSCALE_8_BIT:
00329                     return sizeof(XnGrayscale8Pixel);
00330                 case XN_PIXEL_FORMAT_GRAYSCALE_16_BIT:
00331                     return sizeof(XnGrayscale16Pixel);
00332                 case XN_PIXEL_FORMAT_MJPEG:
00333                     return 2;
00334                 default:
00335                     XN_ASSERT(FALSE);
00336                     return 0;
00337             }
00338         }
00339 
00346         XnStatus AllocateData(XnUInt32 nXRes, XnUInt32 nYRes)
00347         {
00348             XnStatus nRetVal = XN_STATUS_OK;
00349             
00350             XnUInt32 nSize = nXRes * nYRes * BytesPerPixel();
00351             nRetVal = OutputMetaData::AllocateData(nSize);
00352             XN_IS_STATUS_OK(nRetVal);
00353 
00354             FullXRes() = XRes() = nXRes;
00355             FullYRes() = YRes() = nYRes;
00356             XOffset() = YOffset() = 0;
00357             
00358             return (XN_STATUS_OK);
00359         }
00360 
00369         XnStatus ReAdjust(XnUInt32 nXRes, XnUInt32 nYRes, const XnUInt8* pExternalBuffer)
00370         {
00371             XnStatus nRetVal = XN_STATUS_OK;
00372 
00373             if (pExternalBuffer == NULL)
00374             {
00375                 nRetVal = AllocateData(nXRes, nYRes);
00376                 XN_IS_STATUS_OK(nRetVal);
00377             }
00378             else
00379             {
00380                 FullXRes() = XRes() = nXRes;
00381                 FullYRes() = YRes() = nYRes;
00382                 XOffset() = YOffset() = 0;
00383                 Data() = pExternalBuffer;
00384                 DataSize() = nXRes * nYRes * BytesPerPixel();
00385             }
00386 
00387             return (XN_STATUS_OK);
00388         }
00389 
00390     protected:
00391         XnPixelFormat& PixelFormatImpl() { return m_map.PixelFormat; }
00392 
00393     private:
00394         // block copy ctor and assignment operator
00395         MapMetaData& operator=(const MapMetaData&);
00396         inline MapMetaData(const MapMetaData& other);
00397 
00398         // Members
00399         XnMapMetaData m_map;
00400     };
00401 
00402 /* Declares a map data accessor class */
00403 #define _XN_DECLARE_MAP_DATA_CLASS(_name, _pixelType)                           \
00404     class _name                                                                 \
00405     {                                                                           \
00406     public:                                                                     \
00407         inline _name(_pixelType*& pData, XnUInt32& nXRes, XnUInt32 &nYRes) :    \
00408         m_pData(pData), m_nXRes(nXRes), m_nYRes(nYRes) {}                       \
00409                                                                                 \
00410         inline XnUInt32 XRes() const { return m_nXRes; }                        \
00411         inline XnUInt32 YRes() const { return m_nYRes; }                        \
00412                                                                                 \
00413         inline const _pixelType& operator[](XnUInt32 nIndex) const              \
00414         {                                                                       \
00415             XN_ASSERT(nIndex < (m_nXRes * m_nYRes));                            \
00416             return m_pData[nIndex];                                             \
00417         }                                                                       \
00418         inline _pixelType& operator[](XnUInt32 nIndex)                          \
00419         {                                                                       \
00420             XN_ASSERT(nIndex < (m_nXRes *m_nYRes));                             \
00421             return m_pData[nIndex];                                             \
00422         }                                                                       \
00423                                                                                 \
00424         inline const _pixelType& operator()(XnUInt32 x, XnUInt32 y) const       \
00425         {                                                                       \
00426             XN_ASSERT(x < m_nXRes && y < m_nYRes);                              \
00427             return m_pData[y*m_nXRes + x];                                      \
00428         }                                                                       \
00429         inline _pixelType& operator()(XnUInt32 x, XnUInt32 y)                   \
00430         {                                                                       \
00431             XN_ASSERT(x < m_nXRes && y < m_nYRes);                              \
00432             return m_pData[y*m_nXRes + x];                                      \
00433         }                                                                       \
00434                                                                                 \
00435     private:                                                                    \
00436         /* block copy ctor and assignment operator */                           \
00437         _name(const _name& other);                                              \
00438         _name& operator=(const _name&);                                         \
00439                                                                                 \
00440         _pixelType*& m_pData;                                                   \
00441         XnUInt32& m_nXRes;                                                      \
00442         XnUInt32& m_nYRes;                                                      \
00443     };                                                                      
00444 
00445     _XN_DECLARE_MAP_DATA_CLASS(DepthMap, XnDepthPixel);
00446     _XN_DECLARE_MAP_DATA_CLASS(ImageMap, XnUInt8);
00447     _XN_DECLARE_MAP_DATA_CLASS(RGB24Map, XnRGB24Pixel);
00448     _XN_DECLARE_MAP_DATA_CLASS(Grayscale16Map, XnGrayscale16Pixel);
00449     _XN_DECLARE_MAP_DATA_CLASS(Grayscale8Map, XnGrayscale8Pixel);
00450     _XN_DECLARE_MAP_DATA_CLASS(IRMap, XnIRPixel);
00451     _XN_DECLARE_MAP_DATA_CLASS(LabelMap, XnLabel);
00452 
00457     class DepthMetaData : public MapMetaData
00458     {
00459     public:
00463         inline DepthMetaData() : 
00464             MapMetaData(XN_PIXEL_FORMAT_GRAYSCALE_16_BIT, (const XnUInt8**)&m_depth.pData),
00465             m_depthMap(const_cast<XnDepthPixel*&>(m_depth.pData), MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y),
00466             m_writableDepthMap((XnDepthPixel*&)m_pAllocatedData, MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y)
00467         {
00468             xnOSMemSet(&m_depth, 0, sizeof(XnDepthMetaData));
00469             m_depth.pMap = MapMetaData::GetUnderlying();
00470         }
00471 
00477         inline void InitFrom(const DepthMetaData& other)
00478         {
00479             xnCopyDepthMetaData(&m_depth, &other.m_depth);
00480         }
00481 
00491         inline XnStatus InitFrom(const DepthMetaData& other, XnUInt32 nXRes, XnUInt32 nYRes, const XnDepthPixel* pExternalBuffer)
00492         {
00493             InitFrom(other);
00494             return ReAdjust(nXRes, nYRes, pExternalBuffer);
00495         }
00496 
00502         XnStatus CopyFrom(const DepthMetaData& other)
00503         {
00504             // copy props
00505             InitFrom(other);
00506             // and make a copy of the data (this will allocate and copy data)
00507             return MakeDataWritable();
00508         }
00509 
00511         XnStatus ReAdjust(XnUInt32 nXRes, XnUInt32 nYRes, const XnDepthPixel* pExternalBuffer = NULL)
00512         {
00513             return MapMetaData::ReAdjust(nXRes, nYRes, (const XnUInt8*)pExternalBuffer);
00514         }
00515 
00517         inline XnDepthPixel ZRes() const { return m_depth.nZRes; }
00519         inline XnDepthPixel& ZRes() { return m_depth.nZRes; }
00520 
00522         inline const XnDepthPixel* Data() const { return (const XnDepthPixel*)MapMetaData::Data(); }
00524         inline const XnDepthPixel*& Data() { return (const XnDepthPixel*&)MapMetaData::Data(); }
00526         inline XnDepthPixel* WritableData() { return (XnDepthPixel*)MapMetaData::WritableData(); }
00527 
00529         inline const xn::DepthMap& DepthMap() const { return m_depthMap; }
00531         inline xn::DepthMap& WritableDepthMap() 
00532         { 
00533             MakeDataWritable();
00534             return m_writableDepthMap; 
00535         }
00536 
00542         inline const XnDepthPixel& operator[](XnUInt32 nIndex) const 
00543         { 
00544             XN_ASSERT(nIndex < (XRes()*YRes()));
00545             return Data()[nIndex]; 
00546         }
00547 
00554         inline const XnDepthPixel& operator()(XnUInt32 x, XnUInt32 y) const 
00555         {
00556             XN_ASSERT(x < XRes() && y < YRes());
00557             return Data()[y*XRes() + x]; 
00558         }
00559 
00561         inline const XnDepthMetaData* GetUnderlying() const { return &m_depth; }
00563         inline XnDepthMetaData* GetUnderlying() { return &m_depth; }
00564 
00565     private:
00566         // block copy ctor and assignment operator (because we can't return errors in those)
00567         DepthMetaData(const DepthMetaData& other);
00568         DepthMetaData& operator=(const DepthMetaData&);
00569 
00570         XnDepthMetaData m_depth;
00571         const xn::DepthMap m_depthMap;
00572         xn::DepthMap m_writableDepthMap;
00573     };
00574 
00579     class ImageMetaData : public MapMetaData
00580     {
00581     public:
00583         inline ImageMetaData() : 
00584             MapMetaData(XN_PIXEL_FORMAT_RGB24, &m_image.pData),
00585             m_imageMap(const_cast<XnUInt8*&>(m_image.pData), MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y),
00586             m_writableImageMap((XnUInt8*&)m_pAllocatedData, MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y),
00587             m_rgb24Map((XnRGB24Pixel*&)m_image.pData, MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y),
00588             m_writableRgb24Map((XnRGB24Pixel*&)m_pAllocatedData, MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y),
00589             m_gray16Map((XnGrayscale16Pixel*&)m_image.pData, MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y),
00590             m_writableGray16Map((XnGrayscale16Pixel*&)m_pAllocatedData, MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y),
00591             m_gray8Map((XnGrayscale8Pixel*&)m_image.pData, MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y),
00592             m_writableGray8Map((XnGrayscale8Pixel*&)m_pAllocatedData, MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y)
00593         {
00594             xnOSMemSet(&m_image, 0, sizeof(XnImageMetaData));
00595             m_image.pMap = MapMetaData::GetUnderlying();
00596         }
00597 
00603         inline void InitFrom(const ImageMetaData& other)
00604         {
00605             xnCopyImageMetaData(&m_image, &other.m_image);
00606         }
00607 
00618         inline XnStatus InitFrom(const ImageMetaData& other, XnUInt32 nXRes, XnUInt32 nYRes, XnPixelFormat format, const XnUInt8* pExternalBuffer)
00619         {
00620             InitFrom(other);
00621             XnStatus nRetVal = ReAdjust(nXRes, nYRes, format, pExternalBuffer);
00622             XN_IS_STATUS_OK(nRetVal);
00623             PixelFormat() = format;
00624             return XN_STATUS_OK;
00625         }
00626 
00634         inline XnStatus AllocateData(XnUInt32 nXRes, XnUInt32 nYRes, XnPixelFormat format)
00635         {
00636             XnPixelFormat origFormat = PixelFormat();
00637             PixelFormat() = format;
00638             XnStatus nRetVal = MapMetaData::AllocateData(nXRes, nYRes);
00639             if (nRetVal != XN_STATUS_OK)
00640             {
00641                 PixelFormat() = origFormat;
00642                 return (nRetVal);
00643             }
00644 
00645             return XN_STATUS_OK;
00646         }
00647 
00649         inline XnStatus CopyFrom(const ImageMetaData& other)
00650         {
00651             // copy props
00652             xnCopyImageMetaData(&m_image, &other.m_image);
00653             // and make a copy of the data (this will allocate and copy data)
00654             return MakeDataWritable();
00655         }
00656 
00666         XnStatus ReAdjust(XnUInt32 nXRes, XnUInt32 nYRes, XnPixelFormat format, const XnUInt8* pExternalBuffer = NULL)
00667         {
00668             XnPixelFormat origFormat = PixelFormat();
00669             PixelFormat() = format;
00670             XnStatus nRetVal = MapMetaData::ReAdjust(nXRes, nYRes, pExternalBuffer);
00671             if (nRetVal != XN_STATUS_OK)
00672             {
00673                 PixelFormat() = origFormat;
00674                 return (nRetVal);
00675             }
00676 
00677             return XN_STATUS_OK;
00678         }
00679 
00681         inline XnPixelFormat PixelFormat() const { return MapMetaData::PixelFormat(); }
00683         inline XnPixelFormat& PixelFormat() { return MapMetaData::PixelFormatImpl(); }
00684 
00686         inline XnUInt8* WritableData() { return MapMetaData::WritableData(); }
00687 
00689         inline const XnRGB24Pixel* RGB24Data() const { return (const XnRGB24Pixel*)MapMetaData::Data(); }
00691         inline const XnRGB24Pixel*& RGB24Data() { return (const XnRGB24Pixel*&)MapMetaData::Data(); }
00693         inline XnRGB24Pixel* WritableRGB24Data() { return (XnRGB24Pixel*)MapMetaData::WritableData(); }
00694 
00696         inline const XnYUV422DoublePixel* YUV422Data() const { return (const XnYUV422DoublePixel*)MapMetaData::Data(); }
00698         inline const XnYUV422DoublePixel*& YUV422Data() { return (const XnYUV422DoublePixel*&)MapMetaData::Data(); }
00700         inline XnYUV422DoublePixel* WritableYUV422Data() { return (XnYUV422DoublePixel*)MapMetaData::WritableData(); }
00701 
00703         inline const XnGrayscale8Pixel* Grayscale8Data() const { return (const XnGrayscale8Pixel*)MapMetaData::Data(); }
00705         inline const XnGrayscale8Pixel*& Grayscale8Data() { return (const XnGrayscale8Pixel*&)MapMetaData::Data(); }
00707         inline XnGrayscale8Pixel* WritableGrayscale8Data() { return (XnGrayscale8Pixel*)MapMetaData::WritableData(); }
00708 
00710         inline const XnGrayscale16Pixel* Grayscale16Data() const { return (const XnGrayscale16Pixel*)MapMetaData::Data(); }
00712         inline const XnGrayscale16Pixel*& Grayscale16Data() { return (const XnGrayscale16Pixel*&)MapMetaData::Data(); }
00714         inline XnGrayscale16Pixel* WritableGrayscale16Data() { return (XnGrayscale16Pixel*)MapMetaData::WritableData(); }
00715 
00717         inline const xn::ImageMap& ImageMap() const { return m_imageMap; }
00719         inline xn::ImageMap& WritableImageMap() { MakeDataWritable(); return m_writableImageMap; }
00720 
00722         inline const xn::RGB24Map& RGB24Map() const { return m_rgb24Map; }
00724         inline xn::RGB24Map& WritableRGB24Map() { MakeDataWritable(); return m_writableRgb24Map; }
00725 
00727         inline const xn::Grayscale8Map& Grayscale8Map() const { return m_gray8Map; }
00729         inline xn::Grayscale8Map& WritableGrayscale8Map() { MakeDataWritable(); return m_writableGray8Map; }
00730 
00732         inline const xn::Grayscale16Map& Grayscale16Map() const { return m_gray16Map; }
00734         inline xn::Grayscale16Map& WritableGrayscale16Map() { MakeDataWritable(); return m_writableGray16Map; }
00735 
00737         inline const XnImageMetaData* GetUnderlying() const { return &m_image; }
00739         inline XnImageMetaData* GetUnderlying() { return &m_image; }
00740 
00741     private:
00742         // block copy ctor and assignment operator
00743         ImageMetaData(const ImageMetaData& other);
00744         ImageMetaData& operator=(const ImageMetaData&);
00745 
00746         XnImageMetaData m_image;
00747         const xn::ImageMap m_imageMap;
00748         xn::ImageMap m_writableImageMap;
00749         const xn::RGB24Map m_rgb24Map;
00750         xn::RGB24Map m_writableRgb24Map;
00751         const xn::Grayscale16Map m_gray16Map;
00752         xn::Grayscale16Map m_writableGray16Map;
00753         const xn::Grayscale8Map m_gray8Map;
00754         xn::Grayscale8Map m_writableGray8Map;
00755     };
00756 
00761     class IRMetaData : public MapMetaData
00762     {
00763     public:
00765         inline IRMetaData() : 
00766             MapMetaData(XN_PIXEL_FORMAT_GRAYSCALE_16_BIT, (const XnUInt8**)&m_ir.pData),
00767             m_irMap(const_cast<XnIRPixel*&>(m_ir.pData), MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y),
00768             m_writableIRMap((XnIRPixel*&)m_pAllocatedData, MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y)
00769         {
00770             xnOSMemSet(&m_ir, 0, sizeof(XnIRMetaData));
00771             m_ir.pMap = MapMetaData::GetUnderlying();
00772         }
00773 
00779         inline void InitFrom(const IRMetaData& other)
00780         {
00781             xnCopyIRMetaData(&m_ir, &other.m_ir);
00782         }
00783 
00785         inline XnStatus InitFrom(const IRMetaData& other, XnUInt32 nXRes, XnUInt32 nYRes, const XnIRPixel* pExternalBuffer)
00786         {
00787             InitFrom(other);
00788             return ReAdjust(nXRes, nYRes, pExternalBuffer);
00789         }
00790 
00792         XnStatus CopyFrom(const IRMetaData& other)
00793         {
00794             // copy props
00795             xnCopyIRMetaData(&m_ir, &other.m_ir);
00796             // and make a copy of the data (this will allocate and copy data)
00797             return MakeDataWritable();
00798         }
00799 
00801         XnStatus ReAdjust(XnUInt32 nXRes, XnUInt32 nYRes, const XnIRPixel* pExternalBuffer = NULL)
00802         {
00803             return MapMetaData::ReAdjust(nXRes, nYRes, (const XnUInt8*)pExternalBuffer);
00804         }
00805 
00807         inline const XnIRPixel* Data() const { return (const XnIRPixel*)MapMetaData::Data(); }
00809         inline const XnIRPixel*& Data() { return (const XnIRPixel*&)MapMetaData::Data(); }
00811         inline XnIRPixel* WritableData() { return (XnIRPixel*)MapMetaData::WritableData(); }
00812 
00814         inline const xn::IRMap& IRMap() const { return m_irMap; }
00816         inline xn::IRMap& WritableIRMap() { MakeDataWritable(); return m_writableIRMap; }
00817 
00819         inline const XnIRMetaData* GetUnderlying() const { return &m_ir; }
00821         inline XnIRMetaData* GetUnderlying() { return &m_ir; }
00822 
00823     private:
00824         // block copy ctor and assignment operator
00825         IRMetaData(const IRMetaData& other);
00826         IRMetaData& operator=(const IRMetaData&);
00827 
00828         XnIRMetaData m_ir;
00829         const xn::IRMap m_irMap;
00830         xn::IRMap m_writableIRMap;
00831     };
00832 
00837     class AudioMetaData : public OutputMetaData
00838     {
00839     public:
00841         inline AudioMetaData() : OutputMetaData(&m_audio.pData)
00842         {
00843             xnOSMemSet(&m_audio, 0, sizeof(XnAudioMetaData));
00844             m_audio.pOutput = OutputMetaData::GetUnderlying();
00845         }
00846 
00852         inline void InitFrom(const AudioMetaData& other)
00853         {
00854             xnCopyAudioMetaData(&m_audio, &other.m_audio);
00855         }
00856 
00858         inline XnUInt8 NumberOfChannels() const { return m_audio.Wave.nChannels; }
00860         inline XnUInt8& NumberOfChannels() { return m_audio.Wave.nChannels; }
00861 
00863         inline XnUInt32 SampleRate() const { return m_audio.Wave.nSampleRate; }
00865         inline XnUInt32& SampleRate() { return m_audio.Wave.nSampleRate; }
00866 
00868         inline XnUInt16 BitsPerSample() const { return m_audio.Wave.nBitsPerSample; }
00870         inline XnUInt16& BitsPerSample() { return m_audio.Wave.nBitsPerSample; }
00871 
00873         inline const XnAudioMetaData* GetUnderlying() const { return &m_audio; }
00875         inline XnAudioMetaData* GetUnderlying() { return &m_audio; }
00876 
00877     private:
00878         // block copy ctor and assignment operator
00879         AudioMetaData(const AudioMetaData& other);
00880         AudioMetaData& operator=(const AudioMetaData&);
00881 
00882         XnAudioMetaData m_audio;
00883         XnBool m_bAllocated;
00884     };
00885 
00890     class SceneMetaData : public MapMetaData
00891     {
00892     public:
00894         inline SceneMetaData() : 
00895             MapMetaData(XN_PIXEL_FORMAT_GRAYSCALE_16_BIT, (const XnUInt8**)&m_scene.pData),
00896             m_labelMap(const_cast<XnLabel*&>(m_scene.pData), MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y),
00897             m_writableLabelMap((XnLabel*&)m_pAllocatedData, MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y)
00898         {
00899             xnOSMemSet(&m_scene, 0, sizeof(XnSceneMetaData));
00900             m_scene.pMap = MapMetaData::GetUnderlying();
00901         }
00902 
00908         inline void InitFrom(const SceneMetaData& other)
00909         {
00910             xnCopySceneMetaData(&m_scene, &other.m_scene);
00911         }
00912 
00914         inline XnStatus InitFrom(const SceneMetaData& other, XnUInt32 nXRes, XnUInt32 nYRes, const XnLabel* pExternalBuffer)
00915         {
00916             InitFrom(other);
00917             return ReAdjust(nXRes, nYRes, pExternalBuffer);
00918         }
00919 
00921         XnStatus CopyFrom(const SceneMetaData& other)
00922         {
00923             // copy props
00924             xnCopySceneMetaData(&m_scene, &other.m_scene);
00925             // and make a copy of the data (this will allocate and copy data)
00926             return MakeDataWritable();
00927         }
00928 
00930         XnStatus ReAdjust(XnUInt32 nXRes, XnUInt32 nYRes, const XnLabel* pExternalBuffer = NULL)
00931         {
00932             return MapMetaData::ReAdjust(nXRes, nYRes, (const XnUInt8*)pExternalBuffer);
00933         }
00934 
00936         inline const XnLabel* Data() const { return (const XnLabel*)MapMetaData::Data(); }
00938         inline const XnLabel*& Data() { return (const XnLabel*&)MapMetaData::Data(); }
00940         inline XnLabel* WritableData() { return (XnLabel*)MapMetaData::WritableData(); }
00941 
00943         inline const xn::LabelMap& LabelMap() const { return m_labelMap; }
00945         inline xn::LabelMap& WritableLabelMap() { MakeDataWritable(); return m_writableLabelMap; }
00946 
00952         inline const XnLabel& operator[](XnUInt32 nIndex) const
00953         {
00954             XN_ASSERT(nIndex < (XRes()*YRes()));
00955             return Data()[nIndex];
00956         }
00957 
00964         inline const XnLabel& operator()(XnUInt32 x, XnUInt32 y) const
00965         {
00966             XN_ASSERT(x < XRes() && y < YRes());
00967             return (*this)[y*XRes() + x];
00968         }
00969 
00971         inline const XnSceneMetaData* GetUnderlying() const { return &m_scene; }
00973         inline XnSceneMetaData* GetUnderlying() { return &m_scene; }
00974 
00975     private:
00976         // block copy ctor and assignment operator
00977         SceneMetaData(const SceneMetaData& other);
00978         SceneMetaData& operator=(const SceneMetaData&);
00979 
00980         XnSceneMetaData m_scene;
00981         const xn::LabelMap m_labelMap;
00982         xn::LabelMap m_writableLabelMap;
00983     };
00984 
00985     //---------------------------------------------------------------------------
00986     // NodeWrapper
00987     //---------------------------------------------------------------------------
00988 
00993     class NodeWrapper
00994     {
00995     public:
00996         friend class Context;
00997 
01003         inline NodeWrapper(XnNodeHandle hNode) : m_hNode(NULL), m_hShuttingDownCallback(NULL)
01004         {
01005             NodeWrapper::SetHandle(hNode);
01006         }
01007 
01008         inline NodeWrapper(const NodeWrapper& other) : m_hNode(NULL), m_hShuttingDownCallback(NULL)
01009         {
01010             NodeWrapper::SetHandle(other.GetHandle());
01011         }
01012 
01013         inline NodeWrapper& operator=(const NodeWrapper& other)
01014         {
01015             NodeWrapper::SetHandle(other.GetHandle());
01016             return *this;
01017         }
01018 
01019         inline ~NodeWrapper()
01020         {
01021             NodeWrapper::SetHandle(NULL);
01022         }
01023 
01024         inline operator XnNodeHandle() const { return GetHandle(); }
01025 
01027         inline XnNodeHandle GetHandle() const { return m_hNode; }
01028 
01034         inline XnBool operator==(const NodeWrapper& other)
01035         {
01036             return (GetHandle() == other.GetHandle());
01037         }
01038 
01044         inline XnBool operator!=(const NodeWrapper& other)
01045         {
01046             return (GetHandle() != other.GetHandle());
01047         }
01048 
01050         inline XnBool IsValid() const { return (GetHandle() != NULL); }
01051         
01055         const XnChar* GetName() const {return xnGetNodeName(GetHandle()); }
01056 
01060         inline XnStatus AddRef() { return xnProductionNodeAddRef(GetHandle()); }
01061 
01065         inline void Release() 
01066         {
01067             NodeWrapper::SetHandle(NULL);
01068         }
01069 
01070         inline XnStatus XN_API_DEPRECATED("Please use AddRef() instead.") Ref() { return AddRef(); }
01071         inline void XN_API_DEPRECATED("Please use Release() instead.") Unref() { Release(); }
01072 
01074         inline void SetHandle(XnNodeHandle hNode) 
01075         { 
01076             if (m_hNode == hNode)
01077             {
01078                 // Optimization: do nothing
01079                 return;
01080             }
01081 
01082             // check currently held node. If we're holding a node, release it
01083             if (m_hNode != NULL)
01084             {
01085                 XnContext* pContext = xnGetRefContextFromNodeHandle(m_hNode);
01086                 xnContextUnregisterFromShutdown(pContext, m_hShuttingDownCallback);
01087                 xnContextRelease(pContext);
01088                 xnProductionNodeRelease(m_hNode);
01089             }
01090 
01091             // check new node handle, if it points to a node, add ref to it
01092             if (hNode != NULL)
01093             {
01094                 XnStatus nRetVal = xnProductionNodeAddRef(hNode);
01095                 XN_ASSERT(nRetVal == XN_STATUS_OK);
01096 
01097                 XnContext* pContext = xnGetRefContextFromNodeHandle(hNode);
01098 
01099                 nRetVal = xnContextRegisterForShutdown(pContext, ContextShuttingDownCallback, this, &m_hShuttingDownCallback);
01100                 XN_ASSERT(nRetVal == XN_STATUS_OK);
01101 
01102                 xnContextRelease(pContext);
01103             }
01104 
01105             m_hNode = hNode; 
01106         }
01107 
01108         inline void TakeOwnership(XnNodeHandle hNode)
01109         {
01110             SetHandle(hNode);
01111 
01112             if (hNode != NULL)
01113             {
01114                 xnProductionNodeRelease(hNode);
01115             }
01116         }
01117 
01118     private:
01119         XnNodeHandle m_hNode;
01120         XnCallbackHandle m_hShuttingDownCallback;
01121 
01122         static void XN_CALLBACK_TYPE ContextShuttingDownCallback(XnContext* /*pContext*/, void* pCookie)
01123         {
01124             NodeWrapper* pThis = (NodeWrapper*)pCookie;
01125             pThis->m_hNode = NULL;
01126         }
01127     };
01128 
01129     //---------------------------------------------------------------------------
01130     // Node Info
01131     //---------------------------------------------------------------------------
01132 
01137     class NodeInfo
01138     {
01139     public:
01145         NodeInfo(XnNodeInfo* pInfo) : m_pNeededNodes(NULL), m_bOwnerOfNode(FALSE)
01146         {
01147             SetUnderlyingObject(pInfo);
01148         }
01149 
01155         NodeInfo(const NodeInfo& other) : m_pNeededNodes(NULL), m_bOwnerOfNode(FALSE)
01156         {
01157             SetUnderlyingObject(other.m_pInfo);
01158         }
01159 
01161         ~NodeInfo()
01162         {
01163             SetUnderlyingObject(NULL);
01164         }
01165 
01171         inline NodeInfo& operator=(const NodeInfo& other)
01172         {
01173             SetUnderlyingObject(other.m_pInfo);
01174             return *this;
01175         }
01176 
01178         inline operator XnNodeInfo*()
01179         {
01180             return m_pInfo;
01181         }
01182 
01186         inline XnStatus SetInstanceName(const XnChar* strName)
01187         {
01188             return xnNodeInfoSetInstanceName(m_pInfo, strName);
01189         }
01190 
01194         inline const XnProductionNodeDescription& GetDescription() const
01195         {
01196             return *xnNodeInfoGetDescription(m_pInfo);
01197         }
01198 
01202         inline const XnChar* GetInstanceName() const
01203         {
01204             return xnNodeInfoGetInstanceName(m_pInfo);
01205         }
01206         inline const XnChar* GetCreationInfo() const
01210         {
01211             return xnNodeInfoGetCreationInfo(m_pInfo);
01212         }
01213 
01217         inline NodeInfoList& GetNeededNodes() const;
01218 
01226         inline XnStatus GetInstance(ProductionNode& node) const;
01227 
01231         inline const void* GetAdditionalData() const
01232         {
01233             return xnNodeInfoGetAdditionalData(m_pInfo);
01234         }
01235 
01236     private:
01237         inline void SetUnderlyingObject(XnNodeInfo* pInfo);
01238 
01239         XnNodeInfo* m_pInfo;
01240         mutable NodeInfoList* m_pNeededNodes;
01241         XnBool m_bOwnerOfNode; // backwards compatibility
01242         friend class Context;
01243     };
01244 
01245     //---------------------------------------------------------------------------
01246     // Query
01247     //---------------------------------------------------------------------------
01248 
01254     class Query
01255     {
01256     public:
01258         inline Query() : m_bAllocated(TRUE)
01259         {
01260             xnNodeQueryAllocate(&m_pQuery);
01261         }
01262 
01263         inline Query(XnNodeQuery* pNodeQuery) : m_bAllocated(FALSE), m_pQuery(pNodeQuery)
01264         {
01265         }
01266 
01268         ~Query()
01269         {
01270             if (m_bAllocated)
01271             {
01272                 xnNodeQueryFree(m_pQuery);
01273             }
01274         }
01275 
01277         inline const XnNodeQuery* GetUnderlyingObject() const { return m_pQuery; }
01278         inline XnNodeQuery* GetUnderlyingObject() { return m_pQuery; }
01279 
01283         inline XnStatus SetVendor(const XnChar* strVendor)
01284         {
01285             return xnNodeQuerySetVendor(m_pQuery, strVendor);
01286         }
01287 
01291         inline XnStatus SetName(const XnChar* strName)
01292         {
01293             return xnNodeQuerySetName(m_pQuery, strName);
01294         }
01295 
01299         inline XnStatus SetMinVersion(const XnVersion& minVersion)
01300         {
01301             return xnNodeQuerySetMinVersion(m_pQuery, &minVersion);
01302         }
01303 
01307         inline XnStatus SetMaxVersion(const XnVersion& maxVersion)
01308         {
01309             return xnNodeQuerySetMaxVersion(m_pQuery, &maxVersion);
01310         }
01311 
01315         inline XnStatus AddSupportedCapability(const XnChar* strNeededCapability)
01316         {
01317             return xnNodeQueryAddSupportedCapability(m_pQuery, strNeededCapability);
01318         }
01319 
01323         inline XnStatus AddSupportedMapOutputMode(const XnMapOutputMode& MapOutputMode)
01324         {
01325             return xnNodeQueryAddSupportedMapOutputMode(m_pQuery, &MapOutputMode);
01326         }
01327 
01331         inline XnStatus SetSupportedMinUserPositions(const XnUInt32 nCount)
01332         {
01333             return xnNodeQuerySetSupportedMinUserPositions(m_pQuery, nCount);
01334         }
01335 
01339         inline XnStatus SetExistingNodeOnly(XnBool bExistingNode)
01340         {
01341             return xnNodeQuerySetExistingNodeOnly(m_pQuery, bExistingNode);
01342         }
01343 
01347         inline XnStatus AddNeededNode(const XnChar* strInstanceName)
01348         {
01349             return xnNodeQueryAddNeededNode(m_pQuery, strInstanceName);
01350         }
01351 
01355         inline XnStatus SetCreationInfo(const XnChar* strCreationInfo)
01356         {
01357             return xnNodeQuerySetCreationInfo(m_pQuery, strCreationInfo);
01358         }
01359 
01360     private:
01361         XnNodeQuery* m_pQuery;
01362         XnBool m_bAllocated;
01363     };
01364 
01365     //---------------------------------------------------------------------------
01366     // Node Info List
01367     //---------------------------------------------------------------------------
01368 
01373     class NodeInfoList
01374     {
01375     public:
01377         class Iterator
01378         {
01379         public:
01380             friend class NodeInfoList;
01381 
01387             XnBool operator==(const Iterator& other) const
01388             {
01389                 return m_it.pCurrent == other.m_it.pCurrent;
01390             }
01391 
01397             XnBool operator!=(const Iterator& other) const
01398             {
01399                 return m_it.pCurrent != other.m_it.pCurrent;
01400             }
01401 
01406             inline Iterator& operator++()
01407             {
01408                 UpdateInternalObject(xnNodeInfoListGetNext(m_it));
01409                 return *this;
01410             }
01411 
01416             inline Iterator operator++(int)
01417             {
01418                 XnNodeInfoListIterator curr = m_it;
01419                 UpdateInternalObject(xnNodeInfoListGetNext(m_it));
01420                 return Iterator(curr);
01421             }
01422 
01426             inline Iterator& operator--()
01427             {
01428                 UpdateInternalObject(xnNodeInfoListGetPrevious(m_it));
01429                 return *this;
01430             }
01431 
01435             inline Iterator operator--(int)
01436             {
01437                 XnNodeInfoListIterator curr = m_it;
01438                 UpdateInternalObject(xnNodeInfoListGetPrevious(m_it));
01439                 return Iterator(curr);
01440             }
01441 
01443             inline NodeInfo operator*()
01444             {
01445                 return m_Info;
01446             }
01447 
01448         private:
01449             inline Iterator(XnNodeInfoListIterator it) : m_Info(NULL)
01450             {
01451                 UpdateInternalObject(it);
01452             }
01453 
01454             inline void UpdateInternalObject(XnNodeInfoListIterator it)
01455             {
01456                 m_it = it;
01457                 if (xnNodeInfoListIteratorIsValid(it))
01458                 {
01459                     XnNodeInfo* pInfo = xnNodeInfoListGetCurrent(it);
01460                     m_Info = NodeInfo(pInfo);
01461                 }
01462                 else
01463                 {
01464                     m_Info = NodeInfo(NULL);
01465                 }
01466             }
01467 
01468             NodeInfo m_Info;
01469             XnNodeInfoListIterator m_it;
01470         };
01471 
01475         inline NodeInfoList() 
01476         {
01477             xnNodeInfoListAllocate(&m_pList);
01478             m_bAllocated = TRUE;
01479         }
01480 
01487         inline NodeInfoList(XnNodeInfoList* pList) : m_pList(pList), m_bAllocated(FALSE) {}
01488 
01490         inline ~NodeInfoList()
01491         {
01492             FreeImpl();
01493         }
01494 
01496         inline XnNodeInfoList* GetUnderlyingObject() const { return m_pList; }
01497 
01504         inline void ReplaceUnderlyingObject(XnNodeInfoList* pList) 
01505         {
01506             FreeImpl();
01507             m_pList = pList;
01508             m_bAllocated = TRUE;
01509         }
01510 
01514         inline XnStatus Add(XnProductionNodeDescription& description, const XnChar* strCreationInfo, NodeInfoList* pNeededNodes)
01515         {
01516             XnNodeInfoList* pList = (pNeededNodes == NULL) ? NULL : pNeededNodes->GetUnderlyingObject();
01517             return xnNodeInfoListAdd(m_pList, &description, strCreationInfo, pList);
01518         }
01519 
01523         inline XnStatus AddEx(XnProductionNodeDescription& description, const XnChar* strCreationInfo, NodeInfoList* pNeededNodes, const void* pAdditionalData, XnFreeHandler pFreeHandler)
01524         {
01525             XnNodeInfoList* pList = (pNeededNodes == NULL) ? NULL : pNeededNodes->GetUnderlyingObject();
01526             return xnNodeInfoListAddEx(m_pList, &description, strCreationInfo, pList, pAdditionalData, pFreeHandler);
01527         }
01528 
01532         inline XnStatus AddNode(NodeInfo& info)
01533         {
01534             return xnNodeInfoListAddNode(m_pList, info);
01535         }
01536 
01540         inline XnStatus AddNodeFromAnotherList(Iterator& it)
01541         {
01542             return xnNodeInfoListAddNodeFromList(m_pList, it.m_it);
01543         }
01544 
01546         inline Iterator Begin() const
01547         {
01548             return Iterator(xnNodeInfoListGetFirst(m_pList));
01549         }
01550 
01552         inline Iterator End() const
01553         {
01554             XnNodeInfoListIterator it = { NULL };
01555             return Iterator(it);
01556         }
01557 
01559         inline Iterator RBegin() const
01560         {
01561             return Iterator(xnNodeInfoListGetLast(m_pList));
01562         }
01563 
01565         inline Iterator REnd() const
01566         {
01567             XnNodeInfoListIterator it = { NULL };
01568             return Iterator(it);
01569         }
01570 
01574         inline XnStatus Remove(Iterator& it)
01575         {
01576             return xnNodeInfoListRemove(m_pList, it.m_it);
01577         }
01578 
01582         inline XnStatus Clear()
01583         {
01584             return xnNodeInfoListClear(m_pList);
01585         }
01586 
01590         inline XnStatus Append(NodeInfoList& other)
01591         {
01592             return xnNodeInfoListAppend(m_pList, other.GetUnderlyingObject());
01593         }
01594 
01598         inline XnBool IsEmpty()
01599         {
01600             return xnNodeInfoListIsEmpty(m_pList);
01601         }
01602 
01606         inline XnStatus FilterList(Context& context, Query& query);
01607 
01608     private:
01609         inline void FreeImpl()
01610         {
01611             if (m_bAllocated)
01612             {
01613                 xnNodeInfoListFree(m_pList);
01614                 m_bAllocated = FALSE;
01615                 m_pList = NULL;
01616             }
01617         }
01618 
01619         XnNodeInfoList* m_pList;
01620         XnBool m_bAllocated;
01621     };
01622 
01623     //---------------------------------------------------------------------------
01624     // Production Nodes Functionality
01625     //---------------------------------------------------------------------------
01626 
01631     class Capability : public NodeWrapper
01632     {
01633     public:
01639         Capability(XnNodeHandle hNode) : NodeWrapper(hNode) {}
01640         Capability(const NodeWrapper& node) : NodeWrapper(node) {}
01641     };
01642 
01647     class ErrorStateCapability : public Capability
01648     {
01649     public:
01655         ErrorStateCapability(XnNodeHandle hNode) : Capability(hNode) {}
01656         ErrorStateCapability(const NodeWrapper& node) : Capability(node) {}
01657 
01661         inline XnStatus GetErrorState() const
01662         {
01663             return xnGetNodeErrorState(GetHandle());
01664         }
01665 
01669         inline XnStatus RegisterToErrorStateChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
01670         {
01671             return _RegisterToStateChange(xnRegisterToNodeErrorStateChange, GetHandle(), handler, pCookie, hCallback);
01672         }
01673 
01677         inline void UnregisterFromErrorStateChange(XnCallbackHandle hCallback)
01678         {
01679             _UnregisterFromStateChange(xnUnregisterFromNodeErrorStateChange, GetHandle(), hCallback);
01680         }
01681     };
01682 
01687     class GeneralIntCapability : public Capability
01688     {
01689     public:
01696         GeneralIntCapability(XnNodeHandle hNode, const XnChar* strCap) : Capability(hNode), m_strCap(strCap) {}
01697         GeneralIntCapability(const NodeWrapper& node) : Capability(node) {}
01698 
01702         inline void GetRange(XnInt32& nMin, XnInt32& nMax, XnInt32& nStep, XnInt32& nDefault, XnBool& bIsAutoSupported) const
01703         {
01704             xnGetGeneralIntRange(GetHandle(), m_strCap, &nMin, &nMax, &nStep, &nDefault, &bIsAutoSupported);
01705         }
01706 
01710         inline XnInt32 Get()
01711         {
01712             XnInt32 nValue;
01713             xnGetGeneralIntValue(GetHandle(), m_strCap, &nValue);
01714             return nValue;
01715         }
01716 
01720         inline XnStatus Set(XnInt32 nValue)
01721         {
01722             return xnSetGeneralIntValue(GetHandle(), m_strCap, nValue);
01723         }
01724 
01728         XnStatus RegisterToValueChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback);
01729 
01733         void UnregisterFromValueChange(XnCallbackHandle hCallback);
01734 
01735     private:
01736         const XnChar* m_strCap;
01737     };
01738 
01743     class ProductionNode : public NodeWrapper
01744     {
01745     public:
01751         inline ProductionNode(XnNodeHandle hNode = NULL) : NodeWrapper(hNode) {}
01752         inline ProductionNode(const NodeWrapper& other) : NodeWrapper(other) {}
01753 
01757         inline NodeInfo GetInfo() const { return NodeInfo(xnGetNodeInfo(GetHandle())); }
01758 
01762         inline XnStatus AddNeededNode(ProductionNode& needed)
01763         {
01764             return xnAddNeededNode(GetHandle(), needed.GetHandle());
01765         }
01766 
01770         inline XnStatus RemoveNeededNode(ProductionNode& needed)
01771         {
01772             return xnRemoveNeededNode(GetHandle(), needed.GetHandle());
01773         }
01774 
01778         inline void GetContext(Context& context) const;
01779 
01783         inline XnBool IsCapabilitySupported(const XnChar* strCapabilityName) const
01784         {
01785             return xnIsCapabilitySupported(GetHandle(), strCapabilityName);
01786         }
01787 
01791         inline XnStatus SetIntProperty(const XnChar* strName, XnUInt64 nValue)
01792         {
01793             return xnSetIntProperty(GetHandle(), strName, nValue);
01794         }
01795 
01799         inline XnStatus SetRealProperty(const XnChar* strName, XnDouble dValue)
01800         {
01801             return xnSetRealProperty(GetHandle(), strName, dValue);
01802         }
01803 
01807         inline XnStatus SetStringProperty(const XnChar* strName, const XnChar* strValue)
01808         {
01809             return xnSetStringProperty(GetHandle(), strName, strValue);
01810         }
01811 
01815         inline XnStatus SetGeneralProperty(const XnChar* strName, XnUInt32 nBufferSize, const void* pBuffer)
01816         {
01817             return xnSetGeneralProperty(GetHandle(), strName, nBufferSize, pBuffer);
01818         }
01819 
01823         inline XnStatus GetIntProperty(const XnChar* strName, XnUInt64& nValue) const
01824         {
01825             return xnGetIntProperty(GetHandle(), strName, &nValue);
01826         }
01827 
01831         inline XnStatus GetRealProperty(const XnChar* strName, XnDouble &dValue) const
01832         {
01833             return xnGetRealProperty(GetHandle(), strName, &dValue);
01834         }
01835 
01839         inline XnStatus GetStringProperty(const XnChar* strName, XnChar* csValue, XnUInt32 nBufSize) const
01840         {
01841             return xnGetStringProperty(GetHandle(), strName, csValue, nBufSize);
01842         }
01843 
01847         inline XnStatus GetGeneralProperty(const XnChar* strName, XnUInt32 nBufferSize, void* pBuffer) const
01848         {
01849             return xnGetGeneralProperty(GetHandle(), strName, nBufferSize, pBuffer);
01850         }
01851 
01855         inline XnStatus LockForChanges(XnLockHandle* phLock)
01856         {
01857             return xnLockNodeForChanges(GetHandle(), phLock);
01858         }
01859 
01863         inline void UnlockForChanges(XnLockHandle hLock)
01864         {
01865             xnUnlockNodeForChanges(GetHandle(), hLock);
01866         }
01867 
01871         inline XnStatus LockedNodeStartChanges(XnLockHandle hLock)
01872         {
01873             return xnLockedNodeStartChanges(GetHandle(), hLock);
01874         }
01875 
01879         inline void LockedNodeEndChanges(XnLockHandle hLock)
01880         {
01881             xnLockedNodeEndChanges(GetHandle(), hLock);
01882         }
01883 
01889         inline const ErrorStateCapability GetErrorStateCap() const
01890         {
01891             return ErrorStateCapability(GetHandle());
01892         }
01893 
01899         inline ErrorStateCapability GetErrorStateCap()
01900         {
01901             return ErrorStateCapability(GetHandle());
01902         }
01903 
01911         inline GeneralIntCapability GetGeneralIntCap(const XnChar* strCapability)
01912         {
01913             return GeneralIntCapability(GetHandle(), strCapability);
01914         }
01915     };
01916 
01921     class DeviceIdentificationCapability : public Capability
01922     {
01923     public:
01929         DeviceIdentificationCapability(XnNodeHandle hNode) : Capability(hNode) {}
01930         DeviceIdentificationCapability(const NodeWrapper& node) : Capability(node) {}
01931 
01935         inline XnStatus GetDeviceName(XnChar* strBuffer, XnUInt32 nBufferSize)
01936         {
01937             return xnGetDeviceName(GetHandle(), strBuffer, &nBufferSize);
01938         }
01939 
01943         inline XnStatus GetVendorSpecificData(XnChar* strBuffer, XnUInt32 nBufferSize)
01944         {
01945             return xnGetVendorSpecificData(GetHandle(), strBuffer, &nBufferSize);
01946         }
01947 
01951         inline XnStatus GetSerialNumber(XnChar* strBuffer, XnUInt32 nBufferSize)
01952         {
01953             return xnGetSerialNumber(GetHandle(), strBuffer, &nBufferSize);
01954         }
01955     };
01956 
01961     class Device : public ProductionNode
01962     {
01963     public:
01969         inline Device(XnNodeHandle hNode = NULL) : ProductionNode(hNode) {}
01970         inline Device(const NodeWrapper& other) : ProductionNode(other) {}
01971 
01975         inline XnStatus Create(Context& context, Query* pQuery = NULL, EnumerationErrors* pErrors = NULL);
01976 
01982         inline DeviceIdentificationCapability GetIdentificationCap()
01983         {
01984             return DeviceIdentificationCapability(GetHandle());
01985         }
01986     };
01987 
01992     class MirrorCapability : public Capability
01993     {
01994     public:
02000         inline MirrorCapability(XnNodeHandle hNode) : Capability(hNode) {}
02001         MirrorCapability(const NodeWrapper& node) : Capability(node) {}
02002 
02006         inline XnStatus SetMirror(XnBool bMirror)
02007         {
02008             return xnSetMirror(GetHandle(), bMirror);
02009         }
02010 
02014         inline XnBool IsMirrored() const
02015         {
02016             return xnIsMirrored(GetHandle());
02017         }
02018 
02022         inline XnStatus RegisterToMirrorChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
02023         {
02024             return _RegisterToStateChange(xnRegisterToMirrorChange, GetHandle(), handler, pCookie, hCallback);
02025         }
02026 
02030         inline void UnregisterFromMirrorChange(XnCallbackHandle hCallback)
02031         {
02032             _UnregisterFromStateChange(xnUnregisterFromMirrorChange, GetHandle(), hCallback);
02033         }
02034     };
02035 
02040     class AlternativeViewPointCapability : public Capability
02041     {
02042     public:
02048         inline AlternativeViewPointCapability(XnNodeHandle hNode) : Capability(hNode) {}
02049         AlternativeViewPointCapability(const NodeWrapper& node) : Capability(node) {}
02050 
02054         inline XnBool IsViewPointSupported(ProductionNode& otherNode) const
02055         {
02056             return xnIsViewPointSupported(GetHandle(), otherNode.GetHandle());
02057         }
02058 
02062         inline XnStatus SetViewPoint(ProductionNode& otherNode)
02063         {
02064             return xnSetViewPoint(GetHandle(), otherNode.GetHandle());
02065         }
02066 
02070         inline XnStatus ResetViewPoint()
02071         {
02072             return xnResetViewPoint(GetHandle());
02073         }
02074 
02078         inline XnBool IsViewPointAs(ProductionNode& otherNode) const
02079         {
02080             return xnIsViewPointAs(GetHandle(), otherNode.GetHandle());
02081         }
02082 
02086         inline XnStatus RegisterToViewPointChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
02087         {
02088             return _RegisterToStateChange(xnRegisterToViewPointChange, GetHandle(), handler, pCookie, hCallback);
02089         }
02090 
02094         inline void UnregisterFromViewPointChange(XnCallbackHandle hCallback)
02095         {
02096             _UnregisterFromStateChange(xnUnregisterFromViewPointChange, GetHandle(), hCallback);
02097         }
02098     };
02099 
02104     class FrameSyncCapability : public Capability
02105     {
02106     public:
02112         inline FrameSyncCapability(XnNodeHandle hNode) : Capability(hNode) {}
02113         FrameSyncCapability(const NodeWrapper& node) : Capability(node) {}
02114 
02118         inline XnBool CanFrameSyncWith(Generator& other) const;
02119 
02123         inline XnStatus FrameSyncWith(Generator& other);
02124 
02128         inline XnStatus StopFrameSyncWith(Generator& other);
02129 
02133         inline XnBool IsFrameSyncedWith(Generator& other) const;
02134 
02138         inline XnStatus RegisterToFrameSyncChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
02139         {
02140             return _RegisterToStateChange(xnRegisterToFrameSyncChange, GetHandle(), handler, pCookie, hCallback);
02141         }
02142 
02146         inline void UnregisterFromFrameSyncChange(XnCallbackHandle hCallback)
02147         {
02148             _UnregisterFromStateChange(xnUnregisterFromFrameSyncChange, GetHandle(), hCallback);
02149         }
02150     };
02151 
02156     class Generator : public ProductionNode
02157     {
02158     public:
02164         inline Generator(XnNodeHandle hNode = NULL) : ProductionNode(hNode) {}
02165         inline Generator(const NodeWrapper& other) : ProductionNode(other) {}
02166 
02170         inline XnStatus StartGenerating()
02171         {
02172             return xnStartGenerating(GetHandle());
02173         }
02174 
02178         inline XnBool IsGenerating() const
02179         {
02180             return xnIsGenerating(GetHandle());
02181         }
02182 
02186         inline XnStatus StopGenerating()
02187         {
02188             return xnStopGenerating(GetHandle());
02189         }
02190 
02194         inline XnStatus RegisterToGenerationRunningChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle &hCallback)
02195         {
02196             return _RegisterToStateChange(xnRegisterToGenerationRunningChange, GetHandle(), handler, pCookie, hCallback);
02197         }
02198 
02202         inline void UnregisterFromGenerationRunningChange(XnCallbackHandle hCallback)
02203         {
02204             _UnregisterFromStateChange(xnUnregisterFromGenerationRunningChange, GetHandle(), hCallback);
02205         }
02206 
02210         inline XnStatus RegisterToNewDataAvailable(StateChangedHandler handler, void* pCookie, XnCallbackHandle &hCallback)
02211         {
02212             return _RegisterToStateChange(xnRegisterToNewDataAvailable, GetHandle(), handler, pCookie, hCallback);
02213         }
02214 
02218         inline void UnregisterFromNewDataAvailable(XnCallbackHandle hCallback)
02219         {
02220             _UnregisterFromStateChange(xnUnregisterFromNewDataAvailable, GetHandle(), hCallback);
02221         }
02222 
02226         inline XnBool IsNewDataAvailable(XnUInt64* pnTimestamp = NULL) const
02227         {
02228             return xnIsNewDataAvailable(GetHandle(), pnTimestamp);
02229         }
02230 
02234         inline XnStatus WaitAndUpdateData()
02235         {
02236             return xnWaitAndUpdateData(GetHandle());
02237         }
02238 
02242         inline XnBool IsDataNew() const
02243         {
02244             return xnIsDataNew(GetHandle());
02245         }
02246 
02250         inline const void* GetData()
02251         {
02252             return xnGetData(GetHandle());
02253         }
02254         
02258         inline XnUInt32 GetDataSize() const
02259         {
02260             return xnGetDataSize(GetHandle());
02261         }
02262 
02266         inline XnUInt64 GetTimestamp() const
02267         {
02268             return xnGetTimestamp(GetHandle());
02269         }
02270 
02274         inline XnUInt32 GetFrameID() const
02275         {
02276             return xnGetFrameID(GetHandle());
02277         }
02278 
02284         inline const MirrorCapability GetMirrorCap() const
02285         { 
02286             return MirrorCapability(GetHandle()); 
02287         }
02288 
02294         inline MirrorCapability GetMirrorCap()
02295         { 
02296             return MirrorCapability(GetHandle()); 
02297         }
02298 
02304         inline const AlternativeViewPointCapability GetAlternativeViewPointCap() const
02305         { 
02306             return AlternativeViewPointCapability(GetHandle()); 
02307         }
02308 
02314         inline AlternativeViewPointCapability GetAlternativeViewPointCap()
02315         { 
02316             return AlternativeViewPointCapability(GetHandle()); 
02317         }
02318 
02324         inline const FrameSyncCapability GetFrameSyncCap() const
02325         {
02326             return FrameSyncCapability(GetHandle());
02327         }
02328 
02334         inline FrameSyncCapability GetFrameSyncCap()
02335         {
02336             return FrameSyncCapability(GetHandle());
02337         }
02338     };
02339 
02344     class Recorder : public ProductionNode
02345     {
02346     public:
02352         inline Recorder(XnNodeHandle hNode = NULL) : ProductionNode(hNode) {}
02353         inline Recorder(const NodeWrapper& other) : ProductionNode(other) {}
02354 
02358         inline XnStatus Create(Context& context, const XnChar* strFormatName = NULL);
02359 
02363         inline XnStatus SetDestination(XnRecordMedium destType, const XnChar* strDest)
02364         {
02365             return xnSetRecorderDestination(GetHandle(), destType, strDest);
02366         }
02367 
02368         inline XnStatus GetDestination(XnRecordMedium& destType, XnChar* strDest, XnUInt32 nBufSize)
02369         {
02370             return xnGetRecorderDestination(GetHandle(), &destType, strDest, nBufSize);
02371         }
02372 
02376         inline XnStatus AddNodeToRecording(ProductionNode& Node, XnCodecID compression = XN_CODEC_NULL)
02377         {
02378             return xnAddNodeToRecording(GetHandle(), Node.GetHandle(), compression);
02379         }
02380 
02384         inline XnStatus RemoveNodeFromRecording(ProductionNode& Node)
02385         {
02386             return xnRemoveNodeFromRecording(GetHandle(), Node.GetHandle());
02387         }
02388 
02392         inline XnStatus Record()
02393         {
02394             return xnRecord(GetHandle());
02395         }
02396     };
02397 
02402     class Player : public ProductionNode
02403     {
02404     public:
02410         inline Player(XnNodeHandle hNode = NULL) : ProductionNode(hNode) {}
02411         inline Player(const NodeWrapper& other) : ProductionNode(other) {}
02412 
02416         inline XnStatus Create(Context& context, const XnChar* strFormatName);
02417 
02421         inline XnStatus SetRepeat(XnBool bRepeat)
02422         {
02423             return xnSetPlayerRepeat(GetHandle(), bRepeat);
02424         }
02425 
02429         inline XnStatus SetSource(XnRecordMedium sourceType, const XnChar* strSource)
02430         {
02431             return xnSetPlayerSource(GetHandle(), sourceType, strSource);
02432         }
02433 
02437         inline XnStatus GetSource(XnRecordMedium &sourceType, XnChar* strSource, XnUInt32 nBufSize) const
02438         {
02439             return xnGetPlayerSource(GetHandle(), &sourceType, strSource, nBufSize);
02440         }
02441 
02445         inline XnStatus ReadNext()
02446         {
02447             return xnPlayerReadNext(GetHandle());
02448         }
02449 
02453         inline XnStatus SeekToTimeStamp(XnInt64 nTimeOffset, XnPlayerSeekOrigin origin)
02454         {
02455             return xnSeekPlayerToTimeStamp(GetHandle(), nTimeOffset, origin);
02456         }
02457 
02461         inline XnStatus SeekToFrame(const XnChar* strNodeName, XnInt32 nFrameOffset, XnPlayerSeekOrigin origin)
02462         {
02463             return xnSeekPlayerToFrame(GetHandle(), strNodeName, nFrameOffset, origin);
02464         }
02465 
02469         inline XnStatus TellTimestamp(XnUInt64& nTimestamp) const
02470         {
02471             return xnTellPlayerTimestamp(GetHandle(), &nTimestamp);
02472         }
02473 
02477         inline XnStatus TellFrame(const XnChar* strNodeName, XnUInt32& nFrame) const
02478         {
02479             return xnTellPlayerFrame(GetHandle(), strNodeName, &nFrame);
02480         }
02481 
02485         inline XnStatus GetNumFrames(const XnChar* strNodeName, XnUInt32& nFrames) const
02486         {
02487             return xnGetPlayerNumFrames(GetHandle(), strNodeName, &nFrames);
02488         }
02489 
02493         inline const XnChar* GetSupportedFormat() const
02494         {
02495             return xnGetPlayerSupportedFormat(GetHandle());
02496         }
02497 
02501         inline XnStatus EnumerateNodes(NodeInfoList& list) const
02502         {
02503             XnNodeInfoList* pList;
02504             XnStatus nRetVal = xnEnumeratePlayerNodes(GetHandle(), &pList);
02505             XN_IS_STATUS_OK(nRetVal);
02506 
02507             list.ReplaceUnderlyingObject(pList);
02508 
02509             return (XN_STATUS_OK);
02510         }
02511 
02515         inline XnBool IsEOF() const
02516         {
02517             return xnIsPlayerAtEOF(GetHandle());
02518         }
02519 
02523         inline XnStatus RegisterToEndOfFileReached(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
02524         {
02525             return _RegisterToStateChange(xnRegisterToEndOfFileReached, GetHandle(), handler, pCookie, hCallback);
02526         }
02527 
02531         inline void UnregisterFromEndOfFileReached(XnCallbackHandle hCallback)
02532         {
02533             _UnregisterFromStateChange(xnUnregisterFromEndOfFileReached, GetHandle(), hCallback);
02534         }
02535 
02539         inline XnStatus SetPlaybackSpeed(XnDouble dSpeed)
02540         {
02541             return xnSetPlaybackSpeed(GetHandle(), dSpeed);
02542         }
02543 
02547         inline XnDouble GetPlaybackSpeed() const
02548         {
02549             return xnGetPlaybackSpeed(GetHandle());
02550         }
02551     };
02552 
02557     class CroppingCapability : public Capability
02558     {
02559     public:
02565         inline CroppingCapability(XnNodeHandle hNode) : Capability(hNode) {}
02566         CroppingCapability(const NodeWrapper& node) : Capability(node) {}
02567 
02571         inline XnStatus SetCropping(const XnCropping& Cropping)
02572         {
02573             return xnSetCropping(GetHandle(), &Cropping);
02574         }
02575 
02579         inline XnStatus GetCropping(XnCropping& Cropping) const
02580         {
02581             return xnGetCropping(GetHandle(), &Cropping);
02582         }
02583 
02587         inline XnStatus RegisterToCroppingChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
02588         {
02589             return _RegisterToStateChange(xnRegisterToCroppingChange, GetHandle(), handler, pCookie, hCallback);
02590         }
02591 
02595         inline void UnregisterFromCroppingChange(XnCallbackHandle hCallback)
02596         {
02597             _UnregisterFromStateChange(xnUnregisterFromCroppingChange, GetHandle(), hCallback);
02598         }
02599     };
02600 
02605     class AntiFlickerCapability : public Capability
02606     {
02607     public:
02613         inline AntiFlickerCapability(XnNodeHandle hNode) : Capability(hNode) {}
02614         AntiFlickerCapability(const NodeWrapper& node) : Capability(node) {}
02615 
02619         inline XnStatus SetPowerLineFrequency(XnPowerLineFrequency nFrequency)
02620         {
02621             return xnSetPowerLineFrequency(GetHandle(), nFrequency);
02622         }
02623 
02627         inline XnPowerLineFrequency GetPowerLineFrequency()
02628         {
02629             return xnGetPowerLineFrequency(GetHandle());
02630         }
02631 
02635         inline XnStatus RegisterToPowerLineFrequencyChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
02636         {
02637             return _RegisterToStateChange(xnRegisterToPowerLineFrequencyChange, GetHandle(), handler, pCookie, hCallback);
02638         }
02639 
02643         inline void UnregisterFromPowerLineFrequencyChange(XnCallbackHandle hCallback)
02644         {
02645             _UnregisterFromStateChange(xnUnregisterFromPowerLineFrequencyChange, GetHandle(), hCallback);
02646         }
02647     };
02648 
02653     class MapGenerator : public Generator
02654     {
02655     public:
02661         inline MapGenerator(XnNodeHandle hNode = NULL) : Generator(hNode) {}
02662         inline MapGenerator(const NodeWrapper& other) : Generator(other) {}
02663 
02667         inline XnUInt32 GetSupportedMapOutputModesCount() const
02668         {
02669             return xnGetSupportedMapOutputModesCount(GetHandle());
02670         }
02671 
02675         inline XnStatus GetSupportedMapOutputModes(XnMapOutputMode* aModes, XnUInt32& nCount) const
02676         {
02677             return xnGetSupportedMapOutputModes(GetHandle(), aModes, &nCount);
02678         }
02679 
02683         inline XnStatus SetMapOutputMode(const XnMapOutputMode& OutputMode)
02684         {
02685             return xnSetMapOutputMode(GetHandle(), &OutputMode);
02686         }
02687 
02691         inline XnStatus GetMapOutputMode(XnMapOutputMode &OutputMode) const
02692         {
02693             return xnGetMapOutputMode(GetHandle(), &OutputMode);
02694         }
02695 
02699         inline XnUInt32 GetBytesPerPixel() const
02700         {
02701             return xnGetBytesPerPixel(GetHandle());
02702         }
02703 
02707         inline XnStatus RegisterToMapOutputModeChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
02708         {
02709             return _RegisterToStateChange(xnRegisterToMapOutputModeChange, GetHandle(), handler, pCookie, hCallback);
02710         }
02711 
02715         inline void UnregisterFromMapOutputModeChange(XnCallbackHandle hCallback)
02716         {
02717             _UnregisterFromStateChange(xnUnregisterFromMapOutputModeChange, GetHandle(), hCallback);
02718         }
02719 
02725         inline const CroppingCapability GetCroppingCap() const
02726         {
02727             return CroppingCapability(GetHandle());
02728         }
02729 
02735         inline CroppingCapability GetCroppingCap()
02736         {
02737             return CroppingCapability(GetHandle());
02738         }
02739 
02745         inline GeneralIntCapability GetBrightnessCap()
02746         {
02747             return GeneralIntCapability(GetHandle(), XN_CAPABILITY_BRIGHTNESS);
02748         }
02749 
02755         inline GeneralIntCapability GetContrastCap()
02756         {
02757             return GeneralIntCapability(GetHandle(), XN_CAPABILITY_CONTRAST);
02758         }
02759 
02765         inline GeneralIntCapability GetHueCap()
02766         {
02767             return GeneralIntCapability(GetHandle(), XN_CAPABILITY_HUE);
02768         }
02769 
02775         inline GeneralIntCapability GetSaturationCap()
02776         {
02777             return GeneralIntCapability(GetHandle(), XN_CAPABILITY_SATURATION);
02778         }
02779 
02785         inline GeneralIntCapability GetSharpnessCap()
02786         {
02787             return GeneralIntCapability(GetHandle(), XN_CAPABILITY_SHARPNESS);
02788         }
02789 
02795         inline GeneralIntCapability GetGammaCap()
02796         {
02797             return GeneralIntCapability(GetHandle(), XN_CAPABILITY_GAMMA);
02798         }
02799 
02805         inline GeneralIntCapability GetWhiteBalanceCap()
02806         {
02807             return GeneralIntCapability(GetHandle(), XN_CAPABILITY_COLOR_TEMPERATURE);
02808         }
02809 
02815         inline GeneralIntCapability GetBacklightCompensationCap()
02816         {
02817             return GeneralIntCapability(GetHandle(), XN_CAPABILITY_BACKLIGHT_COMPENSATION);
02818         }
02819 
02825         inline GeneralIntCapability GetGainCap()
02826         {
02827             return GeneralIntCapability(GetHandle(), XN_CAPABILITY_GAIN);
02828         }
02829 
02835         inline GeneralIntCapability GetPanCap()
02836         {
02837             return GeneralIntCapability(GetHandle(), XN_CAPABILITY_PAN);
02838         }
02839 
02845         inline GeneralIntCapability GetTiltCap()
02846         {
02847             return GeneralIntCapability(GetHandle(), XN_CAPABILITY_TILT);
02848         }
02849 
02855         inline GeneralIntCapability GetRollCap()
02856         {
02857             return GeneralIntCapability(GetHandle(), XN_CAPABILITY_ROLL);
02858         }
02859 
02865         inline GeneralIntCapability GetZoomCap()
02866         {
02867             return GeneralIntCapability(GetHandle(), XN_CAPABILITY_ZOOM);
02868         }
02869 
02875         inline GeneralIntCapability GetExposureCap()
02876         {
02877             return GeneralIntCapability(GetHandle(), XN_CAPABILITY_EXPOSURE);
02878         }
02879 
02885         inline GeneralIntCapability GetIrisCap()
02886         {
02887             return GeneralIntCapability(GetHandle(), XN_CAPABILITY_IRIS);
02888         }
02889 
02895         inline GeneralIntCapability GetFocusCap()
02896         {
02897             return GeneralIntCapability(GetHandle(), XN_CAPABILITY_FOCUS);
02898         }
02899 
02905         inline GeneralIntCapability GetLowLightCompensationCap()
02906         {
02907             return GeneralIntCapability(GetHandle(), XN_CAPABILITY_LOW_LIGHT_COMPENSATION);
02908         }
02909 
02915         inline AntiFlickerCapability GetAntiFlickerCap()
02916         {
02917             return AntiFlickerCapability(GetHandle());
02918         }
02919     };
02920 
02925     class UserPositionCapability : public Capability
02926     {
02927     public:
02933         inline UserPositionCapability(XnNodeHandle hNode = NULL) : Capability(hNode) {}
02934         UserPositionCapability(const NodeWrapper& node) : Capability(node) {}
02935 
02939         inline XnUInt32 GetSupportedUserPositionsCount() const
02940         {
02941             return xnGetSupportedUserPositionsCount(GetHandle());
02942         }
02943 
02947         inline XnStatus SetUserPosition(XnUInt32 nIndex, const XnBoundingBox3D& Position)
02948         {
02949             return xnSetUserPosition(GetHandle(), nIndex, &Position);
02950         }
02951 
02955         inline XnStatus GetUserPosition(XnUInt32 nIndex, XnBoundingBox3D& Position) const
02956         {
02957             return xnGetUserPosition(GetHandle(), nIndex, &Position);
02958         }
02959 
02963         inline XnStatus RegisterToUserPositionChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
02964         {
02965             return _RegisterToStateChange(xnRegisterToUserPositionChange, GetHandle(), handler, pCookie, hCallback);
02966         }
02967 
02971         inline void UnregisterFromUserPositionChange(XnCallbackHandle hCallback)
02972         {
02973             _UnregisterFromStateChange(xnUnregisterFromUserPositionChange, GetHandle(), hCallback);
02974         }
02975     };
02976 
02981     class DepthGenerator : public MapGenerator
02982     {
02983     public:
02989         inline DepthGenerator(XnNodeHandle hNode = NULL) : MapGenerator(hNode) {}
02990         inline DepthGenerator(const NodeWrapper& other) : MapGenerator(other) {}
02991 
02995         inline XnStatus Create(Context& context, Query* pQuery = NULL, EnumerationErrors* pErrors = NULL);
02996 
03000         inline void GetMetaData(DepthMetaData& metaData) const 
03001         {
03002             xnGetDepthMetaData(GetHandle(), metaData.GetUnderlying());
03003         }
03004 
03008         inline const XnDepthPixel* GetDepthMap() const
03009         {
03010             return xnGetDepthMap(GetHandle());
03011         }
03012 
03016         inline XnDepthPixel GetDeviceMaxDepth() const
03017         {
03018             return xnGetDeviceMaxDepth(GetHandle());
03019         }
03020 
03024         inline XnStatus GetFieldOfView(XnFieldOfView& FOV) const
03025         {
03026             return xnGetDepthFieldOfView(GetHandle(), &FOV);
03027         }
03028 
03032         inline XnStatus RegisterToFieldOfViewChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
03033         {
03034             return _RegisterToStateChange(xnRegisterToDepthFieldOfViewChange, GetHandle(), handler, pCookie, hCallback);
03035         }
03036 
03040         inline void UnregisterFromFieldOfViewChange(XnCallbackHandle hCallback)
03041         {
03042             _UnregisterFromStateChange(xnUnregisterFromDepthFieldOfViewChange, GetHandle(), hCallback);
03043         }
03044 
03048         inline XnStatus ConvertProjectiveToRealWorld(XnUInt32 nCount, const XnPoint3D aProjective[], XnPoint3D aRealWorld[]) const
03049         {
03050             return xnConvertProjectiveToRealWorld(GetHandle(), nCount, aProjective, aRealWorld);
03051         }
03052 
03056         inline XnStatus ConvertRealWorldToProjective(XnUInt32 nCount, const XnPoint3D aRealWorld[], XnPoint3D aProjective[]) const
03057         {
03058             return xnConvertRealWorldToProjective(GetHandle(), nCount, aRealWorld, aProjective);
03059         }
03060 
03066         inline const UserPositionCapability GetUserPositionCap() const
03067         {
03068             return UserPositionCapability(GetHandle());
03069         }
03070 
03076         inline UserPositionCapability GetUserPositionCap()
03077         {
03078             return UserPositionCapability(GetHandle());
03079         }
03080     };
03081 
03086     class MockDepthGenerator : public DepthGenerator
03087     {
03088     public:
03094         inline MockDepthGenerator(XnNodeHandle hNode = NULL) : DepthGenerator(hNode) {}
03095         inline MockDepthGenerator(const NodeWrapper& other) : DepthGenerator(other) {}
03096 
03103         XnStatus Create(Context& context, const XnChar* strName = NULL);
03104 
03111         XnStatus CreateBasedOn(DepthGenerator& other, const XnChar* strName = NULL);
03112 
03116         inline XnStatus SetData(XnUInt32 nFrameID, XnUInt64 nTimestamp, XnUInt32 nDataSize, const XnDepthPixel* pDepthMap)
03117         {
03118             return xnMockDepthSetData(GetHandle(), nFrameID, nTimestamp, nDataSize, pDepthMap);
03119         }
03120 
03128         inline XnStatus SetData(const DepthMetaData& depthMD, XnUInt32 nFrameID, XnUInt64 nTimestamp)
03129         {
03130             return SetData(nFrameID, nTimestamp, depthMD.DataSize(), depthMD.Data());
03131         }
03132 
03138         inline XnStatus SetData(const DepthMetaData& depthMD)
03139         {
03140             return SetData(depthMD, depthMD.FrameID(), depthMD.Timestamp());
03141         }
03142     };
03143 
03148     class ImageGenerator : public MapGenerator
03149     {
03150     public:
03156         inline ImageGenerator(XnNodeHandle hNode = NULL) : MapGenerator(hNode) {}
03157         inline ImageGenerator(const NodeWrapper& other) : MapGenerator(other) {}
03158 
03162         inline XnStatus Create(Context& context, Query* pQuery = NULL, EnumerationErrors* pErrors = NULL);
03163 
03167         inline void GetMetaData(ImageMetaData& metaData) const 
03168         {
03169             xnGetImageMetaData(GetHandle(), metaData.GetUnderlying());
03170         }
03171 
03175         inline const XnRGB24Pixel* GetRGB24ImageMap() const
03176         {
03177             return xnGetRGB24ImageMap(GetHandle());
03178         }
03179 
03183         inline const XnYUV422DoublePixel* GetYUV422ImageMap() const
03184         {
03185             return xnGetYUV422ImageMap(GetHandle());
03186         }
03187 
03191         inline const XnGrayscale8Pixel* GetGrayscale8ImageMap() const
03192         {
03193             return xnGetGrayscale8ImageMap(GetHandle());
03194         }
03195 
03199         inline const XnGrayscale16Pixel* GetGrayscale16ImageMap() const
03200         {
03201             return xnGetGrayscale16ImageMap(GetHandle());
03202         }
03203 
03207         inline const XnUInt8* GetImageMap() const
03208         {
03209             return xnGetImageMap(GetHandle());
03210         }
03211 
03215         inline XnBool IsPixelFormatSupported(XnPixelFormat Format) const
03216         {
03217             return xnIsPixelFormatSupported(GetHandle(), Format);
03218         }
03219 
03223         inline XnStatus SetPixelFormat(XnPixelFormat Format)
03224         {
03225             return xnSetPixelFormat(GetHandle(), Format);
03226         }
03227 
03231         inline XnPixelFormat GetPixelFormat() const
03232         {
03233             return xnGetPixelFormat(GetHandle());
03234         }
03235 
03239         inline XnStatus RegisterToPixelFormatChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
03240         {
03241             return _RegisterToStateChange(xnRegisterToPixelFormatChange, GetHandle(), handler, pCookie, hCallback);
03242         }
03243 
03247         inline void UnregisterFromPixelFormatChange(XnCallbackHandle hCallback)
03248         {
03249             _UnregisterFromStateChange(xnUnregisterFromPixelFormatChange, GetHandle(), hCallback);
03250         }
03251     };
03252 
03257     class MockImageGenerator : public ImageGenerator
03258     {
03259     public:
03265         inline MockImageGenerator(XnNodeHandle hNode = NULL) : ImageGenerator(hNode) {}
03266         inline MockImageGenerator(const NodeWrapper& other) : ImageGenerator(other) {}
03267 
03274         XnStatus Create(Context& context, const XnChar* strName = NULL);
03275 
03282         XnStatus CreateBasedOn(ImageGenerator& other, const XnChar* strName = NULL);
03283 
03287         inline XnStatus SetData(XnUInt32 nFrameID, XnUInt64 nTimestamp, XnUInt32 nDataSize, const XnUInt8* pImageMap)
03288         {
03289             return xnMockImageSetData(GetHandle(), nFrameID, nTimestamp, nDataSize, pImageMap);
03290         }
03291 
03299         inline XnStatus SetData(const ImageMetaData& imageMD, XnUInt32 nFrameID, XnUInt64 nTimestamp)
03300         {
03301             return SetData(nFrameID, nTimestamp, imageMD.DataSize(), imageMD.Data());
03302         }
03303 
03309         inline XnStatus SetData(const ImageMetaData& imageMD)
03310         {
03311             return SetData(imageMD, imageMD.FrameID(), imageMD.Timestamp());
03312         }
03313     };
03314 
03319     class IRGenerator : public MapGenerator
03320     {
03321     public:
03327         inline IRGenerator(XnNodeHandle hNode = NULL) : MapGenerator(hNode) {}
03328         inline IRGenerator(const NodeWrapper& other) : MapGenerator(other) {}
03329 
03333         inline XnStatus Create(Context& context, Query* pQuery = NULL, EnumerationErrors* pErrors = NULL);
03334 
03338         inline void GetMetaData(IRMetaData& metaData) const 
03339         { 
03340             xnGetIRMetaData(GetHandle(), metaData.GetUnderlying());
03341         }
03342 
03346         inline const XnIRPixel* GetIRMap() const
03347         {
03348             return xnGetIRMap(GetHandle());
03349         }
03350     };
03351 
03356     class MockIRGenerator : public IRGenerator
03357     {
03358     public:
03364         inline MockIRGenerator(XnNodeHandle hNode = NULL) : IRGenerator(hNode) {}
03365         inline MockIRGenerator(const NodeWrapper& other) : IRGenerator(other) {}
03366 
03373         XnStatus Create(Context& context, const XnChar* strName = NULL);
03380         XnStatus CreateBasedOn(IRGenerator& other, const XnChar* strName = NULL);
03381 
03385         inline XnStatus SetData(XnUInt32 nFrameID, XnUInt64 nTimestamp, XnUInt32 nDataSize, const XnIRPixel* pIRMap)
03386         {
03387             return xnMockIRSetData(GetHandle(), nFrameID, nTimestamp, nDataSize, pIRMap);
03388         }
03389 
03397         inline XnStatus SetData(const IRMetaData& irMD, XnUInt32 nFrameID, XnUInt64 nTimestamp)
03398         {
03399             return SetData(nFrameID, nTimestamp, irMD.DataSize(), irMD.Data());
03400         }
03401 
03407         inline XnStatus SetData(const IRMetaData& irMD)
03408         {
03409             return SetData(irMD, irMD.FrameID(), irMD.Timestamp());
03410         }
03411     };
03412 
03417     class GestureGenerator : public Generator
03418     {
03419     public:
03425         inline GestureGenerator(XnNodeHandle hNode = NULL) : Generator(hNode) {} 
03426         inline GestureGenerator(const NodeWrapper& other) : Generator(other) {}
03427 
03431         inline XnStatus Create(Context& context, Query* pQuery = NULL, EnumerationErrors* pErrors = NULL);
03432 
03436         inline XnStatus AddGesture(const XnChar* strGesture, XnBoundingBox3D* pArea)
03437         {
03438             return xnAddGesture(GetHandle(), strGesture, pArea);
03439         }
03440 
03444         inline XnStatus RemoveGesture(const XnChar* strGesture)
03445         {
03446             return xnRemoveGesture(GetHandle(), strGesture);
03447         }
03448 
03452         inline XnStatus GetActiveGestures(XnChar*& astrGestures, XnUInt16& nGestures) const
03453         {
03454             return xnGetActiveGestures(GetHandle(), &astrGestures, &nGestures);
03455         }
03456 
03460         inline XnStatus GetAllActiveGestures(XnChar** astrGestures, XnUInt32 nNameLength, XnUInt16& nGestures) const
03461         {
03462             return xnGetAllActiveGestures(GetHandle(), astrGestures, nNameLength, &nGestures);
03463         }
03464 
03468         inline XnStatus EnumerateGestures(XnChar*& astrGestures, XnUInt16& nGestures) const
03469         {
03470             return xnEnumerateGestures(GetHandle(), &astrGestures, &nGestures);
03471         }
03475         inline XnStatus EnumerateAllGestures(XnChar** astrGestures, XnUInt32 nNameLength, XnUInt16& nGestures) const
03476         {
03477             return xnEnumerateAllGestures(GetHandle(), astrGestures, nNameLength, &nGestures);
03478         }
03479 
03483         inline XnBool IsGestureAvailable(const XnChar* strGesture) const
03484         {
03485             return xnIsGestureAvailable(GetHandle(), strGesture);
03486         }
03487 
03491         inline XnBool IsGestureProgressSupported(const XnChar* strGesture) const
03492         {
03493             return xnIsGestureProgressSupported(GetHandle(), strGesture);
03494         }
03495 
03505         typedef void (XN_CALLBACK_TYPE* GestureRecognized)(GestureGenerator& generator, const XnChar* strGesture, const XnPoint3D* pIDPosition, const XnPoint3D* pEndPosition, void* pCookie);
03515         typedef void (XN_CALLBACK_TYPE* GestureProgress)(GestureGenerator& generator, const XnChar* strGesture, const XnPoint3D* pPosition, XnFloat fProgress, void* pCookie);
03516 
03520         XnStatus RegisterGestureCallbacks(GestureRecognized RecognizedCB, GestureProgress ProgressCB, void* pCookie, XnCallbackHandle& hCallback)
03521         {
03522             XnStatus nRetVal = XN_STATUS_OK;
03523             
03524             GestureCookie* pGestureCookie;
03525             XN_VALIDATE_ALLOC(pGestureCookie, GestureCookie);
03526             pGestureCookie->recognizedHandler = RecognizedCB;
03527             pGestureCookie->progressHandler = ProgressCB;
03528             pGestureCookie->pUserCookie = pCookie;
03529 
03530             nRetVal = xnRegisterGestureCallbacks(GetHandle(), GestureRecognizedCallback, GestureProgressCallback, pGestureCookie, &pGestureCookie->hCallback);
03531             if (nRetVal != XN_STATUS_OK)
03532             {
03533                 xnOSFree(pGestureCookie);
03534                 return (nRetVal);
03535             }
03536 
03537             hCallback = pGestureCookie;
03538 
03539             return (XN_STATUS_OK);
03540         }
03541 
03545         inline void UnregisterGestureCallbacks(XnCallbackHandle hCallback)
03546         {
03547             GestureCookie* pGestureCookie = (GestureCookie*)hCallback;
03548             xnUnregisterGestureCallbacks(GetHandle(), pGestureCookie->hCallback);
03549             xnOSFree(pGestureCookie);
03550         }
03551 
03555         inline XnStatus RegisterToGestureChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
03556         {
03557             return _RegisterToStateChange(xnRegisterToGestureChange, GetHandle(), handler, pCookie, hCallback);
03558         }
03559 
03563         inline void UnregisterFromGestureChange(XnCallbackHandle hCallback)
03564         {
03565             _UnregisterFromStateChange(xnUnregisterFromGestureChange, GetHandle(), hCallback);
03566         }
03567 
03576         typedef void (XN_CALLBACK_TYPE* GestureIntermediateStageCompleted)(GestureGenerator& generator, const XnChar* strGesture, const XnPoint3D* pPosition, void* pCookie);
03580         XnStatus RegisterToGestureIntermediateStageCompleted(GestureIntermediateStageCompleted handler, void* pCookie, XnCallbackHandle& hCallback)
03581         {
03582             XnStatus nRetVal = XN_STATUS_OK;
03583 
03584             GestureIntermediateStageCompletedCookie* pGestureCookie;
03585             XN_VALIDATE_ALLOC(pGestureCookie, GestureIntermediateStageCompletedCookie);
03586             pGestureCookie->handler = handler;
03587             pGestureCookie->pUserCookie = pCookie;
03588 
03589             nRetVal = xnRegisterToGestureIntermediateStageCompleted(GetHandle(), GestureIntermediateStageCompletedCallback, pGestureCookie, &pGestureCookie->hCallback);
03590             if (nRetVal != XN_STATUS_OK)
03591             {
03592                 xnOSFree(pGestureCookie);
03593                 return (nRetVal);
03594             }
03595 
03596             hCallback = pGestureCookie;
03597 
03598             return (XN_STATUS_OK);
03599         }
03603         inline void UnregisterFromGestureIntermediateStageCompleted(XnCallbackHandle hCallback)
03604         {
03605             GestureIntermediateStageCompletedCookie* pGestureCookie = (GestureIntermediateStageCompletedCookie*)hCallback;
03606             xnUnregisterFromGestureIntermediateStageCompleted(GetHandle(), pGestureCookie->hCallback);
03607             xnOSFree(pGestureCookie);
03608         }
03609 
03618         typedef void (XN_CALLBACK_TYPE* GestureReadyForNextIntermediateStage)(GestureGenerator& generator, const XnChar* strGesture, const XnPoint3D* pPosition, void* pCookie);
03622         XnStatus RegisterToGestureReadyForNextIntermediateStage(GestureReadyForNextIntermediateStage handler, void* pCookie, XnCallbackHandle& hCallback)
03623         {
03624             XnStatus nRetVal = XN_STATUS_OK;
03625 
03626             GestureReadyForNextIntermediateStageCookie* pGestureCookie;
03627             XN_VALIDATE_ALLOC(pGestureCookie, GestureReadyForNextIntermediateStageCookie);
03628             pGestureCookie->handler = handler;
03629             pGestureCookie->pUserCookie = pCookie;
03630 
03631             nRetVal = xnRegisterToGestureReadyForNextIntermediateStage(GetHandle(), GestureReadyForNextIntermediateStageCallback, pGestureCookie, &pGestureCookie->hCallback);
03632             if (nRetVal != XN_STATUS_OK)
03633             {
03634                 xnOSFree(pGestureCookie);
03635                 return (nRetVal);
03636             }
03637 
03638             hCallback = pGestureCookie;
03639 
03640             return (XN_STATUS_OK);
03641         }
03642 
03646         inline void UnregisterFromGestureReadyForNextIntermediateStageCallbacks(XnCallbackHandle hCallback)
03647         {
03648             GestureReadyForNextIntermediateStageCookie* pGestureCookie = (GestureReadyForNextIntermediateStageCookie*)hCallback;
03649             xnUnregisterFromGestureReadyForNextIntermediateStage(GetHandle(), pGestureCookie->hCallback);
03650             xnOSFree(pGestureCookie);
03651         }
03652 
03653     private:
03654         typedef struct GestureCookie
03655         {
03656             GestureRecognized recognizedHandler;
03657             GestureProgress progressHandler;
03658             void* pUserCookie;
03659             XnCallbackHandle hCallback;
03660         } GestureCookie;
03661 
03662         static void XN_CALLBACK_TYPE GestureRecognizedCallback(XnNodeHandle hNode, const XnChar* strGesture, const XnPoint3D* pIDPosition, const XnPoint3D* pEndPosition, void* pCookie)
03663         {
03664             GestureCookie* pGestureCookie = (GestureCookie*)pCookie;
03665             GestureGenerator gen(hNode);
03666             if (pGestureCookie->recognizedHandler != NULL)
03667             {
03668                 pGestureCookie->recognizedHandler(gen, strGesture, pIDPosition, pEndPosition, pGestureCookie->pUserCookie);
03669             }
03670         }
03671 
03672         static void XN_CALLBACK_TYPE GestureProgressCallback(XnNodeHandle hNode, const XnChar* strGesture, const XnPoint3D* pPosition, XnFloat fProgress, void* pCookie)
03673         {
03674             GestureCookie* pGestureCookie = (GestureCookie*)pCookie;
03675             GestureGenerator gen(hNode);
03676             if (pGestureCookie->progressHandler != NULL)
03677             {
03678                 pGestureCookie->progressHandler(gen, strGesture, pPosition, fProgress, pGestureCookie->pUserCookie);
03679             }
03680         }
03681 
03682         typedef struct GestureIntermediateStageCompletedCookie
03683         {
03684             GestureIntermediateStageCompleted handler;
03685             void* pUserCookie;
03686             XnCallbackHandle hCallback;
03687         } GestureIntermediateStageCompletedCookie;
03688 
03689         static void XN_CALLBACK_TYPE GestureIntermediateStageCompletedCallback(XnNodeHandle hNode, const XnChar* strGesture, const XnPoint3D* pPosition, void* pCookie)
03690         {
03691             GestureIntermediateStageCompletedCookie* pGestureCookie = (GestureIntermediateStageCompletedCookie*)pCookie;
03692             GestureGenerator gen(hNode);
03693             if (pGestureCookie->handler != NULL)
03694             {
03695                 pGestureCookie->handler(gen, strGesture, pPosition, pGestureCookie->pUserCookie);
03696             }
03697         }
03698 
03699         typedef struct GestureReadyForNextIntermediateStageCookie
03700         {
03701             GestureReadyForNextIntermediateStage handler;
03702             void* pUserCookie;
03703             XnCallbackHandle hCallback;
03704         } GestureReadyForNextIntermediateStageCookie;
03705 
03706         static void XN_CALLBACK_TYPE GestureReadyForNextIntermediateStageCallback(XnNodeHandle hNode, const XnChar* strGesture, const XnPoint3D* pPosition, void* pCookie)
03707         {
03708             GestureReadyForNextIntermediateStageCookie* pGestureCookie = (GestureReadyForNextIntermediateStageCookie*)pCookie;
03709             GestureGenerator gen(hNode);
03710             if (pGestureCookie->handler != NULL)
03711             {
03712                 pGestureCookie->handler(gen, strGesture, pPosition, pGestureCookie->pUserCookie);
03713             }
03714         }
03715     };
03716 
03721     class SceneAnalyzer : public MapGenerator
03722     {
03723     public:
03729         inline SceneAnalyzer(XnNodeHandle hNode = NULL) : MapGenerator(hNode) {}
03730         inline SceneAnalyzer(const NodeWrapper& other) : MapGenerator(other) {}
03731 
03735         inline XnStatus Create(Context& context, Query* pQuery = NULL, EnumerationErrors* pErrors = NULL);
03736 
03740         inline void GetMetaData(SceneMetaData& metaData) const
03741         {
03742             xnGetSceneMetaData(GetHandle(), metaData.GetUnderlying());
03743         }
03744 
03748         inline const XnLabel* GetLabelMap() const
03749         {
03750             return xnGetLabelMap(GetHandle());
03751         }
03752 
03756         inline XnStatus GetFloor(XnPlane3D& Plane) const
03757         {
03758             return xnGetFloor(GetHandle(), &Plane);
03759         }
03760     };
03761 
03766     class HandTouchingFOVEdgeCapability : public Capability
03767     {
03768     public:
03774         inline HandTouchingFOVEdgeCapability(XnNodeHandle hNode) : Capability(hNode) {}
03775         HandTouchingFOVEdgeCapability(const NodeWrapper& node) : Capability(node) {}
03776 
03787         typedef void (XN_CALLBACK_TYPE* HandTouchingFOVEdge)(HandTouchingFOVEdgeCapability& touchingfov, XnUserID user, const XnPoint3D* pPosition, XnFloat fTime, XnDirection eDir, void* pCookie);
03791         inline XnStatus RegisterToHandTouchingFOVEdge(HandTouchingFOVEdge handler, void* pCookie, XnCallbackHandle& hCallback)
03792         {
03793             XnStatus nRetVal = XN_STATUS_OK;
03794 
03795             HandTouchingFOVEdgeCookie* pHandCookie;
03796             XN_VALIDATE_ALLOC(pHandCookie, HandTouchingFOVEdgeCookie);
03797             pHandCookie->handler = handler;
03798             pHandCookie->pUserCookie = pCookie;
03799 
03800             nRetVal = xnRegisterToHandTouchingFOVEdge(GetHandle(), HandTouchingFOVEdgeCB, pHandCookie, &pHandCookie->hCallback);
03801             if (nRetVal != XN_STATUS_OK)
03802             {
03803                 xnOSFree(pHandCookie);
03804                 return (nRetVal);
03805             }
03806 
03807             hCallback = pHandCookie;
03808 
03809             return (XN_STATUS_OK);
03810         }
03811 
03815         inline void UnregisterFromHandTouchingFOVEdge(XnCallbackHandle hCallback)
03816         {
03817             HandTouchingFOVEdgeCookie* pHandCookie = (HandTouchingFOVEdgeCookie*)hCallback;
03818             xnUnregisterFromHandTouchingFOVEdge(GetHandle(), pHandCookie->hCallback);
03819             xnOSFree(pHandCookie);
03820         }
03821     private:
03822         typedef struct HandTouchingFOVEdgeCookie
03823         {
03824             HandTouchingFOVEdge handler;
03825             void* pUserCookie;
03826             XnCallbackHandle hCallback;
03827         } HandTouchingFOVEdgeCookie;
03828 
03829         static void XN_CALLBACK_TYPE HandTouchingFOVEdgeCB(XnNodeHandle hNode, XnUserID user, const XnPoint3D* pPosition, XnFloat fTime, XnDirection eDir, void* pCookie)
03830         {
03831             HandTouchingFOVEdgeCookie* pHandCookie = (HandTouchingFOVEdgeCookie*)pCookie;
03832             HandTouchingFOVEdgeCapability cap(hNode);
03833             if (pHandCookie->handler != NULL)
03834             {
03835                 pHandCookie->handler(cap, user, pPosition, fTime, eDir, pHandCookie->pUserCookie);
03836             }
03837         }
03838 
03839     };
03844     class HandsGenerator : public Generator
03845     {
03846     public:
03852         inline HandsGenerator(XnNodeHandle hNode = NULL) : Generator(hNode) {}
03853         inline HandsGenerator(const NodeWrapper& other) : Generator(other) {}
03854 
03858         inline XnStatus Create(Context& context, Query* pQuery = NULL, EnumerationErrors* pErrors = NULL);
03859 
03869         typedef void (XN_CALLBACK_TYPE* HandCreate)(HandsGenerator& generator, XnUserID user, const XnPoint3D* pPosition, XnFloat fTime, void* pCookie);
03879         typedef void (XN_CALLBACK_TYPE* HandUpdate)(HandsGenerator& generator, XnUserID user, const XnPoint3D* pPosition, XnFloat fTime, void* pCookie);
03888         typedef void (XN_CALLBACK_TYPE* HandDestroy)(HandsGenerator& generator, XnUserID user, XnFloat fTime, void* pCookie);
03889 
03893         inline XnStatus RegisterHandCallbacks(HandCreate CreateCB, HandUpdate UpdateCB, HandDestroy DestroyCB, void* pCookie, XnCallbackHandle& hCallback)
03894         {
03895             XnStatus nRetVal = XN_STATUS_OK;
03896 
03897             HandCookie* pHandCookie;
03898             XN_VALIDATE_ALLOC(pHandCookie, HandCookie);
03899             pHandCookie->createHandler = CreateCB;
03900             pHandCookie->updateHandler = UpdateCB;
03901             pHandCookie->destroyHandler = DestroyCB;
03902             pHandCookie->pUserCookie = pCookie;
03903 
03904             nRetVal = xnRegisterHandCallbacks(GetHandle(), HandCreateCB, HandUpdateCB, HandDestroyCB, pHandCookie, &pHandCookie->hCallback);
03905             if (nRetVal != XN_STATUS_OK)
03906             {
03907                 xnOSFree(pHandCookie);
03908                 return (nRetVal);
03909             }
03910 
03911             hCallback = pHandCookie;
03912 
03913             return (XN_STATUS_OK);
03914         }
03915 
03919         inline void UnregisterHandCallbacks(XnCallbackHandle hCallback)
03920         {
03921             HandCookie* pHandCookie = (HandCookie*)hCallback;
03922             xnUnregisterHandCallbacks(GetHandle(), pHandCookie->hCallback);
03923             xnOSFree(pHandCookie);
03924         }
03925 
03929         inline XnStatus StopTracking(XnUserID user)
03930         {
03931             return xnStopTracking(GetHandle(), user);
03932         }
03933 
03937         inline XnStatus StopTrackingAll()
03938         {
03939             return xnStopTrackingAll(GetHandle());
03940         }
03941 
03945         inline XnStatus StartTracking(const XnPoint3D& ptPosition)
03946         {
03947             return xnStartTracking(GetHandle(), &ptPosition);
03948         }
03949 
03953         inline XnStatus SetSmoothing(XnFloat fSmoothingFactor)
03954         {
03955             return xnSetTrackingSmoothing(GetHandle(), fSmoothingFactor);
03956         }
03957 
03963         inline const HandTouchingFOVEdgeCapability GetHandTouchingFOVEdgeCap() const
03964         {
03965             return HandTouchingFOVEdgeCapability(GetHandle());
03966         }
03967 
03973         inline HandTouchingFOVEdgeCapability GetHandTouchingFOVEdgeCap()
03974         {
03975             return HandTouchingFOVEdgeCapability(GetHandle());
03976         }
03977 
03978     private:
03979         typedef struct HandCookie
03980         {
03981             HandCreate createHandler;
03982             HandUpdate updateHandler;
03983             HandDestroy destroyHandler;
03984             void* pUserCookie;
03985             XnCallbackHandle hCallback;
03986         } HandCookie;
03987 
03988         static void XN_CALLBACK_TYPE HandCreateCB(XnNodeHandle hNode, XnUserID user, const XnPoint3D* pPosition, XnFloat fTime, void* pCookie)
03989         {
03990             HandCookie* pHandCookie = (HandCookie*)pCookie;
03991             HandsGenerator gen(hNode);
03992             if (pHandCookie->createHandler != NULL)
03993             {
03994                 pHandCookie->createHandler(gen, user, pPosition, fTime, pHandCookie->pUserCookie);
03995             }
03996         }
03997         static void XN_CALLBACK_TYPE HandUpdateCB(XnNodeHandle hNode, XnUserID user, const XnPoint3D* pPosition, XnFloat fTime, void* pCookie)
03998         {
03999             HandCookie* pHandCookie = (HandCookie*)pCookie;
04000             HandsGenerator gen(hNode);
04001             if (pHandCookie->updateHandler != NULL)
04002             {
04003                 pHandCookie->updateHandler(gen, user, pPosition, fTime, pHandCookie->pUserCookie);
04004             }
04005         }
04006         static void XN_CALLBACK_TYPE HandDestroyCB(XnNodeHandle hNode, XnUserID user, XnFloat fTime, void* pCookie)
04007         {
04008             HandCookie* pHandCookie = (HandCookie*)pCookie;
04009             HandsGenerator gen(hNode);
04010             if (pHandCookie->destroyHandler != NULL)
04011             {
04012                 pHandCookie->destroyHandler(gen, user, fTime, pHandCookie->pUserCookie);
04013             }
04014         }
04015     };
04016 
04021     class SkeletonCapability : public Capability
04022     {
04023     public:
04029         inline SkeletonCapability(XnNodeHandle hNode) : Capability(hNode) {}
04030         SkeletonCapability(const NodeWrapper& node) : Capability(node) {}
04031 
04035         inline XnBool IsJointAvailable(XnSkeletonJoint eJoint) const
04036         {
04037             return xnIsJointAvailable(GetHandle(), eJoint);
04038         }
04039 
04043         inline XnBool IsProfileAvailable(XnSkeletonProfile eProfile) const
04044         {
04045             return xnIsProfileAvailable(GetHandle(), eProfile);
04046         }
04047 
04051         inline XnStatus SetSkeletonProfile(XnSkeletonProfile eProfile)
04052         {
04053             return xnSetSkeletonProfile(GetHandle(), eProfile);
04054         }
04055 
04059         inline XnStatus SetJointActive(XnSkeletonJoint eJoint, XnBool bState)
04060         {
04061             return xnSetJointActive(GetHandle(), eJoint, bState);
04062         }
04063 
04067         XN_API_DEPRECATED("Use the version with one argument") 
04068         inline XnBool IsJointActive(XnSkeletonJoint eJoint, XnBool /*bState*/) const
04069         {
04070             return xnIsJointActive(GetHandle(), eJoint);
04071         }
04072 
04076         inline XnBool IsJointActive(XnSkeletonJoint eJoint) const
04077         {
04078             return xnIsJointActive(GetHandle(), eJoint);
04079         }
04080 
04084         inline XnStatus RegisterToJointConfigurationChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
04085         {
04086             return _RegisterToStateChange(xnRegisterToJointConfigurationChange, GetHandle(), handler, pCookie, hCallback);
04087         }
04088 
04092         inline void UnregisterFromJointConfigurationChange(XnCallbackHandle hCallback)
04093         {
04094             _UnregisterFromStateChange(xnUnregisterFromJointConfigurationChange, GetHandle(), hCallback);
04095         }
04096 
04100         inline XnStatus EnumerateActiveJoints(XnSkeletonJoint* pJoints, XnUInt16& nJoints) const
04101         {
04102             return xnEnumerateActiveJoints(GetHandle(), pJoints, &nJoints);
04103         }
04104 
04108         inline XnStatus GetSkeletonJoint(XnUserID user, XnSkeletonJoint eJoint, XnSkeletonJointTransformation& Joint) const
04109         {
04110             return xnGetSkeletonJoint(GetHandle(), user, eJoint, &Joint);
04111         }
04112 
04116         inline XnStatus GetSkeletonJointPosition(XnUserID user, XnSkeletonJoint eJoint, XnSkeletonJointPosition& Joint) const
04117         {
04118             return xnGetSkeletonJointPosition(GetHandle(), user, eJoint, &Joint);
04119         }
04120 
04124         inline XnStatus GetSkeletonJointOrientation(XnUserID user, XnSkeletonJoint eJoint, XnSkeletonJointOrientation& Joint) const
04125         {
04126             return xnGetSkeletonJointOrientation(GetHandle(), user, eJoint, &Joint);
04127         }
04128 
04132         inline XnBool IsTracking(XnUserID user) const
04133         {
04134             return xnIsSkeletonTracking(GetHandle(), user);
04135         }
04136 
04140         inline XnBool IsCalibrated(XnUserID user) const
04141         {
04142             return xnIsSkeletonCalibrated(GetHandle(), user);
04143         }
04144 
04148         inline XnBool IsCalibrating(XnUserID user) const
04149         {
04150             return xnIsSkeletonCalibrating(GetHandle(), user);
04151         }
04152 
04156         inline XnStatus RequestCalibration(XnUserID user, XnBool bForce)
04157         {
04158             return xnRequestSkeletonCalibration(GetHandle(), user, bForce);
04159         }
04160 
04164         inline XnStatus AbortCalibration(XnUserID user)
04165         {
04166             return xnAbortSkeletonCalibration(GetHandle(), user);
04167         }
04168 
04172         inline XnStatus SaveCalibrationDataToFile(XnUserID user, const XnChar* strFileName)
04173         {
04174             return xnSaveSkeletonCalibrationDataToFile(GetHandle(), user, strFileName);
04175         }
04176 
04180         inline XnStatus LoadCalibrationDataFromFile(XnUserID user, const XnChar* strFileName)
04181         {
04182             return xnLoadSkeletonCalibrationDataFromFile(GetHandle(), user, strFileName);
04183         }
04184 
04188         inline XnStatus SaveCalibrationData(XnUserID user, XnUInt32 nSlot)
04189         {
04190             return xnSaveSkeletonCalibrationData(GetHandle(), user, nSlot);
04191         }
04192 
04196         inline XnStatus LoadCalibrationData(XnUserID user, XnUInt32 nSlot)
04197         {
04198             return xnLoadSkeletonCalibrationData(GetHandle(), user, nSlot);
04199         }
04200 
04204         inline XnStatus ClearCalibrationData(XnUInt32 nSlot)
04205         {
04206             return xnClearSkeletonCalibrationData(GetHandle(), nSlot);
04207         }
04208 
04212         inline XnBool IsCalibrationData(XnUInt32 nSlot) const
04213         {
04214             return xnIsSkeletonCalibrationData(GetHandle(), nSlot);
04215         }
04216 
04220         inline XnStatus StartTracking(XnUserID user)
04221         {
04222             return xnStartSkeletonTracking(GetHandle(), user);
04223         }
04224 
04228         inline XnStatus StopTracking(XnUserID user)
04229         {
04230             return xnStopSkeletonTracking(GetHandle(), user);
04231         }
04232 
04236         inline XnStatus Reset(XnUserID user)
04237         {
04238             return xnResetSkeleton(GetHandle(), user);
04239         }
04240 
04244         inline XnBool NeedPoseForCalibration() const
04245         {
04246             return xnNeedPoseForSkeletonCalibration(GetHandle());
04247         }
04248 
04252         inline XnStatus GetCalibrationPose(XnChar* strPose) const
04253         {
04254             return xnGetSkeletonCalibrationPose(GetHandle(), strPose);
04255         }
04256 
04260         inline XnStatus SetSmoothing(XnFloat fSmoothingFactor)
04261         {
04262             return xnSetSkeletonSmoothing(GetHandle(), fSmoothingFactor);
04263         }
04264 
04272         typedef void (XN_CALLBACK_TYPE* CalibrationStart)(SkeletonCapability& skeleton, XnUserID user, void* pCookie);
04281         typedef void (XN_CALLBACK_TYPE* CalibrationEnd)(SkeletonCapability& skeleton, XnUserID user, XnBool bSuccess, void* pCookie);
04282 
04286         inline XnStatus XN_API_DEPRECATED("Please use RegisterToCalibrationStart/Complete") RegisterCalibrationCallbacks(CalibrationStart CalibrationStartCB, CalibrationEnd CalibrationEndCB, void* pCookie, XnCallbackHandle& hCallback)
04287         {
04288             XnStatus nRetVal = XN_STATUS_OK;
04289 
04290             SkeletonCookie* pSkeletonCookie;
04291             XN_VALIDATE_ALLOC(pSkeletonCookie, SkeletonCookie);
04292             pSkeletonCookie->startHandler = CalibrationStartCB;
04293             pSkeletonCookie->endHandler = CalibrationEndCB;
04294             pSkeletonCookie->pUserCookie = pCookie;
04295 
04296 #pragma warning (push)
04297 #pragma warning (disable: XN_DEPRECATED_WARNING_IDS)
04298             nRetVal = xnRegisterCalibrationCallbacks(GetHandle(), CalibrationStartBundleCallback, CalibrationEndBundleCallback, pSkeletonCookie, &pSkeletonCookie->hCallback);
04299 #pragma warning (pop)
04300             if (nRetVal != XN_STATUS_OK)
04301             {
04302                 xnOSFree(pSkeletonCookie);
04303                 return (nRetVal);
04304             }
04305 
04306             hCallback = pSkeletonCookie;
04307 
04308             return (XN_STATUS_OK);
04309         }
04310 
04314         inline void XN_API_DEPRECATED("Please use UnregisterFromCalibrationStart/Complete") UnregisterCalibrationCallbacks(XnCallbackHandle hCallback)
04315         {
04316             SkeletonCookie* pSkeletonCookie = (SkeletonCookie*)hCallback;
04317 #pragma warning (push)
04318 #pragma warning (disable: XN_DEPRECATED_WARNING_IDS)
04319             xnUnregisterCalibrationCallbacks(GetHandle(), pSkeletonCookie->hCallback);
04320 #pragma warning (pop)
04321             xnOSFree(pSkeletonCookie);
04322         }
04323 
04327         inline XnStatus RegisterToCalibrationStart(CalibrationStart handler, void* pCookie, XnCallbackHandle& hCallback)
04328         {
04329             XnStatus nRetVal = XN_STATUS_OK;
04330             CalibrationStartCookie* pCalibrationCookie;
04331             XN_VALIDATE_ALLOC(pCalibrationCookie, CalibrationStartCookie);
04332             pCalibrationCookie->handler = handler;
04333             pCalibrationCookie->pUserCookie = pCookie;
04334             nRetVal = xnRegisterToCalibrationStart(GetHandle(), CalibrationStartCallback, pCalibrationCookie, &pCalibrationCookie->hCallback);
04335             if (nRetVal != XN_STATUS_OK)
04336             {
04337                 xnOSFree(pCalibrationCookie);
04338                 return nRetVal;
04339             }
04340             hCallback = pCalibrationCookie;
04341             return XN_STATUS_OK;
04342         }
04346         inline XnStatus UnregisterFromCalibrationStart(XnCallbackHandle hCallback)
04347         {
04348             CalibrationStartCookie* pCalibrationCookie = (CalibrationStartCookie*)hCallback;
04349             xnUnregisterFromCalibrationStart(GetHandle(), pCalibrationCookie->hCallback);
04350             xnOSFree(pCalibrationCookie);
04351         }
04352 
04361         typedef void (XN_CALLBACK_TYPE* CalibrationInProgress)(SkeletonCapability& skeleton, XnUserID user, XnCalibrationStatus calibrationError, void* pCookie);
04362 
04366         inline XnStatus RegisterToCalibrationInProgress(CalibrationInProgress handler, void* pCookie, XnCallbackHandle& hCallback)
04367         {
04368             XnStatus nRetVal = XN_STATUS_OK;
04369 
04370             CalibrationInProgressCookie* pSkeletonCookie;
04371             XN_VALIDATE_ALLOC(pSkeletonCookie, CalibrationInProgressCookie);
04372             pSkeletonCookie->handler = handler;
04373             pSkeletonCookie->pUserCookie = pCookie;
04374 
04375             nRetVal = xnRegisterToCalibrationInProgress(GetHandle(), CalibrationInProgressCallback, pSkeletonCookie, &pSkeletonCookie->hCallback);
04376             if (nRetVal != XN_STATUS_OK)
04377             {
04378                 xnOSFree(pSkeletonCookie);
04379                 return (nRetVal);
04380             }
04381 
04382             hCallback = pSkeletonCookie;
04383 
04384             return (XN_STATUS_OK);
04385         }
04386 
04390         inline void UnregisterFromCalibrationInProgress(XnCallbackHandle hCallback)
04391         {
04392             CalibrationInProgressCookie* pSkeletonCookie = (CalibrationInProgressCookie*)hCallback;
04393             xnUnregisterFromCalibrationInProgress(GetHandle(), pSkeletonCookie->hCallback);
04394             xnOSFree(pSkeletonCookie);
04395         }
04396 
04405         typedef void (XN_CALLBACK_TYPE* CalibrationComplete)(SkeletonCapability& skeleton, XnUserID user, XnCalibrationStatus calibrationError, void* pCookie);
04409         inline XnStatus RegisterToCalibrationComplete(CalibrationComplete handler, void* pCookie, XnCallbackHandle& hCallback)
04410         {
04411             XnStatus nRetVal = XN_STATUS_OK;
04412 
04413             CalibrationCompleteCookie* pSkeletonCookie;
04414             XN_VALIDATE_ALLOC(pSkeletonCookie, CalibrationCompleteCookie);
04415             pSkeletonCookie->handler = handler;
04416             pSkeletonCookie->pUserCookie = pCookie;
04417 
04418             nRetVal = xnRegisterToCalibrationComplete(GetHandle(), CalibrationCompleteCallback, pSkeletonCookie, &pSkeletonCookie->hCallback);
04419             if (nRetVal != XN_STATUS_OK)
04420             {
04421                 xnOSFree(pSkeletonCookie);
04422                 return (nRetVal);
04423             }
04424 
04425             hCallback = pSkeletonCookie;
04426 
04427             return (XN_STATUS_OK);
04428         }
04429 
04433         inline void UnregisterFromCalibrationComplete(XnCallbackHandle hCallback)
04434         {
04435             CalibrationCompleteCookie* pSkeletonCookie = (CalibrationCompleteCookie*)hCallback;
04436             xnUnregisterFromCalibrationComplete(GetHandle(), pSkeletonCookie->hCallback);
04437             xnOSFree(pSkeletonCookie);
04438         }
04439     private:
04440         typedef struct SkeletonCookie
04441         {
04442             CalibrationStart startHandler;
04443             CalibrationEnd endHandler;
04444             void* pUserCookie;
04445             XnCallbackHandle hCallback;
04446         } SkeletonCookie;
04447 
04448         static void XN_CALLBACK_TYPE CalibrationStartBundleCallback(XnNodeHandle hNode, XnUserID user, void* pCookie)
04449         {
04450             SkeletonCookie* pSkeletonCookie = (SkeletonCookie*)pCookie;
04451             SkeletonCapability cap(hNode);
04452             if (pSkeletonCookie->startHandler != NULL)
04453             {
04454                 pSkeletonCookie->startHandler(cap, user, pSkeletonCookie->pUserCookie);
04455             }
04456         }
04457 
04458         static void XN_CALLBACK_TYPE CalibrationEndBundleCallback(XnNodeHandle hNode, XnUserID user, XnBool bSuccess, void* pCookie)
04459         {
04460             SkeletonCookie* pSkeletonCookie = (SkeletonCookie*)pCookie;
04461             SkeletonCapability cap(hNode);
04462             if (pSkeletonCookie->endHandler != NULL)
04463             {
04464                 pSkeletonCookie->endHandler(cap, user, bSuccess, pSkeletonCookie->pUserCookie);
04465             }
04466         }
04467         typedef struct CalibrationStartCookie
04468         {
04469             CalibrationStart handler;
04470             void* pUserCookie;
04471             XnCallbackHandle hCallback;
04472         } CalibrationStartCookie;
04473 
04474         static void XN_CALLBACK_TYPE CalibrationStartCallback(XnNodeHandle hNode, XnUserID user, void* pCookie)
04475         {
04476             CalibrationStartCookie* pCalibrationCookie = (CalibrationStartCookie*)pCookie;
04477             SkeletonCapability cap(hNode);
04478             if (pCalibrationCookie->handler != NULL)
04479             {
04480                 pCalibrationCookie->handler(cap, user, pCalibrationCookie->pUserCookie);
04481             }
04482         }
04483         typedef struct CalibrationInProgressCookie
04484         {
04485             CalibrationInProgress handler;
04486             void* pUserCookie;
04487             XnCallbackHandle hCallback;
04488         } CalibrationInProgressCookie;
04489 
04490         static void XN_CALLBACK_TYPE CalibrationInProgressCallback(XnNodeHandle hNode, XnUserID user, XnCalibrationStatus calibrationError, void* pCookie)
04491         {
04492             CalibrationInProgressCookie* pSkeletonCookie = (CalibrationInProgressCookie*)pCookie;
04493             SkeletonCapability cap(hNode);
04494             if (pSkeletonCookie->handler != NULL)
04495             {
04496                 pSkeletonCookie->handler(cap, user, calibrationError, pSkeletonCookie->pUserCookie);
04497             }
04498         }
04499 
04500         typedef struct CalibrationCompleteCookie
04501         {
04502             CalibrationComplete handler;
04503             void* pUserCookie;
04504             XnCallbackHandle hCallback;
04505         } CalibrationCompleteCookie;
04506 
04507         static void XN_CALLBACK_TYPE CalibrationCompleteCallback(XnNodeHandle hNode, XnUserID user, XnCalibrationStatus calibrationError, void* pCookie)
04508         {
04509             CalibrationCompleteCookie* pSkeletonCookie = (CalibrationCompleteCookie*)pCookie;
04510             SkeletonCapability cap(hNode);
04511             if (pSkeletonCookie->handler != NULL)
04512             {
04513                 pSkeletonCookie->handler(cap, user, calibrationError, pSkeletonCookie->pUserCookie);
04514             }
04515         }
04516     };
04517 
04522     class PoseDetectionCapability : public Capability
04523     {
04524     public:
04530         inline PoseDetectionCapability(XnNodeHandle hNode) : Capability(hNode) {}
04531         PoseDetectionCapability(const NodeWrapper& node) : Capability(node) {}
04532 
04541         typedef void (XN_CALLBACK_TYPE* PoseDetection)(PoseDetectionCapability& pose, const XnChar* strPose, XnUserID user, void* pCookie);
04542 
04546         inline XnUInt32 GetNumberOfPoses() const
04547         {
04548             return xnGetNumberOfPoses(GetHandle());
04549         }
04550 
04554         inline XnStatus GetAvailablePoses(XnChar** pstrPoses, XnUInt32& nPoses) const
04555         {
04556             return xnGetAvailablePoses(GetHandle(), pstrPoses, &nPoses);
04557         }
04561         inline XnStatus GetAllAvailablePoses(XnChar** pstrPoses, XnUInt32 nNameLength, XnUInt32& nPoses) const
04562         {
04563             return xnGetAllAvailablePoses(GetHandle(), pstrPoses, nNameLength, &nPoses);
04564         }
04565 
04569         inline XnStatus StartPoseDetection(const XnChar* strPose, XnUserID user)
04570         {
04571             return xnStartPoseDetection(GetHandle(), strPose, user);
04572         }
04573 
04577         inline XnStatus StopPoseDetection(XnUserID user)
04578         {
04579             return xnStopPoseDetection(GetHandle(), user);
04580         }
04581 
04585         inline XnStatus XN_API_DEPRECATED("Please use RegisterToPoseDetected/RegisterToOutOfPose instead") RegisterToPoseCallbacks(PoseDetection PoseStartCB, PoseDetection PoseEndCB, void* pCookie, XnCallbackHandle& hCallback)
04586         {
04587             XnStatus nRetVal = XN_STATUS_OK;
04588 
04589             PoseCookie* pPoseCookie;
04590             XN_VALIDATE_ALLOC(pPoseCookie, PoseCookie);
04591             pPoseCookie->startHandler = PoseStartCB;
04592             pPoseCookie->endHandler = PoseEndCB;
04593             pPoseCookie->pPoseCookie = pCookie;
04594 
04595 #pragma warning (push)
04596 #pragma warning (disable: XN_DEPRECATED_WARNING_IDS)
04597             nRetVal = xnRegisterToPoseCallbacks(GetHandle(), PoseDetectionStartBundleCallback, PoseDetectionStartEndBundleCallback, pPoseCookie, &pPoseCookie->hCallback);
04598 #pragma warning (pop)
04599             if (nRetVal != XN_STATUS_OK)
04600             {
04601                 xnOSFree(pPoseCookie);
04602                 return (nRetVal);
04603             }
04604 
04605             hCallback = pPoseCookie;
04606 
04607             return (XN_STATUS_OK);
04608         }
04609 
04613         inline void XN_API_DEPRECATED("Please use UnregisterFromPoseDetected/UnregisterFromOutOfPose instead") UnregisterFromPoseCallbacks(XnCallbackHandle hCallback)
04614         {
04615             PoseCookie* pPoseCookie = (PoseCookie*)hCallback;
04616 #pragma warning (push)
04617 #pragma warning (disable: XN_DEPRECATED_WARNING_IDS)
04618             xnUnregisterFromPoseCallbacks(GetHandle(), pPoseCookie->hCallback);
04619 #pragma warning (pop)
04620             xnOSFree(pPoseCookie);
04621         }
04622 
04626         inline XnStatus RegisterToPoseDetected(PoseDetection handler, void* pCookie, XnCallbackHandle& hCallback)
04627         {
04628             XnStatus nRetVal = XN_STATUS_OK;
04629             PoseDetectionCookie* pPoseCookie;
04630             XN_VALIDATE_ALLOC(pPoseCookie, PoseDetectionCookie);
04631             pPoseCookie->handler = handler;
04632             pPoseCookie->pPoseCookie = pCookie;
04633 
04634             nRetVal = xnRegisterToPoseDetected(GetHandle(), PoseDetectionCallback, pPoseCookie, &pPoseCookie->hCallback);
04635             if (nRetVal != XN_STATUS_OK)
04636             {
04637                 xnOSFree(pPoseCookie);
04638                 return nRetVal;
04639             }
04640             hCallback = pPoseCookie;
04641             return XN_STATUS_OK;
04642         }
04646         inline XnStatus RegisterToOutOfPose(PoseDetection handler, void* pCookie, XnCallbackHandle& hCallback)
04647         {
04648             XnStatus nRetVal = XN_STATUS_OK;
04649             PoseDetectionCookie* pPoseCookie;
04650             XN_VALIDATE_ALLOC(pPoseCookie, PoseDetectionCookie);
04651             pPoseCookie->handler = handler;
04652             pPoseCookie->pPoseCookie = pCookie;
04653 
04654             nRetVal = xnRegisterToOutOfPose(GetHandle(), PoseDetectionCallback, pPoseCookie, &pPoseCookie->hCallback);
04655             if (nRetVal != XN_STATUS_OK)
04656             {
04657                 xnOSFree(pPoseCookie);
04658                 return nRetVal;
04659             }
04660             hCallback = pPoseCookie;
04661             return XN_STATUS_OK;
04662         }
04666         inline void UnregisterFromPoseDetected(XnCallbackHandle hCallback)
04667         {
04668             PoseDetectionCookie* pPoseCookie = (PoseDetectionCookie*)hCallback;
04669             xnUnregisterFromPoseDetected(GetHandle(), pPoseCookie->hCallback);
04670             xnOSFree(pPoseCookie);
04671         }
04675         inline void UnregisterFromOutOfPose(XnCallbackHandle hCallback)
04676         {
04677             PoseDetectionCookie* pPoseCookie = (PoseDetectionCookie*)hCallback;
04678             xnUnregisterFromOutOfPose(GetHandle(), pPoseCookie->hCallback);
04679             xnOSFree(pPoseCookie);
04680         }
04681 
04691         typedef void (XN_CALLBACK_TYPE* PoseInProgress)(PoseDetectionCapability& pose, const XnChar* strPose, XnUserID user, XnPoseDetectionStatus poseError, void* pCookie);
04695         inline XnStatus RegisterToPoseInProgress(PoseInProgress handler, void* pCookie, XnCallbackHandle& hCallback)
04696         {
04697             XnStatus nRetVal = XN_STATUS_OK;
04698 
04699             PoseInProgressCookie* pPoseCookie;
04700             XN_VALIDATE_ALLOC(pPoseCookie, PoseInProgressCookie);
04701             pPoseCookie->handler = handler;
04702             pPoseCookie->pPoseCookie = pCookie;
04703 
04704             nRetVal = xnRegisterToPoseDetectionInProgress(GetHandle(), PoseDetectionInProgressCallback, pPoseCookie, &pPoseCookie->hCallback);
04705             if (nRetVal != XN_STATUS_OK)
04706             {
04707                 xnOSFree(pPoseCookie);
04708                 return (nRetVal);
04709             }
04710 
04711             hCallback = pPoseCookie;
04712 
04713             return (XN_STATUS_OK);
04714         }
04715 
04719         inline void UnregisterFromPoseInProgress(XnCallbackHandle hCallback)
04720         {
04721             PoseInProgressCookie* pPoseCookie = (PoseInProgressCookie*)hCallback;
04722             xnUnregisterFromPoseDetectionInProgress(GetHandle(), pPoseCookie->hCallback);
04723             xnOSFree(pPoseCookie);
04724         }
04725 
04726     private:
04727         typedef struct PoseCookie
04728         {
04729             PoseDetection startHandler;
04730             PoseDetection endHandler;
04731             void* pPoseCookie;
04732             XnCallbackHandle hCallback;
04733         } PoseCookie;
04734 
04735         static void XN_CALLBACK_TYPE PoseDetectionStartBundleCallback(XnNodeHandle hNode, const XnChar* strPose, XnUserID user, void* pCookie)
04736         {
04737             PoseCookie* pPoseCookie = (PoseCookie*)pCookie;
04738             PoseDetectionCapability cap(hNode);
04739             if (pPoseCookie->startHandler != NULL)
04740             {
04741                 pPoseCookie->startHandler(cap, strPose, user, pPoseCookie->pPoseCookie);
04742             }
04743         }
04744 
04745         static void XN_CALLBACK_TYPE PoseDetectionStartEndBundleCallback(XnNodeHandle hNode, const XnChar* strPose, XnUserID user, void* pCookie)
04746         {
04747             PoseCookie* pPoseCookie = (PoseCookie*)pCookie;
04748             PoseDetectionCapability cap(hNode);
04749             if (pPoseCookie->endHandler != NULL)
04750             {
04751                 pPoseCookie->endHandler(cap, strPose, user, pPoseCookie->pPoseCookie);
04752             }
04753         }
04754         typedef struct PoseDetectionCookie
04755         {
04756             PoseDetection handler;
04757             void* pPoseCookie;
04758             XnCallbackHandle hCallback;
04759         } PoseDetectionCookie;
04760         static void XN_CALLBACK_TYPE PoseDetectionCallback(XnNodeHandle hNode, const XnChar* strPose, XnUserID user, void* pCookie)
04761         {
04762             PoseDetectionCookie* pPoseDetectionCookie = (PoseDetectionCookie*)pCookie;
04763             PoseDetectionCapability cap(hNode);
04764             if (pPoseDetectionCookie->handler != NULL)
04765             {
04766                 pPoseDetectionCookie->handler(cap, strPose, user, pPoseDetectionCookie->pPoseCookie);
04767             }
04768         }
04769 
04770         typedef struct PoseInProgressCookie
04771         {
04772             PoseInProgress handler;
04773             void* pPoseCookie;
04774             XnCallbackHandle hCallback;
04775         } PoseInProgressCookie;
04776 
04777         static void XN_CALLBACK_TYPE PoseDetectionInProgressCallback(XnNodeHandle hNode, const XnChar* strPose, XnUserID user, XnPoseDetectionStatus poseErrors, void* pCookie)
04778         {
04779             PoseInProgressCookie* pPoseCookie = (PoseInProgressCookie*)pCookie;
04780             PoseDetectionCapability cap(hNode);
04781             if (pPoseCookie->handler != NULL)
04782             {
04783                 pPoseCookie->handler(cap, strPose, user, poseErrors, pPoseCookie->pPoseCookie);
04784             }
04785         }
04786     };
04787 
04792     class UserGenerator : public Generator
04793     {
04794     public:
04800         inline UserGenerator(XnNodeHandle hNode = NULL) : Generator(hNode) {}
04801         inline UserGenerator(const NodeWrapper& other) : Generator(other) {}
04802 
04806         inline XnStatus Create(Context& context, Query* pQuery = NULL, EnumerationErrors* pErrors = NULL);
04807 
04808         typedef void (XN_CALLBACK_TYPE* UserHandler)(UserGenerator& generator, XnUserID user, void* pCookie);
04809 
04813         inline XnUInt16 GetNumberOfUsers() const
04814         {
04815             return xnGetNumberOfUsers(GetHandle());
04816         }
04817 
04821         inline XnStatus GetUsers(XnUserID aUsers[], XnUInt16& nUsers) const
04822         {
04823             return xnGetUsers(GetHandle(), aUsers, &nUsers);
04824         }
04825 
04829         inline XnStatus GetCoM(XnUserID user, XnPoint3D& com) const
04830         {
04831             return xnGetUserCoM(GetHandle(), user, &com);
04832         }
04833 
04837         inline XnStatus GetUserPixels(XnUserID user, SceneMetaData& smd) const
04838         {
04839             return xnGetUserPixels(GetHandle(), user, smd.GetUnderlying());
04840         }
04841         
04845         inline XnStatus RegisterUserCallbacks(UserHandler NewUserCB, UserHandler LostUserCB, void* pCookie, XnCallbackHandle& hCallback)
04846         {
04847             XnStatus nRetVal = XN_STATUS_OK;
04848 
04849             UserCookie* pUserCookie;
04850             XN_VALIDATE_ALLOC(pUserCookie, UserCookie);
04851             pUserCookie->newHandler = NewUserCB;
04852             pUserCookie->lostHandler = LostUserCB;
04853             pUserCookie->pUserCookie = pCookie;
04854 
04855             nRetVal = xnRegisterUserCallbacks(GetHandle(), NewUserCallback, LostUserCallback, pUserCookie, &pUserCookie->hCallback);
04856             if (nRetVal != XN_STATUS_OK)
04857             {
04858                 xnOSFree(pUserCookie);
04859                 return (nRetVal);
04860             }
04861 
04862             hCallback = pUserCookie;
04863 
04864             return (XN_STATUS_OK);
04865         }
04866 
04870         inline void UnregisterUserCallbacks(XnCallbackHandle hCallback)
04871         {
04872             UserCookie* pUserCookie = (UserCookie*)hCallback;
04873             xnUnregisterUserCallbacks(GetHandle(), pUserCookie->hCallback);
04874             xnOSFree(pUserCookie);
04875         }
04876 
04882         inline const SkeletonCapability GetSkeletonCap() const
04883         {
04884             return SkeletonCapability(GetHandle());
04885         }
04886 
04892         inline SkeletonCapability GetSkeletonCap()
04893         {
04894             return SkeletonCapability(GetHandle());
04895         }
04896 
04902         inline const PoseDetectionCapability GetPoseDetectionCap() const
04903         {
04904             return PoseDetectionCapability(GetHandle());
04905         }
04906 
04912         inline PoseDetectionCapability GetPoseDetectionCap()
04913         {
04914             return PoseDetectionCapability(GetHandle());
04915         }
04916 
04920         inline XnStatus RegisterToUserExit(UserHandler handler, void* pCookie, XnCallbackHandle& hCallback)
04921         {
04922             XnStatus nRetVal = XN_STATUS_OK;
04923 
04924             UserSingleCookie* pUserCookie;
04925             XN_VALIDATE_ALLOC(pUserCookie, UserSingleCookie);
04926             pUserCookie->handler = handler;
04927             pUserCookie->pUserCookie = pCookie;
04928 
04929             nRetVal = xnRegisterToUserExit(GetHandle(), UserSingleCallback, pUserCookie, &pUserCookie->hCallback);
04930             if (nRetVal != XN_STATUS_OK)
04931             {
04932                 xnOSFree(pUserCookie);
04933                 return (nRetVal);
04934             }
04935 
04936             hCallback = pUserCookie;
04937 
04938             return (XN_STATUS_OK);
04939         }
04940 
04944         inline void UnregisterFromUserExit(XnCallbackHandle hCallback)
04945         {
04946             UserSingleCookie* pUserCookie = (UserSingleCookie*)hCallback;
04947             xnUnregisterFromUserExit(GetHandle(), pUserCookie->hCallback);
04948             xnOSFree(pUserCookie);
04949         }
04950 
04954         inline XnStatus RegisterToUserReEnter(UserHandler handler, void* pCookie, XnCallbackHandle& hCallback)
04955         {
04956             XnStatus nRetVal = XN_STATUS_OK;
04957 
04958             UserSingleCookie* pUserCookie;
04959             XN_VALIDATE_ALLOC(pUserCookie, UserSingleCookie);
04960             pUserCookie->handler = handler;
04961             pUserCookie->pUserCookie = pCookie;
04962 
04963             nRetVal = xnRegisterToUserReEnter(GetHandle(), UserSingleCallback, pUserCookie, &pUserCookie->hCallback);
04964             if (nRetVal != XN_STATUS_OK)
04965             {
04966                 xnOSFree(pUserCookie);
04967                 return (nRetVal);
04968             }
04969 
04970             hCallback = pUserCookie;
04971 
04972             return (XN_STATUS_OK);
04973         }
04974 
04978         inline void UnregisterFromUserReEnter(XnCallbackHandle hCallback)
04979         {
04980             UserSingleCookie* pUserCookie = (UserSingleCookie*)hCallback;
04981             xnUnregisterFromUserReEnter(GetHandle(), pUserCookie->hCallback);
04982             xnOSFree(pUserCookie);
04983         }
04984 
04985     private:
04986         typedef struct UserCookie
04987         {
04988             UserHandler newHandler;
04989             UserHandler lostHandler;
04990             void* pUserCookie;
04991             XnCallbackHandle hCallback;
04992         } UserCookie;
04993 
04994         static void XN_CALLBACK_TYPE NewUserCallback(XnNodeHandle hNode, XnUserID user, void* pCookie)
04995         {
04996             UserCookie* pUserCookie = (UserCookie*)pCookie;
04997             UserGenerator gen(hNode);
04998             if (pUserCookie->newHandler != NULL)
04999             {
05000                 pUserCookie->newHandler(gen, user, pUserCookie->pUserCookie);
05001             }
05002         }
05003 
05004         static void XN_CALLBACK_TYPE LostUserCallback(XnNodeHandle hNode, XnUserID user, void* pCookie)
05005         {
05006             UserCookie* pUserCookie = (UserCookie*)pCookie;
05007             UserGenerator gen(hNode);
05008             if (pUserCookie->lostHandler != NULL)
05009             {
05010                 pUserCookie->lostHandler(gen, user, pUserCookie->pUserCookie);
05011             }
05012         }
05013 
05014         typedef struct UserSingleCookie
05015         {
05016             UserHandler handler;
05017             void* pUserCookie;
05018             XnCallbackHandle hCallback;
05019         } UserSingleCookie;
05020 
05021         static void XN_CALLBACK_TYPE UserSingleCallback(XnNodeHandle hNode, XnUserID user, void* pCookie)
05022         {
05023             UserSingleCookie* pUserCookie = (UserSingleCookie*)pCookie;
05024             UserGenerator gen(hNode);
05025             if (pUserCookie->handler != NULL)
05026             {
05027                 pUserCookie->handler(gen, user, pUserCookie->pUserCookie);
05028             }
05029         }
05030     };
05031 
05036     class AudioGenerator : public Generator
05037     {
05038     public:
05044         inline AudioGenerator(XnNodeHandle hNode = NULL) : Generator(hNode) {}
05045         inline AudioGenerator(const NodeWrapper& other) : Generator(other) {}
05046 
05050         inline XnStatus Create(Context& context, Query* pQuery = NULL, EnumerationErrors* pErrors = NULL);
05051 
05055         inline void GetMetaData(AudioMetaData& metaData) const
05056         {
05057             xnGetAudioMetaData(GetHandle(), metaData.GetUnderlying());
05058         }
05059 
05063         inline const XnUChar* GetAudioBuffer() const
05064         {
05065             return xnGetAudioBuffer(GetHandle());
05066         }
05067 
05071         inline XnUInt32 GetSupportedWaveOutputModesCount() const
05072         {
05073             return xnGetSupportedWaveOutputModesCount(GetHandle());
05074         }
05075 
05079         inline XnStatus GetSupportedWaveOutputModes(XnWaveOutputMode* aSupportedModes, XnUInt32& nCount) const
05080         {
05081             return xnGetSupportedWaveOutputModes(GetHandle(), aSupportedModes, &nCount);
05082         }
05083 
05087         inline XnStatus SetWaveOutputMode(const XnWaveOutputMode& OutputMode)
05088         {
05089             return xnSetWaveOutputMode(GetHandle(), &OutputMode);
05090         }
05091 
05095         inline XnStatus GetWaveOutputMode(XnWaveOutputMode& OutputMode) const
05096         {
05097             return xnGetWaveOutputMode(GetHandle(), &OutputMode);
05098         }
05099 
05103         inline XnStatus RegisterToWaveOutputModeChanges(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
05104         {
05105             return _RegisterToStateChange(xnRegisterToWaveOutputModeChanges, GetHandle(), handler, pCookie, hCallback);
05106         }
05107 
05111         inline void UnregisterFromWaveOutputModeChanges(XnCallbackHandle hCallback)
05112         {
05113             _UnregisterFromStateChange(xnUnregisterFromWaveOutputModeChanges, GetHandle(), hCallback);
05114         }
05115     };
05116 
05121     class MockAudioGenerator : public AudioGenerator
05122     {
05123     public:
05129         inline MockAudioGenerator(XnNodeHandle hNode = NULL) : AudioGenerator(hNode) {}
05130         inline MockAudioGenerator(const NodeWrapper& other) : AudioGenerator(other) {}
05131 
05138         XnStatus Create(Context& context, const XnChar* strName = NULL);
05139 
05146         XnStatus CreateBasedOn(AudioGenerator& other, const XnChar* strName = NULL);
05147 
05151         inline XnStatus SetData(XnUInt32 nFrameID, XnUInt64 nTimestamp, XnUInt32 nDataSize, const XnUInt8* pAudioBuffer)
05152         {
05153             return xnMockAudioSetData(GetHandle(), nFrameID, nTimestamp, nDataSize, pAudioBuffer);
05154         }
05155 
05163         inline XnStatus SetData(const AudioMetaData& audioMD, XnUInt32 nFrameID, XnUInt64 nTimestamp)
05164         {
05165             return SetData(nFrameID, nTimestamp, audioMD.DataSize(), audioMD.Data());
05166         }
05167 
05173         inline XnStatus SetData(const AudioMetaData& audioMD)
05174         {
05175             return SetData(audioMD, audioMD.FrameID(), audioMD.Timestamp());
05176         }
05177     };
05178 
05179     class MockRawGenerator : public Generator
05180     {
05181     public:
05182         MockRawGenerator(XnNodeHandle hNode = NULL) : Generator(hNode) {}
05183         MockRawGenerator(const NodeWrapper& other) : Generator(other) {}
05184 
05185         inline XnStatus Create(Context& context, const XnChar* strName = NULL);
05186 
05187         inline XnStatus SetData(XnUInt32 nFrameID, XnUInt64 nTimestamp, XnUInt32 nDataSize, const void* pData)
05188         {
05189             return xnMockRawSetData(GetHandle(), nFrameID, nTimestamp, nDataSize, pData);
05190         }
05191 
05192     };
05193 
05198     class Codec : public ProductionNode
05199     {
05200     public:
05206         inline Codec(XnNodeHandle hNode = NULL) : ProductionNode(hNode) {}
05207         inline Codec(const NodeWrapper& other) : ProductionNode(other) {}
05208 
05212         inline XnStatus Create(Context& context, XnCodecID codecID, ProductionNode& initializerNode);
05213 
05217         inline XnCodecID GetCodecID() const
05218         {
05219             return xnGetCodecID(GetHandle());
05220         }
05221 
05225         inline XnStatus EncodeData(const void* pSrc, XnUInt32 nSrcSize, void* pDst, XnUInt32 nDstSize, XnUInt* pnBytesWritten) const
05226         {
05227             return xnEncodeData(GetHandle(), pSrc, nSrcSize, pDst, nDstSize, pnBytesWritten);
05228         }
05229 
05233         inline XnStatus DecodeData(const void* pSrc, XnUInt32 nSrcSize, void* pDst, XnUInt32 nDstSize, XnUInt* pnBytesWritten) const
05234         {
05235             return xnDecodeData(GetHandle(), pSrc, nSrcSize, pDst, nDstSize, pnBytesWritten);
05236         }
05237     };
05238 
05243     class ScriptNode : public ProductionNode
05244     {
05245     public:
05251         inline ScriptNode(XnNodeHandle hNode = NULL) : ProductionNode(hNode) {}
05252         inline ScriptNode(const NodeWrapper& other) : ProductionNode(other) {}
05253 
05254         inline const XnChar* GetSupportedFormat()
05255         {
05256             return xnScriptNodeGetSupportedFormat(GetHandle());
05257         }
05258 
05259         inline XnStatus LoadScriptFromFile(const XnChar* strFileName)
05260         {
05261             return xnLoadScriptFromFile(GetHandle(), strFileName);
05262         }
05263 
05264         inline XnStatus LoadScriptFromString(const XnChar* strScript)
05265         {
05266             return xnLoadScriptFromString(GetHandle(), strScript);
05267         }
05268 
05269         inline XnStatus Run(EnumerationErrors* pErrors);
05270     };
05271 
05272     //---------------------------------------------------------------------------
05273     // EnumerationErrors
05274     //---------------------------------------------------------------------------
05279     class EnumerationErrors
05280     {
05281     public:
05283         inline EnumerationErrors() : m_bAllocated(TRUE), m_pErrors(NULL) { xnEnumerationErrorsAllocate(&m_pErrors); }
05284 
05291         inline EnumerationErrors(XnEnumerationErrors* pErrors, XnBool bOwn = FALSE) : m_bAllocated(bOwn), m_pErrors(pErrors) {}
05292 
05294         ~EnumerationErrors() { Free(); }
05295 
05297         class Iterator
05298         {
05299         public:
05300             friend class EnumerationErrors;
05301 
05307             XnBool operator==(const Iterator& other) const
05308             {
05309                 return m_it == other.m_it;
05310             }
05311 
05317             XnBool operator!=(const Iterator& other) const
05318             {
05319                 return m_it != other.m_it;
05320             }
05321 
05326             inline Iterator& operator++()
05327             {
05328                 m_it = xnEnumerationErrorsGetNext(m_it);
05329                 return *this;
05330             }
05331 
05336             inline Iterator operator++(int)
05337             {
05338                 return Iterator(xnEnumerationErrorsGetNext(m_it));
05339             }
05340 
05342             inline const XnProductionNodeDescription& Description() { return *xnEnumerationErrorsGetCurrentDescription(m_it); }
05344             inline XnStatus Error() { return xnEnumerationErrorsGetCurrentError(m_it); }
05345 
05346         private:
05347             inline Iterator(XnEnumerationErrorsIterator it) : m_it(it) {}
05348 
05349             XnEnumerationErrorsIterator m_it;
05350         };
05351 
05353         inline Iterator Begin() const { return Iterator(xnEnumerationErrorsGetFirst(m_pErrors)); } 
05355         inline Iterator End() const { return Iterator(NULL); } 
05356 
05360         inline XnStatus ToString(XnChar* csBuffer, XnUInt32 nSize)
05361         {
05362             return xnEnumerationErrorsToString(m_pErrors, csBuffer, nSize);
05363         }
05364 
05368         inline void Free()
05369         {
05370             if (m_bAllocated)
05371             {
05372                 xnEnumerationErrorsFree(m_pErrors);
05373                 m_pErrors = NULL;
05374                 m_bAllocated = FALSE;
05375             }
05376         }
05377 
05379         inline XnEnumerationErrors* GetUnderlying() { return m_pErrors; }
05380 
05381     private:
05382         XnEnumerationErrors* m_pErrors;
05383         XnBool m_bAllocated;
05384     };
05385 
05386     //---------------------------------------------------------------------------
05387     // Context
05388     //---------------------------------------------------------------------------
05389 
05394     class Context
05395     {
05396     public:
05398         inline Context() : m_pContext(NULL), m_bUsingDeprecatedAPI(FALSE), m_bAllocated(FALSE), m_hShuttingDownCallback(NULL) {}
05399 
05405         inline Context(XnContext* pContext) : m_pContext(NULL), m_bUsingDeprecatedAPI(FALSE), m_bAllocated(FALSE), m_hShuttingDownCallback(NULL)
05406         {
05407             SetHandle(pContext);
05408         }
05409 
05416         inline Context(const Context& other) : m_pContext(NULL), m_bUsingDeprecatedAPI(FALSE), m_bAllocated(FALSE), m_hShuttingDownCallback(NULL)
05417         {
05418             SetHandle(other.m_pContext);
05419         }
05420 
05422         ~Context() 
05423         { 
05424             SetHandle(NULL);
05425         }
05426 
05427         inline Context& operator=(const Context& other)
05428         {
05429             SetHandle(other.m_pContext);
05430             return *this;
05431         }
05432 
05434         inline XnContext* GetUnderlyingObject() const { return m_pContext; }
05435 
05439         inline XnStatus Init()
05440         {
05441             XnContext* pContext = NULL;
05442             XnStatus nRetVal = xnInit(&pContext);
05443             XN_IS_STATUS_OK(nRetVal);
05444 
05445             TakeOwnership(pContext);
05446             m_bAllocated = TRUE;
05447 
05448             return (XN_STATUS_OK);
05449         }
05450 
05454         inline XnStatus XN_API_DEPRECATED("Use other overload!") RunXmlScript(const XnChar* strScript, EnumerationErrors* pErrors = NULL)
05455         {
05456             m_bUsingDeprecatedAPI = TRUE;
05457             #pragma warning (push)
05458             #pragma warning (disable: XN_DEPRECATED_WARNING_IDS)
05459             return xnContextRunXmlScript(m_pContext, strScript, pErrors == NULL ? NULL : pErrors->GetUnderlying());
05460             #pragma warning (pop)
05461         }
05462 
05466         inline XnStatus RunXmlScript(const XnChar* strScript, ScriptNode& scriptNode, EnumerationErrors* pErrors = NULL)
05467         {
05468             XnStatus nRetVal = XN_STATUS_OK;
05469             
05470             XnNodeHandle hScriptNode;
05471             nRetVal = xnContextRunXmlScriptEx(m_pContext, strScript, pErrors == NULL ? NULL : pErrors->GetUnderlying(), &hScriptNode);
05472             XN_IS_STATUS_OK(nRetVal);
05473 
05474             scriptNode.TakeOwnership(hScriptNode);
05475             
05476             return (XN_STATUS_OK);
05477         }
05478 
05482         inline XnStatus XN_API_DEPRECATED("Use other overload!") RunXmlScriptFromFile(const XnChar* strFileName, EnumerationErrors* pErrors = NULL)
05483         {
05484             m_bUsingDeprecatedAPI = TRUE;
05485             #pragma warning (push)
05486             #pragma warning (disable: XN_DEPRECATED_WARNING_IDS)
05487             return xnContextRunXmlScriptFromFile(m_pContext, strFileName, pErrors == NULL ? NULL : pErrors->GetUnderlying());
05488             #pragma warning (pop)
05489         }
05490 
05494         inline XnStatus RunXmlScriptFromFile(const XnChar* strFileName, ScriptNode& scriptNode, EnumerationErrors* pErrors = NULL)
05495         {
05496             XnStatus nRetVal = XN_STATUS_OK;
05497 
05498             XnNodeHandle hScriptNode;
05499             nRetVal = xnContextRunXmlScriptFromFileEx(m_pContext, strFileName, pErrors == NULL ? NULL : pErrors->GetUnderlying(), &hScriptNode);
05500             XN_IS_STATUS_OK(nRetVal);
05501 
05502             scriptNode.TakeOwnership(hScriptNode);
05503 
05504             return (XN_STATUS_OK);
05505         }
05506 
05510         inline XnStatus XN_API_DEPRECATED("Use other overload!") InitFromXmlFile(const XnChar* strFileName, EnumerationErrors* pErrors = NULL)
05511         {
05512             XnContext* pContext = NULL;
05513             m_bUsingDeprecatedAPI = TRUE;
05514 
05515             #pragma warning (push)
05516             #pragma warning (disable: XN_DEPRECATED_WARNING_IDS)
05517             XnStatus nRetVal = xnInitFromXmlFile(strFileName, &pContext, pErrors == NULL ? NULL : pErrors->GetUnderlying());
05518             #pragma warning (pop)
05519             XN_IS_STATUS_OK(nRetVal);
05520 
05521             TakeOwnership(pContext);
05522             m_bAllocated = TRUE;
05523 
05524             return (XN_STATUS_OK);
05525         }
05526 
05530         inline XnStatus InitFromXmlFile(const XnChar* strFileName, ScriptNode& scriptNode, EnumerationErrors* pErrors = NULL)
05531         {
05532             XnContext* pContext = NULL;
05533 
05534             XnNodeHandle hScriptNode;
05535             XnStatus nRetVal = xnInitFromXmlFileEx(strFileName, &pContext, pErrors == NULL ? NULL : pErrors->GetUnderlying(), &hScriptNode);
05536             XN_IS_STATUS_OK(nRetVal);
05537 
05538             scriptNode.TakeOwnership(hScriptNode);
05539             TakeOwnership(pContext);
05540             m_bAllocated = TRUE;
05541 
05542             return (XN_STATUS_OK);
05543         }
05544 
05548         inline XnStatus XN_API_DEPRECATED("Use other overload!") OpenFileRecording(const XnChar* strFileName)
05549         {
05550             m_bUsingDeprecatedAPI = TRUE;
05551             #pragma warning (push)
05552             #pragma warning (disable: XN_DEPRECATED_WARNING_IDS)
05553             return xnContextOpenFileRecording(m_pContext, strFileName);
05554             #pragma warning (pop)
05555         }
05556 
05560         inline XnStatus OpenFileRecording(const XnChar* strFileName, ProductionNode& playerNode)
05561         {
05562             XnStatus nRetVal = XN_STATUS_OK;
05563             
05564             XnNodeHandle hPlayer;
05565             nRetVal = xnContextOpenFileRecordingEx(m_pContext, strFileName, &hPlayer);
05566             XN_IS_STATUS_OK(nRetVal);
05567 
05568             playerNode.TakeOwnership(hPlayer);
05569             
05570             return (XN_STATUS_OK);
05571         }
05572 
05576         inline XnStatus CreateMockNode(XnProductionNodeType type, const XnChar* strName, ProductionNode& mockNode)
05577         {
05578             XnStatus nRetVal = XN_STATUS_OK;
05579             
05580             XnNodeHandle hMockNode;
05581             nRetVal = xnCreateMockNode(m_pContext, type, strName, &hMockNode);
05582             XN_IS_STATUS_OK(nRetVal);
05583 
05584             mockNode.TakeOwnership(hMockNode);
05585             
05586             return (XN_STATUS_OK);
05587         }
05588 
05592         inline XnStatus CreateMockNodeBasedOn(ProductionNode& originalNode, const XnChar* strName, ProductionNode& mockNode)
05593         {
05594             XnStatus nRetVal = XN_STATUS_OK;
05595 
05596             XnNodeHandle hMockNode;
05597             nRetVal = xnCreateMockNodeBasedOn(m_pContext, originalNode, strName, &hMockNode);
05598             XN_IS_STATUS_OK(nRetVal);
05599 
05600             mockNode.TakeOwnership(hMockNode);
05601 
05602             return (XN_STATUS_OK);
05603         }
05604 
05608         inline XnStatus CreateCodec(XnCodecID codecID, ProductionNode& initializerNode, Codec& codec)
05609         {
05610             XnStatus nRetVal = XN_STATUS_OK;
05611 
05612             XnNodeHandle hCodec;
05613             nRetVal =  xnCreateCodec(m_pContext, codecID, initializerNode.GetHandle(), &hCodec);
05614             XN_IS_STATUS_OK(nRetVal);
05615 
05616             codec.TakeOwnership(hCodec);
05617 
05618             return (XN_STATUS_OK);
05619         }
05620 
05624         inline XnStatus AddRef()
05625         {
05626             return xnContextAddRef(m_pContext);
05627         }
05628 
05632         inline void Release()
05633         {
05634             SetHandle(NULL);
05635         }
05636 
05640         inline void XN_API_DEPRECATED("You may use Release() instead, or count on dtor") Shutdown()
05641         {
05642             if (m_pContext != NULL)
05643             {
05644                 #pragma warning (push)
05645                 #pragma warning (disable: XN_DEPRECATED_WARNING_IDS)
05646                 xnShutdown(m_pContext);
05647                 #pragma warning (pop)
05648                 m_pContext = NULL;
05649             }
05650         }
05651 
05655         inline XnStatus AddLicense(const XnLicense& License)
05656         {
05657             return xnAddLicense(m_pContext, &License);
05658         }
05659 
05663         inline XnStatus EnumerateLicenses(XnLicense*& aLicenses, XnUInt32& nCount) const
05664         {
05665             return xnEnumerateLicenses(m_pContext, &aLicenses, &nCount);
05666         }
05667 
05671         inline static void FreeLicensesList(XnLicense aLicenses[])
05672         {
05673             xnFreeLicensesList(aLicenses);
05674         }
05675 
05679         XnStatus EnumerateProductionTrees(XnProductionNodeType Type, const Query* pQuery, NodeInfoList& TreesList, EnumerationErrors* pErrors = NULL) const
05680         {
05681             XnStatus nRetVal = XN_STATUS_OK;
05682 
05683             const XnNodeQuery* pInternalQuery = (pQuery != NULL) ? pQuery->GetUnderlyingObject() : NULL;
05684 
05685             XnNodeInfoList* pList = NULL;
05686             nRetVal = xnEnumerateProductionTrees(m_pContext, Type, pInternalQuery, &pList, pErrors == NULL ? NULL : pErrors->GetUnderlying());
05687             XN_IS_STATUS_OK(nRetVal);
05688 
05689             TreesList.ReplaceUnderlyingObject(pList);
05690 
05691             return (XN_STATUS_OK);
05692         }
05693 
05697         XnStatus CreateAnyProductionTree(XnProductionNodeType type, Query* pQuery, ProductionNode& node, EnumerationErrors* pErrors = NULL)
05698         {
05699             XnStatus nRetVal = XN_STATUS_OK;
05700             
05701             XnNodeQuery* pInternalQuery = (pQuery != NULL) ? pQuery->GetUnderlyingObject() : NULL;
05702 
05703             XnNodeHandle hNode;
05704             nRetVal = xnCreateAnyProductionTree(m_pContext, type, pInternalQuery, &hNode, pErrors == NULL ? NULL : pErrors->GetUnderlying());
05705             XN_IS_STATUS_OK(nRetVal);
05706 
05707             node.TakeOwnership(hNode);
05708 
05709             return (XN_STATUS_OK);
05710         }
05711 
05715         XnStatus XN_API_DEPRECATED("Please use other overload") CreateProductionTree(NodeInfo& Tree)
05716         {
05717             XnStatus nRetVal = XN_STATUS_OK;
05718 
05719             XnNodeHandle hNode;
05720             nRetVal = xnCreateProductionTree(m_pContext, Tree, &hNode);
05721             XN_IS_STATUS_OK(nRetVal);
05722 
05723             Tree.m_bOwnerOfNode = TRUE;
05724 
05725             return (XN_STATUS_OK);
05726         }
05727 
05731         XnStatus CreateProductionTree(NodeInfo& Tree, ProductionNode& node)
05732         {
05733             XnStatus nRetVal = XN_STATUS_OK;
05734 
05735             XnNodeHandle hNode;
05736             nRetVal = xnCreateProductionTree(m_pContext, Tree, &hNode);
05737             XN_IS_STATUS_OK(nRetVal);
05738 
05739             node.TakeOwnership(hNode);
05740 
05741             return (XN_STATUS_OK);
05742         }
05743 
05747         XnStatus EnumerateExistingNodes(NodeInfoList& list) const
05748         {
05749             XnNodeInfoList* pList;
05750             XnStatus nRetVal = xnEnumerateExistingNodes(m_pContext, &pList);
05751             XN_IS_STATUS_OK(nRetVal);
05752 
05753             list.ReplaceUnderlyingObject(pList);
05754 
05755             return (XN_STATUS_OK);
05756         }
05757 
05761         XnStatus EnumerateExistingNodes(NodeInfoList& list, XnProductionNodeType type) const
05762         {
05763             XnNodeInfoList* pList;
05764             XnStatus nRetVal = xnEnumerateExistingNodesByType(m_pContext, type, &pList);
05765             XN_IS_STATUS_OK(nRetVal);
05766 
05767             list.ReplaceUnderlyingObject(pList);
05768 
05769             return (XN_STATUS_OK);
05770         }
05771 
05775         XnStatus FindExistingNode(XnProductionNodeType type, ProductionNode& node) const
05776         {
05777             XnStatus nRetVal = XN_STATUS_OK;
05778 
05779             XnNodeHandle hNode;
05780             nRetVal = xnFindExistingRefNodeByType(m_pContext, type, &hNode);
05781             XN_IS_STATUS_OK(nRetVal);
05782 
05783             node.TakeOwnership(hNode);
05784 
05785             return (XN_STATUS_OK);
05786         }
05787 
05791         XnStatus GetProductionNodeByName(const XnChar* strInstanceName, ProductionNode& node) const
05792         {
05793             XnStatus nRetVal = XN_STATUS_OK;
05794 
05795             XnNodeHandle hNode;
05796             nRetVal = xnGetRefNodeHandleByName(m_pContext, strInstanceName, &hNode);
05797             XN_IS_STATUS_OK(nRetVal);
05798 
05799             node.TakeOwnership(hNode);
05800 
05801             return (XN_STATUS_OK);
05802         }
05803 
05807         XnStatus GetProductionNodeInfoByName(const XnChar* strInstanceName, NodeInfo& nodeInfo) const
05808         {
05809             XnStatus nRetVal = XN_STATUS_OK;
05810 
05811             XnNodeHandle hNode;
05812             nRetVal = xnGetRefNodeHandleByName(m_pContext, strInstanceName, &hNode);
05813             XN_IS_STATUS_OK(nRetVal);
05814 
05815             xnProductionNodeRelease(hNode);
05816 
05817             nodeInfo = NodeInfo(xnGetNodeInfo(hNode));
05818 
05819             return (XN_STATUS_OK);
05820         }
05821 
05825         inline XnStatus StartGeneratingAll()
05826         {
05827             return xnStartGeneratingAll(m_pContext);
05828         }
05829 
05833         inline XnStatus StopGeneratingAll()
05834         {
05835             return xnStopGeneratingAll(m_pContext);
05836         }
05837 
05841         inline XnStatus SetGlobalMirror(XnBool bMirror)
05842         {
05843             return xnSetGlobalMirror(m_pContext, bMirror);
05844         }
05845 
05849         inline XnBool GetGlobalMirror()
05850         {
05851             return xnGetGlobalMirror(m_pContext);
05852         }
05853 
05857         inline XnStatus GetGlobalErrorState()
05858         {
05859             return xnGetGlobalErrorState(m_pContext);
05860         }
05861 
05865         inline XnStatus RegisterToErrorStateChange(XnErrorStateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
05866         {
05867             return xnRegisterToGlobalErrorStateChange(m_pContext, handler, pCookie, &hCallback);
05868         }
05869 
05873         inline void UnregisterFromErrorStateChange(XnCallbackHandle hCallback)
05874         {
05875             xnUnregisterFromGlobalErrorStateChange(m_pContext, hCallback);
05876         }
05877 
05881         inline XnStatus WaitAndUpdateAll()
05882         {
05883             return xnWaitAndUpdateAll(m_pContext);
05884         }
05885 
05889         inline XnStatus WaitAnyUpdateAll()
05890         {
05891             return xnWaitAnyUpdateAll(m_pContext);
05892         }
05893 
05897         inline XnStatus WaitOneUpdateAll(ProductionNode& node)
05898         {
05899             return xnWaitOneUpdateAll(m_pContext, node.GetHandle());
05900         }
05901 
05905         inline XnStatus WaitNoneUpdateAll()
05906         {
05907             return xnWaitNoneUpdateAll(m_pContext);
05908         }
05909 
05913         inline XnStatus AutoEnumerateOverSingleInput(NodeInfoList& List, XnProductionNodeDescription& description, const XnChar* strCreationInfo, XnProductionNodeType InputType, EnumerationErrors* pErrors, Query* pQuery = NULL) const
05914         {
05915             return xnAutoEnumerateOverSingleInput(m_pContext, List.GetUnderlyingObject(), &description, strCreationInfo, InputType, pErrors == NULL ? NULL : pErrors->GetUnderlying(), pQuery == NULL ? NULL : pQuery->GetUnderlyingObject());
05916         }
05917 
05919         inline void SetHandle(XnContext* pContext)
05920         {
05921             if (m_pContext == pContext)
05922             {
05923                 return;
05924             }
05925 
05926             if (m_pContext != NULL)
05927             {
05928                 if (m_bUsingDeprecatedAPI && m_bAllocated)
05929                 {
05930                     // Backwards compatibility: call shutdown instead of release, to make old programs get the 
05931                     // exact same behavior they used to have.
05932                     xnForceShutdown(m_pContext);
05933                 }
05934                 else
05935                 {
05936                     xnContextUnregisterFromShutdown(m_pContext, m_hShuttingDownCallback);
05937                     xnContextRelease(m_pContext);
05938                 }
05939             }
05940 
05941             if (pContext != NULL)
05942             {
05943                 XnStatus nRetVal = xnContextAddRef(pContext);
05944                 XN_ASSERT(nRetVal == XN_STATUS_OK);
05945 
05946                 nRetVal = xnContextRegisterForShutdown(pContext, ContextShuttingDownCallback, this, &m_hShuttingDownCallback);
05947                 XN_ASSERT(nRetVal == XN_STATUS_OK);
05948             }
05949 
05950             m_pContext = pContext;
05951         }
05952 
05953         inline void TakeOwnership(XnContext* pContext)
05954         {
05955             SetHandle(pContext);
05956 
05957             if (pContext != NULL)
05958             {
05959                 xnContextRelease(pContext);
05960             }
05961         }
05962 
05963     private:
05964         static void XN_CALLBACK_TYPE ContextShuttingDownCallback(XnContext* /*pContext*/, void* pCookie)
05965         {
05966             Context* pThis = (Context*)pCookie;
05967             pThis->m_pContext = NULL;
05968         }
05969 
05970         XnContext* m_pContext;
05971         XnBool m_bUsingDeprecatedAPI;
05972         XnBool m_bAllocated;
05973         XnCallbackHandle m_hShuttingDownCallback;
05974     };
05975 
05980     class Resolution
05981     {
05982     public:
05988         inline Resolution(XnResolution res) : m_Res(res)
05989         {
05990             m_nXRes = xnResolutionGetXRes(res);
05991             m_nYRes = xnResolutionGetYRes(res);
05992             m_strName = xnResolutionGetName(res);
05993         }
05994 
06001         inline Resolution(XnUInt32 xRes, XnUInt32 yRes) : m_nXRes(xRes), m_nYRes(yRes)
06002         {
06003             m_Res = xnResolutionGetFromXYRes(xRes, yRes);
06004             m_strName = xnResolutionGetName(m_Res);
06005         }
06006 
06012         inline Resolution(const XnChar* strName)
06013         {
06014             m_Res = xnResolutionGetFromName(strName);
06015             m_nXRes = xnResolutionGetXRes(m_Res);
06016             m_nYRes = xnResolutionGetYRes(m_Res);
06017             m_strName = xnResolutionGetName(m_Res);
06018         }
06019 
06021         inline XnResolution GetResolution() const { return m_Res; }
06023         inline XnUInt32 GetXResolution() const { return m_nXRes; }
06025         inline XnUInt32 GetYResolution() const { return m_nYRes; }
06027         inline const XnChar* GetName() const { return m_strName; }
06028 
06029     private:
06030         XnResolution m_Res;
06031         XnUInt32 m_nXRes;
06032         XnUInt32 m_nYRes;
06033         const XnChar* m_strName;
06034     };
06035 
06036     //---------------------------------------------------------------------------
06037     // Functions Implementation
06038     //---------------------------------------------------------------------------
06039     inline XnStatus NodeInfoList::FilterList(Context& context, Query& query)
06040     {
06041         return xnNodeQueryFilterList(context.GetUnderlyingObject(), query.GetUnderlyingObject(), m_pList);
06042     }
06043 
06044     inline void ProductionNode::GetContext(Context& context) const
06045     {
06046         context.TakeOwnership(xnGetRefContextFromNodeHandle(GetHandle()));
06047     }
06048 
06049     inline NodeInfoList& NodeInfo::GetNeededNodes() const
06050     {
06051         if (m_pNeededNodes == NULL)
06052         {
06053             XnNodeInfoList* pList = xnNodeInfoGetNeededNodes(m_pInfo);
06054             m_pNeededNodes = XN_NEW(NodeInfoList, pList);
06055         }
06056 
06057         return *m_pNeededNodes;
06058     }
06059 
06060     inline void NodeInfo::SetUnderlyingObject(XnNodeInfo* pInfo)
06061     {
06062         if (m_pNeededNodes != NULL)
06063         {
06064             XN_DELETE(m_pNeededNodes);
06065         }
06066 
06067         m_bOwnerOfNode = FALSE;
06068         m_pInfo = pInfo;
06069         m_pNeededNodes = NULL;
06070     }
06071 
06072     inline XnBool FrameSyncCapability::CanFrameSyncWith(Generator& other) const
06073     {
06074         return xnCanFrameSyncWith(GetHandle(), other.GetHandle());
06075     }
06076 
06077     inline XnStatus FrameSyncCapability::FrameSyncWith(Generator& other)
06078     {
06079         return xnFrameSyncWith(GetHandle(), other.GetHandle());
06080     }
06081 
06082     inline XnStatus FrameSyncCapability::StopFrameSyncWith(Generator& other)
06083     {
06084         return xnStopFrameSyncWith(GetHandle(), other.GetHandle());
06085     }
06086 
06087     inline XnBool FrameSyncCapability::IsFrameSyncedWith(Generator& other) const
06088     {
06089         return xnIsFrameSyncedWith(GetHandle(), other.GetHandle());
06090     }
06091 
06092     inline XnStatus NodeInfo::GetInstance(ProductionNode& node) const
06093     {
06094         if (m_pInfo == NULL)
06095         {
06096             return XN_STATUS_INVALID_OPERATION;
06097         }
06098 
06099         XnNodeHandle hNode = xnNodeInfoGetRefHandle(m_pInfo);
06100         node.TakeOwnership(hNode);
06101 
06102         if (m_bOwnerOfNode)
06103         {
06104             xnProductionNodeRelease(hNode);
06105         }
06106 
06107         return (XN_STATUS_OK);
06108     }
06109 
06110     //---------------------------------------------------------------------------
06111     // Node creation functions
06112     //---------------------------------------------------------------------------
06113 
06114     inline XnStatus Device::Create(Context& context, Query* pQuery/*=NULL*/, EnumerationErrors* pErrors/*=NULL*/)
06115     {
06116         XnNodeHandle hNode;
06117         XnStatus nRetVal = xnCreateDevice(context.GetUnderlyingObject(), &hNode, pQuery == NULL ? NULL : pQuery->GetUnderlyingObject(), pErrors == NULL ? NULL : pErrors->GetUnderlying());
06118         XN_IS_STATUS_OK(nRetVal);
06119         TakeOwnership(hNode);
06120         return (XN_STATUS_OK);
06121     }
06122 
06123     inline XnStatus Recorder::Create(Context& context, const XnChar* strFormatName /*= NULL*/)
06124     {
06125         XnNodeHandle hNode;
06126         XnStatus nRetVal = xnCreateRecorder(context.GetUnderlyingObject(), strFormatName, &hNode);
06127         XN_IS_STATUS_OK(nRetVal);
06128         TakeOwnership(hNode);
06129         return (XN_STATUS_OK);
06130     }
06131 
06132     inline XnStatus Player::Create(Context& context, const XnChar* strFormatName)
06133     {
06134         XnNodeHandle hNode;
06135         XnStatus nRetVal = xnCreatePlayer(context.GetUnderlyingObject(), strFormatName, &hNode);
06136         XN_IS_STATUS_OK(nRetVal);
06137         TakeOwnership(hNode);
06138         return (XN_STATUS_OK);
06139     }
06140 
06141     inline XnStatus DepthGenerator::Create(Context& context, Query* pQuery/*=NULL*/, EnumerationErrors* pErrors/*=NULL*/)
06142     {
06143         XnNodeHandle hNode;
06144         XnStatus nRetVal = xnCreateDepthGenerator(context.GetUnderlyingObject(), &hNode, pQuery == NULL ? NULL : pQuery->GetUnderlyingObject(), pErrors == NULL ? NULL : pErrors->GetUnderlying());
06145         XN_IS_STATUS_OK(nRetVal);
06146         TakeOwnership(hNode);
06147         return (XN_STATUS_OK);
06148     }
06149 
06150     inline XnStatus MockDepthGenerator::Create(Context& context, const XnChar* strName /* = NULL */)
06151     {
06152         XnNodeHandle hNode;
06153         XnStatus nRetVal = xnCreateMockNode(context.GetUnderlyingObject(), XN_NODE_TYPE_DEPTH, strName, &hNode);
06154         XN_IS_STATUS_OK(nRetVal);
06155         TakeOwnership(hNode);
06156         return (XN_STATUS_OK);
06157     }
06158 
06159     inline XnStatus MockDepthGenerator::CreateBasedOn(DepthGenerator& other, const XnChar* strName /* = NULL */)
06160     {
06161         Context context;
06162         other.GetContext(context);
06163         XnNodeHandle hNode;
06164         XnStatus nRetVal = xnCreateMockNodeBasedOn(context.GetUnderlyingObject(), other.GetHandle(), strName, &hNode);
06165         XN_IS_STATUS_OK(nRetVal);
06166         TakeOwnership(hNode);
06167         return (XN_STATUS_OK);
06168     }
06169 
06170     inline XnStatus ImageGenerator::Create(Context& context, Query* pQuery/*=NULL*/, EnumerationErrors* pErrors/*=NULL*/)
06171     {
06172         XnNodeHandle hNode;
06173         XnStatus nRetVal = xnCreateImageGenerator(context.GetUnderlyingObject(), &hNode, pQuery == NULL ? NULL : pQuery->GetUnderlyingObject(), pErrors == NULL ? NULL : pErrors->GetUnderlying());
06174         XN_IS_STATUS_OK(nRetVal);
06175         TakeOwnership(hNode);
06176         return (XN_STATUS_OK);
06177     }
06178 
06179     inline XnStatus MockImageGenerator::Create(Context& context, const XnChar* strName /* = NULL */)
06180     {
06181         XnNodeHandle hNode;
06182         XnStatus nRetVal = xnCreateMockNode(context.GetUnderlyingObject(), XN_NODE_TYPE_IMAGE, strName, &hNode);
06183         XN_IS_STATUS_OK(nRetVal);
06184         TakeOwnership(hNode);
06185         return (XN_STATUS_OK);
06186     }
06187 
06188     inline XnStatus MockImageGenerator::CreateBasedOn(ImageGenerator& other, const XnChar* strName /* = NULL */)
06189     {
06190         Context context;
06191         other.GetContext(context);
06192         XnNodeHandle hNode;
06193         XnStatus nRetVal = xnCreateMockNodeBasedOn(context.GetUnderlyingObject(), other.GetHandle(), strName, &hNode);
06194         XN_IS_STATUS_OK(nRetVal);
06195         TakeOwnership(hNode);
06196         return (XN_STATUS_OK);
06197     }
06198 
06199     inline XnStatus IRGenerator::Create(Context& context, Query* pQuery/*=NULL*/, EnumerationErrors* pErrors/*=NULL*/)
06200     {
06201         XnNodeHandle hNode;
06202         XnStatus nRetVal = xnCreateIRGenerator(context.GetUnderlyingObject(), &hNode, pQuery == NULL ? NULL : pQuery->GetUnderlyingObject(), pErrors == NULL ? NULL : pErrors->GetUnderlying());
06203         XN_IS_STATUS_OK(nRetVal);
06204         TakeOwnership(hNode);
06205         return (XN_STATUS_OK);
06206     }
06207     
06208     inline XnStatus MockIRGenerator::Create(Context& context, const XnChar* strName /* = NULL */)
06209     {
06210         XnNodeHandle hNode;
06211         XnStatus nRetVal = xnCreateMockNode(context.GetUnderlyingObject(), XN_NODE_TYPE_IR, strName, &hNode);
06212         XN_IS_STATUS_OK(nRetVal);
06213         TakeOwnership(hNode);
06214         return (XN_STATUS_OK);
06215     }
06216 
06217     inline XnStatus MockIRGenerator::CreateBasedOn(IRGenerator& other, const XnChar* strName /* = NULL */)
06218     {
06219         Context context;
06220         other.GetContext(context);
06221         XnNodeHandle hNode;
06222         XnStatus nRetVal = xnCreateMockNodeBasedOn(context.GetUnderlyingObject(), other.GetHandle(), strName, &hNode);
06223         XN_IS_STATUS_OK(nRetVal);
06224         TakeOwnership(hNode);
06225         return (XN_STATUS_OK);
06226     }
06227 
06228     inline XnStatus GestureGenerator::Create(Context& context, Query* pQuery/*=NULL*/, EnumerationErrors* pErrors/*=NULL*/)
06229     {
06230         XnNodeHandle hNode;
06231         XnStatus nRetVal = xnCreateGestureGenerator(context.GetUnderlyingObject(), &hNode, pQuery == NULL ? NULL : pQuery->GetUnderlyingObject(), pErrors == NULL ? NULL : pErrors->GetUnderlying());
06232         XN_IS_STATUS_OK(nRetVal);
06233         TakeOwnership(hNode);
06234         return (XN_STATUS_OK);
06235     }
06236 
06237     inline XnStatus SceneAnalyzer::Create(Context& context, Query* pQuery/*=NULL*/, EnumerationErrors* pErrors/*=NULL*/)
06238     {
06239         //You're creating a scene!
06240         XnNodeHandle hNode;
06241         XnStatus nRetVal = xnCreateSceneAnalyzer(context.GetUnderlyingObject(), &hNode, pQuery == NULL ? NULL : pQuery->GetUnderlyingObject(), pErrors == NULL ? NULL : pErrors->GetUnderlying());
06242         XN_IS_STATUS_OK(nRetVal);
06243         TakeOwnership(hNode);
06244         return (XN_STATUS_OK);
06245     }
06246 
06247     inline XnStatus HandsGenerator::Create(Context& context, Query* pQuery/*=NULL*/, EnumerationErrors* pErrors/*=NULL*/)
06248     {
06249         XnNodeHandle hNode;
06250         XnStatus nRetVal = xnCreateHandsGenerator(context.GetUnderlyingObject(), &hNode, pQuery == NULL ? NULL : pQuery->GetUnderlyingObject(), pErrors == NULL ? NULL : pErrors->GetUnderlying());
06251         XN_IS_STATUS_OK(nRetVal);
06252         TakeOwnership(hNode);
06253         return (XN_STATUS_OK);
06254     }
06255 
06256     inline XnStatus UserGenerator::Create(Context& context, Query* pQuery/*=NULL*/, EnumerationErrors* pErrors/*=NULL*/)
06257     {
06258         XnNodeHandle hNode;
06259         XnStatus nRetVal = xnCreateUserGenerator(context.GetUnderlyingObject(), &hNode, pQuery == NULL ? NULL : pQuery->GetUnderlyingObject(), pErrors == NULL ? NULL : pErrors->GetUnderlying());
06260         XN_IS_STATUS_OK(nRetVal);
06261         TakeOwnership(hNode);
06262         return (XN_STATUS_OK);
06263     }
06264 
06265     inline XnStatus AudioGenerator::Create(Context& context, Query* pQuery/*=NULL*/, EnumerationErrors* pErrors/*=NULL*/)
06266     {
06267         XnNodeHandle hNode;
06268         XnStatus nRetVal = xnCreateAudioGenerator(context.GetUnderlyingObject(), &hNode, pQuery == NULL ? NULL : pQuery->GetUnderlyingObject(), pErrors == NULL ? NULL : pErrors->GetUnderlying());
06269         XN_IS_STATUS_OK(nRetVal);
06270         TakeOwnership(hNode);
06271         return (XN_STATUS_OK);
06272     }
06273 
06274     inline XnStatus MockAudioGenerator::Create(Context& context, const XnChar* strName /* = NULL */)
06275     {
06276         XnNodeHandle hNode;
06277         XnStatus nRetVal = xnCreateMockNode(context.GetUnderlyingObject(), XN_NODE_TYPE_AUDIO, strName, &hNode);
06278         XN_IS_STATUS_OK(nRetVal);
06279         TakeOwnership(hNode);
06280         return (XN_STATUS_OK);
06281     }
06282 
06283     inline XnStatus MockAudioGenerator::CreateBasedOn(AudioGenerator& other, const XnChar* strName /* = NULL */)
06284     {
06285         Context context;
06286         other.GetContext(context);
06287         XnNodeHandle hNode;
06288         XnStatus nRetVal = xnCreateMockNodeBasedOn(context.GetUnderlyingObject(), other.GetHandle(), strName, &hNode);
06289         XN_IS_STATUS_OK(nRetVal);
06290         TakeOwnership(hNode);
06291         return (XN_STATUS_OK);
06292     }
06293 
06294     inline XnStatus MockRawGenerator::Create(Context& context, const XnChar* strName /*= NULL*/)
06295     {
06296         XnNodeHandle hNode;
06297         XnStatus nRetVal = xnCreateMockNode(context.GetUnderlyingObject(), XN_NODE_TYPE_GENERATOR, strName, &hNode);
06298         XN_IS_STATUS_OK(nRetVal);
06299         TakeOwnership(hNode);
06300         return (XN_STATUS_OK);
06301     }
06302 
06303     inline XnStatus Codec::Create(Context& context, XnCodecID codecID, ProductionNode& initializerNode)
06304     {
06305         XnNodeHandle hNode;
06306         XnStatus nRetVal = xnCreateCodec(context.GetUnderlyingObject(), codecID, initializerNode.GetHandle(), &hNode);
06307         XN_IS_STATUS_OK(nRetVal);
06308         TakeOwnership(hNode);
06309         return (XN_STATUS_OK);
06310     }
06311 
06312     inline XnStatus ScriptNode::Run(EnumerationErrors* pErrors)
06313     {
06314         return xnScriptNodeRun(GetHandle(), pErrors == NULL ? NULL : pErrors->GetUnderlying());
06315     }
06316 
06317     //---------------------------------------------------------------------------
06318     // Global Helper Functions
06319     //---------------------------------------------------------------------------
06320 
06324     inline void GetVersion(XnVersion& Version)
06325     {
06326         xnGetVersion(&Version);
06327     }
06328 
06329     //---------------------------------------------------------------------------
06330     // Internal Helper Classes and Functions
06331     //---------------------------------------------------------------------------
06332 
06333     class StateChangedCallbackTranslator
06334     {
06335     public:
06336         StateChangedCallbackTranslator(StateChangedHandler handler, void* pCookie) : m_UserHandler(handler), m_pUserCookie(pCookie), m_hCallback(NULL) {}
06337 
06338         XnStatus Register(_XnRegisterStateChangeFuncPtr xnFunc, XnNodeHandle hNode)
06339         {
06340             return xnFunc(hNode, StateChangedCallback, this, &m_hCallback);
06341         }
06342 
06343         void Unregister(_XnUnregisterStateChangeFuncPtr xnFunc, XnNodeHandle hNode)
06344         {
06345             xnFunc(hNode, m_hCallback);
06346         }
06347 
06348         static XnStatus RegisterToUnderlying(_XnRegisterStateChangeFuncPtr xnFunc, XnNodeHandle hNode, StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
06349         {
06350             XnStatus nRetVal = XN_STATUS_OK;
06351             
06352             StateChangedCallbackTranslator* pTrans;
06353             XN_VALIDATE_NEW(pTrans, StateChangedCallbackTranslator, handler, pCookie);
06354 
06355             nRetVal = pTrans->Register(xnFunc, hNode);
06356             if (nRetVal != XN_STATUS_OK)
06357             {
06358                 XN_DELETE(pTrans);
06359                 return (nRetVal);
06360             }
06361 
06362             hCallback = pTrans;
06363             
06364             return (XN_STATUS_OK);
06365         }
06366 
06367         static XnStatus UnregisterFromUnderlying(_XnUnregisterStateChangeFuncPtr xnFunc, XnNodeHandle hNode, XnCallbackHandle hCallback)
06368         {
06369             StateChangedCallbackTranslator* pTrans = (StateChangedCallbackTranslator*)hCallback;
06370             pTrans->Unregister(xnFunc, hNode);
06371             XN_DELETE(pTrans);
06372             return XN_STATUS_OK;
06373         }
06374 
06375     private:
06376         friend class GeneralIntCapability;
06377 
06378         typedef struct StateChangeCookie
06379         {
06380             StateChangedHandler userHandler;
06381             void* pUserCookie;
06382             XnCallbackHandle hCallback;
06383         } StateChangeCookie;
06384 
06385         static void XN_CALLBACK_TYPE StateChangedCallback(XnNodeHandle hNode, void* pCookie)
06386         {
06387             StateChangedCallbackTranslator* pTrans = (StateChangedCallbackTranslator*)pCookie;
06388             ProductionNode node(hNode);
06389             pTrans->m_UserHandler(node, pTrans->m_pUserCookie);
06390         }
06391 
06392         StateChangedHandler m_UserHandler;
06393         void* m_pUserCookie;
06394         XnCallbackHandle m_hCallback;
06395     };
06396 
06397     static XnStatus _RegisterToStateChange(_XnRegisterStateChangeFuncPtr xnFunc, XnNodeHandle hNode, StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
06398     {
06399         return StateChangedCallbackTranslator::RegisterToUnderlying(xnFunc, hNode, handler, pCookie, hCallback);
06400     }
06401 
06402     static void _UnregisterFromStateChange(_XnUnregisterStateChangeFuncPtr xnFunc, XnNodeHandle hNode, XnCallbackHandle hCallback)
06403     {
06404         StateChangedCallbackTranslator::UnregisterFromUnderlying(xnFunc, hNode, hCallback);
06405     }
06406 
06407     inline XnStatus GeneralIntCapability::RegisterToValueChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
06408     {
06409         XnStatus nRetVal = XN_STATUS_OK;
06410 
06411         StateChangedCallbackTranslator* pTrans;
06412         XN_VALIDATE_NEW(pTrans, StateChangedCallbackTranslator, handler, pCookie);
06413 
06414         nRetVal = xnRegisterToGeneralIntValueChange(GetHandle(), m_strCap, pTrans->StateChangedCallback, pTrans, &pTrans->m_hCallback);
06415         if (nRetVal != XN_STATUS_OK)
06416         {
06417             XN_DELETE(pTrans);
06418             return (nRetVal);
06419         }
06420 
06421         hCallback = pTrans;
06422 
06423         return (XN_STATUS_OK);
06424     }
06425 
06426     inline void GeneralIntCapability::UnregisterFromValueChange(XnCallbackHandle hCallback)
06427     {
06428         StateChangedCallbackTranslator* pTrans = (StateChangedCallbackTranslator*)hCallback;
06429         xnUnregisterFromGeneralIntValueChange(GetHandle(), m_strCap, pTrans->m_hCallback);
06430         XN_DELETE(pTrans);
06431     }
06432 
06434 };
06435 
06436 #endif // __XN_CPP_WRAPPER_H__