• Main Page
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

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_pAllocatedData(NULL), m_ppData(ppData), m_nAllocatedSize(0)
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 
01156         NodeInfo(const NodeInfo& other) : m_pNeededNodes(NULL), m_bOwnerOfNode(FALSE)
01157         {
01158             SetUnderlyingObject(other.m_pInfo);
01159         }
01160 
01162         ~NodeInfo()
01163         {
01164             SetUnderlyingObject(NULL);
01165         }
01166 
01172         inline NodeInfo& operator=(const NodeInfo& other)
01173         {
01174             SetUnderlyingObject(other.m_pInfo);
01175             return *this;
01176         }
01177 
01179         inline operator XnNodeInfo*()
01180         {
01181             return m_pInfo;
01182         }
01183 
01187         inline XnStatus SetInstanceName(const XnChar* strName)
01188         {
01189             return xnNodeInfoSetInstanceName(m_pInfo, strName);
01190         }
01191 
01195         inline const XnProductionNodeDescription& GetDescription() const
01196         {
01197             return *xnNodeInfoGetDescription(m_pInfo);
01198         }
01199 
01203         inline const XnChar* GetInstanceName() const
01204         {
01205             return xnNodeInfoGetInstanceName(m_pInfo);
01206         }
01207         inline const XnChar* GetCreationInfo() const
01211         {
01212             return xnNodeInfoGetCreationInfo(m_pInfo);
01213         }
01214 
01218         inline NodeInfoList& GetNeededNodes() const;
01219 
01227         inline XnStatus GetInstance(ProductionNode& node) const;
01228 
01232         inline const void* GetAdditionalData() const
01233         {
01234             return xnNodeInfoGetAdditionalData(m_pInfo);
01235         }
01236 
01237     private:
01238         inline void SetUnderlyingObject(XnNodeInfo* pInfo);
01239 
01240         XnNodeInfo* m_pInfo;
01241         mutable NodeInfoList* m_pNeededNodes;
01242         XnBool m_bOwnerOfNode; // backwards compatibility
01243         friend class Context;
01244     };
01245 
01246     //---------------------------------------------------------------------------
01247     // Query
01248     //---------------------------------------------------------------------------
01249 
01255     class Query
01256     {
01257     public:
01259         inline Query() : m_bAllocated(TRUE)
01260         {
01261             xnNodeQueryAllocate(&m_pQuery);
01262         }
01263 
01264         inline Query(XnNodeQuery* pNodeQuery) : m_pQuery(pNodeQuery), m_bAllocated(FALSE)
01265         {
01266         }
01267 
01269         ~Query()
01270         {
01271             if (m_bAllocated)
01272             {
01273                 xnNodeQueryFree(m_pQuery);
01274             }
01275         }
01276 
01278         inline const XnNodeQuery* GetUnderlyingObject() const { return m_pQuery; }
01279         inline XnNodeQuery* GetUnderlyingObject() { return m_pQuery; }
01280 
01284         inline XnStatus SetVendor(const XnChar* strVendor)
01285         {
01286             return xnNodeQuerySetVendor(m_pQuery, strVendor);
01287         }
01288 
01292         inline XnStatus SetName(const XnChar* strName)
01293         {
01294             return xnNodeQuerySetName(m_pQuery, strName);
01295         }
01296 
01300         inline XnStatus SetMinVersion(const XnVersion& minVersion)
01301         {
01302             return xnNodeQuerySetMinVersion(m_pQuery, &minVersion);
01303         }
01304 
01308         inline XnStatus SetMaxVersion(const XnVersion& maxVersion)
01309         {
01310             return xnNodeQuerySetMaxVersion(m_pQuery, &maxVersion);
01311         }
01312 
01316         inline XnStatus AddSupportedCapability(const XnChar* strNeededCapability)
01317         {
01318             return xnNodeQueryAddSupportedCapability(m_pQuery, strNeededCapability);
01319         }
01320 
01324         inline XnStatus AddSupportedMapOutputMode(const XnMapOutputMode& MapOutputMode)
01325         {
01326             return xnNodeQueryAddSupportedMapOutputMode(m_pQuery, &MapOutputMode);
01327         }
01328 
01332         inline XnStatus SetSupportedMinUserPositions(const XnUInt32 nCount)
01333         {
01334             return xnNodeQuerySetSupportedMinUserPositions(m_pQuery, nCount);
01335         }
01336 
01340         inline XnStatus SetExistingNodeOnly(XnBool bExistingNode)
01341         {
01342             return xnNodeQuerySetExistingNodeOnly(m_pQuery, bExistingNode);
01343         }
01344 
01348         inline XnStatus AddNeededNode(const XnChar* strInstanceName)
01349         {
01350             return xnNodeQueryAddNeededNode(m_pQuery, strInstanceName);
01351         }
01352 
01356         inline XnStatus SetCreationInfo(const XnChar* strCreationInfo)
01357         {
01358             return xnNodeQuerySetCreationInfo(m_pQuery, strCreationInfo);
01359         }
01360 
01361     private:
01362         XnNodeQuery* m_pQuery;
01363         XnBool m_bAllocated;
01364     };
01365 
01366     //---------------------------------------------------------------------------
01367     // Node Info List
01368     //---------------------------------------------------------------------------
01369 
01374     class NodeInfoList
01375     {
01376     public:
01378         class Iterator
01379         {
01380         public:
01381             friend class NodeInfoList;
01382 
01388             XnBool operator==(const Iterator& other) const
01389             {
01390                 return m_it.pCurrent == other.m_it.pCurrent;
01391             }
01392 
01398             XnBool operator!=(const Iterator& other) const
01399             {
01400                 return m_it.pCurrent != other.m_it.pCurrent;
01401             }
01402 
01407             inline Iterator& operator++()
01408             {
01409                 UpdateInternalObject(xnNodeInfoListGetNext(m_it));
01410                 return *this;
01411             }
01412 
01417             inline Iterator operator++(int)
01418             {
01419                 XnNodeInfoListIterator curr = m_it;
01420                 UpdateInternalObject(xnNodeInfoListGetNext(m_it));
01421                 return Iterator(curr);
01422             }
01423 
01427             inline Iterator& operator--()
01428             {
01429                 UpdateInternalObject(xnNodeInfoListGetPrevious(m_it));
01430                 return *this;
01431             }
01432 
01436             inline Iterator operator--(int)
01437             {
01438                 XnNodeInfoListIterator curr = m_it;
01439                 UpdateInternalObject(xnNodeInfoListGetPrevious(m_it));
01440                 return Iterator(curr);
01441             }
01442 
01444             inline NodeInfo operator*()
01445             {
01446                 return m_Info;
01447             }
01448 
01449         private:
01450             inline Iterator(XnNodeInfoListIterator it) : m_Info(NULL)
01451             {
01452                 UpdateInternalObject(it);
01453             }
01454 
01455             inline void UpdateInternalObject(XnNodeInfoListIterator it)
01456             {
01457                 m_it = it;
01458                 if (xnNodeInfoListIteratorIsValid(it))
01459                 {
01460                     XnNodeInfo* pInfo = xnNodeInfoListGetCurrent(it);
01461                     m_Info = NodeInfo(pInfo);
01462                 }
01463                 else
01464                 {
01465                     m_Info = NodeInfo(NULL);
01466                 }
01467             }
01468 
01469             NodeInfo m_Info;
01470             XnNodeInfoListIterator m_it;
01471         };
01472 
01476         inline NodeInfoList() 
01477         {
01478             xnNodeInfoListAllocate(&m_pList);
01479             m_bAllocated = TRUE;
01480         }
01481 
01488         inline NodeInfoList(XnNodeInfoList* pList) : m_pList(pList), m_bAllocated(FALSE) {}
01489 
01491         inline ~NodeInfoList()
01492         {
01493             FreeImpl();
01494         }
01495 
01497         inline XnNodeInfoList* GetUnderlyingObject() const { return m_pList; }
01498 
01505         inline void ReplaceUnderlyingObject(XnNodeInfoList* pList) 
01506         {
01507             FreeImpl();
01508             m_pList = pList;
01509             m_bAllocated = TRUE;
01510         }
01511 
01515         inline XnStatus Add(XnProductionNodeDescription& description, const XnChar* strCreationInfo, NodeInfoList* pNeededNodes)
01516         {
01517             XnNodeInfoList* pList = (pNeededNodes == NULL) ? NULL : pNeededNodes->GetUnderlyingObject();
01518             return xnNodeInfoListAdd(m_pList, &description, strCreationInfo, pList);
01519         }
01520 
01524         inline XnStatus AddEx(XnProductionNodeDescription& description, const XnChar* strCreationInfo, NodeInfoList* pNeededNodes, const void* pAdditionalData, XnFreeHandler pFreeHandler)
01525         {
01526             XnNodeInfoList* pList = (pNeededNodes == NULL) ? NULL : pNeededNodes->GetUnderlyingObject();
01527             return xnNodeInfoListAddEx(m_pList, &description, strCreationInfo, pList, pAdditionalData, pFreeHandler);
01528         }
01529 
01533         inline XnStatus AddNode(NodeInfo& info)
01534         {
01535             return xnNodeInfoListAddNode(m_pList, info);
01536         }
01537 
01541         inline XnStatus AddNodeFromAnotherList(Iterator& it)
01542         {
01543             return xnNodeInfoListAddNodeFromList(m_pList, it.m_it);
01544         }
01545 
01547         inline Iterator Begin() const
01548         {
01549             return Iterator(xnNodeInfoListGetFirst(m_pList));
01550         }
01551 
01553         inline Iterator End() const
01554         {
01555             XnNodeInfoListIterator it = { NULL };
01556             return Iterator(it);
01557         }
01558 
01560         inline Iterator RBegin() const
01561         {
01562             return Iterator(xnNodeInfoListGetLast(m_pList));
01563         }
01564 
01566         inline Iterator REnd() const
01567         {
01568             XnNodeInfoListIterator it = { NULL };
01569             return Iterator(it);
01570         }
01571 
01575         inline XnStatus Remove(Iterator& it)
01576         {
01577             return xnNodeInfoListRemove(m_pList, it.m_it);
01578         }
01579 
01583         inline XnStatus Clear()
01584         {
01585             return xnNodeInfoListClear(m_pList);
01586         }
01587 
01591         inline XnStatus Append(NodeInfoList& other)
01592         {
01593             return xnNodeInfoListAppend(m_pList, other.GetUnderlyingObject());
01594         }
01595 
01599         inline XnBool IsEmpty()
01600         {
01601             return xnNodeInfoListIsEmpty(m_pList);
01602         }
01603 
01607         inline XnStatus FilterList(Context& context, Query& query);
01608 
01609     private:
01610         inline void FreeImpl()
01611         {
01612             if (m_bAllocated)
01613             {
01614                 xnNodeInfoListFree(m_pList);
01615                 m_bAllocated = FALSE;
01616                 m_pList = NULL;
01617             }
01618         }
01619 
01620         XnNodeInfoList* m_pList;
01621         XnBool m_bAllocated;
01622     };
01623 
01624     //---------------------------------------------------------------------------
01625     // Production Nodes Functionality
01626     //---------------------------------------------------------------------------
01627 
01632     class Capability : public NodeWrapper
01633     {
01634     public:
01640         Capability(XnNodeHandle hNode) : NodeWrapper(hNode) {}
01641         Capability(const NodeWrapper& node) : NodeWrapper(node) {}
01642     };
01643 
01648     class ErrorStateCapability : public Capability
01649     {
01650     public:
01656         ErrorStateCapability(XnNodeHandle hNode) : Capability(hNode) {}
01657         ErrorStateCapability(const NodeWrapper& node) : Capability(node) {}
01658 
01662         inline XnStatus GetErrorState() const
01663         {
01664             return xnGetNodeErrorState(GetHandle());
01665         }
01666 
01670         inline XnStatus RegisterToErrorStateChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
01671         {
01672             return _RegisterToStateChange(xnRegisterToNodeErrorStateChange, GetHandle(), handler, pCookie, hCallback);
01673         }
01674 
01678         inline void UnregisterFromErrorStateChange(XnCallbackHandle hCallback)
01679         {
01680             _UnregisterFromStateChange(xnUnregisterFromNodeErrorStateChange, GetHandle(), hCallback);
01681         }
01682     };
01683 
01688     class GeneralIntCapability : public Capability
01689     {
01690     public:
01697         GeneralIntCapability(XnNodeHandle hNode, const XnChar* strCap) : Capability(hNode), m_strCap(strCap) {}
01698         GeneralIntCapability(const NodeWrapper& node) : Capability(node) {}
01699 
01703         inline void GetRange(XnInt32& nMin, XnInt32& nMax, XnInt32& nStep, XnInt32& nDefault, XnBool& bIsAutoSupported) const
01704         {
01705             xnGetGeneralIntRange(GetHandle(), m_strCap, &nMin, &nMax, &nStep, &nDefault, &bIsAutoSupported);
01706         }
01707 
01711         inline XnInt32 Get()
01712         {
01713             XnInt32 nValue;
01714             xnGetGeneralIntValue(GetHandle(), m_strCap, &nValue);
01715             return nValue;
01716         }
01717 
01721         inline XnStatus Set(XnInt32 nValue)
01722         {
01723             return xnSetGeneralIntValue(GetHandle(), m_strCap, nValue);
01724         }
01725 
01729         XnStatus RegisterToValueChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback);
01730 
01734         void UnregisterFromValueChange(XnCallbackHandle hCallback);
01735 
01736     private:
01737         const XnChar* m_strCap;
01738     };
01739 
01744     class ProductionNode : public NodeWrapper
01745     {
01746     public:
01752         inline ProductionNode(XnNodeHandle hNode = NULL) : NodeWrapper(hNode) {}
01753         inline ProductionNode(const NodeWrapper& other) : NodeWrapper(other) {}
01754 
01758         inline NodeInfo GetInfo() const { return NodeInfo(xnGetNodeInfo(GetHandle())); }
01759 
01763         inline XnStatus AddNeededNode(ProductionNode& needed)
01764         {
01765             return xnAddNeededNode(GetHandle(), needed.GetHandle());
01766         }
01767 
01771         inline XnStatus RemoveNeededNode(ProductionNode& needed)
01772         {
01773             return xnRemoveNeededNode(GetHandle(), needed.GetHandle());
01774         }
01775 
01779         inline void GetContext(Context& context) const;
01780 
01784         inline XnBool IsCapabilitySupported(const XnChar* strCapabilityName) const
01785         {
01786             return xnIsCapabilitySupported(GetHandle(), strCapabilityName);
01787         }
01788 
01792         inline XnStatus SetIntProperty(const XnChar* strName, XnUInt64 nValue)
01793         {
01794             return xnSetIntProperty(GetHandle(), strName, nValue);
01795         }
01796 
01800         inline XnStatus SetRealProperty(const XnChar* strName, XnDouble dValue)
01801         {
01802             return xnSetRealProperty(GetHandle(), strName, dValue);
01803         }
01804 
01808         inline XnStatus SetStringProperty(const XnChar* strName, const XnChar* strValue)
01809         {
01810             return xnSetStringProperty(GetHandle(), strName, strValue);
01811         }
01812 
01816         inline XnStatus SetGeneralProperty(const XnChar* strName, XnUInt32 nBufferSize, const void* pBuffer)
01817         {
01818             return xnSetGeneralProperty(GetHandle(), strName, nBufferSize, pBuffer);
01819         }
01820 
01824         inline XnStatus GetIntProperty(const XnChar* strName, XnUInt64& nValue) const
01825         {
01826             return xnGetIntProperty(GetHandle(), strName, &nValue);
01827         }
01828 
01832         inline XnStatus GetRealProperty(const XnChar* strName, XnDouble &dValue) const
01833         {
01834             return xnGetRealProperty(GetHandle(), strName, &dValue);
01835         }
01836 
01840         inline XnStatus GetStringProperty(const XnChar* strName, XnChar* csValue, XnUInt32 nBufSize) const
01841         {
01842             return xnGetStringProperty(GetHandle(), strName, csValue, nBufSize);
01843         }
01844 
01848         inline XnStatus GetGeneralProperty(const XnChar* strName, XnUInt32 nBufferSize, void* pBuffer) const
01849         {
01850             return xnGetGeneralProperty(GetHandle(), strName, nBufferSize, pBuffer);
01851         }
01852 
01856         inline XnStatus LockForChanges(XnLockHandle* phLock)
01857         {
01858             return xnLockNodeForChanges(GetHandle(), phLock);
01859         }
01860 
01864         inline void UnlockForChanges(XnLockHandle hLock)
01865         {
01866             xnUnlockNodeForChanges(GetHandle(), hLock);
01867         }
01868 
01872         inline XnStatus LockedNodeStartChanges(XnLockHandle hLock)
01873         {
01874             return xnLockedNodeStartChanges(GetHandle(), hLock);
01875         }
01876 
01880         inline void LockedNodeEndChanges(XnLockHandle hLock)
01881         {
01882             xnLockedNodeEndChanges(GetHandle(), hLock);
01883         }
01884 
01890         inline const ErrorStateCapability GetErrorStateCap() const
01891         {
01892             return ErrorStateCapability(GetHandle());
01893         }
01894 
01900         inline ErrorStateCapability GetErrorStateCap()
01901         {
01902             return ErrorStateCapability(GetHandle());
01903         }
01904 
01912         inline GeneralIntCapability GetGeneralIntCap(const XnChar* strCapability)
01913         {
01914             return GeneralIntCapability(GetHandle(), strCapability);
01915         }
01916     };
01917 
01922     class DeviceIdentificationCapability : public Capability
01923     {
01924     public:
01930         DeviceIdentificationCapability(XnNodeHandle hNode) : Capability(hNode) {}
01931         DeviceIdentificationCapability(const NodeWrapper& node) : Capability(node) {}
01932 
01936         inline XnStatus GetDeviceName(XnChar* strBuffer, XnUInt32 nBufferSize)
01937         {
01938             return xnGetDeviceName(GetHandle(), strBuffer, &nBufferSize);
01939         }
01940 
01944         inline XnStatus GetVendorSpecificData(XnChar* strBuffer, XnUInt32 nBufferSize)
01945         {
01946             return xnGetVendorSpecificData(GetHandle(), strBuffer, &nBufferSize);
01947         }
01948 
01952         inline XnStatus GetSerialNumber(XnChar* strBuffer, XnUInt32 nBufferSize)
01953         {
01954             return xnGetSerialNumber(GetHandle(), strBuffer, &nBufferSize);
01955         }
01956     };
01957 
01962     class Device : public ProductionNode
01963     {
01964     public:
01970         inline Device(XnNodeHandle hNode = NULL) : ProductionNode(hNode) {}
01971         inline Device(const NodeWrapper& other) : ProductionNode(other) {}
01972 
01976         inline XnStatus Create(Context& context, Query* pQuery = NULL, EnumerationErrors* pErrors = NULL);
01977 
01983         inline DeviceIdentificationCapability GetIdentificationCap()
01984         {
01985             return DeviceIdentificationCapability(GetHandle());
01986         }
01987     };
01988 
01993     class MirrorCapability : public Capability
01994     {
01995     public:
02001         inline MirrorCapability(XnNodeHandle hNode) : Capability(hNode) {}
02002         MirrorCapability(const NodeWrapper& node) : Capability(node) {}
02003 
02007         inline XnStatus SetMirror(XnBool bMirror)
02008         {
02009             return xnSetMirror(GetHandle(), bMirror);
02010         }
02011 
02015         inline XnBool IsMirrored() const
02016         {
02017             return xnIsMirrored(GetHandle());
02018         }
02019 
02023         inline XnStatus RegisterToMirrorChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
02024         {
02025             return _RegisterToStateChange(xnRegisterToMirrorChange, GetHandle(), handler, pCookie, hCallback);
02026         }
02027 
02031         inline void UnregisterFromMirrorChange(XnCallbackHandle hCallback)
02032         {
02033             _UnregisterFromStateChange(xnUnregisterFromMirrorChange, GetHandle(), hCallback);
02034         }
02035     };
02036 
02041     class AlternativeViewPointCapability : public Capability
02042     {
02043     public:
02049         inline AlternativeViewPointCapability(XnNodeHandle hNode) : Capability(hNode) {}
02050         AlternativeViewPointCapability(const NodeWrapper& node) : Capability(node) {}
02051 
02055         inline XnBool IsViewPointSupported(ProductionNode& otherNode) const
02056         {
02057             return xnIsViewPointSupported(GetHandle(), otherNode.GetHandle());
02058         }
02059 
02063         inline XnStatus SetViewPoint(ProductionNode& otherNode)
02064         {
02065             return xnSetViewPoint(GetHandle(), otherNode.GetHandle());
02066         }
02067 
02071         inline XnStatus ResetViewPoint()
02072         {
02073             return xnResetViewPoint(GetHandle());
02074         }
02075 
02079         inline XnBool IsViewPointAs(ProductionNode& otherNode) const
02080         {
02081             return xnIsViewPointAs(GetHandle(), otherNode.GetHandle());
02082         }
02083 
02087         inline XnStatus RegisterToViewPointChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
02088         {
02089             return _RegisterToStateChange(xnRegisterToViewPointChange, GetHandle(), handler, pCookie, hCallback);
02090         }
02091 
02095         inline void UnregisterFromViewPointChange(XnCallbackHandle hCallback)
02096         {
02097             _UnregisterFromStateChange(xnUnregisterFromViewPointChange, GetHandle(), hCallback);
02098         }
02099     };
02100 
02105     class FrameSyncCapability : public Capability
02106     {
02107     public:
02113         inline FrameSyncCapability(XnNodeHandle hNode) : Capability(hNode) {}
02114         FrameSyncCapability(const NodeWrapper& node) : Capability(node) {}
02115 
02119         inline XnBool CanFrameSyncWith(Generator& other) const;
02120 
02124         inline XnStatus FrameSyncWith(Generator& other);
02125 
02129         inline XnStatus StopFrameSyncWith(Generator& other);
02130 
02134         inline XnBool IsFrameSyncedWith(Generator& other) const;
02135 
02139         inline XnStatus RegisterToFrameSyncChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
02140         {
02141             return _RegisterToStateChange(xnRegisterToFrameSyncChange, GetHandle(), handler, pCookie, hCallback);
02142         }
02143 
02147         inline void UnregisterFromFrameSyncChange(XnCallbackHandle hCallback)
02148         {
02149             _UnregisterFromStateChange(xnUnregisterFromFrameSyncChange, GetHandle(), hCallback);
02150         }
02151     };
02152 
02157     class Generator : public ProductionNode
02158     {
02159     public:
02165         inline Generator(XnNodeHandle hNode = NULL) : ProductionNode(hNode) {}
02166         inline Generator(const NodeWrapper& other) : ProductionNode(other) {}
02167 
02171         inline XnStatus StartGenerating()
02172         {
02173             return xnStartGenerating(GetHandle());
02174         }
02175 
02179         inline XnBool IsGenerating() const
02180         {
02181             return xnIsGenerating(GetHandle());
02182         }
02183 
02187         inline XnStatus StopGenerating()
02188         {
02189             return xnStopGenerating(GetHandle());
02190         }
02191 
02195         inline XnStatus RegisterToGenerationRunningChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle &hCallback)
02196         {
02197             return _RegisterToStateChange(xnRegisterToGenerationRunningChange, GetHandle(), handler, pCookie, hCallback);
02198         }
02199 
02203         inline void UnregisterFromGenerationRunningChange(XnCallbackHandle hCallback)
02204         {
02205             _UnregisterFromStateChange(xnUnregisterFromGenerationRunningChange, GetHandle(), hCallback);
02206         }
02207 
02211         inline XnStatus RegisterToNewDataAvailable(StateChangedHandler handler, void* pCookie, XnCallbackHandle &hCallback)
02212         {
02213             return _RegisterToStateChange(xnRegisterToNewDataAvailable, GetHandle(), handler, pCookie, hCallback);
02214         }
02215 
02219         inline void UnregisterFromNewDataAvailable(XnCallbackHandle hCallback)
02220         {
02221             _UnregisterFromStateChange(xnUnregisterFromNewDataAvailable, GetHandle(), hCallback);
02222         }
02223 
02227         inline XnBool IsNewDataAvailable(XnUInt64* pnTimestamp = NULL) const
02228         {
02229             return xnIsNewDataAvailable(GetHandle(), pnTimestamp);
02230         }
02231 
02235         inline XnStatus WaitAndUpdateData()
02236         {
02237             return xnWaitAndUpdateData(GetHandle());
02238         }
02239 
02243         inline XnBool IsDataNew() const
02244         {
02245             return xnIsDataNew(GetHandle());
02246         }
02247 
02251         inline const void* GetData()
02252         {
02253             return xnGetData(GetHandle());
02254         }
02255         
02259         inline XnUInt32 GetDataSize() const
02260         {
02261             return xnGetDataSize(GetHandle());
02262         }
02263 
02267         inline XnUInt64 GetTimestamp() const
02268         {
02269             return xnGetTimestamp(GetHandle());
02270         }
02271 
02275         inline XnUInt32 GetFrameID() const
02276         {
02277             return xnGetFrameID(GetHandle());
02278         }
02279 
02285         inline const MirrorCapability GetMirrorCap() const
02286         { 
02287             return MirrorCapability(GetHandle()); 
02288         }
02289 
02295         inline MirrorCapability GetMirrorCap()
02296         { 
02297             return MirrorCapability(GetHandle()); 
02298         }
02299 
02305         inline const AlternativeViewPointCapability GetAlternativeViewPointCap() const
02306         { 
02307             return AlternativeViewPointCapability(GetHandle()); 
02308         }
02309 
02315         inline AlternativeViewPointCapability GetAlternativeViewPointCap()
02316         { 
02317             return AlternativeViewPointCapability(GetHandle()); 
02318         }
02319 
02325         inline const FrameSyncCapability GetFrameSyncCap() const
02326         {
02327             return FrameSyncCapability(GetHandle());
02328         }
02329 
02335         inline FrameSyncCapability GetFrameSyncCap()
02336         {
02337             return FrameSyncCapability(GetHandle());
02338         }
02339     };
02340 
02345     class Recorder : public ProductionNode
02346     {
02347     public:
02353         inline Recorder(XnNodeHandle hNode = NULL) : ProductionNode(hNode) {}
02354         inline Recorder(const NodeWrapper& other) : ProductionNode(other) {}
02355 
02359         inline XnStatus Create(Context& context, const XnChar* strFormatName = NULL);
02360 
02364         inline XnStatus SetDestination(XnRecordMedium destType, const XnChar* strDest)
02365         {
02366             return xnSetRecorderDestination(GetHandle(), destType, strDest);
02367         }
02368 
02369         inline XnStatus GetDestination(XnRecordMedium& destType, XnChar* strDest, XnUInt32 nBufSize)
02370         {
02371             return xnGetRecorderDestination(GetHandle(), &destType, strDest, nBufSize);
02372         }
02373 
02377         inline XnStatus AddNodeToRecording(ProductionNode& Node, XnCodecID compression = XN_CODEC_NULL)
02378         {
02379             return xnAddNodeToRecording(GetHandle(), Node.GetHandle(), compression);
02380         }
02381 
02385         inline XnStatus RemoveNodeFromRecording(ProductionNode& Node)
02386         {
02387             return xnRemoveNodeFromRecording(GetHandle(), Node.GetHandle());
02388         }
02389 
02393         inline XnStatus Record()
02394         {
02395             return xnRecord(GetHandle());
02396         }
02397     };
02398 
02403     class Player : public ProductionNode
02404     {
02405     public:
02411         inline Player(XnNodeHandle hNode = NULL) : ProductionNode(hNode) {}
02412         inline Player(const NodeWrapper& other) : ProductionNode(other) {}
02413 
02417         inline XnStatus Create(Context& context, const XnChar* strFormatName);
02418 
02422         inline XnStatus SetRepeat(XnBool bRepeat)
02423         {
02424             return xnSetPlayerRepeat(GetHandle(), bRepeat);
02425         }
02426 
02430         inline XnStatus SetSource(XnRecordMedium sourceType, const XnChar* strSource)
02431         {
02432             return xnSetPlayerSource(GetHandle(), sourceType, strSource);
02433         }
02434 
02438         inline XnStatus GetSource(XnRecordMedium &sourceType, XnChar* strSource, XnUInt32 nBufSize) const
02439         {
02440             return xnGetPlayerSource(GetHandle(), &sourceType, strSource, nBufSize);
02441         }
02442 
02446         inline XnStatus ReadNext()
02447         {
02448             return xnPlayerReadNext(GetHandle());
02449         }
02450 
02454         inline XnStatus SeekToTimeStamp(XnInt64 nTimeOffset, XnPlayerSeekOrigin origin)
02455         {
02456             return xnSeekPlayerToTimeStamp(GetHandle(), nTimeOffset, origin);
02457         }
02458 
02462         inline XnStatus SeekToFrame(const XnChar* strNodeName, XnInt32 nFrameOffset, XnPlayerSeekOrigin origin)
02463         {
02464             return xnSeekPlayerToFrame(GetHandle(), strNodeName, nFrameOffset, origin);
02465         }
02466 
02470         inline XnStatus TellTimestamp(XnUInt64& nTimestamp) const
02471         {
02472             return xnTellPlayerTimestamp(GetHandle(), &nTimestamp);
02473         }
02474 
02478         inline XnStatus TellFrame(const XnChar* strNodeName, XnUInt32& nFrame) const
02479         {
02480             return xnTellPlayerFrame(GetHandle(), strNodeName, &nFrame);
02481         }
02482 
02486         inline XnStatus GetNumFrames(const XnChar* strNodeName, XnUInt32& nFrames) const
02487         {
02488             return xnGetPlayerNumFrames(GetHandle(), strNodeName, &nFrames);
02489         }
02490 
02494         inline const XnChar* GetSupportedFormat() const
02495         {
02496             return xnGetPlayerSupportedFormat(GetHandle());
02497         }
02498 
02502         inline XnStatus EnumerateNodes(NodeInfoList& list) const
02503         {
02504             XnNodeInfoList* pList;
02505             XnStatus nRetVal = xnEnumeratePlayerNodes(GetHandle(), &pList);
02506             XN_IS_STATUS_OK(nRetVal);
02507 
02508             list.ReplaceUnderlyingObject(pList);
02509 
02510             return (XN_STATUS_OK);
02511         }
02512 
02516         inline XnBool IsEOF() const
02517         {
02518             return xnIsPlayerAtEOF(GetHandle());
02519         }
02520 
02524         inline XnStatus RegisterToEndOfFileReached(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
02525         {
02526             return _RegisterToStateChange(xnRegisterToEndOfFileReached, GetHandle(), handler, pCookie, hCallback);
02527         }
02528 
02532         inline void UnregisterFromEndOfFileReached(XnCallbackHandle hCallback)
02533         {
02534             _UnregisterFromStateChange(xnUnregisterFromEndOfFileReached, GetHandle(), hCallback);
02535         }
02536 
02540         inline XnStatus SetPlaybackSpeed(XnDouble dSpeed)
02541         {
02542             return xnSetPlaybackSpeed(GetHandle(), dSpeed);
02543         }
02544 
02548         inline XnDouble GetPlaybackSpeed() const
02549         {
02550             return xnGetPlaybackSpeed(GetHandle());
02551         }
02552     };
02553 
02558     class CroppingCapability : public Capability
02559     {
02560     public:
02566         inline CroppingCapability(XnNodeHandle hNode) : Capability(hNode) {}
02567         CroppingCapability(const NodeWrapper& node) : Capability(node) {}
02568 
02572         inline XnStatus SetCropping(const XnCropping& Cropping)
02573         {
02574             return xnSetCropping(GetHandle(), &Cropping);
02575         }
02576 
02580         inline XnStatus GetCropping(XnCropping& Cropping) const
02581         {
02582             return xnGetCropping(GetHandle(), &Cropping);
02583         }
02584 
02588         inline XnStatus RegisterToCroppingChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
02589         {
02590             return _RegisterToStateChange(xnRegisterToCroppingChange, GetHandle(), handler, pCookie, hCallback);
02591         }
02592 
02596         inline void UnregisterFromCroppingChange(XnCallbackHandle hCallback)
02597         {
02598             _UnregisterFromStateChange(xnUnregisterFromCroppingChange, GetHandle(), hCallback);
02599         }
02600     };
02601 
02606     class AntiFlickerCapability : public Capability
02607     {
02608     public:
02614         inline AntiFlickerCapability(XnNodeHandle hNode) : Capability(hNode) {}
02615         AntiFlickerCapability(const NodeWrapper& node) : Capability(node) {}
02616 
02620         inline XnStatus SetPowerLineFrequency(XnPowerLineFrequency nFrequency)
02621         {
02622             return xnSetPowerLineFrequency(GetHandle(), nFrequency);
02623         }
02624 
02628         inline XnPowerLineFrequency GetPowerLineFrequency()
02629         {
02630             return xnGetPowerLineFrequency(GetHandle());
02631         }
02632 
02636         inline XnStatus RegisterToPowerLineFrequencyChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
02637         {
02638             return _RegisterToStateChange(xnRegisterToPowerLineFrequencyChange, GetHandle(), handler, pCookie, hCallback);
02639         }
02640 
02644         inline void UnregisterFromPowerLineFrequencyChange(XnCallbackHandle hCallback)
02645         {
02646             _UnregisterFromStateChange(xnUnregisterFromPowerLineFrequencyChange, GetHandle(), hCallback);
02647         }
02648     };
02649 
02654     class MapGenerator : public Generator
02655     {
02656     public:
02662         inline MapGenerator(XnNodeHandle hNode = NULL) : Generator(hNode) {}
02663         inline MapGenerator(const NodeWrapper& other) : Generator(other) {}
02664 
02668         inline XnUInt32 GetSupportedMapOutputModesCount() const
02669         {
02670             return xnGetSupportedMapOutputModesCount(GetHandle());
02671         }
02672 
02676         inline XnStatus GetSupportedMapOutputModes(XnMapOutputMode* aModes, XnUInt32& nCount) const
02677         {
02678             return xnGetSupportedMapOutputModes(GetHandle(), aModes, &nCount);
02679         }
02680 
02684         inline XnStatus SetMapOutputMode(const XnMapOutputMode& OutputMode)
02685         {
02686             return xnSetMapOutputMode(GetHandle(), &OutputMode);
02687         }
02688 
02692         inline XnStatus GetMapOutputMode(XnMapOutputMode &OutputMode) const
02693         {
02694             return xnGetMapOutputMode(GetHandle(), &OutputMode);
02695         }
02696 
02700         inline XnUInt32 GetBytesPerPixel() const
02701         {
02702             return xnGetBytesPerPixel(GetHandle());
02703         }
02704 
02708         inline XnStatus RegisterToMapOutputModeChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
02709         {
02710             return _RegisterToStateChange(xnRegisterToMapOutputModeChange, GetHandle(), handler, pCookie, hCallback);
02711         }
02712 
02716         inline void UnregisterFromMapOutputModeChange(XnCallbackHandle hCallback)
02717         {
02718             _UnregisterFromStateChange(xnUnregisterFromMapOutputModeChange, GetHandle(), hCallback);
02719         }
02720 
02726         inline const CroppingCapability GetCroppingCap() const
02727         {
02728             return CroppingCapability(GetHandle());
02729         }
02730 
02736         inline CroppingCapability GetCroppingCap()
02737         {
02738             return CroppingCapability(GetHandle());
02739         }
02740 
02746         inline GeneralIntCapability GetBrightnessCap()
02747         {
02748             return GeneralIntCapability(GetHandle(), XN_CAPABILITY_BRIGHTNESS);
02749         }
02750 
02756         inline GeneralIntCapability GetContrastCap()
02757         {
02758             return GeneralIntCapability(GetHandle(), XN_CAPABILITY_CONTRAST);
02759         }
02760 
02766         inline GeneralIntCapability GetHueCap()
02767         {
02768             return GeneralIntCapability(GetHandle(), XN_CAPABILITY_HUE);
02769         }
02770 
02776         inline GeneralIntCapability GetSaturationCap()
02777         {
02778             return GeneralIntCapability(GetHandle(), XN_CAPABILITY_SATURATION);
02779         }
02780 
02786         inline GeneralIntCapability GetSharpnessCap()
02787         {
02788             return GeneralIntCapability(GetHandle(), XN_CAPABILITY_SHARPNESS);
02789         }
02790 
02796         inline GeneralIntCapability GetGammaCap()
02797         {
02798             return GeneralIntCapability(GetHandle(), XN_CAPABILITY_GAMMA);
02799         }
02800 
02806         inline GeneralIntCapability GetWhiteBalanceCap()
02807         {
02808             return GeneralIntCapability(GetHandle(), XN_CAPABILITY_COLOR_TEMPERATURE);
02809         }
02810 
02816         inline GeneralIntCapability GetBacklightCompensationCap()
02817         {
02818             return GeneralIntCapability(GetHandle(), XN_CAPABILITY_BACKLIGHT_COMPENSATION);
02819         }
02820 
02826         inline GeneralIntCapability GetGainCap()
02827         {
02828             return GeneralIntCapability(GetHandle(), XN_CAPABILITY_GAIN);
02829         }
02830 
02836         inline GeneralIntCapability GetPanCap()
02837         {
02838             return GeneralIntCapability(GetHandle(), XN_CAPABILITY_PAN);
02839         }
02840 
02846         inline GeneralIntCapability GetTiltCap()
02847         {
02848             return GeneralIntCapability(GetHandle(), XN_CAPABILITY_TILT);
02849         }
02850 
02856         inline GeneralIntCapability GetRollCap()
02857         {
02858             return GeneralIntCapability(GetHandle(), XN_CAPABILITY_ROLL);
02859         }
02860 
02866         inline GeneralIntCapability GetZoomCap()
02867         {
02868             return GeneralIntCapability(GetHandle(), XN_CAPABILITY_ZOOM);
02869         }
02870 
02876         inline GeneralIntCapability GetExposureCap()
02877         {
02878             return GeneralIntCapability(GetHandle(), XN_CAPABILITY_EXPOSURE);
02879         }
02880 
02886         inline GeneralIntCapability GetIrisCap()
02887         {
02888             return GeneralIntCapability(GetHandle(), XN_CAPABILITY_IRIS);
02889         }
02890 
02896         inline GeneralIntCapability GetFocusCap()
02897         {
02898             return GeneralIntCapability(GetHandle(), XN_CAPABILITY_FOCUS);
02899         }
02900 
02906         inline GeneralIntCapability GetLowLightCompensationCap()
02907         {
02908             return GeneralIntCapability(GetHandle(), XN_CAPABILITY_LOW_LIGHT_COMPENSATION);
02909         }
02910 
02916         inline AntiFlickerCapability GetAntiFlickerCap()
02917         {
02918             return AntiFlickerCapability(GetHandle());
02919         }
02920     };
02921 
02926     class UserPositionCapability : public Capability
02927     {
02928     public:
02934         inline UserPositionCapability(XnNodeHandle hNode = NULL) : Capability(hNode) {}
02935         UserPositionCapability(const NodeWrapper& node) : Capability(node) {}
02936 
02940         inline XnUInt32 GetSupportedUserPositionsCount() const
02941         {
02942             return xnGetSupportedUserPositionsCount(GetHandle());
02943         }
02944 
02948         inline XnStatus SetUserPosition(XnUInt32 nIndex, const XnBoundingBox3D& Position)
02949         {
02950             return xnSetUserPosition(GetHandle(), nIndex, &Position);
02951         }
02952 
02956         inline XnStatus GetUserPosition(XnUInt32 nIndex, XnBoundingBox3D& Position) const
02957         {
02958             return xnGetUserPosition(GetHandle(), nIndex, &Position);
02959         }
02960 
02964         inline XnStatus RegisterToUserPositionChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
02965         {
02966             return _RegisterToStateChange(xnRegisterToUserPositionChange, GetHandle(), handler, pCookie, hCallback);
02967         }
02968 
02972         inline void UnregisterFromUserPositionChange(XnCallbackHandle hCallback)
02973         {
02974             _UnregisterFromStateChange(xnUnregisterFromUserPositionChange, GetHandle(), hCallback);
02975         }
02976     };
02977 
02982     class DepthGenerator : public MapGenerator
02983     {
02984     public:
02990         inline DepthGenerator(XnNodeHandle hNode = NULL) : MapGenerator(hNode) {}
02991         inline DepthGenerator(const NodeWrapper& other) : MapGenerator(other) {}
02992 
02996         inline XnStatus Create(Context& context, Query* pQuery = NULL, EnumerationErrors* pErrors = NULL);
02997 
03001         inline void GetMetaData(DepthMetaData& metaData) const 
03002         {
03003             xnGetDepthMetaData(GetHandle(), metaData.GetUnderlying());
03004         }
03005 
03009         inline const XnDepthPixel* GetDepthMap() const
03010         {
03011             return xnGetDepthMap(GetHandle());
03012         }
03013 
03017         inline XnDepthPixel GetDeviceMaxDepth() const
03018         {
03019             return xnGetDeviceMaxDepth(GetHandle());
03020         }
03021 
03025         inline XnStatus GetFieldOfView(XnFieldOfView& FOV) const
03026         {
03027             return xnGetDepthFieldOfView(GetHandle(), &FOV);
03028         }
03029 
03033         inline XnStatus RegisterToFieldOfViewChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
03034         {
03035             return _RegisterToStateChange(xnRegisterToDepthFieldOfViewChange, GetHandle(), handler, pCookie, hCallback);
03036         }
03037 
03041         inline void UnregisterFromFieldOfViewChange(XnCallbackHandle hCallback)
03042         {
03043             _UnregisterFromStateChange(xnUnregisterFromDepthFieldOfViewChange, GetHandle(), hCallback);
03044         }
03045 
03049         inline XnStatus ConvertProjectiveToRealWorld(XnUInt32 nCount, const XnPoint3D aProjective[], XnPoint3D aRealWorld[]) const
03050         {
03051             return xnConvertProjectiveToRealWorld(GetHandle(), nCount, aProjective, aRealWorld);
03052         }
03053 
03057         inline XnStatus ConvertRealWorldToProjective(XnUInt32 nCount, const XnPoint3D aRealWorld[], XnPoint3D aProjective[]) const
03058         {
03059             return xnConvertRealWorldToProjective(GetHandle(), nCount, aRealWorld, aProjective);
03060         }
03061 
03067         inline const UserPositionCapability GetUserPositionCap() const
03068         {
03069             return UserPositionCapability(GetHandle());
03070         }
03071 
03077         inline UserPositionCapability GetUserPositionCap()
03078         {
03079             return UserPositionCapability(GetHandle());
03080         }
03081     };
03082 
03087     class MockDepthGenerator : public DepthGenerator
03088     {
03089     public:
03095         inline MockDepthGenerator(XnNodeHandle hNode = NULL) : DepthGenerator(hNode) {}
03096         inline MockDepthGenerator(const NodeWrapper& other) : DepthGenerator(other) {}
03097 
03104         XnStatus Create(Context& context, const XnChar* strName = NULL);
03105 
03112         XnStatus CreateBasedOn(DepthGenerator& other, const XnChar* strName = NULL);
03113 
03117         inline XnStatus SetData(XnUInt32 nFrameID, XnUInt64 nTimestamp, XnUInt32 nDataSize, const XnDepthPixel* pDepthMap)
03118         {
03119             return xnMockDepthSetData(GetHandle(), nFrameID, nTimestamp, nDataSize, pDepthMap);
03120         }
03121 
03129         inline XnStatus SetData(const DepthMetaData& depthMD, XnUInt32 nFrameID, XnUInt64 nTimestamp)
03130         {
03131             return SetData(nFrameID, nTimestamp, depthMD.DataSize(), depthMD.Data());
03132         }
03133 
03139         inline XnStatus SetData(const DepthMetaData& depthMD)
03140         {
03141             return SetData(depthMD, depthMD.FrameID(), depthMD.Timestamp());
03142         }
03143     };
03144 
03149     class ImageGenerator : public MapGenerator
03150     {
03151     public:
03157         inline ImageGenerator(XnNodeHandle hNode = NULL) : MapGenerator(hNode) {}
03158         inline ImageGenerator(const NodeWrapper& other) : MapGenerator(other) {}
03159 
03163         inline XnStatus Create(Context& context, Query* pQuery = NULL, EnumerationErrors* pErrors = NULL);
03164 
03168         inline void GetMetaData(ImageMetaData& metaData) const 
03169         {
03170             xnGetImageMetaData(GetHandle(), metaData.GetUnderlying());
03171         }
03172 
03176         inline const XnRGB24Pixel* GetRGB24ImageMap() const
03177         {
03178             return xnGetRGB24ImageMap(GetHandle());
03179         }
03180 
03184         inline const XnYUV422DoublePixel* GetYUV422ImageMap() const
03185         {
03186             return xnGetYUV422ImageMap(GetHandle());
03187         }
03188 
03192         inline const XnGrayscale8Pixel* GetGrayscale8ImageMap() const
03193         {
03194             return xnGetGrayscale8ImageMap(GetHandle());
03195         }
03196 
03200         inline const XnGrayscale16Pixel* GetGrayscale16ImageMap() const
03201         {
03202             return xnGetGrayscale16ImageMap(GetHandle());
03203         }
03204 
03208         inline const XnUInt8* GetImageMap() const
03209         {
03210             return xnGetImageMap(GetHandle());
03211         }
03212 
03216         inline XnBool IsPixelFormatSupported(XnPixelFormat Format) const
03217         {
03218             return xnIsPixelFormatSupported(GetHandle(), Format);
03219         }
03220 
03224         inline XnStatus SetPixelFormat(XnPixelFormat Format)
03225         {
03226             return xnSetPixelFormat(GetHandle(), Format);
03227         }
03228 
03232         inline XnPixelFormat GetPixelFormat() const
03233         {
03234             return xnGetPixelFormat(GetHandle());
03235         }
03236 
03240         inline XnStatus RegisterToPixelFormatChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
03241         {
03242             return _RegisterToStateChange(xnRegisterToPixelFormatChange, GetHandle(), handler, pCookie, hCallback);
03243         }
03244 
03248         inline void UnregisterFromPixelFormatChange(XnCallbackHandle hCallback)
03249         {
03250             _UnregisterFromStateChange(xnUnregisterFromPixelFormatChange, GetHandle(), hCallback);
03251         }
03252     };
03253 
03258     class MockImageGenerator : public ImageGenerator
03259     {
03260     public:
03266         inline MockImageGenerator(XnNodeHandle hNode = NULL) : ImageGenerator(hNode) {}
03267         inline MockImageGenerator(const NodeWrapper& other) : ImageGenerator(other) {}
03268 
03275         XnStatus Create(Context& context, const XnChar* strName = NULL);
03276 
03283         XnStatus CreateBasedOn(ImageGenerator& other, const XnChar* strName = NULL);
03284 
03288         inline XnStatus SetData(XnUInt32 nFrameID, XnUInt64 nTimestamp, XnUInt32 nDataSize, const XnUInt8* pImageMap)
03289         {
03290             return xnMockImageSetData(GetHandle(), nFrameID, nTimestamp, nDataSize, pImageMap);
03291         }
03292 
03300         inline XnStatus SetData(const ImageMetaData& imageMD, XnUInt32 nFrameID, XnUInt64 nTimestamp)
03301         {
03302             return SetData(nFrameID, nTimestamp, imageMD.DataSize(), imageMD.Data());
03303         }
03304 
03310         inline XnStatus SetData(const ImageMetaData& imageMD)
03311         {
03312             return SetData(imageMD, imageMD.FrameID(), imageMD.Timestamp());
03313         }
03314     };
03315 
03320     class IRGenerator : public MapGenerator
03321     {
03322     public:
03328         inline IRGenerator(XnNodeHandle hNode = NULL) : MapGenerator(hNode) {}
03329         inline IRGenerator(const NodeWrapper& other) : MapGenerator(other) {}
03330 
03334         inline XnStatus Create(Context& context, Query* pQuery = NULL, EnumerationErrors* pErrors = NULL);
03335 
03339         inline void GetMetaData(IRMetaData& metaData) const 
03340         { 
03341             xnGetIRMetaData(GetHandle(), metaData.GetUnderlying());
03342         }
03343 
03347         inline const XnIRPixel* GetIRMap() const
03348         {
03349             return xnGetIRMap(GetHandle());
03350         }
03351     };
03352 
03357     class MockIRGenerator : public IRGenerator
03358     {
03359     public:
03365         inline MockIRGenerator(XnNodeHandle hNode = NULL) : IRGenerator(hNode) {}
03366         inline MockIRGenerator(const NodeWrapper& other) : IRGenerator(other) {}
03367 
03374         XnStatus Create(Context& context, const XnChar* strName = NULL);
03381         XnStatus CreateBasedOn(IRGenerator& other, const XnChar* strName = NULL);
03382 
03386         inline XnStatus SetData(XnUInt32 nFrameID, XnUInt64 nTimestamp, XnUInt32 nDataSize, const XnIRPixel* pIRMap)
03387         {
03388             return xnMockIRSetData(GetHandle(), nFrameID, nTimestamp, nDataSize, pIRMap);
03389         }
03390 
03398         inline XnStatus SetData(const IRMetaData& irMD, XnUInt32 nFrameID, XnUInt64 nTimestamp)
03399         {
03400             return SetData(nFrameID, nTimestamp, irMD.DataSize(), irMD.Data());
03401         }
03402 
03408         inline XnStatus SetData(const IRMetaData& irMD)
03409         {
03410             return SetData(irMD, irMD.FrameID(), irMD.Timestamp());
03411         }
03412     };
03413 
03418     class GestureGenerator : public Generator
03419     {
03420     public:
03426         inline GestureGenerator(XnNodeHandle hNode = NULL) : Generator(hNode) {} 
03427         inline GestureGenerator(const NodeWrapper& other) : Generator(other) {}
03428 
03432         inline XnStatus Create(Context& context, Query* pQuery = NULL, EnumerationErrors* pErrors = NULL);
03433 
03437         inline XnStatus AddGesture(const XnChar* strGesture, XnBoundingBox3D* pArea)
03438         {
03439             return xnAddGesture(GetHandle(), strGesture, pArea);
03440         }
03441 
03445         inline XnStatus RemoveGesture(const XnChar* strGesture)
03446         {
03447             return xnRemoveGesture(GetHandle(), strGesture);
03448         }
03449 
03453         inline XnStatus GetActiveGestures(XnChar*& astrGestures, XnUInt16& nGestures) const
03454         {
03455             return xnGetActiveGestures(GetHandle(), &astrGestures, &nGestures);
03456         }
03457 
03461         inline XnStatus GetAllActiveGestures(XnChar** astrGestures, XnUInt32 nNameLength, XnUInt16& nGestures) const
03462         {
03463             return xnGetAllActiveGestures(GetHandle(), astrGestures, nNameLength, &nGestures);
03464         }
03465 
03469         inline XnStatus EnumerateGestures(XnChar*& astrGestures, XnUInt16& nGestures) const
03470         {
03471             return xnEnumerateGestures(GetHandle(), &astrGestures, &nGestures);
03472         }
03476         inline XnStatus EnumerateAllGestures(XnChar** astrGestures, XnUInt32 nNameLength, XnUInt16& nGestures) const
03477         {
03478             return xnEnumerateAllGestures(GetHandle(), astrGestures, nNameLength, &nGestures);
03479         }
03480 
03484         inline XnBool IsGestureAvailable(const XnChar* strGesture) const
03485         {
03486             return xnIsGestureAvailable(GetHandle(), strGesture);
03487         }
03488 
03492         inline XnBool IsGestureProgressSupported(const XnChar* strGesture) const
03493         {
03494             return xnIsGestureProgressSupported(GetHandle(), strGesture);
03495         }
03496 
03506         typedef void (XN_CALLBACK_TYPE* GestureRecognized)(GestureGenerator& generator, const XnChar* strGesture, const XnPoint3D* pIDPosition, const XnPoint3D* pEndPosition, void* pCookie);
03516         typedef void (XN_CALLBACK_TYPE* GestureProgress)(GestureGenerator& generator, const XnChar* strGesture, const XnPoint3D* pPosition, XnFloat fProgress, void* pCookie);
03517 
03521         XnStatus RegisterGestureCallbacks(GestureRecognized RecognizedCB, GestureProgress ProgressCB, void* pCookie, XnCallbackHandle& hCallback)
03522         {
03523             XnStatus nRetVal = XN_STATUS_OK;
03524             
03525             GestureCookie* pGestureCookie;
03526             XN_VALIDATE_ALLOC(pGestureCookie, GestureCookie);
03527             pGestureCookie->recognizedHandler = RecognizedCB;
03528             pGestureCookie->progressHandler = ProgressCB;
03529             pGestureCookie->pUserCookie = pCookie;
03530 
03531             nRetVal = xnRegisterGestureCallbacks(GetHandle(), GestureRecognizedCallback, GestureProgressCallback, pGestureCookie, &pGestureCookie->hCallback);
03532             if (nRetVal != XN_STATUS_OK)
03533             {
03534                 xnOSFree(pGestureCookie);
03535                 return (nRetVal);
03536             }
03537 
03538             hCallback = pGestureCookie;
03539 
03540             return (XN_STATUS_OK);
03541         }
03542 
03546         inline void UnregisterGestureCallbacks(XnCallbackHandle hCallback)
03547         {
03548             GestureCookie* pGestureCookie = (GestureCookie*)hCallback;
03549             xnUnregisterGestureCallbacks(GetHandle(), pGestureCookie->hCallback);
03550             xnOSFree(pGestureCookie);
03551         }
03552 
03556         inline XnStatus RegisterToGestureChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
03557         {
03558             return _RegisterToStateChange(xnRegisterToGestureChange, GetHandle(), handler, pCookie, hCallback);
03559         }
03560 
03564         inline void UnregisterFromGestureChange(XnCallbackHandle hCallback)
03565         {
03566             _UnregisterFromStateChange(xnUnregisterFromGestureChange, GetHandle(), hCallback);
03567         }
03568 
03577         typedef void (XN_CALLBACK_TYPE* GestureIntermediateStageCompleted)(GestureGenerator& generator, const XnChar* strGesture, const XnPoint3D* pPosition, void* pCookie);
03581         XnStatus RegisterToGestureIntermediateStageCompleted(GestureIntermediateStageCompleted handler, void* pCookie, XnCallbackHandle& hCallback)
03582         {
03583             XnStatus nRetVal = XN_STATUS_OK;
03584 
03585             GestureIntermediateStageCompletedCookie* pGestureCookie;
03586             XN_VALIDATE_ALLOC(pGestureCookie, GestureIntermediateStageCompletedCookie);
03587             pGestureCookie->handler = handler;
03588             pGestureCookie->pUserCookie = pCookie;
03589 
03590             nRetVal = xnRegisterToGestureIntermediateStageCompleted(GetHandle(), GestureIntermediateStageCompletedCallback, pGestureCookie, &pGestureCookie->hCallback);
03591             if (nRetVal != XN_STATUS_OK)
03592             {
03593                 xnOSFree(pGestureCookie);
03594                 return (nRetVal);
03595             }
03596 
03597             hCallback = pGestureCookie;
03598 
03599             return (XN_STATUS_OK);
03600         }
03604         inline void UnregisterFromGestureIntermediateStageCompleted(XnCallbackHandle hCallback)
03605         {
03606             GestureIntermediateStageCompletedCookie* pGestureCookie = (GestureIntermediateStageCompletedCookie*)hCallback;
03607             xnUnregisterFromGestureIntermediateStageCompleted(GetHandle(), pGestureCookie->hCallback);
03608             xnOSFree(pGestureCookie);
03609         }
03610 
03619         typedef void (XN_CALLBACK_TYPE* GestureReadyForNextIntermediateStage)(GestureGenerator& generator, const XnChar* strGesture, const XnPoint3D* pPosition, void* pCookie);
03623         XnStatus RegisterToGestureReadyForNextIntermediateStage(GestureReadyForNextIntermediateStage handler, void* pCookie, XnCallbackHandle& hCallback)
03624         {
03625             XnStatus nRetVal = XN_STATUS_OK;
03626 
03627             GestureReadyForNextIntermediateStageCookie* pGestureCookie;
03628             XN_VALIDATE_ALLOC(pGestureCookie, GestureReadyForNextIntermediateStageCookie);
03629             pGestureCookie->handler = handler;
03630             pGestureCookie->pUserCookie = pCookie;
03631 
03632             nRetVal = xnRegisterToGestureReadyForNextIntermediateStage(GetHandle(), GestureReadyForNextIntermediateStageCallback, pGestureCookie, &pGestureCookie->hCallback);
03633             if (nRetVal != XN_STATUS_OK)
03634             {
03635                 xnOSFree(pGestureCookie);
03636                 return (nRetVal);
03637             }
03638 
03639             hCallback = pGestureCookie;
03640 
03641             return (XN_STATUS_OK);
03642         }
03643 
03647         inline void UnregisterFromGestureReadyForNextIntermediateStageCallbacks(XnCallbackHandle hCallback)
03648         {
03649             GestureReadyForNextIntermediateStageCookie* pGestureCookie = (GestureReadyForNextIntermediateStageCookie*)hCallback;
03650             xnUnregisterFromGestureReadyForNextIntermediateStage(GetHandle(), pGestureCookie->hCallback);
03651             xnOSFree(pGestureCookie);
03652         }
03653 
03654     private:
03655         typedef struct GestureCookie
03656         {
03657             GestureRecognized recognizedHandler;
03658             GestureProgress progressHandler;
03659             void* pUserCookie;
03660             XnCallbackHandle hCallback;
03661         } GestureCookie;
03662 
03663         static void XN_CALLBACK_TYPE GestureRecognizedCallback(XnNodeHandle hNode, const XnChar* strGesture, const XnPoint3D* pIDPosition, const XnPoint3D* pEndPosition, void* pCookie)
03664         {
03665             GestureCookie* pGestureCookie = (GestureCookie*)pCookie;
03666             GestureGenerator gen(hNode);
03667             if (pGestureCookie->recognizedHandler != NULL)
03668             {
03669                 pGestureCookie->recognizedHandler(gen, strGesture, pIDPosition, pEndPosition, pGestureCookie->pUserCookie);
03670             }
03671         }
03672 
03673         static void XN_CALLBACK_TYPE GestureProgressCallback(XnNodeHandle hNode, const XnChar* strGesture, const XnPoint3D* pPosition, XnFloat fProgress, void* pCookie)
03674         {
03675             GestureCookie* pGestureCookie = (GestureCookie*)pCookie;
03676             GestureGenerator gen(hNode);
03677             if (pGestureCookie->progressHandler != NULL)
03678             {
03679                 pGestureCookie->progressHandler(gen, strGesture, pPosition, fProgress, pGestureCookie->pUserCookie);
03680             }
03681         }
03682 
03683         typedef struct GestureIntermediateStageCompletedCookie
03684         {
03685             GestureIntermediateStageCompleted handler;
03686             void* pUserCookie;
03687             XnCallbackHandle hCallback;
03688         } GestureIntermediateStageCompletedCookie;
03689 
03690         static void XN_CALLBACK_TYPE GestureIntermediateStageCompletedCallback(XnNodeHandle hNode, const XnChar* strGesture, const XnPoint3D* pPosition, void* pCookie)
03691         {
03692             GestureIntermediateStageCompletedCookie* pGestureCookie = (GestureIntermediateStageCompletedCookie*)pCookie;
03693             GestureGenerator gen(hNode);
03694             if (pGestureCookie->handler != NULL)
03695             {
03696                 pGestureCookie->handler(gen, strGesture, pPosition, pGestureCookie->pUserCookie);
03697             }
03698         }
03699 
03700         typedef struct GestureReadyForNextIntermediateStageCookie
03701         {
03702             GestureReadyForNextIntermediateStage handler;
03703             void* pUserCookie;
03704             XnCallbackHandle hCallback;
03705         } GestureReadyForNextIntermediateStageCookie;
03706 
03707         static void XN_CALLBACK_TYPE GestureReadyForNextIntermediateStageCallback(XnNodeHandle hNode, const XnChar* strGesture, const XnPoint3D* pPosition, void* pCookie)
03708         {
03709             GestureReadyForNextIntermediateStageCookie* pGestureCookie = (GestureReadyForNextIntermediateStageCookie*)pCookie;
03710             GestureGenerator gen(hNode);
03711             if (pGestureCookie->handler != NULL)
03712             {
03713                 pGestureCookie->handler(gen, strGesture, pPosition, pGestureCookie->pUserCookie);
03714             }
03715         }
03716     };
03717 
03722     class SceneAnalyzer : public MapGenerator
03723     {
03724     public:
03730         inline SceneAnalyzer(XnNodeHandle hNode = NULL) : MapGenerator(hNode) {}
03731         inline SceneAnalyzer(const NodeWrapper& other) : MapGenerator(other) {}
03732 
03736         inline XnStatus Create(Context& context, Query* pQuery = NULL, EnumerationErrors* pErrors = NULL);
03737 
03741         inline void GetMetaData(SceneMetaData& metaData) const
03742         {
03743             xnGetSceneMetaData(GetHandle(), metaData.GetUnderlying());
03744         }
03745 
03749         inline const XnLabel* GetLabelMap() const
03750         {
03751             return xnGetLabelMap(GetHandle());
03752         }
03753 
03757         inline XnStatus GetFloor(XnPlane3D& Plane) const
03758         {
03759             return xnGetFloor(GetHandle(), &Plane);
03760         }
03761     };
03762 
03767     class HandTouchingFOVEdgeCapability : public Capability
03768     {
03769     public:
03775         inline HandTouchingFOVEdgeCapability(XnNodeHandle hNode) : Capability(hNode) {}
03776         HandTouchingFOVEdgeCapability(const NodeWrapper& node) : Capability(node) {}
03777 
03788         typedef void (XN_CALLBACK_TYPE* HandTouchingFOVEdge)(HandTouchingFOVEdgeCapability& touchingfov, XnUserID user, const XnPoint3D* pPosition, XnFloat fTime, XnDirection eDir, void* pCookie);
03792         inline XnStatus RegisterToHandTouchingFOVEdge(HandTouchingFOVEdge handler, void* pCookie, XnCallbackHandle& hCallback)
03793         {
03794             XnStatus nRetVal = XN_STATUS_OK;
03795 
03796             HandTouchingFOVEdgeCookie* pHandCookie;
03797             XN_VALIDATE_ALLOC(pHandCookie, HandTouchingFOVEdgeCookie);
03798             pHandCookie->handler = handler;
03799             pHandCookie->pUserCookie = pCookie;
03800 
03801             nRetVal = xnRegisterToHandTouchingFOVEdge(GetHandle(), HandTouchingFOVEdgeCB, pHandCookie, &pHandCookie->hCallback);
03802             if (nRetVal != XN_STATUS_OK)
03803             {
03804                 xnOSFree(pHandCookie);
03805                 return (nRetVal);
03806             }
03807 
03808             hCallback = pHandCookie;
03809 
03810             return (XN_STATUS_OK);
03811         }
03812 
03816         inline void UnregisterFromHandTouchingFOVEdge(XnCallbackHandle hCallback)
03817         {
03818             HandTouchingFOVEdgeCookie* pHandCookie = (HandTouchingFOVEdgeCookie*)hCallback;
03819             xnUnregisterFromHandTouchingFOVEdge(GetHandle(), pHandCookie->hCallback);
03820             xnOSFree(pHandCookie);
03821         }
03822     private:
03823         typedef struct HandTouchingFOVEdgeCookie
03824         {
03825             HandTouchingFOVEdge handler;
03826             void* pUserCookie;
03827             XnCallbackHandle hCallback;
03828         } HandTouchingFOVEdgeCookie;
03829 
03830         static void XN_CALLBACK_TYPE HandTouchingFOVEdgeCB(XnNodeHandle hNode, XnUserID user, const XnPoint3D* pPosition, XnFloat fTime, XnDirection eDir, void* pCookie)
03831         {
03832             HandTouchingFOVEdgeCookie* pHandCookie = (HandTouchingFOVEdgeCookie*)pCookie;
03833             HandTouchingFOVEdgeCapability cap(hNode);
03834             if (pHandCookie->handler != NULL)
03835             {
03836                 pHandCookie->handler(cap, user, pPosition, fTime, eDir, pHandCookie->pUserCookie);
03837             }
03838         }
03839 
03840     };
03845     class HandsGenerator : public Generator
03846     {
03847     public:
03853         inline HandsGenerator(XnNodeHandle hNode = NULL) : Generator(hNode) {}
03854         inline HandsGenerator(const NodeWrapper& other) : Generator(other) {}
03855 
03859         inline XnStatus Create(Context& context, Query* pQuery = NULL, EnumerationErrors* pErrors = NULL);
03860 
03870         typedef void (XN_CALLBACK_TYPE* HandCreate)(HandsGenerator& generator, XnUserID user, const XnPoint3D* pPosition, XnFloat fTime, void* pCookie);
03880         typedef void (XN_CALLBACK_TYPE* HandUpdate)(HandsGenerator& generator, XnUserID user, const XnPoint3D* pPosition, XnFloat fTime, void* pCookie);
03889         typedef void (XN_CALLBACK_TYPE* HandDestroy)(HandsGenerator& generator, XnUserID user, XnFloat fTime, void* pCookie);
03890 
03894         inline XnStatus RegisterHandCallbacks(HandCreate CreateCB, HandUpdate UpdateCB, HandDestroy DestroyCB, void* pCookie, XnCallbackHandle& hCallback)
03895         {
03896             XnStatus nRetVal = XN_STATUS_OK;
03897 
03898             HandCookie* pHandCookie;
03899             XN_VALIDATE_ALLOC(pHandCookie, HandCookie);
03900             pHandCookie->createHandler = CreateCB;
03901             pHandCookie->updateHandler = UpdateCB;
03902             pHandCookie->destroyHandler = DestroyCB;
03903             pHandCookie->pUserCookie = pCookie;
03904 
03905             nRetVal = xnRegisterHandCallbacks(GetHandle(), HandCreateCB, HandUpdateCB, HandDestroyCB, pHandCookie, &pHandCookie->hCallback);
03906             if (nRetVal != XN_STATUS_OK)
03907             {
03908                 xnOSFree(pHandCookie);
03909                 return (nRetVal);
03910             }
03911 
03912             hCallback = pHandCookie;
03913 
03914             return (XN_STATUS_OK);
03915         }
03916 
03920         inline void UnregisterHandCallbacks(XnCallbackHandle hCallback)
03921         {
03922             HandCookie* pHandCookie = (HandCookie*)hCallback;
03923             xnUnregisterHandCallbacks(GetHandle(), pHandCookie->hCallback);
03924             xnOSFree(pHandCookie);
03925         }
03926 
03930         inline XnStatus StopTracking(XnUserID user)
03931         {
03932             return xnStopTracking(GetHandle(), user);
03933         }
03934 
03938         inline XnStatus StopTrackingAll()
03939         {
03940             return xnStopTrackingAll(GetHandle());
03941         }
03942 
03946         inline XnStatus StartTracking(const XnPoint3D& ptPosition)
03947         {
03948             return xnStartTracking(GetHandle(), &ptPosition);
03949         }
03950 
03954         inline XnStatus SetSmoothing(XnFloat fSmoothingFactor)
03955         {
03956             return xnSetTrackingSmoothing(GetHandle(), fSmoothingFactor);
03957         }
03958 
03964         inline const HandTouchingFOVEdgeCapability GetHandTouchingFOVEdgeCap() const
03965         {
03966             return HandTouchingFOVEdgeCapability(GetHandle());
03967         }
03968 
03974         inline HandTouchingFOVEdgeCapability GetHandTouchingFOVEdgeCap()
03975         {
03976             return HandTouchingFOVEdgeCapability(GetHandle());
03977         }
03978 
03979     private:
03980         typedef struct HandCookie
03981         {
03982             HandCreate createHandler;
03983             HandUpdate updateHandler;
03984             HandDestroy destroyHandler;
03985             void* pUserCookie;
03986             XnCallbackHandle hCallback;
03987         } HandCookie;
03988 
03989         static void XN_CALLBACK_TYPE HandCreateCB(XnNodeHandle hNode, XnUserID user, const XnPoint3D* pPosition, XnFloat fTime, void* pCookie)
03990         {
03991             HandCookie* pHandCookie = (HandCookie*)pCookie;
03992             HandsGenerator gen(hNode);
03993             if (pHandCookie->createHandler != NULL)
03994             {
03995                 pHandCookie->createHandler(gen, user, pPosition, fTime, pHandCookie->pUserCookie);
03996             }
03997         }
03998         static void XN_CALLBACK_TYPE HandUpdateCB(XnNodeHandle hNode, XnUserID user, const XnPoint3D* pPosition, XnFloat fTime, void* pCookie)
03999         {
04000             HandCookie* pHandCookie = (HandCookie*)pCookie;
04001             HandsGenerator gen(hNode);
04002             if (pHandCookie->updateHandler != NULL)
04003             {
04004                 pHandCookie->updateHandler(gen, user, pPosition, fTime, pHandCookie->pUserCookie);
04005             }
04006         }
04007         static void XN_CALLBACK_TYPE HandDestroyCB(XnNodeHandle hNode, XnUserID user, XnFloat fTime, void* pCookie)
04008         {
04009             HandCookie* pHandCookie = (HandCookie*)pCookie;
04010             HandsGenerator gen(hNode);
04011             if (pHandCookie->destroyHandler != NULL)
04012             {
04013                 pHandCookie->destroyHandler(gen, user, fTime, pHandCookie->pUserCookie);
04014             }
04015         }
04016     };
04017 
04022     class SkeletonCapability : public Capability
04023     {
04024     public:
04030         inline SkeletonCapability(XnNodeHandle hNode) : Capability(hNode) {}
04031         SkeletonCapability(const NodeWrapper& node) : Capability(node) {}
04032 
04036         inline XnBool IsJointAvailable(XnSkeletonJoint eJoint) const
04037         {
04038             return xnIsJointAvailable(GetHandle(), eJoint);
04039         }
04040 
04044         inline XnBool IsProfileAvailable(XnSkeletonProfile eProfile) const
04045         {
04046             return xnIsProfileAvailable(GetHandle(), eProfile);
04047         }
04048 
04052         inline XnStatus SetSkeletonProfile(XnSkeletonProfile eProfile)
04053         {
04054             return xnSetSkeletonProfile(GetHandle(), eProfile);
04055         }
04056 
04060         inline XnStatus SetJointActive(XnSkeletonJoint eJoint, XnBool bState)
04061         {
04062             return xnSetJointActive(GetHandle(), eJoint, bState);
04063         }
04064 
04068         XN_API_DEPRECATED("Use the version with one argument") 
04069         inline XnBool IsJointActive(XnSkeletonJoint eJoint, XnBool /*bState*/) const
04070         {
04071             return xnIsJointActive(GetHandle(), eJoint);
04072         }
04073 
04077         inline XnBool IsJointActive(XnSkeletonJoint eJoint) const
04078         {
04079             return xnIsJointActive(GetHandle(), eJoint);
04080         }
04081 
04085         inline XnStatus RegisterToJointConfigurationChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
04086         {
04087             return _RegisterToStateChange(xnRegisterToJointConfigurationChange, GetHandle(), handler, pCookie, hCallback);
04088         }
04089 
04093         inline void UnregisterFromJointConfigurationChange(XnCallbackHandle hCallback)
04094         {
04095             _UnregisterFromStateChange(xnUnregisterFromJointConfigurationChange, GetHandle(), hCallback);
04096         }
04097 
04101         inline XnStatus EnumerateActiveJoints(XnSkeletonJoint* pJoints, XnUInt16& nJoints) const
04102         {
04103             return xnEnumerateActiveJoints(GetHandle(), pJoints, &nJoints);
04104         }
04105 
04109         inline XnStatus GetSkeletonJoint(XnUserID user, XnSkeletonJoint eJoint, XnSkeletonJointTransformation& Joint) const
04110         {
04111             return xnGetSkeletonJoint(GetHandle(), user, eJoint, &Joint);
04112         }
04113 
04117         inline XnStatus GetSkeletonJointPosition(XnUserID user, XnSkeletonJoint eJoint, XnSkeletonJointPosition& Joint) const
04118         {
04119             return xnGetSkeletonJointPosition(GetHandle(), user, eJoint, &Joint);
04120         }
04121 
04125         inline XnStatus GetSkeletonJointOrientation(XnUserID user, XnSkeletonJoint eJoint, XnSkeletonJointOrientation& Joint) const
04126         {
04127             return xnGetSkeletonJointOrientation(GetHandle(), user, eJoint, &Joint);
04128         }
04129 
04133         inline XnBool IsTracking(XnUserID user) const
04134         {
04135             return xnIsSkeletonTracking(GetHandle(), user);
04136         }
04137 
04141         inline XnBool IsCalibrated(XnUserID user) const
04142         {
04143 
04144             return xnIsSkeletonCalibrated(GetHandle(), user);
04145         }
04146 
04150         inline XnBool IsCalibrating(XnUserID user) const
04151         {
04152             return xnIsSkeletonCalibrating(GetHandle(), user);
04153         }
04154 
04158         inline XnStatus RequestCalibration(XnUserID user, XnBool bForce)
04159         {
04160             return xnRequestSkeletonCalibration(GetHandle(), user, bForce);
04161         }
04162 
04166         inline XnStatus AbortCalibration(XnUserID user)
04167         {
04168             return xnAbortSkeletonCalibration(GetHandle(), user);
04169         }
04170 
04174         inline XnStatus SaveCalibrationDataToFile(XnUserID user, const XnChar* strFileName)
04175         {
04176             return xnSaveSkeletonCalibrationDataToFile(GetHandle(), user, strFileName);
04177         }
04178 
04182         inline XnStatus LoadCalibrationDataFromFile(XnUserID user, const XnChar* strFileName)
04183         {
04184             return xnLoadSkeletonCalibrationDataFromFile(GetHandle(), user, strFileName);
04185         }
04186 
04190         inline XnStatus SaveCalibrationData(XnUserID user, XnUInt32 nSlot)
04191         {
04192             return xnSaveSkeletonCalibrationData(GetHandle(), user, nSlot);
04193         }
04194 
04198         inline XnStatus LoadCalibrationData(XnUserID user, XnUInt32 nSlot)
04199         {
04200             return xnLoadSkeletonCalibrationData(GetHandle(), user, nSlot);
04201         }
04202 
04206         inline XnStatus ClearCalibrationData(XnUInt32 nSlot)
04207         {
04208             return xnClearSkeletonCalibrationData(GetHandle(), nSlot);
04209         }
04210 
04214         inline XnBool IsCalibrationData(XnUInt32 nSlot) const
04215         {
04216             return xnIsSkeletonCalibrationData(GetHandle(), nSlot);
04217         }
04218 
04222         inline XnStatus StartTracking(XnUserID user)
04223         {
04224             return xnStartSkeletonTracking(GetHandle(), user);
04225         }
04226 
04230         inline XnStatus StopTracking(XnUserID user)
04231         {
04232             return xnStopSkeletonTracking(GetHandle(), user);
04233         }
04234 
04238         inline XnStatus Reset(XnUserID user)
04239         {
04240             return xnResetSkeleton(GetHandle(), user);
04241         }
04242 
04246         inline XnBool NeedPoseForCalibration() const
04247         {
04248             return xnNeedPoseForSkeletonCalibration(GetHandle());
04249         }
04250 
04254         inline XnStatus GetCalibrationPose(XnChar* strPose) const
04255         {
04256             return xnGetSkeletonCalibrationPose(GetHandle(), strPose);
04257         }
04258 
04262         inline XnStatus SetSmoothing(XnFloat fSmoothingFactor)
04263         {
04264             return xnSetSkeletonSmoothing(GetHandle(), fSmoothingFactor);
04265         }
04266 
04274         typedef void (XN_CALLBACK_TYPE* CalibrationStart)(SkeletonCapability& skeleton, XnUserID user, void* pCookie);
04283         typedef void (XN_CALLBACK_TYPE* CalibrationEnd)(SkeletonCapability& skeleton, XnUserID user, XnBool bSuccess, void* pCookie);
04284 
04288         inline XnStatus XN_API_DEPRECATED("Please use RegisterToCalibrationStart/Complete") RegisterCalibrationCallbacks(CalibrationStart CalibrationStartCB, CalibrationEnd CalibrationEndCB, void* pCookie, XnCallbackHandle& hCallback)
04289         {
04290             XnStatus nRetVal = XN_STATUS_OK;
04291 
04292             SkeletonCookie* pSkeletonCookie;
04293             XN_VALIDATE_ALLOC(pSkeletonCookie, SkeletonCookie);
04294             pSkeletonCookie->startHandler = CalibrationStartCB;
04295             pSkeletonCookie->endHandler = CalibrationEndCB;
04296             pSkeletonCookie->pUserCookie = pCookie;
04297 
04298 #pragma warning (push)
04299 #pragma warning (disable: XN_DEPRECATED_WARNING_IDS)
04300             nRetVal = xnRegisterCalibrationCallbacks(GetHandle(), CalibrationStartBundleCallback, CalibrationEndBundleCallback, pSkeletonCookie, &pSkeletonCookie->hCallback);
04301 #pragma warning (pop)
04302             if (nRetVal != XN_STATUS_OK)
04303             {
04304                 xnOSFree(pSkeletonCookie);
04305                 return (nRetVal);
04306             }
04307 
04308             hCallback = pSkeletonCookie;
04309 
04310             return (XN_STATUS_OK);
04311         }
04312 
04316         inline void XN_API_DEPRECATED("Please use UnregisterFromCalibrationStart/Complete") UnregisterCalibrationCallbacks(XnCallbackHandle hCallback)
04317         {
04318             SkeletonCookie* pSkeletonCookie = (SkeletonCookie*)hCallback;
04319 #pragma warning (push)
04320 #pragma warning (disable: XN_DEPRECATED_WARNING_IDS)
04321             xnUnregisterCalibrationCallbacks(GetHandle(), pSkeletonCookie->hCallback);
04322 #pragma warning (pop)
04323             xnOSFree(pSkeletonCookie);
04324         }
04325 
04329         inline XnStatus RegisterToCalibrationStart(CalibrationStart handler, void* pCookie, XnCallbackHandle& hCallback)
04330         {
04331             XnStatus nRetVal = XN_STATUS_OK;
04332             CalibrationStartCookie* pCalibrationCookie;
04333             XN_VALIDATE_ALLOC(pCalibrationCookie, CalibrationStartCookie);
04334             pCalibrationCookie->handler = handler;
04335             pCalibrationCookie->pUserCookie = pCookie;
04336             nRetVal = xnRegisterToCalibrationStart(GetHandle(), CalibrationStartCallback, pCalibrationCookie, &pCalibrationCookie->hCallback);
04337             if (nRetVal != XN_STATUS_OK)
04338             {
04339                 xnOSFree(pCalibrationCookie);
04340                 return nRetVal;
04341             }
04342             hCallback = pCalibrationCookie;
04343             return XN_STATUS_OK;
04344         }
04348         inline XnStatus UnregisterFromCalibrationStart(XnCallbackHandle hCallback)
04349         {
04350             CalibrationStartCookie* pCalibrationCookie = (CalibrationStartCookie*)hCallback;
04351             xnUnregisterFromCalibrationStart(GetHandle(), pCalibrationCookie->hCallback);
04352             xnOSFree(pCalibrationCookie);
04353             return XN_STATUS_OK;
04354         }
04355 
04364         typedef void (XN_CALLBACK_TYPE* CalibrationInProgress)(SkeletonCapability& skeleton, XnUserID user, XnCalibrationStatus calibrationError, void* pCookie);
04365 
04369         inline XnStatus RegisterToCalibrationInProgress(CalibrationInProgress handler, void* pCookie, XnCallbackHandle& hCallback)
04370         {
04371             XnStatus nRetVal = XN_STATUS_OK;
04372 
04373             CalibrationInProgressCookie* pSkeletonCookie;
04374             XN_VALIDATE_ALLOC(pSkeletonCookie, CalibrationInProgressCookie);
04375             pSkeletonCookie->handler = handler;
04376             pSkeletonCookie->pUserCookie = pCookie;
04377 
04378             nRetVal = xnRegisterToCalibrationInProgress(GetHandle(), CalibrationInProgressCallback, pSkeletonCookie, &pSkeletonCookie->hCallback);
04379             if (nRetVal != XN_STATUS_OK)
04380             {
04381                 xnOSFree(pSkeletonCookie);
04382                 return (nRetVal);
04383             }
04384 
04385             hCallback = pSkeletonCookie;
04386 
04387             return (XN_STATUS_OK);
04388         }
04389 
04393         inline void UnregisterFromCalibrationInProgress(XnCallbackHandle hCallback)
04394         {
04395             CalibrationInProgressCookie* pSkeletonCookie = (CalibrationInProgressCookie*)hCallback;
04396             xnUnregisterFromCalibrationInProgress(GetHandle(), pSkeletonCookie->hCallback);
04397             xnOSFree(pSkeletonCookie);
04398         }
04399 
04408         typedef void (XN_CALLBACK_TYPE* CalibrationComplete)(SkeletonCapability& skeleton, XnUserID user, XnCalibrationStatus calibrationError, void* pCookie);
04412         inline XnStatus RegisterToCalibrationComplete(CalibrationComplete handler, void* pCookie, XnCallbackHandle& hCallback)
04413         {
04414             XnStatus nRetVal = XN_STATUS_OK;
04415 
04416             CalibrationCompleteCookie* pSkeletonCookie;
04417             XN_VALIDATE_ALLOC(pSkeletonCookie, CalibrationCompleteCookie);
04418             pSkeletonCookie->handler = handler;
04419             pSkeletonCookie->pUserCookie = pCookie;
04420 
04421             nRetVal = xnRegisterToCalibrationComplete(GetHandle(), CalibrationCompleteCallback, pSkeletonCookie, &pSkeletonCookie->hCallback);
04422             if (nRetVal != XN_STATUS_OK)
04423             {
04424                 xnOSFree(pSkeletonCookie);
04425                 return (nRetVal);
04426             }
04427 
04428             hCallback = pSkeletonCookie;
04429 
04430             return (XN_STATUS_OK);
04431         }
04432 
04436         inline void UnregisterFromCalibrationComplete(XnCallbackHandle hCallback)
04437         {
04438             CalibrationCompleteCookie* pSkeletonCookie = (CalibrationCompleteCookie*)hCallback;
04439             xnUnregisterFromCalibrationComplete(GetHandle(), pSkeletonCookie->hCallback);
04440             xnOSFree(pSkeletonCookie);
04441         }
04442     private:
04443         typedef struct SkeletonCookie
04444         {
04445             CalibrationStart startHandler;
04446             CalibrationEnd endHandler;
04447             void* pUserCookie;
04448             XnCallbackHandle hCallback;
04449         } SkeletonCookie;
04450 
04451         static void XN_CALLBACK_TYPE CalibrationStartBundleCallback(XnNodeHandle hNode, XnUserID user, void* pCookie)
04452         {
04453             SkeletonCookie* pSkeletonCookie = (SkeletonCookie*)pCookie;
04454             SkeletonCapability cap(hNode);
04455             if (pSkeletonCookie->startHandler != NULL)
04456             {
04457                 pSkeletonCookie->startHandler(cap, user, pSkeletonCookie->pUserCookie);
04458             }
04459         }
04460 
04461         static void XN_CALLBACK_TYPE CalibrationEndBundleCallback(XnNodeHandle hNode, XnUserID user, XnBool bSuccess, void* pCookie)
04462         {
04463             SkeletonCookie* pSkeletonCookie = (SkeletonCookie*)pCookie;
04464             SkeletonCapability cap(hNode);
04465             if (pSkeletonCookie->endHandler != NULL)
04466             {
04467                 pSkeletonCookie->endHandler(cap, user, bSuccess, pSkeletonCookie->pUserCookie);
04468             }
04469         }
04470         typedef struct CalibrationStartCookie
04471         {
04472             CalibrationStart handler;
04473             void* pUserCookie;
04474             XnCallbackHandle hCallback;
04475         } CalibrationStartCookie;
04476 
04477         static void XN_CALLBACK_TYPE CalibrationStartCallback(XnNodeHandle hNode, XnUserID user, void* pCookie)
04478         {
04479             CalibrationStartCookie* pCalibrationCookie = (CalibrationStartCookie*)pCookie;
04480             SkeletonCapability cap(hNode);
04481             if (pCalibrationCookie->handler != NULL)
04482             {
04483                 pCalibrationCookie->handler(cap, user, pCalibrationCookie->pUserCookie);
04484             }
04485         }
04486         typedef struct CalibrationInProgressCookie
04487         {
04488             CalibrationInProgress handler;
04489             void* pUserCookie;
04490             XnCallbackHandle hCallback;
04491         } CalibrationInProgressCookie;
04492 
04493         static void XN_CALLBACK_TYPE CalibrationInProgressCallback(XnNodeHandle hNode, XnUserID user, XnCalibrationStatus calibrationError, void* pCookie)
04494         {
04495             CalibrationInProgressCookie* pSkeletonCookie = (CalibrationInProgressCookie*)pCookie;
04496             SkeletonCapability cap(hNode);
04497             if (pSkeletonCookie->handler != NULL)
04498             {
04499                 pSkeletonCookie->handler(cap, user, calibrationError, pSkeletonCookie->pUserCookie);
04500             }
04501         }
04502 
04503         typedef struct CalibrationCompleteCookie
04504         {
04505             CalibrationComplete handler;
04506             void* pUserCookie;
04507             XnCallbackHandle hCallback;
04508         } CalibrationCompleteCookie;
04509 
04510         static void XN_CALLBACK_TYPE CalibrationCompleteCallback(XnNodeHandle hNode, XnUserID user, XnCalibrationStatus calibrationError, void* pCookie)
04511         {
04512             CalibrationCompleteCookie* pSkeletonCookie = (CalibrationCompleteCookie*)pCookie;
04513             SkeletonCapability cap(hNode);
04514             if (pSkeletonCookie->handler != NULL)
04515             {
04516                 pSkeletonCookie->handler(cap, user, calibrationError, pSkeletonCookie->pUserCookie);
04517             }
04518         }
04519     };
04520 
04525     class PoseDetectionCapability : public Capability
04526     {
04527     public:
04533         inline PoseDetectionCapability(XnNodeHandle hNode) : Capability(hNode) {}
04534         PoseDetectionCapability(const NodeWrapper& node) : Capability(node) {}
04535 
04544         typedef void (XN_CALLBACK_TYPE* PoseDetection)(PoseDetectionCapability& pose, const XnChar* strPose, XnUserID user, void* pCookie);
04545 
04549         inline XnUInt32 GetNumberOfPoses() const
04550         {
04551             return xnGetNumberOfPoses(GetHandle());
04552         }
04553 
04557         inline XnStatus GetAvailablePoses(XnChar** pstrPoses, XnUInt32& nPoses) const
04558         {
04559             return xnGetAvailablePoses(GetHandle(), pstrPoses, &nPoses);
04560         }
04564         inline XnStatus GetAllAvailablePoses(XnChar** pstrPoses, XnUInt32 nNameLength, XnUInt32& nPoses) const
04565         {
04566             return xnGetAllAvailablePoses(GetHandle(), pstrPoses, nNameLength, &nPoses);
04567         }
04568 
04572         inline XnStatus StartPoseDetection(const XnChar* strPose, XnUserID user)
04573         {
04574             return xnStartPoseDetection(GetHandle(), strPose, user);
04575         }
04576 
04580         inline XnStatus StopPoseDetection(XnUserID user)
04581         {
04582             return xnStopPoseDetection(GetHandle(), user);
04583         }
04584 
04588         inline XnStatus XN_API_DEPRECATED("Please use RegisterToPoseDetected/RegisterToOutOfPose instead") RegisterToPoseCallbacks(PoseDetection PoseStartCB, PoseDetection PoseEndCB, void* pCookie, XnCallbackHandle& hCallback)
04589         {
04590             XnStatus nRetVal = XN_STATUS_OK;
04591 
04592             PoseCookie* pPoseCookie;
04593             XN_VALIDATE_ALLOC(pPoseCookie, PoseCookie);
04594             pPoseCookie->startHandler = PoseStartCB;
04595             pPoseCookie->endHandler = PoseEndCB;
04596             pPoseCookie->pPoseCookie = pCookie;
04597 
04598 #pragma warning (push)
04599 #pragma warning (disable: XN_DEPRECATED_WARNING_IDS)
04600             nRetVal = xnRegisterToPoseCallbacks(GetHandle(), PoseDetectionStartBundleCallback, PoseDetectionStartEndBundleCallback, pPoseCookie, &pPoseCookie->hCallback);
04601 #pragma warning (pop)
04602             if (nRetVal != XN_STATUS_OK)
04603             {
04604                 xnOSFree(pPoseCookie);
04605                 return (nRetVal);
04606             }
04607 
04608             hCallback = pPoseCookie;
04609 
04610             return (XN_STATUS_OK);
04611         }
04612 
04616         inline void XN_API_DEPRECATED("Please use UnregisterFromPoseDetected/UnregisterFromOutOfPose instead") UnregisterFromPoseCallbacks(XnCallbackHandle hCallback)
04617         {
04618             PoseCookie* pPoseCookie = (PoseCookie*)hCallback;
04619 #pragma warning (push)
04620 #pragma warning (disable: XN_DEPRECATED_WARNING_IDS)
04621             xnUnregisterFromPoseCallbacks(GetHandle(), pPoseCookie->hCallback);
04622 #pragma warning (pop)
04623             xnOSFree(pPoseCookie);
04624         }
04625 
04629         inline XnStatus RegisterToPoseDetected(PoseDetection handler, void* pCookie, XnCallbackHandle& hCallback)
04630         {
04631             XnStatus nRetVal = XN_STATUS_OK;
04632             PoseDetectionCookie* pPoseCookie;
04633             XN_VALIDATE_ALLOC(pPoseCookie, PoseDetectionCookie);
04634             pPoseCookie->handler = handler;
04635             pPoseCookie->pPoseCookie = pCookie;
04636 
04637             nRetVal = xnRegisterToPoseDetected(GetHandle(), PoseDetectionCallback, pPoseCookie, &pPoseCookie->hCallback);
04638             if (nRetVal != XN_STATUS_OK)
04639             {
04640                 xnOSFree(pPoseCookie);
04641                 return nRetVal;
04642             }
04643             hCallback = pPoseCookie;
04644             return XN_STATUS_OK;
04645         }
04649         inline XnStatus RegisterToOutOfPose(PoseDetection handler, void* pCookie, XnCallbackHandle& hCallback)
04650         {
04651             XnStatus nRetVal = XN_STATUS_OK;
04652             PoseDetectionCookie* pPoseCookie;
04653             XN_VALIDATE_ALLOC(pPoseCookie, PoseDetectionCookie);
04654             pPoseCookie->handler = handler;
04655             pPoseCookie->pPoseCookie = pCookie;
04656 
04657             nRetVal = xnRegisterToOutOfPose(GetHandle(), PoseDetectionCallback, pPoseCookie, &pPoseCookie->hCallback);
04658             if (nRetVal != XN_STATUS_OK)
04659             {
04660                 xnOSFree(pPoseCookie);
04661                 return nRetVal;
04662             }
04663             hCallback = pPoseCookie;
04664             return XN_STATUS_OK;
04665         }
04669         inline void UnregisterFromPoseDetected(XnCallbackHandle hCallback)
04670         {
04671             PoseDetectionCookie* pPoseCookie = (PoseDetectionCookie*)hCallback;
04672             xnUnregisterFromPoseDetected(GetHandle(), pPoseCookie->hCallback);
04673             xnOSFree(pPoseCookie);
04674         }
04678         inline void UnregisterFromOutOfPose(XnCallbackHandle hCallback)
04679         {
04680             PoseDetectionCookie* pPoseCookie = (PoseDetectionCookie*)hCallback;
04681             xnUnregisterFromOutOfPose(GetHandle(), pPoseCookie->hCallback);
04682             xnOSFree(pPoseCookie);
04683         }
04684 
04694         typedef void (XN_CALLBACK_TYPE* PoseInProgress)(PoseDetectionCapability& pose, const XnChar* strPose, XnUserID user, XnPoseDetectionStatus poseError, void* pCookie);
04698         inline XnStatus RegisterToPoseInProgress(PoseInProgress handler, void* pCookie, XnCallbackHandle& hCallback)
04699         {
04700             XnStatus nRetVal = XN_STATUS_OK;
04701 
04702             PoseInProgressCookie* pPoseCookie;
04703             XN_VALIDATE_ALLOC(pPoseCookie, PoseInProgressCookie);
04704             pPoseCookie->handler = handler;
04705             pPoseCookie->pPoseCookie = pCookie;
04706 
04707             nRetVal = xnRegisterToPoseDetectionInProgress(GetHandle(), PoseDetectionInProgressCallback, pPoseCookie, &pPoseCookie->hCallback);
04708             if (nRetVal != XN_STATUS_OK)
04709             {
04710                 xnOSFree(pPoseCookie);
04711                 return (nRetVal);
04712             }
04713 
04714             hCallback = pPoseCookie;
04715 
04716             return (XN_STATUS_OK);
04717         }
04718 
04722         inline void UnregisterFromPoseInProgress(XnCallbackHandle hCallback)
04723         {
04724             PoseInProgressCookie* pPoseCookie = (PoseInProgressCookie*)hCallback;
04725             xnUnregisterFromPoseDetectionInProgress(GetHandle(), pPoseCookie->hCallback);
04726             xnOSFree(pPoseCookie);
04727         }
04728 
04729     private:
04730         typedef struct PoseCookie
04731         {
04732             PoseDetection startHandler;
04733             PoseDetection endHandler;
04734             void* pPoseCookie;
04735             XnCallbackHandle hCallback;
04736         } PoseCookie;
04737 
04738         static void XN_CALLBACK_TYPE PoseDetectionStartBundleCallback(XnNodeHandle hNode, const XnChar* strPose, XnUserID user, void* pCookie)
04739         {
04740             PoseCookie* pPoseCookie = (PoseCookie*)pCookie;
04741             PoseDetectionCapability cap(hNode);
04742             if (pPoseCookie->startHandler != NULL)
04743             {
04744                 pPoseCookie->startHandler(cap, strPose, user, pPoseCookie->pPoseCookie);
04745             }
04746         }
04747 
04748         static void XN_CALLBACK_TYPE PoseDetectionStartEndBundleCallback(XnNodeHandle hNode, const XnChar* strPose, XnUserID user, void* pCookie)
04749         {
04750             PoseCookie* pPoseCookie = (PoseCookie*)pCookie;
04751             PoseDetectionCapability cap(hNode);
04752             if (pPoseCookie->endHandler != NULL)
04753             {
04754                 pPoseCookie->endHandler(cap, strPose, user, pPoseCookie->pPoseCookie);
04755             }
04756         }
04757         typedef struct PoseDetectionCookie
04758         {
04759             PoseDetection handler;
04760             void* pPoseCookie;
04761             XnCallbackHandle hCallback;
04762         } PoseDetectionCookie;
04763         static void XN_CALLBACK_TYPE PoseDetectionCallback(XnNodeHandle hNode, const XnChar* strPose, XnUserID user, void* pCookie)
04764         {
04765             PoseDetectionCookie* pPoseDetectionCookie = (PoseDetectionCookie*)pCookie;
04766             PoseDetectionCapability cap(hNode);
04767             if (pPoseDetectionCookie->handler != NULL)
04768             {
04769                 pPoseDetectionCookie->handler(cap, strPose, user, pPoseDetectionCookie->pPoseCookie);
04770             }
04771         }
04772 
04773         typedef struct PoseInProgressCookie
04774         {
04775             PoseInProgress handler;
04776             void* pPoseCookie;
04777             XnCallbackHandle hCallback;
04778         } PoseInProgressCookie;
04779 
04780         static void XN_CALLBACK_TYPE PoseDetectionInProgressCallback(XnNodeHandle hNode, const XnChar* strPose, XnUserID user, XnPoseDetectionStatus poseErrors, void* pCookie)
04781         {
04782             PoseInProgressCookie* pPoseCookie = (PoseInProgressCookie*)pCookie;
04783             PoseDetectionCapability cap(hNode);
04784             if (pPoseCookie->handler != NULL)
04785             {
04786                 pPoseCookie->handler(cap, strPose, user, poseErrors, pPoseCookie->pPoseCookie);
04787             }
04788         }
04789     };
04790 
04795     class UserGenerator : public Generator
04796     {
04797     public:
04803         inline UserGenerator(XnNodeHandle hNode = NULL) : Generator(hNode) {}
04804         inline UserGenerator(const NodeWrapper& other) : Generator(other) {}
04805 
04809         inline XnStatus Create(Context& context, Query* pQuery = NULL, EnumerationErrors* pErrors = NULL);
04810 
04811         typedef void (XN_CALLBACK_TYPE* UserHandler)(UserGenerator& generator, XnUserID user, void* pCookie);
04812 
04816         inline XnUInt16 GetNumberOfUsers() const
04817         {
04818             return xnGetNumberOfUsers(GetHandle());
04819         }
04820 
04824         inline XnStatus GetUsers(XnUserID aUsers[], XnUInt16& nUsers) const
04825         {
04826             return xnGetUsers(GetHandle(), aUsers, &nUsers);
04827         }
04828 
04832         inline XnStatus GetCoM(XnUserID user, XnPoint3D& com) const
04833         {
04834             return xnGetUserCoM(GetHandle(), user, &com);
04835         }
04836 
04840         inline XnStatus GetUserPixels(XnUserID user, SceneMetaData& smd) const
04841         {
04842             return xnGetUserPixels(GetHandle(), user, smd.GetUnderlying());
04843         }
04844         
04848         inline XnStatus RegisterUserCallbacks(UserHandler NewUserCB, UserHandler LostUserCB, void* pCookie, XnCallbackHandle& hCallback)
04849         {
04850             XnStatus nRetVal = XN_STATUS_OK;
04851 
04852             UserCookie* pUserCookie;
04853             XN_VALIDATE_ALLOC(pUserCookie, UserCookie);
04854             pUserCookie->newHandler = NewUserCB;
04855             pUserCookie->lostHandler = LostUserCB;
04856             pUserCookie->pUserCookie = pCookie;
04857 
04858             nRetVal = xnRegisterUserCallbacks(GetHandle(), NewUserCallback, LostUserCallback, pUserCookie, &pUserCookie->hCallback);
04859             if (nRetVal != XN_STATUS_OK)
04860             {
04861                 xnOSFree(pUserCookie);
04862                 return (nRetVal);
04863             }
04864 
04865             hCallback = pUserCookie;
04866 
04867             return (XN_STATUS_OK);
04868         }
04869 
04873         inline void UnregisterUserCallbacks(XnCallbackHandle hCallback)
04874         {
04875             UserCookie* pUserCookie = (UserCookie*)hCallback;
04876             xnUnregisterUserCallbacks(GetHandle(), pUserCookie->hCallback);
04877             xnOSFree(pUserCookie);
04878         }
04879 
04885         inline const SkeletonCapability GetSkeletonCap() const
04886         {
04887             return SkeletonCapability(GetHandle());
04888         }
04889 
04895         inline SkeletonCapability GetSkeletonCap()
04896         {
04897             return SkeletonCapability(GetHandle());
04898         }
04899 
04905         inline const PoseDetectionCapability GetPoseDetectionCap() const
04906         {
04907             return PoseDetectionCapability(GetHandle());
04908         }
04909 
04915         inline PoseDetectionCapability GetPoseDetectionCap()
04916         {
04917             return PoseDetectionCapability(GetHandle());
04918         }
04919 
04923         inline XnStatus RegisterToUserExit(UserHandler handler, void* pCookie, XnCallbackHandle& hCallback)
04924         {
04925             XnStatus nRetVal = XN_STATUS_OK;
04926 
04927             UserSingleCookie* pUserCookie;
04928             XN_VALIDATE_ALLOC(pUserCookie, UserSingleCookie);
04929             pUserCookie->handler = handler;
04930             pUserCookie->pUserCookie = pCookie;
04931 
04932             nRetVal = xnRegisterToUserExit(GetHandle(), UserSingleCallback, pUserCookie, &pUserCookie->hCallback);
04933             if (nRetVal != XN_STATUS_OK)
04934             {
04935                 xnOSFree(pUserCookie);
04936                 return (nRetVal);
04937             }
04938 
04939             hCallback = pUserCookie;
04940 
04941             return (XN_STATUS_OK);
04942         }
04943 
04947         inline void UnregisterFromUserExit(XnCallbackHandle hCallback)
04948         {
04949             UserSingleCookie* pUserCookie = (UserSingleCookie*)hCallback;
04950             xnUnregisterFromUserExit(GetHandle(), pUserCookie->hCallback);
04951             xnOSFree(pUserCookie);
04952         }
04953 
04957         inline XnStatus RegisterToUserReEnter(UserHandler handler, void* pCookie, XnCallbackHandle& hCallback)
04958         {
04959             XnStatus nRetVal = XN_STATUS_OK;
04960 
04961             UserSingleCookie* pUserCookie;
04962             XN_VALIDATE_ALLOC(pUserCookie, UserSingleCookie);
04963             pUserCookie->handler = handler;
04964             pUserCookie->pUserCookie = pCookie;
04965 
04966             nRetVal = xnRegisterToUserReEnter(GetHandle(), UserSingleCallback, pUserCookie, &pUserCookie->hCallback);
04967             if (nRetVal != XN_STATUS_OK)
04968             {
04969                 xnOSFree(pUserCookie);
04970                 return (nRetVal);
04971             }
04972 
04973             hCallback = pUserCookie;
04974 
04975             return (XN_STATUS_OK);
04976         }
04977 
04981         inline void UnregisterFromUserReEnter(XnCallbackHandle hCallback)
04982         {
04983             UserSingleCookie* pUserCookie = (UserSingleCookie*)hCallback;
04984             xnUnregisterFromUserReEnter(GetHandle(), pUserCookie->hCallback);
04985             xnOSFree(pUserCookie);
04986         }
04987 
04988     private:
04989         typedef struct UserCookie
04990         {
04991             UserHandler newHandler;
04992             UserHandler lostHandler;
04993             void* pUserCookie;
04994             XnCallbackHandle hCallback;
04995         } UserCookie;
04996 
04997         static void XN_CALLBACK_TYPE NewUserCallback(XnNodeHandle hNode, XnUserID user, void* pCookie)
04998         {
04999             UserCookie* pUserCookie = (UserCookie*)pCookie;
05000             UserGenerator gen(hNode);
05001             if (pUserCookie->newHandler != NULL)
05002             {
05003                 pUserCookie->newHandler(gen, user, pUserCookie->pUserCookie);
05004             }
05005         }
05006 
05007         static void XN_CALLBACK_TYPE LostUserCallback(XnNodeHandle hNode, XnUserID user, void* pCookie)
05008         {
05009             UserCookie* pUserCookie = (UserCookie*)pCookie;
05010             UserGenerator gen(hNode);
05011             if (pUserCookie->lostHandler != NULL)
05012             {
05013                 pUserCookie->lostHandler(gen, user, pUserCookie->pUserCookie);
05014             }
05015         }
05016 
05017         typedef struct UserSingleCookie
05018         {
05019             UserHandler handler;
05020             void* pUserCookie;
05021             XnCallbackHandle hCallback;
05022         } UserSingleCookie;
05023 
05024         static void XN_CALLBACK_TYPE UserSingleCallback(XnNodeHandle hNode, XnUserID user, void* pCookie)
05025         {
05026             UserSingleCookie* pUserCookie = (UserSingleCookie*)pCookie;
05027             UserGenerator gen(hNode);
05028             if (pUserCookie->handler != NULL)
05029             {
05030                 pUserCookie->handler(gen, user, pUserCookie->pUserCookie);
05031             }
05032         }
05033     };
05034 
05039     class AudioGenerator : public Generator
05040     {
05041     public:
05047         inline AudioGenerator(XnNodeHandle hNode = NULL) : Generator(hNode) {}
05048         inline AudioGenerator(const NodeWrapper& other) : Generator(other) {}
05049 
05053         inline XnStatus Create(Context& context, Query* pQuery = NULL, EnumerationErrors* pErrors = NULL);
05054 
05058         inline void GetMetaData(AudioMetaData& metaData) const
05059         {
05060             xnGetAudioMetaData(GetHandle(), metaData.GetUnderlying());
05061         }
05062 
05066         inline const XnUChar* GetAudioBuffer() const
05067         {
05068             return xnGetAudioBuffer(GetHandle());
05069         }
05070 
05074         inline XnUInt32 GetSupportedWaveOutputModesCount() const
05075         {
05076             return xnGetSupportedWaveOutputModesCount(GetHandle());
05077         }
05078 
05082         inline XnStatus GetSupportedWaveOutputModes(XnWaveOutputMode* aSupportedModes, XnUInt32& nCount) const
05083         {
05084             return xnGetSupportedWaveOutputModes(GetHandle(), aSupportedModes, &nCount);
05085         }
05086 
05090         inline XnStatus SetWaveOutputMode(const XnWaveOutputMode& OutputMode)
05091         {
05092             return xnSetWaveOutputMode(GetHandle(), &OutputMode);
05093         }
05094 
05098         inline XnStatus GetWaveOutputMode(XnWaveOutputMode& OutputMode) const
05099         {
05100             return xnGetWaveOutputMode(GetHandle(), &OutputMode);
05101         }
05102 
05106         inline XnStatus RegisterToWaveOutputModeChanges(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
05107         {
05108             return _RegisterToStateChange(xnRegisterToWaveOutputModeChanges, GetHandle(), handler, pCookie, hCallback);
05109         }
05110 
05114         inline void UnregisterFromWaveOutputModeChanges(XnCallbackHandle hCallback)
05115         {
05116             _UnregisterFromStateChange(xnUnregisterFromWaveOutputModeChanges, GetHandle(), hCallback);
05117         }
05118     };
05119 
05124     class MockAudioGenerator : public AudioGenerator
05125     {
05126     public:
05132         inline MockAudioGenerator(XnNodeHandle hNode = NULL) : AudioGenerator(hNode) {}
05133         inline MockAudioGenerator(const NodeWrapper& other) : AudioGenerator(other) {}
05134 
05141         XnStatus Create(Context& context, const XnChar* strName = NULL);
05142 
05149         XnStatus CreateBasedOn(AudioGenerator& other, const XnChar* strName = NULL);
05150 
05154         inline XnStatus SetData(XnUInt32 nFrameID, XnUInt64 nTimestamp, XnUInt32 nDataSize, const XnUInt8* pAudioBuffer)
05155         {
05156             return xnMockAudioSetData(GetHandle(), nFrameID, nTimestamp, nDataSize, pAudioBuffer);
05157         }
05158 
05166         inline XnStatus SetData(const AudioMetaData& audioMD, XnUInt32 nFrameID, XnUInt64 nTimestamp)
05167         {
05168             return SetData(nFrameID, nTimestamp, audioMD.DataSize(), audioMD.Data());
05169         }
05170 
05176         inline XnStatus SetData(const AudioMetaData& audioMD)
05177         {
05178             return SetData(audioMD, audioMD.FrameID(), audioMD.Timestamp());
05179         }
05180     };
05181 
05182     class MockRawGenerator : public Generator
05183     {
05184     public:
05185         MockRawGenerator(XnNodeHandle hNode = NULL) : Generator(hNode) {}
05186         MockRawGenerator(const NodeWrapper& other) : Generator(other) {}
05187 
05188         inline XnStatus Create(Context& context, const XnChar* strName = NULL);
05189 
05190         inline XnStatus SetData(XnUInt32 nFrameID, XnUInt64 nTimestamp, XnUInt32 nDataSize, const void* pData)
05191         {
05192             return xnMockRawSetData(GetHandle(), nFrameID, nTimestamp, nDataSize, pData);
05193         }
05194 
05195     };
05196 
05201     class Codec : public ProductionNode
05202     {
05203     public:
05209         inline Codec(XnNodeHandle hNode = NULL) : ProductionNode(hNode) {}
05210         inline Codec(const NodeWrapper& other) : ProductionNode(other) {}
05211 
05215         inline XnStatus Create(Context& context, XnCodecID codecID, ProductionNode& initializerNode);
05216 
05220         inline XnCodecID GetCodecID() const
05221         {
05222             return xnGetCodecID(GetHandle());
05223         }
05224 
05228         inline XnStatus EncodeData(const void* pSrc, XnUInt32 nSrcSize, void* pDst, XnUInt32 nDstSize, XnUInt* pnBytesWritten) const
05229         {
05230             return xnEncodeData(GetHandle(), pSrc, nSrcSize, pDst, nDstSize, pnBytesWritten);
05231         }
05232 
05236         inline XnStatus DecodeData(const void* pSrc, XnUInt32 nSrcSize, void* pDst, XnUInt32 nDstSize, XnUInt* pnBytesWritten) const
05237         {
05238             return xnDecodeData(GetHandle(), pSrc, nSrcSize, pDst, nDstSize, pnBytesWritten);
05239         }
05240     };
05241 
05246     class ScriptNode : public ProductionNode
05247     {
05248     public:
05254         inline ScriptNode(XnNodeHandle hNode = NULL) : ProductionNode(hNode) {}
05255         inline ScriptNode(const NodeWrapper& other) : ProductionNode(other) {}
05256 
05257         inline const XnChar* GetSupportedFormat()
05258         {
05259             return xnScriptNodeGetSupportedFormat(GetHandle());
05260         }
05261 
05262         inline XnStatus LoadScriptFromFile(const XnChar* strFileName)
05263         {
05264             return xnLoadScriptFromFile(GetHandle(), strFileName);
05265         }
05266 
05267         inline XnStatus LoadScriptFromString(const XnChar* strScript)
05268         {
05269             return xnLoadScriptFromString(GetHandle(), strScript);
05270         }
05271 
05272         inline XnStatus Run(EnumerationErrors* pErrors);
05273     };
05274 
05275     //---------------------------------------------------------------------------
05276     // EnumerationErrors
05277     //---------------------------------------------------------------------------
05282     class EnumerationErrors
05283     {
05284     public:
05286         inline EnumerationErrors() : m_pErrors(NULL), m_bAllocated(TRUE) { xnEnumerationErrorsAllocate(&m_pErrors); }
05287 
05294         inline EnumerationErrors(XnEnumerationErrors* pErrors, XnBool bOwn = FALSE) : m_pErrors(pErrors), m_bAllocated(bOwn) {}
05295 
05297         ~EnumerationErrors() { Free(); }
05298 
05300         class Iterator
05301         {
05302         public:
05303             friend class EnumerationErrors;
05304 
05310             XnBool operator==(const Iterator& other) const
05311             {
05312                 return m_it == other.m_it;
05313             }
05314 
05320             XnBool operator!=(const Iterator& other) const
05321             {
05322                 return m_it != other.m_it;
05323             }
05324 
05329             inline Iterator& operator++()
05330             {
05331                 m_it = xnEnumerationErrorsGetNext(m_it);
05332                 return *this;
05333             }
05334 
05339             inline Iterator operator++(int)
05340             {
05341                 return Iterator(xnEnumerationErrorsGetNext(m_it));
05342             }
05343 
05345             inline const XnProductionNodeDescription& Description() { return *xnEnumerationErrorsGetCurrentDescription(m_it); }
05347             inline XnStatus Error() { return xnEnumerationErrorsGetCurrentError(m_it); }
05348 
05349         private:
05350             inline Iterator(XnEnumerationErrorsIterator it) : m_it(it) {}
05351 
05352             XnEnumerationErrorsIterator m_it;
05353         };
05354 
05356         inline Iterator Begin() const { return Iterator(xnEnumerationErrorsGetFirst(m_pErrors)); } 
05358         inline Iterator End() const { return Iterator(NULL); } 
05359 
05363         inline XnStatus ToString(XnChar* csBuffer, XnUInt32 nSize)
05364         {
05365             return xnEnumerationErrorsToString(m_pErrors, csBuffer, nSize);
05366         }
05367 
05371         inline void Free()
05372         {
05373             if (m_bAllocated)
05374             {
05375                 xnEnumerationErrorsFree(m_pErrors);
05376                 m_pErrors = NULL;
05377                 m_bAllocated = FALSE;
05378             }
05379         }
05380 
05382         inline XnEnumerationErrors* GetUnderlying() { return m_pErrors; }
05383 
05384     private:
05385         XnEnumerationErrors* m_pErrors;
05386         XnBool m_bAllocated;
05387     };
05388 
05389     //---------------------------------------------------------------------------
05390     // Context
05391     //---------------------------------------------------------------------------
05392 
05397     class Context
05398     {
05399     public:
05401         inline Context() : m_pContext(NULL), m_bUsingDeprecatedAPI(FALSE), m_bAllocated(FALSE), m_hShuttingDownCallback(NULL) {}
05402 
05408         inline Context(XnContext* pContext) : m_pContext(NULL), m_bUsingDeprecatedAPI(FALSE), m_bAllocated(FALSE), m_hShuttingDownCallback(NULL)
05409         {
05410             SetHandle(pContext);
05411         }
05412 
05419         inline Context(const Context& other) : m_pContext(NULL), m_bUsingDeprecatedAPI(FALSE), m_bAllocated(FALSE), m_hShuttingDownCallback(NULL)
05420         {
05421             SetHandle(other.m_pContext);
05422         }
05423 
05425         ~Context() 
05426         { 
05427             SetHandle(NULL);
05428         }
05429 
05430         inline Context& operator=(const Context& other)
05431         {
05432             SetHandle(other.m_pContext);
05433             return *this;
05434         }
05435 
05437         inline XnContext* GetUnderlyingObject() const { return m_pContext; }
05438 
05442         inline XnStatus Init()
05443         {
05444             XnContext* pContext = NULL;
05445             XnStatus nRetVal = xnInit(&pContext);
05446             XN_IS_STATUS_OK(nRetVal);
05447 
05448             TakeOwnership(pContext);
05449             m_bAllocated = TRUE;
05450 
05451             return (XN_STATUS_OK);
05452         }
05453 
05457         inline XnStatus XN_API_DEPRECATED("Use other overload!") RunXmlScript(const XnChar* strScript, EnumerationErrors* pErrors = NULL)
05458         {
05459             m_bUsingDeprecatedAPI = TRUE;
05460             #pragma warning (push)
05461             #pragma warning (disable: XN_DEPRECATED_WARNING_IDS)
05462             return xnContextRunXmlScript(m_pContext, strScript, pErrors == NULL ? NULL : pErrors->GetUnderlying());
05463             #pragma warning (pop)
05464         }
05465 
05469         inline XnStatus RunXmlScript(const XnChar* strScript, ScriptNode& scriptNode, EnumerationErrors* pErrors = NULL)
05470         {
05471             XnStatus nRetVal = XN_STATUS_OK;
05472             
05473             XnNodeHandle hScriptNode;
05474             nRetVal = xnContextRunXmlScriptEx(m_pContext, strScript, pErrors == NULL ? NULL : pErrors->GetUnderlying(), &hScriptNode);
05475             XN_IS_STATUS_OK(nRetVal);
05476 
05477             scriptNode.TakeOwnership(hScriptNode);
05478             
05479             return (XN_STATUS_OK);
05480         }
05481 
05485         inline XnStatus XN_API_DEPRECATED("Use other overload!") RunXmlScriptFromFile(const XnChar* strFileName, EnumerationErrors* pErrors = NULL)
05486         {
05487             m_bUsingDeprecatedAPI = TRUE;
05488             #pragma warning (push)
05489             #pragma warning (disable: XN_DEPRECATED_WARNING_IDS)
05490             return xnContextRunXmlScriptFromFile(m_pContext, strFileName, pErrors == NULL ? NULL : pErrors->GetUnderlying());
05491             #pragma warning (pop)
05492         }
05493 
05497         inline XnStatus RunXmlScriptFromFile(const XnChar* strFileName, ScriptNode& scriptNode, EnumerationErrors* pErrors = NULL)
05498         {
05499             XnStatus nRetVal = XN_STATUS_OK;
05500 
05501             XnNodeHandle hScriptNode;
05502             nRetVal = xnContextRunXmlScriptFromFileEx(m_pContext, strFileName, pErrors == NULL ? NULL : pErrors->GetUnderlying(), &hScriptNode);
05503             XN_IS_STATUS_OK(nRetVal);
05504 
05505             scriptNode.TakeOwnership(hScriptNode);
05506 
05507             return (XN_STATUS_OK);
05508         }
05509 
05513         inline XnStatus XN_API_DEPRECATED("Use other overload!") InitFromXmlFile(const XnChar* strFileName, EnumerationErrors* pErrors = NULL)
05514         {
05515             XnContext* pContext = NULL;
05516             m_bUsingDeprecatedAPI = TRUE;
05517 
05518             #pragma warning (push)
05519             #pragma warning (disable: XN_DEPRECATED_WARNING_IDS)
05520             XnStatus nRetVal = xnInitFromXmlFile(strFileName, &pContext, pErrors == NULL ? NULL : pErrors->GetUnderlying());
05521             #pragma warning (pop)
05522             XN_IS_STATUS_OK(nRetVal);
05523 
05524             TakeOwnership(pContext);
05525             m_bAllocated = TRUE;
05526 
05527             return (XN_STATUS_OK);
05528         }
05529 
05533         inline XnStatus InitFromXmlFile(const XnChar* strFileName, ScriptNode& scriptNode, EnumerationErrors* pErrors = NULL)
05534         {
05535             XnContext* pContext = NULL;
05536 
05537             XnNodeHandle hScriptNode;
05538             XnStatus nRetVal = xnInitFromXmlFileEx(strFileName, &pContext, pErrors == NULL ? NULL : pErrors->GetUnderlying(), &hScriptNode);
05539             XN_IS_STATUS_OK(nRetVal);
05540 
05541             scriptNode.TakeOwnership(hScriptNode);
05542             TakeOwnership(pContext);
05543             m_bAllocated = TRUE;
05544 
05545             return (XN_STATUS_OK);
05546         }
05547 
05551         inline XnStatus XN_API_DEPRECATED("Use other overload!") OpenFileRecording(const XnChar* strFileName)
05552         {
05553             m_bUsingDeprecatedAPI = TRUE;
05554             #pragma warning (push)
05555             #pragma warning (disable: XN_DEPRECATED_WARNING_IDS)
05556             return xnContextOpenFileRecording(m_pContext, strFileName);
05557             #pragma warning (pop)
05558         }
05559 
05563         inline XnStatus OpenFileRecording(const XnChar* strFileName, ProductionNode& playerNode)
05564         {
05565             XnStatus nRetVal = XN_STATUS_OK;
05566             
05567             XnNodeHandle hPlayer;
05568             nRetVal = xnContextOpenFileRecordingEx(m_pContext, strFileName, &hPlayer);
05569             XN_IS_STATUS_OK(nRetVal);
05570 
05571             playerNode.TakeOwnership(hPlayer);
05572             
05573             return (XN_STATUS_OK);
05574         }
05575 
05579         inline XnStatus CreateMockNode(XnProductionNodeType type, const XnChar* strName, ProductionNode& mockNode)
05580         {
05581             XnStatus nRetVal = XN_STATUS_OK;
05582             
05583             XnNodeHandle hMockNode;
05584             nRetVal = xnCreateMockNode(m_pContext, type, strName, &hMockNode);
05585             XN_IS_STATUS_OK(nRetVal);
05586 
05587             mockNode.TakeOwnership(hMockNode);
05588             
05589             return (XN_STATUS_OK);
05590         }
05591 
05595         inline XnStatus CreateMockNodeBasedOn(ProductionNode& originalNode, const XnChar* strName, ProductionNode& mockNode)
05596         {
05597             XnStatus nRetVal = XN_STATUS_OK;
05598 
05599             XnNodeHandle hMockNode;
05600             nRetVal = xnCreateMockNodeBasedOn(m_pContext, originalNode, strName, &hMockNode);
05601             XN_IS_STATUS_OK(nRetVal);
05602 
05603             mockNode.TakeOwnership(hMockNode);
05604 
05605             return (XN_STATUS_OK);
05606         }
05607 
05611         inline XnStatus CreateCodec(XnCodecID codecID, ProductionNode& initializerNode, Codec& codec)
05612         {
05613             XnStatus nRetVal = XN_STATUS_OK;
05614 
05615             XnNodeHandle hCodec;
05616             nRetVal =  xnCreateCodec(m_pContext, codecID, initializerNode.GetHandle(), &hCodec);
05617             XN_IS_STATUS_OK(nRetVal);
05618 
05619             codec.TakeOwnership(hCodec);
05620 
05621             return (XN_STATUS_OK);
05622         }
05623 
05627         inline XnStatus AddRef()
05628         {
05629             return xnContextAddRef(m_pContext);
05630         }
05631 
05635         inline void Release()
05636         {
05637             SetHandle(NULL);
05638         }
05639 
05643         inline void XN_API_DEPRECATED("You may use Release() instead, or count on dtor") Shutdown()
05644         {
05645             if (m_pContext != NULL)
05646             {
05647                 #pragma warning (push)
05648                 #pragma warning (disable: XN_DEPRECATED_WARNING_IDS)
05649                 xnShutdown(m_pContext);
05650                 #pragma warning (pop)
05651                 m_pContext = NULL;
05652             }
05653         }
05654 
05658         inline XnStatus AddLicense(const XnLicense& License)
05659         {
05660             return xnAddLicense(m_pContext, &License);
05661         }
05662 
05666         inline XnStatus EnumerateLicenses(XnLicense*& aLicenses, XnUInt32& nCount) const
05667         {
05668             return xnEnumerateLicenses(m_pContext, &aLicenses, &nCount);
05669         }
05670 
05674         inline static void FreeLicensesList(XnLicense aLicenses[])
05675         {
05676             xnFreeLicensesList(aLicenses);
05677         }
05678 
05682         XnStatus EnumerateProductionTrees(XnProductionNodeType Type, const Query* pQuery, NodeInfoList& TreesList, EnumerationErrors* pErrors = NULL) const
05683         {
05684             XnStatus nRetVal = XN_STATUS_OK;
05685 
05686             const XnNodeQuery* pInternalQuery = (pQuery != NULL) ? pQuery->GetUnderlyingObject() : NULL;
05687 
05688             XnNodeInfoList* pList = NULL;
05689             nRetVal = xnEnumerateProductionTrees(m_pContext, Type, pInternalQuery, &pList, pErrors == NULL ? NULL : pErrors->GetUnderlying());
05690             XN_IS_STATUS_OK(nRetVal);
05691 
05692             TreesList.ReplaceUnderlyingObject(pList);
05693 
05694             return (XN_STATUS_OK);
05695         }
05696 
05700         XnStatus CreateAnyProductionTree(XnProductionNodeType type, Query* pQuery, ProductionNode& node, EnumerationErrors* pErrors = NULL)
05701         {
05702             XnStatus nRetVal = XN_STATUS_OK;
05703             
05704             XnNodeQuery* pInternalQuery = (pQuery != NULL) ? pQuery->GetUnderlyingObject() : NULL;
05705 
05706             XnNodeHandle hNode;
05707             nRetVal = xnCreateAnyProductionTree(m_pContext, type, pInternalQuery, &hNode, pErrors == NULL ? NULL : pErrors->GetUnderlying());
05708             XN_IS_STATUS_OK(nRetVal);
05709 
05710             node.TakeOwnership(hNode);
05711 
05712             return (XN_STATUS_OK);
05713         }
05714 
05718         XnStatus XN_API_DEPRECATED("Please use other overload") CreateProductionTree(NodeInfo& Tree)
05719         {
05720             XnStatus nRetVal = XN_STATUS_OK;
05721 
05722             XnNodeHandle hNode;
05723             nRetVal = xnCreateProductionTree(m_pContext, Tree, &hNode);
05724             XN_IS_STATUS_OK(nRetVal);
05725 
05726             Tree.m_bOwnerOfNode = TRUE;
05727 
05728             return (XN_STATUS_OK);
05729         }
05730 
05734         XnStatus CreateProductionTree(NodeInfo& Tree, ProductionNode& node)
05735         {
05736             XnStatus nRetVal = XN_STATUS_OK;
05737 
05738             XnNodeHandle hNode;
05739             nRetVal = xnCreateProductionTree(m_pContext, Tree, &hNode);
05740             XN_IS_STATUS_OK(nRetVal);
05741 
05742             node.TakeOwnership(hNode);
05743 
05744             return (XN_STATUS_OK);
05745         }
05746 
05750         XnStatus EnumerateExistingNodes(NodeInfoList& list) const
05751         {
05752             XnNodeInfoList* pList;
05753             XnStatus nRetVal = xnEnumerateExistingNodes(m_pContext, &pList);
05754             XN_IS_STATUS_OK(nRetVal);
05755 
05756             list.ReplaceUnderlyingObject(pList);
05757 
05758             return (XN_STATUS_OK);
05759         }
05760 
05764         XnStatus EnumerateExistingNodes(NodeInfoList& list, XnProductionNodeType type) const
05765         {
05766             XnNodeInfoList* pList;
05767             XnStatus nRetVal = xnEnumerateExistingNodesByType(m_pContext, type, &pList);
05768             XN_IS_STATUS_OK(nRetVal);
05769 
05770             list.ReplaceUnderlyingObject(pList);
05771 
05772             return (XN_STATUS_OK);
05773         }
05774 
05778         XnStatus FindExistingNode(XnProductionNodeType type, ProductionNode& node) const
05779         {
05780             XnStatus nRetVal = XN_STATUS_OK;
05781 
05782             XnNodeHandle hNode;
05783             nRetVal = xnFindExistingRefNodeByType(m_pContext, type, &hNode);
05784             XN_IS_STATUS_OK(nRetVal);
05785 
05786             node.TakeOwnership(hNode);
05787 
05788             return (XN_STATUS_OK);
05789         }
05790 
05794         XnStatus GetProductionNodeByName(const XnChar* strInstanceName, ProductionNode& node) const
05795         {
05796             XnStatus nRetVal = XN_STATUS_OK;
05797 
05798             XnNodeHandle hNode;
05799             nRetVal = xnGetRefNodeHandleByName(m_pContext, strInstanceName, &hNode);
05800             XN_IS_STATUS_OK(nRetVal);
05801 
05802             node.TakeOwnership(hNode);
05803 
05804             return (XN_STATUS_OK);
05805         }
05806 
05810         XnStatus GetProductionNodeInfoByName(const XnChar* strInstanceName, NodeInfo& nodeInfo) const
05811         {
05812             XnStatus nRetVal = XN_STATUS_OK;
05813 
05814             XnNodeHandle hNode;
05815             nRetVal = xnGetRefNodeHandleByName(m_pContext, strInstanceName, &hNode);
05816             XN_IS_STATUS_OK(nRetVal);
05817 
05818             xnProductionNodeRelease(hNode);
05819 
05820             nodeInfo = NodeInfo(xnGetNodeInfo(hNode));
05821 
05822             return (XN_STATUS_OK);
05823         }
05824 
05828         inline XnStatus StartGeneratingAll()
05829         {
05830             return xnStartGeneratingAll(m_pContext);
05831         }
05832 
05836         inline XnStatus StopGeneratingAll()
05837         {
05838             return xnStopGeneratingAll(m_pContext);
05839         }
05840 
05844         inline XnStatus SetGlobalMirror(XnBool bMirror)
05845         {
05846             return xnSetGlobalMirror(m_pContext, bMirror);
05847         }
05848 
05852         inline XnBool GetGlobalMirror()
05853         {
05854             return xnGetGlobalMirror(m_pContext);
05855         }
05856 
05860         inline XnStatus GetGlobalErrorState()
05861         {
05862             return xnGetGlobalErrorState(m_pContext);
05863         }
05864 
05868         inline XnStatus RegisterToErrorStateChange(XnErrorStateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
05869         {
05870             return xnRegisterToGlobalErrorStateChange(m_pContext, handler, pCookie, &hCallback);
05871         }
05872 
05877         inline void UnregisterFromErrorStateChange(XnCallbackHandle hCallback)
05878         {
05879             xnUnregisterFromGlobalErrorStateChange(m_pContext, hCallback);
05880         }
05881 
05885         inline XnStatus WaitAndUpdateAll()
05886         {
05887             return xnWaitAndUpdateAll(m_pContext);
05888         }
05889 
05893         inline XnStatus WaitAnyUpdateAll()
05894         {
05895             return xnWaitAnyUpdateAll(m_pContext);
05896         }
05897 
05901         inline XnStatus WaitOneUpdateAll(ProductionNode& node)
05902         {
05903             return xnWaitOneUpdateAll(m_pContext, node.GetHandle());
05904         }
05905 
05909         inline XnStatus WaitNoneUpdateAll()
05910         {
05911             return xnWaitNoneUpdateAll(m_pContext);
05912         }
05913 
05917         inline XnStatus AutoEnumerateOverSingleInput(NodeInfoList& List, XnProductionNodeDescription& description, const XnChar* strCreationInfo, XnProductionNodeType InputType, EnumerationErrors* pErrors, Query* pQuery = NULL) const
05918         {
05919             return xnAutoEnumerateOverSingleInput(m_pContext, List.GetUnderlyingObject(), &description, strCreationInfo, InputType, pErrors == NULL ? NULL : pErrors->GetUnderlying(), pQuery == NULL ? NULL : pQuery->GetUnderlyingObject());
05920         }
05921 
05923         inline void SetHandle(XnContext* pContext)
05924         {
05925             if (m_pContext == pContext)
05926             {
05927                 return;
05928             }
05929 
05930             if (m_pContext != NULL)
05931             {
05932                 if (m_bUsingDeprecatedAPI && m_bAllocated)
05933                 {
05934                     // Backwards compatibility: call shutdown instead of release, to make old programs get the 
05935                     // exact same behavior they used to have.
05936                     xnForceShutdown(m_pContext);
05937                 }
05938                 else
05939                 {
05940                     xnContextUnregisterFromShutdown(m_pContext, m_hShuttingDownCallback);
05941                     xnContextRelease(m_pContext);
05942                 }
05943             }
05944 
05945             if (pContext != NULL)
05946             {
05947                 XnStatus nRetVal = xnContextAddRef(pContext);
05948                 XN_ASSERT(nRetVal == XN_STATUS_OK);
05949 
05950                 nRetVal = xnContextRegisterForShutdown(pContext, ContextShuttingDownCallback, this, &m_hShuttingDownCallback);
05951                 XN_ASSERT(nRetVal == XN_STATUS_OK);
05952             }
05953 
05954             m_pContext = pContext;
05955         }
05956 
05957         inline void TakeOwnership(XnContext* pContext)
05958         {
05959             SetHandle(pContext);
05960 
05961             if (pContext != NULL)
05962             {
05963                 xnContextRelease(pContext);
05964             }
05965         }
05966 
05967     private:
05968         static void XN_CALLBACK_TYPE ContextShuttingDownCallback(XnContext* /*pContext*/, void* pCookie)
05969         {
05970             Context* pThis = (Context*)pCookie;
05971             pThis->m_pContext = NULL;
05972         }
05973 
05974         XnContext* m_pContext;
05975         XnBool m_bUsingDeprecatedAPI;
05976         XnBool m_bAllocated;
05977         XnCallbackHandle m_hShuttingDownCallback;
05978     };
05979 
05984     class Resolution
05985     {
05986     public:
05992         inline Resolution(XnResolution res) : m_Res(res)
05993         {
05994             m_nXRes = xnResolutionGetXRes(res);
05995             m_nYRes = xnResolutionGetYRes(res);
05996             m_strName = xnResolutionGetName(res);
05997         }
05998 
06005         inline Resolution(XnUInt32 xRes, XnUInt32 yRes) : m_nXRes(xRes), m_nYRes(yRes)
06006         {
06007             m_Res = xnResolutionGetFromXYRes(xRes, yRes);
06008             m_strName = xnResolutionGetName(m_Res);
06009         }
06010 
06016         inline Resolution(const XnChar* strName)
06017         {
06018             m_Res = xnResolutionGetFromName(strName);
06019             m_nXRes = xnResolutionGetXRes(m_Res);
06020             m_nYRes = xnResolutionGetYRes(m_Res);
06021             m_strName = xnResolutionGetName(m_Res);
06022         }
06023 
06025         inline XnResolution GetResolution() const { return m_Res; }
06027         inline XnUInt32 GetXResolution() const { return m_nXRes; }
06029         inline XnUInt32 GetYResolution() const { return m_nYRes; }
06031         inline const XnChar* GetName() const { return m_strName; }
06032 
06033     private:
06034         XnResolution m_Res;
06035         XnUInt32 m_nXRes;
06036         XnUInt32 m_nYRes;
06037         const XnChar* m_strName;
06038     };
06039 
06040     //---------------------------------------------------------------------------
06041     // Functions Implementation
06042     //---------------------------------------------------------------------------
06043     inline XnStatus NodeInfoList::FilterList(Context& context, Query& query)
06044     {
06045         return xnNodeQueryFilterList(context.GetUnderlyingObject(), query.GetUnderlyingObject(), m_pList);
06046     }
06047 
06048     inline void ProductionNode::GetContext(Context& context) const
06049     {
06050         context.TakeOwnership(xnGetRefContextFromNodeHandle(GetHandle()));
06051     }
06052 
06053     inline NodeInfoList& NodeInfo::GetNeededNodes() const
06054     {
06055         if (m_pNeededNodes == NULL)
06056         {
06057             XnNodeInfoList* pList = xnNodeInfoGetNeededNodes(m_pInfo);
06058             m_pNeededNodes = XN_NEW(NodeInfoList, pList);
06059         }
06060 
06061         return *m_pNeededNodes;
06062     }
06063 
06064     inline void NodeInfo::SetUnderlyingObject(XnNodeInfo* pInfo)
06065     {
06066         if (m_pNeededNodes != NULL)
06067         {
06068             XN_DELETE(m_pNeededNodes);
06069         }
06070 
06071         m_bOwnerOfNode = FALSE;
06072         m_pInfo = pInfo;
06073         m_pNeededNodes = NULL;
06074     }
06075 
06076     inline XnBool FrameSyncCapability::CanFrameSyncWith(Generator& other) const
06077     {
06078         return xnCanFrameSyncWith(GetHandle(), other.GetHandle());
06079     }
06080 
06081     inline XnStatus FrameSyncCapability::FrameSyncWith(Generator& other)
06082     {
06083         return xnFrameSyncWith(GetHandle(), other.GetHandle());
06084     }
06085 
06086     inline XnStatus FrameSyncCapability::StopFrameSyncWith(Generator& other)
06087     {
06088         return xnStopFrameSyncWith(GetHandle(), other.GetHandle());
06089     }
06090 
06091     inline XnBool FrameSyncCapability::IsFrameSyncedWith(Generator& other) const
06092     {
06093         return xnIsFrameSyncedWith(GetHandle(), other.GetHandle());
06094     }
06095 
06096     inline XnStatus NodeInfo::GetInstance(ProductionNode& node) const
06097     {
06098         if (m_pInfo == NULL)
06099         {
06100             return XN_STATUS_INVALID_OPERATION;
06101         }
06102 
06103         XnNodeHandle hNode = xnNodeInfoGetRefHandle(m_pInfo);
06104         node.TakeOwnership(hNode);
06105 
06106         if (m_bOwnerOfNode)
06107         {
06108             xnProductionNodeRelease(hNode);
06109         }
06110 
06111         return (XN_STATUS_OK);
06112     }
06113 
06114     //---------------------------------------------------------------------------
06115     // Node creation functions
06116     //---------------------------------------------------------------------------
06117 
06118     inline XnStatus Device::Create(Context& context, Query* pQuery/*=NULL*/, EnumerationErrors* pErrors/*=NULL*/)
06119     {
06120         XnNodeHandle hNode;
06121         XnStatus nRetVal = xnCreateDevice(context.GetUnderlyingObject(), &hNode, pQuery == NULL ? NULL : pQuery->GetUnderlyingObject(), pErrors == NULL ? NULL : pErrors->GetUnderlying());
06122         XN_IS_STATUS_OK(nRetVal);
06123         TakeOwnership(hNode);
06124         return (XN_STATUS_OK);
06125     }
06126 
06127     inline XnStatus Recorder::Create(Context& context, const XnChar* strFormatName /*= NULL*/)
06128     {
06129         XnNodeHandle hNode;
06130         XnStatus nRetVal = xnCreateRecorder(context.GetUnderlyingObject(), strFormatName, &hNode);
06131         XN_IS_STATUS_OK(nRetVal);
06132         TakeOwnership(hNode);
06133         return (XN_STATUS_OK);
06134     }
06135 
06136     inline XnStatus Player::Create(Context& context, const XnChar* strFormatName)
06137     {
06138         XnNodeHandle hNode;
06139         XnStatus nRetVal = xnCreatePlayer(context.GetUnderlyingObject(), strFormatName, &hNode);
06140         XN_IS_STATUS_OK(nRetVal);
06141         TakeOwnership(hNode);
06142         return (XN_STATUS_OK);
06143     }
06144 
06145     inline XnStatus DepthGenerator::Create(Context& context, Query* pQuery/*=NULL*/, EnumerationErrors* pErrors/*=NULL*/)
06146     {
06147         XnNodeHandle hNode;
06148         XnStatus nRetVal = xnCreateDepthGenerator(context.GetUnderlyingObject(), &hNode, pQuery == NULL ? NULL : pQuery->GetUnderlyingObject(), pErrors == NULL ? NULL : pErrors->GetUnderlying());
06149         XN_IS_STATUS_OK(nRetVal);
06150         TakeOwnership(hNode);
06151         return (XN_STATUS_OK);
06152     }
06153 
06154     inline XnStatus MockDepthGenerator::Create(Context& context, const XnChar* strName /* = NULL */)
06155     {
06156         XnNodeHandle hNode;
06157         XnStatus nRetVal = xnCreateMockNode(context.GetUnderlyingObject(), XN_NODE_TYPE_DEPTH, strName, &hNode);
06158         XN_IS_STATUS_OK(nRetVal);
06159         TakeOwnership(hNode);
06160         return (XN_STATUS_OK);
06161     }
06162 
06163     inline XnStatus MockDepthGenerator::CreateBasedOn(DepthGenerator& other, const XnChar* strName /* = NULL */)
06164     {
06165         Context context;
06166         other.GetContext(context);
06167         XnNodeHandle hNode;
06168         XnStatus nRetVal = xnCreateMockNodeBasedOn(context.GetUnderlyingObject(), other.GetHandle(), strName, &hNode);
06169         XN_IS_STATUS_OK(nRetVal);
06170         TakeOwnership(hNode);
06171         return (XN_STATUS_OK);
06172     }
06173 
06174     inline XnStatus ImageGenerator::Create(Context& context, Query* pQuery/*=NULL*/, EnumerationErrors* pErrors/*=NULL*/)
06175     {
06176         XnNodeHandle hNode;
06177         XnStatus nRetVal = xnCreateImageGenerator(context.GetUnderlyingObject(), &hNode, pQuery == NULL ? NULL : pQuery->GetUnderlyingObject(), pErrors == NULL ? NULL : pErrors->GetUnderlying());
06178         XN_IS_STATUS_OK(nRetVal);
06179         TakeOwnership(hNode);
06180         return (XN_STATUS_OK);
06181     }
06182 
06183     inline XnStatus MockImageGenerator::Create(Context& context, const XnChar* strName /* = NULL */)
06184     {
06185         XnNodeHandle hNode;
06186         XnStatus nRetVal = xnCreateMockNode(context.GetUnderlyingObject(), XN_NODE_TYPE_IMAGE, strName, &hNode);
06187         XN_IS_STATUS_OK(nRetVal);
06188         TakeOwnership(hNode);
06189         return (XN_STATUS_OK);
06190     }
06191 
06192     inline XnStatus MockImageGenerator::CreateBasedOn(ImageGenerator& other, const XnChar* strName /* = NULL */)
06193     {
06194         Context context;
06195         other.GetContext(context);
06196         XnNodeHandle hNode;
06197         XnStatus nRetVal = xnCreateMockNodeBasedOn(context.GetUnderlyingObject(), other.GetHandle(), strName, &hNode);
06198         XN_IS_STATUS_OK(nRetVal);
06199         TakeOwnership(hNode);
06200         return (XN_STATUS_OK);
06201     }
06202 
06203     inline XnStatus IRGenerator::Create(Context& context, Query* pQuery/*=NULL*/, EnumerationErrors* pErrors/*=NULL*/)
06204     {
06205         XnNodeHandle hNode;
06206         XnStatus nRetVal = xnCreateIRGenerator(context.GetUnderlyingObject(), &hNode, pQuery == NULL ? NULL : pQuery->GetUnderlyingObject(), pErrors == NULL ? NULL : pErrors->GetUnderlying());
06207         XN_IS_STATUS_OK(nRetVal);
06208         TakeOwnership(hNode);
06209         return (XN_STATUS_OK);
06210     }
06211     
06212     inline XnStatus MockIRGenerator::Create(Context& context, const XnChar* strName /* = NULL */)
06213     {
06214         XnNodeHandle hNode;
06215         XnStatus nRetVal = xnCreateMockNode(context.GetUnderlyingObject(), XN_NODE_TYPE_IR, strName, &hNode);
06216         XN_IS_STATUS_OK(nRetVal);
06217         TakeOwnership(hNode);
06218         return (XN_STATUS_OK);
06219     }
06220 
06221     inline XnStatus MockIRGenerator::CreateBasedOn(IRGenerator& other, const XnChar* strName /* = NULL */)
06222     {
06223         Context context;
06224         other.GetContext(context);
06225         XnNodeHandle hNode;
06226         XnStatus nRetVal = xnCreateMockNodeBasedOn(context.GetUnderlyingObject(), other.GetHandle(), strName, &hNode);
06227         XN_IS_STATUS_OK(nRetVal);
06228         TakeOwnership(hNode);
06229         return (XN_STATUS_OK);
06230     }
06231 
06232     inline XnStatus GestureGenerator::Create(Context& context, Query* pQuery/*=NULL*/, EnumerationErrors* pErrors/*=NULL*/)
06233     {
06234         XnNodeHandle hNode;
06235         XnStatus nRetVal = xnCreateGestureGenerator(context.GetUnderlyingObject(), &hNode, pQuery == NULL ? NULL : pQuery->GetUnderlyingObject(), pErrors == NULL ? NULL : pErrors->GetUnderlying());
06236         XN_IS_STATUS_OK(nRetVal);
06237         TakeOwnership(hNode);
06238         return (XN_STATUS_OK);
06239     }
06240 
06241     inline XnStatus SceneAnalyzer::Create(Context& context, Query* pQuery/*=NULL*/, EnumerationErrors* pErrors/*=NULL*/)
06242     {
06243         //You're creating a scene!
06244         XnNodeHandle hNode;
06245         XnStatus nRetVal = xnCreateSceneAnalyzer(context.GetUnderlyingObject(), &hNode, pQuery == NULL ? NULL : pQuery->GetUnderlyingObject(), pErrors == NULL ? NULL : pErrors->GetUnderlying());
06246         XN_IS_STATUS_OK(nRetVal);
06247         TakeOwnership(hNode);
06248         return (XN_STATUS_OK);
06249     }
06250 
06251     inline XnStatus HandsGenerator::Create(Context& context, Query* pQuery/*=NULL*/, EnumerationErrors* pErrors/*=NULL*/)
06252     {
06253         XnNodeHandle hNode;
06254         XnStatus nRetVal = xnCreateHandsGenerator(context.GetUnderlyingObject(), &hNode, pQuery == NULL ? NULL : pQuery->GetUnderlyingObject(), pErrors == NULL ? NULL : pErrors->GetUnderlying());
06255         XN_IS_STATUS_OK(nRetVal);
06256         TakeOwnership(hNode);
06257         return (XN_STATUS_OK);
06258     }
06259 
06260     inline XnStatus UserGenerator::Create(Context& context, Query* pQuery/*=NULL*/, EnumerationErrors* pErrors/*=NULL*/)
06261     {
06262         XnNodeHandle hNode;
06263         XnStatus nRetVal = xnCreateUserGenerator(context.GetUnderlyingObject(), &hNode, pQuery == NULL ? NULL : pQuery->GetUnderlyingObject(), pErrors == NULL ? NULL : pErrors->GetUnderlying());
06264         XN_IS_STATUS_OK(nRetVal);
06265         TakeOwnership(hNode);
06266         return (XN_STATUS_OK);
06267     }
06268 
06269     inline XnStatus AudioGenerator::Create(Context& context, Query* pQuery/*=NULL*/, EnumerationErrors* pErrors/*=NULL*/)
06270     {
06271         XnNodeHandle hNode;
06272         XnStatus nRetVal = xnCreateAudioGenerator(context.GetUnderlyingObject(), &hNode, pQuery == NULL ? NULL : pQuery->GetUnderlyingObject(), pErrors == NULL ? NULL : pErrors->GetUnderlying());
06273         XN_IS_STATUS_OK(nRetVal);
06274         TakeOwnership(hNode);
06275         return (XN_STATUS_OK);
06276     }
06277 
06278     inline XnStatus MockAudioGenerator::Create(Context& context, const XnChar* strName /* = NULL */)
06279     {
06280         XnNodeHandle hNode;
06281         XnStatus nRetVal = xnCreateMockNode(context.GetUnderlyingObject(), XN_NODE_TYPE_AUDIO, strName, &hNode);
06282         XN_IS_STATUS_OK(nRetVal);
06283         TakeOwnership(hNode);
06284         return (XN_STATUS_OK);
06285     }
06286 
06287     inline XnStatus MockAudioGenerator::CreateBasedOn(AudioGenerator& other, const XnChar* strName /* = NULL */)
06288     {
06289         Context context;
06290         other.GetContext(context);
06291         XnNodeHandle hNode;
06292         XnStatus nRetVal = xnCreateMockNodeBasedOn(context.GetUnderlyingObject(), other.GetHandle(), strName, &hNode);
06293         XN_IS_STATUS_OK(nRetVal);
06294         TakeOwnership(hNode);
06295         return (XN_STATUS_OK);
06296     }
06297 
06298     inline XnStatus MockRawGenerator::Create(Context& context, const XnChar* strName /*= NULL*/)
06299     {
06300         XnNodeHandle hNode;
06301         XnStatus nRetVal = xnCreateMockNode(context.GetUnderlyingObject(), XN_NODE_TYPE_GENERATOR, strName, &hNode);
06302         XN_IS_STATUS_OK(nRetVal);
06303         TakeOwnership(hNode);
06304         return (XN_STATUS_OK);
06305     }
06306 
06307     inline XnStatus Codec::Create(Context& context, XnCodecID codecID, ProductionNode& initializerNode)
06308     {
06309         XnNodeHandle hNode;
06310         XnStatus nRetVal = xnCreateCodec(context.GetUnderlyingObject(), codecID, initializerNode.GetHandle(), &hNode);
06311         XN_IS_STATUS_OK(nRetVal);
06312         TakeOwnership(hNode);
06313         return (XN_STATUS_OK);
06314     }
06315 
06316     inline XnStatus ScriptNode::Run(EnumerationErrors* pErrors)
06317     {
06318         return xnScriptNodeRun(GetHandle(), pErrors == NULL ? NULL : pErrors->GetUnderlying());
06319     }
06320 
06321     //---------------------------------------------------------------------------
06322     // Global Helper Functions
06323     //---------------------------------------------------------------------------
06324 
06328     inline void GetVersion(XnVersion& Version)
06329     {
06330         xnGetVersion(&Version);
06331     }
06332 
06333     //---------------------------------------------------------------------------
06334     // Internal Helper Classes and Functions
06335     //---------------------------------------------------------------------------
06336 
06337     class StateChangedCallbackTranslator
06338     {
06339     public:
06340         StateChangedCallbackTranslator(StateChangedHandler handler, void* pCookie) : m_UserHandler(handler), m_pUserCookie(pCookie), m_hCallback(NULL) {}
06341 
06342         XnStatus Register(_XnRegisterStateChangeFuncPtr xnFunc, XnNodeHandle hNode)
06343         {
06344             return xnFunc(hNode, StateChangedCallback, this, &m_hCallback);
06345         }
06346 
06347         void Unregister(_XnUnregisterStateChangeFuncPtr xnFunc, XnNodeHandle hNode)
06348         {
06349             xnFunc(hNode, m_hCallback);
06350         }
06351 
06352         static XnStatus RegisterToUnderlying(_XnRegisterStateChangeFuncPtr xnFunc, XnNodeHandle hNode, StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
06353         {
06354             XnStatus nRetVal = XN_STATUS_OK;
06355             
06356             StateChangedCallbackTranslator* pTrans;
06357             XN_VALIDATE_NEW(pTrans, StateChangedCallbackTranslator, handler, pCookie);
06358 
06359             nRetVal = pTrans->Register(xnFunc, hNode);
06360             if (nRetVal != XN_STATUS_OK)
06361             {
06362                 XN_DELETE(pTrans);
06363                 return (nRetVal);
06364             }
06365 
06366             hCallback = pTrans;
06367             
06368             return (XN_STATUS_OK);
06369         }
06370 
06371         static XnStatus UnregisterFromUnderlying(_XnUnregisterStateChangeFuncPtr xnFunc, XnNodeHandle hNode, XnCallbackHandle hCallback)
06372         {
06373             StateChangedCallbackTranslator* pTrans = (StateChangedCallbackTranslator*)hCallback;
06374             pTrans->Unregister(xnFunc, hNode);
06375             XN_DELETE(pTrans);
06376             return XN_STATUS_OK;
06377         }
06378 
06379     private:
06380         friend class GeneralIntCapability;
06381 
06382         typedef struct StateChangeCookie
06383         {
06384             StateChangedHandler userHandler;
06385             void* pUserCookie;
06386             XnCallbackHandle hCallback;
06387         } StateChangeCookie;
06388 
06389         static void XN_CALLBACK_TYPE StateChangedCallback(XnNodeHandle hNode, void* pCookie)
06390         {
06391             StateChangedCallbackTranslator* pTrans = (StateChangedCallbackTranslator*)pCookie;
06392             ProductionNode node(hNode);
06393             pTrans->m_UserHandler(node, pTrans->m_pUserCookie);
06394         }
06395 
06396         StateChangedHandler m_UserHandler;
06397         void* m_pUserCookie;
06398         XnCallbackHandle m_hCallback;
06399     };
06400 
06401     static XnStatus _RegisterToStateChange(_XnRegisterStateChangeFuncPtr xnFunc, XnNodeHandle hNode, StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
06402     {
06403         return StateChangedCallbackTranslator::RegisterToUnderlying(xnFunc, hNode, handler, pCookie, hCallback);
06404     }
06405 
06406     static void _UnregisterFromStateChange(_XnUnregisterStateChangeFuncPtr xnFunc, XnNodeHandle hNode, XnCallbackHandle hCallback)
06407     {
06408         StateChangedCallbackTranslator::UnregisterFromUnderlying(xnFunc, hNode, hCallback);
06409     }
06410 
06411     inline XnStatus GeneralIntCapability::RegisterToValueChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
06412     {
06413         XnStatus nRetVal = XN_STATUS_OK;
06414 
06415         StateChangedCallbackTranslator* pTrans;
06416         XN_VALIDATE_NEW(pTrans, StateChangedCallbackTranslator, handler, pCookie);
06417 
06418         nRetVal = xnRegisterToGeneralIntValueChange(GetHandle(), m_strCap, pTrans->StateChangedCallback, pTrans, &pTrans->m_hCallback);
06419         if (nRetVal != XN_STATUS_OK)
06420         {
06421             XN_DELETE(pTrans);
06422             return (nRetVal);
06423         }
06424 
06425         hCallback = pTrans;
06426 
06427         return (XN_STATUS_OK);
06428     }
06429 
06430     inline void GeneralIntCapability::UnregisterFromValueChange(XnCallbackHandle hCallback)
06431     {
06432         StateChangedCallbackTranslator* pTrans = (StateChangedCallbackTranslator*)hCallback;
06433         xnUnregisterFromGeneralIntValueChange(GetHandle(), m_strCap, pTrans->m_hCallback);
06434         XN_DELETE(pTrans);
06435     }
06436 
06438 };
06439 
06440 #endif // __XN_CPP_WRAPPER_H__

Generated on Fri Nov 9 2012 23:01:16 for OpenNI 1.3.2 by  doxygen 1.7.1