XnCppWrapper.h
Go to the documentation of this file.
00001 /*****************************************************************************
00002 *                                                                            *
00003 *  OpenNI 1.0 Alpha                                                          *
00004 *  Copyright (C) 2010 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 
00023 
00024 
00025 
00026 #ifndef __XN_CPP_WRAPPER_H__
00027 #define __XN_CPP_WRAPPER_H__
00028 
00029 //---------------------------------------------------------------------------
00030 // Includes
00031 //---------------------------------------------------------------------------
00032 #include <XnOpenNI.h>
00033 #include <XnCodecIDs.h>
00034 
00035 //---------------------------------------------------------------------------
00036 // Types
00037 //---------------------------------------------------------------------------
00038 namespace xn
00039 {
00040         //---------------------------------------------------------------------------
00041         // Forward Declarations
00042         //---------------------------------------------------------------------------
00043         class ProductionNode;
00044         class EnumerationErrors;
00045         class NodeInfo;
00046         class NodeInfoList;
00047         class Context;
00048         class Query;
00049         class Generator;
00050 
00056         //---------------------------------------------------------------------------
00057         // Types
00058         //---------------------------------------------------------------------------
00059 
00066         typedef void (XN_CALLBACK_TYPE* StateChangedHandler)(ProductionNode& node, void* pCookie);
00067 
00068         //---------------------------------------------------------------------------
00069         // Internal stuff
00070         //---------------------------------------------------------------------------
00071         typedef XnStatus (*_XnRegisterStateChangeFuncPtr)(XnNodeHandle hNode, XnStateChangedHandler handler, void* pCookie, XnCallbackHandle* phCallback);
00072         typedef void (*_XnUnregisterStateChangeFuncPtr)(XnNodeHandle hNode, XnCallbackHandle hCallback);
00073 
00074         static XnStatus _RegisterToStateChange(_XnRegisterStateChangeFuncPtr xnFunc, XnNodeHandle hNode, StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback);
00075         static void _UnregisterFromStateChange(_XnUnregisterStateChangeFuncPtr xnFunc, XnNodeHandle hNode, XnCallbackHandle hCallback);
00076 
00077         //---------------------------------------------------------------------------
00078         // Meta Data
00079         //---------------------------------------------------------------------------
00080 
00085         class OutputMetaData
00086         {
00087         public:
00093                 inline OutputMetaData(const XnUInt8** ppData) : m_ppData(ppData), m_nAllocatedSize(0), m_pAllocatedData(NULL)
00094                 {
00095                         xnOSMemSet(&m_output, 0, sizeof(XnOutputMetaData));
00096                 }
00097 
00101                 virtual ~OutputMetaData() { Free(); }
00102 
00104                 inline XnUInt64 Timestamp() const { return m_output.nTimestamp; }
00106                 inline XnUInt64& Timestamp() { return m_output.nTimestamp; }
00107 
00109                 inline XnUInt32 FrameID() const { return m_output.nFrameID; }
00111                 inline XnUInt32& FrameID() { return m_output.nFrameID; }
00112 
00114                 inline XnUInt32 DataSize() const { return m_output.nDataSize; }
00116                 inline XnUInt32& DataSize() { return m_output.nDataSize; }
00117 
00119                 inline XnBool IsDataNew() const { return m_output.bIsNew; }
00121                 inline XnBool& IsDataNew() { return m_output.bIsNew; }
00122 
00124                 inline const XnOutputMetaData* GetUnderlying() const { return &m_output; }
00126                 inline XnOutputMetaData* GetUnderlying() { return &m_output; }
00127 
00129                 inline const XnUInt8* Data() const { return *m_ppData; }
00131                 inline const XnUInt8*& Data() { return *m_ppData; }
00133                 inline XnUInt8* WritableData()
00134                 {
00135                         MakeDataWritable();
00136                         return m_pAllocatedData;
00137                 }
00138 
00145                 XnStatus AllocateData(XnUInt32 nBytes)
00146                 {
00147                         if (nBytes > m_nAllocatedSize)
00148                         {
00149                                 // reallocate
00150                                 XnUInt8* pData = (XnUInt8*)xnOSMallocAligned(nBytes, XN_DEFAULT_MEM_ALIGN);
00151                                 XN_VALIDATE_ALLOC_PTR(pData);
00152 
00153                                 // allocation succeeded, replace
00154                                 Free();
00155                                 m_pAllocatedData = pData;
00156                                 m_nAllocatedSize = nBytes;
00157                         }
00158 
00159                         DataSize() = nBytes;
00160                         *m_ppData = m_pAllocatedData;
00161 
00162                         return XN_STATUS_OK;
00163                 }
00164 
00168                 void Free()
00169                 {
00170                         if (m_nAllocatedSize != 0)
00171                         {
00172                                 xnOSFreeAligned(m_pAllocatedData);
00173                                 m_pAllocatedData = NULL;
00174                                 m_nAllocatedSize = 0;
00175                         }
00176                 }
00177 
00182                 XnStatus MakeDataWritable()
00183                 {
00184                         XnStatus nRetVal = XN_STATUS_OK;
00185 
00186                         // check data isn't already writable
00187                         if (Data() != m_pAllocatedData || DataSize() > m_nAllocatedSize)
00188                         {
00189                                 const XnUInt8* pOrigData = *m_ppData;
00190 
00191                                 nRetVal = AllocateData(DataSize());
00192                                 XN_IS_STATUS_OK(nRetVal);
00193 
00194                                 if (pOrigData != NULL)
00195                                 {
00196                                         xnOSMemCopy(m_pAllocatedData, pOrigData, DataSize());
00197                                 }
00198                                 else
00199                                 {
00200                                         xnOSMemSet(m_pAllocatedData, 0, DataSize());
00201                                 }
00202                         }
00203 
00204                         return (XN_STATUS_OK);
00205                 }
00206 
00207         protected:
00208                 XnUInt8* m_pAllocatedData;
00209 
00210         private:
00211                 XnOutputMetaData m_output;
00212 
00213                 const XnUInt8** m_ppData;
00214                 XnUInt32 m_nAllocatedSize;
00215         };
00216 
00221         class MapMetaData : public OutputMetaData
00222         {
00223         public:
00230                 inline MapMetaData(XnPixelFormat format, const XnUInt8** ppData) : OutputMetaData(ppData)
00231                 {
00232                         xnOSMemSet(&m_map, 0, sizeof(XnMapMetaData));
00233                         m_map.pOutput = OutputMetaData::GetUnderlying();
00234                         m_map.PixelFormat = format;
00235                 }
00236 
00238                 inline XnUInt32 XRes() const { return m_map.Res.X; }
00240                 inline XnUInt32& XRes() { return m_map.Res.X; }
00241 
00243                 inline XnUInt32 YRes() const { return m_map.Res.Y; }
00245                 inline XnUInt32& YRes() { return m_map.Res.Y; }
00246 
00248                 inline XnUInt32 XOffset() const { return m_map.Offset.X; }
00250                 inline XnUInt32& XOffset() { return m_map.Offset.X; }
00251 
00253                 inline XnUInt32 YOffset() const { return m_map.Offset.Y; }
00255                 inline XnUInt32& YOffset() { return m_map.Offset.Y; }
00256 
00258                 inline XnUInt32 FullXRes() const { return m_map.FullRes.X; }
00260                 inline XnUInt32& FullXRes() { return m_map.FullRes.X; }
00261 
00263                 inline XnUInt32 FullYRes() const { return m_map.FullRes.Y; }
00265                 inline XnUInt32& FullYRes() { return m_map.FullRes.Y; }
00266 
00268                 inline XnUInt32 FPS() const { return m_map.nFPS; }
00270                 inline XnUInt32& FPS() { return m_map.nFPS; }
00271 
00273                 inline XnPixelFormat PixelFormat() const { return m_map.PixelFormat; }
00274 
00276                 inline const XnMapMetaData* GetUnderlying() const { return &m_map; }
00278                 inline XnMapMetaData* GetUnderlying() { return &m_map; }
00279 
00281                 inline XnUInt32 BytesPerPixel() const
00282                 {
00283                         switch (PixelFormat())
00284                         {
00285                                 case XN_PIXEL_FORMAT_RGB24:
00286                                         return sizeof(XnRGB24Pixel);
00287                                 case XN_PIXEL_FORMAT_YUV422:
00288                                         return sizeof(XnYUV422DoublePixel)/2;
00289                                 case XN_PIXEL_FORMAT_GRAYSCALE_8_BIT:
00290                                         return sizeof(XnGrayscale8Pixel);
00291                                 case XN_PIXEL_FORMAT_GRAYSCALE_16_BIT:
00292                                         return sizeof(XnGrayscale16Pixel);
00293                                 default:
00294                                         XN_ASSERT(FALSE);
00295                                         return 0;
00296                         }
00297                 }
00298 
00305                 XnStatus AllocateData(XnUInt32 nXRes, XnUInt32 nYRes)
00306                 {
00307                         XnStatus nRetVal = XN_STATUS_OK;
00308                         
00309                         XnUInt32 nSize = nXRes * nYRes * BytesPerPixel();
00310                         nRetVal = OutputMetaData::AllocateData(nSize);
00311                         XN_IS_STATUS_OK(nRetVal);
00312 
00313                         FullXRes() = XRes() = nXRes;
00314                         FullYRes() = YRes() = nYRes;
00315                         XOffset() = YOffset() = 0;
00316                         
00317                         return (XN_STATUS_OK);
00318                 }
00319 
00328                 XnStatus ReAdjust(XnUInt32 nXRes, XnUInt32 nYRes, const XnUInt8* pExternalBuffer)
00329                 {
00330                         XnStatus nRetVal = XN_STATUS_OK;
00331 
00332                         if (pExternalBuffer == NULL)
00333                         {
00334                                 nRetVal = AllocateData(nXRes, nYRes);
00335                                 XN_IS_STATUS_OK(nRetVal);
00336                         }
00337                         else
00338                         {
00339                                 FullXRes() = XRes() = nXRes;
00340                                 FullYRes() = YRes() = nYRes;
00341                                 XOffset() = YOffset() = 0;
00342                                 Data() = pExternalBuffer;
00343                                 DataSize() = nXRes * nYRes * BytesPerPixel();
00344                         }
00345 
00346                         return (XN_STATUS_OK);
00347                 }
00348 
00349         protected:
00350                 XnPixelFormat& PixelFormatImpl() { return m_map.PixelFormat; }
00351 
00352         private:
00353                 // block copy ctor and assignment operator
00354                 MapMetaData& operator=(const MapMetaData&);
00355                 inline MapMetaData(const MapMetaData& other);
00356 
00357                 // Members
00358                 XnMapMetaData m_map;
00359         };
00360 
00361 /* Declares a map data accessor class */
00362 #define _XN_DECLARE_MAP_DATA_CLASS(_name, _pixelType)                                                   \
00363         class _name                                                                                                                                     \
00364         {                                                                                                                                                       \
00365         public:                                                                                                                                         \
00366                 inline _name(_pixelType*& pData, XnUInt32& nXRes, XnUInt32 &nYRes) :    \
00367                 m_pData(pData), m_nXRes(nXRes), m_nYRes(nYRes) {}                                               \
00368                                                                                                                                                                 \
00369                 inline XnUInt32 XRes() const { return m_nXRes; }                                                \
00370                 inline XnUInt32 YRes() const { return m_nYRes; }                                                \
00371                                                                                                                                                                 \
00372                 inline const _pixelType& operator[](XnUInt32 nIndex) const                              \
00373                 {                                                                                                                                               \
00374                         XN_ASSERT(nIndex < (m_nXRes * m_nYRes));                                                        \
00375                         return m_pData[nIndex];                                                                                         \
00376                 }                                                                                                                                               \
00377                 inline _pixelType& operator[](XnUInt32 nIndex)                                                  \
00378                 {                                                                                                                                               \
00379                         XN_ASSERT(nIndex < (m_nXRes *m_nYRes));                                                         \
00380                         return m_pData[nIndex];                                                                                         \
00381                 }                                                                                                                                               \
00382                                                                                                                                                                 \
00383                 inline const _pixelType& operator()(XnUInt32 x, XnUInt32 y) const               \
00384                 {                                                                                                                                               \
00385                         XN_ASSERT(x < m_nXRes && y < m_nYRes);                                                          \
00386                         return m_pData[y*m_nXRes + x];                                                                          \
00387                 }                                                                                                                                               \
00388                 inline _pixelType& operator()(XnUInt32 x, XnUInt32 y)                                   \
00389                 {                                                                                                                                               \
00390                         XN_ASSERT(x < m_nXRes && y < m_nYRes);                                                          \
00391                         return m_pData[y*m_nXRes + x];                                                                          \
00392                 }                                                                                                                                               \
00393                                                                                                                                                                 \
00394         private:                                                                                                                                        \
00395                 /* block copy ctor and assignment operator */                                                   \
00396                 _name(const _name& other);                                                                                              \
00397                 _name& operator=(const _name&);                                                                                 \
00398                                                                                                                                                                 \
00399                 _pixelType*& m_pData;                                                                                                   \
00400                 XnUInt32& m_nXRes;                                                                                                              \
00401                 XnUInt32& m_nYRes;                                                                                                              \
00402         };                                                                                                                                              
00403 
00404         _XN_DECLARE_MAP_DATA_CLASS(DepthMap, XnDepthPixel);
00405         _XN_DECLARE_MAP_DATA_CLASS(ImageMap, XnUInt8);
00406         _XN_DECLARE_MAP_DATA_CLASS(RGB24Map, XnRGB24Pixel);
00407         _XN_DECLARE_MAP_DATA_CLASS(Grayscale16Map, XnGrayscale16Pixel);
00408         _XN_DECLARE_MAP_DATA_CLASS(Grayscale8Map, XnGrayscale8Pixel);
00409         _XN_DECLARE_MAP_DATA_CLASS(IRMap, XnIRPixel);
00410         _XN_DECLARE_MAP_DATA_CLASS(LabelMap, XnLabel);
00411 
00416         class DepthMetaData : public MapMetaData
00417         {
00418         public:
00422                 inline DepthMetaData() : 
00423                         MapMetaData(XN_PIXEL_FORMAT_GRAYSCALE_16_BIT, (const XnUInt8**)&m_depth.pData),
00424                         m_depthMap(const_cast<XnDepthPixel*&>(m_depth.pData), MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y),
00425                         m_writableDepthMap((XnDepthPixel*&)m_pAllocatedData, MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y)
00426                 {
00427                         xnOSMemSet(&m_depth, 0, sizeof(XnDepthMetaData));
00428                         m_depth.pMap = MapMetaData::GetUnderlying();
00429                 }
00430 
00436                 inline void InitFrom(const DepthMetaData& other)
00437                 {
00438                         xnCopyDepthMetaData(&m_depth, &other.m_depth);
00439                 }
00440 
00450                 inline XnStatus InitFrom(const DepthMetaData& other, XnUInt32 nXRes, XnUInt32 nYRes, const XnDepthPixel* pExternalBuffer)
00451                 {
00452                         InitFrom(other);
00453                         return ReAdjust(nXRes, nYRes, pExternalBuffer);
00454                 }
00455 
00461                 XnStatus CopyFrom(const DepthMetaData& other)
00462                 {
00463                         // copy props
00464                         InitFrom(other);
00465                         // and make a copy of the data (this will allocate and copy data)
00466                         return MakeDataWritable();
00467                 }
00468 
00470                 XnStatus ReAdjust(XnUInt32 nXRes, XnUInt32 nYRes, const XnDepthPixel* pExternalBuffer = NULL)
00471                 {
00472                         return MapMetaData::ReAdjust(nXRes, nYRes, (const XnUInt8*)pExternalBuffer);
00473                 }
00474 
00476                 inline XnDepthPixel ZRes() const { return m_depth.nZRes; }
00478                 inline XnDepthPixel& ZRes() { return m_depth.nZRes; }
00479 
00481                 inline const XnDepthPixel* Data() const { return (const XnDepthPixel*)MapMetaData::Data(); }
00483                 inline const XnDepthPixel*& Data() { return (const XnDepthPixel*&)MapMetaData::Data(); }
00485                 inline XnDepthPixel* WritableData() { return (XnDepthPixel*)MapMetaData::WritableData(); }
00486 
00488                 inline const xn::DepthMap& DepthMap() const { return m_depthMap; }
00490                 inline xn::DepthMap& WritableDepthMap() 
00491                 { 
00492                         MakeDataWritable();
00493                         return m_writableDepthMap; 
00494                 }
00495 
00501                 inline const XnDepthPixel& operator[](XnUInt32 nIndex) const 
00502                 { 
00503                         XN_ASSERT(nIndex < (XRes()*YRes()));
00504                         return Data()[nIndex]; 
00505                 }
00506 
00513                 inline const XnDepthPixel& operator()(XnUInt32 x, XnUInt32 y) const 
00514                 {
00515                         XN_ASSERT(x < XRes() && y < YRes());
00516                         return Data()[y*XRes() + x]; 
00517                 }
00518 
00520                 inline const XnDepthMetaData* GetUnderlying() const { return &m_depth; }
00522                 inline XnDepthMetaData* GetUnderlying() { return &m_depth; }
00523 
00524         private:
00525                 // block copy ctor and assignment operator (because we can't return errors in those)
00526                 DepthMetaData(const DepthMetaData& other);
00527                 DepthMetaData& operator=(const DepthMetaData&);
00528 
00529                 XnDepthMetaData m_depth;
00530                 const xn::DepthMap m_depthMap;
00531                 xn::DepthMap m_writableDepthMap;
00532         };
00533 
00538         class ImageMetaData : public MapMetaData
00539         {
00540         public:
00542                 inline ImageMetaData() : 
00543                         MapMetaData(XN_PIXEL_FORMAT_RGB24, &m_image.pData),
00544                         m_imageMap(const_cast<XnUInt8*&>(m_image.pData), MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y),
00545                         m_writableImageMap((XnUInt8*&)m_pAllocatedData, MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y),
00546                         m_rgb24Map((XnRGB24Pixel*&)m_image.pData, MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y),
00547                         m_writableRgb24Map((XnRGB24Pixel*&)m_pAllocatedData, MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y),
00548                         m_gray16Map((XnGrayscale16Pixel*&)m_image.pData, MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y),
00549                         m_writableGray16Map((XnGrayscale16Pixel*&)m_pAllocatedData, MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y),
00550                         m_gray8Map((XnGrayscale8Pixel*&)m_image.pData, MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y),
00551                         m_writableGray8Map((XnGrayscale8Pixel*&)m_pAllocatedData, MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y)
00552                 {
00553                         xnOSMemSet(&m_image, 0, sizeof(XnImageMetaData));
00554                         m_image.pMap = MapMetaData::GetUnderlying();
00555                 }
00556 
00562                 inline void InitFrom(const ImageMetaData& other)
00563                 {
00564                         xnCopyImageMetaData(&m_image, &other.m_image);
00565                 }
00566 
00577                 inline XnStatus InitFrom(const ImageMetaData& other, XnUInt32 nXRes, XnUInt32 nYRes, XnPixelFormat format, const XnUInt8* pExternalBuffer)
00578                 {
00579                         InitFrom(other);
00580                         XnStatus nRetVal = ReAdjust(nXRes, nYRes, format, pExternalBuffer);
00581                         XN_IS_STATUS_OK(nRetVal);
00582                         PixelFormat() = format;
00583                         return XN_STATUS_OK;
00584                 }
00585 
00593                 inline XnStatus AllocateData(XnUInt32 nXRes, XnUInt32 nYRes, XnPixelFormat format)
00594                 {
00595                         XnPixelFormat origFormat = PixelFormat();
00596                         PixelFormat() = format;
00597                         XnStatus nRetVal = MapMetaData::AllocateData(nXRes, nYRes);
00598                         if (nRetVal != XN_STATUS_OK)
00599                         {
00600                                 PixelFormat() = origFormat;
00601                                 return (nRetVal);
00602                         }
00603 
00604                         return XN_STATUS_OK;
00605                 }
00606 
00608                 inline XnStatus CopyFrom(const ImageMetaData& other)
00609                 {
00610                         // copy props
00611                         xnCopyImageMetaData(&m_image, &other.m_image);
00612                         // and make a copy of the data (this will allocate and copy data)
00613                         return MakeDataWritable();
00614                 }
00615 
00625                 XnStatus ReAdjust(XnUInt32 nXRes, XnUInt32 nYRes, XnPixelFormat format, const XnUInt8* pExternalBuffer = NULL)
00626                 {
00627                         XnPixelFormat origFormat = PixelFormat();
00628                         PixelFormat() = format;
00629                         XnStatus nRetVal = MapMetaData::ReAdjust(nXRes, nYRes, pExternalBuffer);
00630                         if (nRetVal != XN_STATUS_OK)
00631                         {
00632                                 PixelFormat() = origFormat;
00633                                 return (nRetVal);
00634                         }
00635 
00636                         return XN_STATUS_OK;
00637                 }
00638 
00640                 inline XnPixelFormat PixelFormat() const { return MapMetaData::PixelFormat(); }
00642                 inline XnPixelFormat& PixelFormat() { return MapMetaData::PixelFormatImpl(); }
00643 
00645                 inline XnUInt8* WritableData() { return MapMetaData::WritableData(); }
00646 
00648                 inline const XnRGB24Pixel* RGB24Data() const { return (const XnRGB24Pixel*)MapMetaData::Data(); }
00650                 inline const XnRGB24Pixel*& RGB24Data() { return (const XnRGB24Pixel*&)MapMetaData::Data(); }
00652                 inline XnRGB24Pixel* WritableRGB24Data() { return (XnRGB24Pixel*)MapMetaData::WritableData(); }
00653 
00655                 inline const XnYUV422DoublePixel* YUV422Data() const { return (const XnYUV422DoublePixel*)MapMetaData::Data(); }
00657                 inline const XnYUV422DoublePixel*& YUV422Data() { return (const XnYUV422DoublePixel*&)MapMetaData::Data(); }
00659                 inline XnYUV422DoublePixel* WritableYUV422Data() { return (XnYUV422DoublePixel*)MapMetaData::WritableData(); }
00660 
00662                 inline const XnGrayscale8Pixel* Grayscale8Data() const { return (const XnGrayscale8Pixel*)MapMetaData::Data(); }
00664                 inline const XnGrayscale8Pixel*& Grayscale8Data() { return (const XnGrayscale8Pixel*&)MapMetaData::Data(); }
00666                 inline XnGrayscale8Pixel* WritableGrayscale8Data() { return (XnGrayscale8Pixel*)MapMetaData::WritableData(); }
00667 
00669                 inline const XnGrayscale16Pixel* Grayscale16Data() const { return (const XnGrayscale16Pixel*)MapMetaData::Data(); }
00671                 inline const XnGrayscale16Pixel*& Grayscale16Data() { return (const XnGrayscale16Pixel*&)MapMetaData::Data(); }
00673                 inline XnGrayscale16Pixel* WritableGrayscale16Data() { return (XnGrayscale16Pixel*)MapMetaData::WritableData(); }
00674 
00676                 inline const xn::ImageMap& ImageMap() const { return m_imageMap; }
00678                 inline xn::ImageMap& WritableImageMap() { MakeDataWritable(); return m_writableImageMap; }
00679 
00681                 inline const xn::RGB24Map& RGB24Map() const { return m_rgb24Map; }
00683                 inline xn::RGB24Map& WritableRGB24Map() { MakeDataWritable(); return m_writableRgb24Map; }
00684 
00686                 inline const xn::Grayscale8Map& Grayscale8Map() const { return m_gray8Map; }
00688                 inline xn::Grayscale8Map& WritableGrayscale8Map() { MakeDataWritable(); return m_writableGray8Map; }
00689 
00691                 inline const xn::Grayscale16Map& Grayscale16Map() const { return m_gray16Map; }
00693                 inline xn::Grayscale16Map& WritableGrayscale16Map() { MakeDataWritable(); return m_writableGray16Map; }
00694 
00696                 inline const XnImageMetaData* GetUnderlying() const { return &m_image; }
00698                 inline XnImageMetaData* GetUnderlying() { return &m_image; }
00699 
00700         private:
00701                 // block copy ctor and assignment operator
00702                 ImageMetaData(const ImageMetaData& other);
00703                 ImageMetaData& operator=(const ImageMetaData&);
00704 
00705                 XnImageMetaData m_image;
00706                 const xn::ImageMap m_imageMap;
00707                 xn::ImageMap m_writableImageMap;
00708                 const xn::RGB24Map m_rgb24Map;
00709                 xn::RGB24Map m_writableRgb24Map;
00710                 const xn::Grayscale16Map m_gray16Map;
00711                 xn::Grayscale16Map m_writableGray16Map;
00712                 const xn::Grayscale8Map m_gray8Map;
00713                 xn::Grayscale8Map m_writableGray8Map;
00714         };
00715 
00720         class IRMetaData : public MapMetaData
00721         {
00722         public:
00724                 inline IRMetaData() : 
00725                         MapMetaData(XN_PIXEL_FORMAT_GRAYSCALE_16_BIT, (const XnUInt8**)&m_ir.pData),
00726                         m_irMap(const_cast<XnIRPixel*&>(m_ir.pData), MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y),
00727                         m_writableIRMap((XnIRPixel*&)m_pAllocatedData, MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y)
00728                 {
00729                         xnOSMemSet(&m_ir, 0, sizeof(XnIRMetaData));
00730                         m_ir.pMap = MapMetaData::GetUnderlying();
00731                 }
00732 
00738                 inline void InitFrom(const IRMetaData& other)
00739                 {
00740                         xnCopyIRMetaData(&m_ir, &other.m_ir);
00741                 }
00742 
00744                 inline XnStatus InitFrom(const IRMetaData& other, XnUInt32 nXRes, XnUInt32 nYRes, const XnIRPixel* pExternalBuffer)
00745                 {
00746                         InitFrom(other);
00747                         return ReAdjust(nXRes, nYRes, pExternalBuffer);
00748                 }
00749 
00751                 XnStatus CopyFrom(const IRMetaData& other)
00752                 {
00753                         // copy props
00754                         xnCopyIRMetaData(&m_ir, &other.m_ir);
00755                         // and make a copy of the data (this will allocate and copy data)
00756                         return MakeDataWritable();
00757                 }
00758 
00760                 XnStatus ReAdjust(XnUInt32 nXRes, XnUInt32 nYRes, const XnIRPixel* pExternalBuffer = NULL)
00761                 {
00762                         return MapMetaData::ReAdjust(nXRes, nYRes, (const XnUInt8*)pExternalBuffer);
00763                 }
00764 
00766                 inline const XnIRPixel* Data() const { return (const XnIRPixel*)MapMetaData::Data(); }
00768                 inline const XnIRPixel*& Data() { return (const XnIRPixel*&)MapMetaData::Data(); }
00770                 inline XnIRPixel* WritableData() { return (XnIRPixel*)MapMetaData::WritableData(); }
00771 
00773                 inline const xn::IRMap& IRMap() const { return m_irMap; }
00775                 inline xn::IRMap& WritableIRMap() { MakeDataWritable(); return m_writableIRMap; }
00776 
00778                 inline const XnIRMetaData* GetUnderlying() const { return &m_ir; }
00780                 inline XnIRMetaData* GetUnderlying() { return &m_ir; }
00781 
00782         private:
00783                 // block copy ctor and assignment operator
00784                 IRMetaData(const IRMetaData& other);
00785                 IRMetaData& operator=(const IRMetaData&);
00786 
00787                 XnIRMetaData m_ir;
00788                 const xn::IRMap m_irMap;
00789                 xn::IRMap m_writableIRMap;
00790         };
00791 
00796         class AudioMetaData : public OutputMetaData
00797         {
00798         public:
00800                 inline AudioMetaData() : OutputMetaData(&m_audio.pData)
00801                 {
00802                         xnOSMemSet(&m_audio, 0, sizeof(XnAudioMetaData));
00803                         m_audio.pOutput = OutputMetaData::GetUnderlying();
00804                 }
00805 
00811                 inline void InitFrom(const AudioMetaData& other)
00812                 {
00813                         xnCopyAudioMetaData(&m_audio, &other.m_audio);
00814                 }
00815 
00817                 inline XnUInt8 NumberOfChannels() const { return m_audio.Wave.nChannels; }
00819                 inline XnUInt8& NumberOfChannels() { return m_audio.Wave.nChannels; }
00820 
00822                 inline XnUInt32 SampleRate() const { return m_audio.Wave.nSampleRate; }
00824                 inline XnUInt32& SampleRate() { return m_audio.Wave.nSampleRate; }
00825 
00827                 inline XnUInt16 BitsPerSample() const { return m_audio.Wave.nBitsPerSample; }
00829                 inline XnUInt16& BitsPerSample() { return m_audio.Wave.nBitsPerSample; }
00830 
00832                 inline const XnAudioMetaData* GetUnderlying() const { return &m_audio; }
00834                 inline XnAudioMetaData* GetUnderlying() { return &m_audio; }
00835 
00836         private:
00837                 // block copy ctor and assignment operator
00838                 AudioMetaData(const AudioMetaData& other);
00839                 AudioMetaData& operator=(const AudioMetaData&);
00840 
00841                 XnAudioMetaData m_audio;
00842                 XnBool m_bAllocated;
00843         };
00844 
00849         class SceneMetaData : public MapMetaData
00850         {
00851         public:
00853                 inline SceneMetaData() : 
00854                         MapMetaData(XN_PIXEL_FORMAT_GRAYSCALE_16_BIT, (const XnUInt8**)&m_scene.pData),
00855                         m_labelMap(const_cast<XnLabel*&>(m_scene.pData), MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y),
00856                         m_writableLabelMap((XnLabel*&)m_pAllocatedData, MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y)
00857                 {
00858                         xnOSMemSet(&m_scene, 0, sizeof(XnSceneMetaData));
00859                         m_scene.pMap = MapMetaData::GetUnderlying();
00860                 }
00861 
00867                 inline void InitFrom(const SceneMetaData& other)
00868                 {
00869                         xnCopySceneMetaData(&m_scene, &other.m_scene);
00870                 }
00871 
00873                 inline XnStatus InitFrom(const SceneMetaData& other, XnUInt32 nXRes, XnUInt32 nYRes, const XnLabel* pExternalBuffer)
00874                 {
00875                         InitFrom(other);
00876                         return ReAdjust(nXRes, nYRes, pExternalBuffer);
00877                 }
00878 
00880                 XnStatus CopyFrom(const SceneMetaData& other)
00881                 {
00882                         // copy props
00883                         xnCopySceneMetaData(&m_scene, &other.m_scene);
00884                         // and make a copy of the data (this will allocate and copy data)
00885                         return MakeDataWritable();
00886                 }
00887 
00889                 XnStatus ReAdjust(XnUInt32 nXRes, XnUInt32 nYRes, const XnLabel* pExternalBuffer = NULL)
00890                 {
00891                         return MapMetaData::ReAdjust(nXRes, nYRes, (const XnUInt8*)pExternalBuffer);
00892                 }
00893 
00895                 inline const XnLabel* Data() const { return (const XnLabel*)MapMetaData::Data(); }
00897                 inline const XnLabel*& Data() { return (const XnLabel*&)MapMetaData::Data(); }
00899                 inline XnLabel* WritableData() { return (XnLabel*)MapMetaData::WritableData(); }
00900 
00902                 inline const xn::LabelMap& LabelMap() const { return m_labelMap; }
00904                 inline xn::LabelMap& WritableLabelMap() { MakeDataWritable(); return m_writableLabelMap; }
00905 
00911                 inline const XnLabel& operator[](XnUInt32 nIndex) const
00912                 {
00913                         XN_ASSERT(nIndex < (XRes()*YRes()));
00914                         return Data()[nIndex];
00915                 }
00916 
00923                 inline const XnLabel& operator()(XnUInt32 x, XnUInt32 y) const
00924                 {
00925                         XN_ASSERT(x < XRes() && y < YRes());
00926                         return (*this)[y*XRes() + x];
00927                 }
00928 
00930                 inline const XnSceneMetaData* GetUnderlying() const { return &m_scene; }
00932                 inline XnSceneMetaData* GetUnderlying() { return &m_scene; }
00933 
00934         private:
00935                 // block copy ctor and assignment operator
00936                 SceneMetaData(const SceneMetaData& other);
00937                 SceneMetaData& operator=(const SceneMetaData&);
00938 
00939                 XnSceneMetaData m_scene;
00940                 const xn::LabelMap m_labelMap;
00941                 xn::LabelMap m_writableLabelMap;
00942         };
00943 
00944         //---------------------------------------------------------------------------
00945         // NodeWrapper
00946         //---------------------------------------------------------------------------
00947 
00952         class NodeWrapper
00953         {
00954         public:
00955                 friend class Context;
00956 
00962                 inline NodeWrapper(XnNodeHandle hNode)
00963                 {
00964                         NodeWrapper::SetHandle(hNode);
00965                 }
00966 
00968                 inline operator XnNodeHandle() const { return m_hNode; }
00969 
00975                 inline XnBool operator==(const NodeWrapper& other)
00976                 {
00977                         return (m_hNode == other.m_hNode);
00978                 }
00979 
00985                 inline XnBool operator!=(const NodeWrapper& other)
00986                 {
00987                         return (m_hNode != other.m_hNode);
00988                 }
00989 
00991                 inline XnBool IsValid() const { return (m_hNode != NULL); }
00992                 
00996                 const XnChar* GetName() const {return xnGetNodeName(m_hNode); }
00997 
00999                 virtual void SetHandle(XnNodeHandle hNode) { m_hNode = hNode; }
01000 
01001         protected:
01002                 XnNodeHandle m_hNode;
01003         };
01004 
01005         //---------------------------------------------------------------------------
01006         // Node Info
01007         //---------------------------------------------------------------------------
01008 
01013         class NodeInfo
01014         {
01015         public:
01021                 NodeInfo(XnNodeInfo* pInfo) : m_pNeededNodes(NULL)
01022                 {
01023                         SetUnderlyingObject(pInfo);
01024                 }
01025 
01031                 NodeInfo(const NodeInfo& other) : m_pNeededNodes(NULL)
01032                 {
01033                         SetUnderlyingObject(other.m_pInfo);
01034                 }
01035 
01037                 ~NodeInfo()
01038                 {
01039                         SetUnderlyingObject(NULL);
01040                 }
01041 
01047                 inline NodeInfo& operator=(const NodeInfo& other)
01048                 {
01049                         SetUnderlyingObject(other.m_pInfo);
01050                         return *this;
01051                 }
01052 
01054                 inline operator XnNodeInfo*()
01055                 {
01056                         return m_pInfo;
01057                 }
01058 
01062                 inline XnStatus SetInstanceName(const XnChar* strName)
01063                 {
01064                         return xnNodeInfoSetInstanceName(m_pInfo, strName);
01065                 }
01066 
01070                 inline const XnProductionNodeDescription& GetDescription() const
01071                 {
01072                         return *xnNodeInfoGetDescription(m_pInfo);
01073                 }
01074 
01078                 inline const XnChar* GetInstanceName() const
01079                 {
01080                         return xnNodeInfoGetInstanceName(m_pInfo);
01081                 }
01082                 inline const XnChar* GetCreationInfo() const
01086                 {
01087                         return xnNodeInfoGetCreationInfo(m_pInfo);
01088                 }
01089 
01093                 inline NodeInfoList& GetNeededNodes() const;
01094 
01102                 inline XnStatus GetInstance(ProductionNode& node) const;
01103 
01104         private:
01105                 inline void SetUnderlyingObject(XnNodeInfo* pInfo);
01106 
01107                 XnNodeInfo* m_pInfo;
01108                 mutable NodeInfoList* m_pNeededNodes;
01109         };
01110 
01111         //---------------------------------------------------------------------------
01112         // Query
01113         //---------------------------------------------------------------------------
01114 
01120         class Query
01121         {
01122         public:
01124                 inline Query()
01125                 {
01126                         xnNodeQueryAllocate(&m_pQuery);
01127                 }
01128 
01130                 ~Query()
01131                 {
01132                         xnNodeQueryFree(m_pQuery);
01133                         m_pQuery = NULL;
01134                 }
01135 
01137                 inline XnNodeQuery* GetUnderlyingObject() const { return m_pQuery; }
01138 
01142                 inline XnStatus SetVendor(const XnChar* strVendor)
01143                 {
01144                         return xnNodeQuerySetVendor(m_pQuery, strVendor);
01145                 }
01146 
01150                 inline XnStatus SetName(const XnChar* strName)
01151                 {
01152                         return xnNodeQuerySetName(m_pQuery, strName);
01153                 }
01154 
01158                 inline XnStatus SetMinVersion(const XnVersion& minVersion)
01159                 {
01160                         return xnNodeQuerySetMinVersion(m_pQuery, &minVersion);
01161                 }
01162 
01166                 inline XnStatus SetMaxVersion(const XnVersion& maxVersion)
01167                 {
01168                         return xnNodeQuerySetMaxVersion(m_pQuery, &maxVersion);
01169                 }
01170 
01174                 inline XnStatus AddSupportedCapability(const XnChar* strNeededCapability)
01175                 {
01176                         return xnNodeQueryAddSupportedCapability(m_pQuery, strNeededCapability);
01177                 }
01178 
01182                 inline XnStatus AddSupportedMapOutputMode(const XnMapOutputMode& MapOutputMode)
01183                 {
01184                         return xnNodeQueryAddSupportedMapOutputMode(m_pQuery, &MapOutputMode);
01185                 }
01186 
01190                 inline XnStatus SetSupportedMinUserPositions(const XnUInt32 nCount)
01191                 {
01192                         return xnNodeQuerySetSupportedMinUserPositions(m_pQuery, nCount);
01193                 }
01194 
01198                 inline XnStatus SetExistingNodeOnly(XnBool bExistingNode)
01199                 {
01200                         return xnNodeQuerySetExistingNodeOnly(m_pQuery, bExistingNode);
01201                 }
01202 
01206                 inline XnStatus AddNeededNode(const XnChar* strInstanceName)
01207                 {
01208                         return xnNodeQueryAddNeededNode(m_pQuery, strInstanceName);
01209                 }
01210 
01214                 inline XnStatus SetCreationInfo(const XnChar* strCreationInfo)
01215                 {
01216                         return xnNodeQuerySetCreationInfo(m_pQuery, strCreationInfo);
01217                 }
01218 
01219         private:
01220                 XnNodeQuery* m_pQuery;
01221         };
01222 
01223         //---------------------------------------------------------------------------
01224         // Node Info List
01225         //---------------------------------------------------------------------------
01226 
01231         class NodeInfoList
01232         {
01233         public:
01235                 class Iterator
01236                 {
01237                 public:
01238                         friend class NodeInfoList;
01239 
01245                         XnBool operator==(const Iterator& other) const
01246                         {
01247                                 return m_it.pCurrent == other.m_it.pCurrent;
01248                         }
01249 
01255                         XnBool operator!=(const Iterator& other) const
01256                         {
01257                                 return m_it.pCurrent != other.m_it.pCurrent;
01258                         }
01259 
01264                         inline Iterator& operator++()
01265                         {
01266                                 UpdateInternalObject(xnNodeInfoListGetNext(m_it));
01267                                 return *this;
01268                         }
01269 
01274                         inline Iterator operator++(int)
01275                         {
01276                                 XnNodeInfoListIterator curr = m_it;
01277                                 UpdateInternalObject(xnNodeInfoListGetNext(m_it));
01278                                 return Iterator(curr);
01279                         }
01280 
01284                         inline Iterator& operator--()
01285                         {
01286                                 UpdateInternalObject(xnNodeInfoListGetPrevious(m_it));
01287                                 return *this;
01288                         }
01289 
01293                         inline Iterator operator--(int)
01294                         {
01295                                 XnNodeInfoListIterator curr = m_it;
01296                                 UpdateInternalObject(xnNodeInfoListGetPrevious(m_it));
01297                                 return Iterator(curr);
01298                         }
01299 
01301                         inline NodeInfo operator*()
01302                         {
01303                                 return m_Info;
01304                         }
01305 
01306                 private:
01307                         inline Iterator(XnNodeInfoListIterator it) : m_Info(NULL)
01308                         {
01309                                 UpdateInternalObject(it);
01310                         }
01311 
01312                         inline void UpdateInternalObject(XnNodeInfoListIterator it)
01313                         {
01314                                 m_it = it;
01315                                 if (xnNodeInfoListIteratorIsValid(it))
01316                                 {
01317                                         XnNodeInfo* pInfo = xnNodeInfoListGetCurrent(it);
01318                                         m_Info = NodeInfo(pInfo);
01319                                 }
01320                                 else
01321                                 {
01322                                         m_Info = NodeInfo(NULL);
01323                                 }
01324                         }
01325 
01326                         NodeInfo m_Info;
01327                         XnNodeInfoListIterator m_it;
01328                 };
01329 
01333                 inline NodeInfoList() 
01334                 {
01335                         xnNodeInfoListAllocate(&m_pList);
01336                         m_bAllocated = TRUE;
01337                 }
01338 
01345                 inline NodeInfoList(XnNodeInfoList* pList) : m_pList(pList), m_bAllocated(FALSE) {}
01346 
01348                 inline ~NodeInfoList()
01349                 {
01350                         FreeImpl();
01351                 }
01352 
01354                 inline XnNodeInfoList* GetUnderlyingObject() const { return m_pList; }
01355 
01362                 inline void ReplaceUnderlyingObject(XnNodeInfoList* pList) 
01363                 {
01364                         FreeImpl();
01365                         m_pList = pList;
01366                         m_bAllocated = TRUE;
01367                 }
01368 
01373                 inline XnStatus Add(XnProductionNodeDescription& description, const XnChar* strCreationInfo, NodeInfoList* pNeededNodes)
01374                 {
01375                         XnNodeInfoList* pList = (pNeededNodes == NULL) ? NULL : pNeededNodes->GetUnderlyingObject();
01376                         return xnNodeInfoListAdd(m_pList, &description, strCreationInfo, pList);
01377                 }
01378 
01382                 inline XnStatus AddNode(NodeInfo& info)
01383                 {
01384                         return xnNodeInfoListAddNode(m_pList, info);
01385                 }
01386 
01390                 inline XnStatus AddNodeFromAnotherList(Iterator& it)
01391                 {
01392                         return xnNodeInfoListAddNodeFromList(m_pList, it.m_it);
01393                 }
01394 
01396                 inline Iterator Begin() const
01397                 {
01398                         return Iterator(xnNodeInfoListGetFirst(m_pList));
01399                 }
01400 
01402                 inline Iterator End() const
01403                 {
01404                         XnNodeInfoListIterator it = { NULL };
01405                         return Iterator(it);
01406                 }
01407 
01409                 inline Iterator RBegin() const
01410                 {
01411                         return Iterator(xnNodeInfoListGetLast(m_pList));
01412                 }
01413 
01415                 inline Iterator REnd() const
01416                 {
01417                         XnNodeInfoListIterator it = { NULL };
01418                         return Iterator(it);
01419                 }
01420 
01424                 inline XnStatus Remove(Iterator& it)
01425                 {
01426                         return xnNodeInfoListRemove(m_pList, it.m_it);
01427                 }
01428 
01432                 inline XnStatus Clear()
01433                 {
01434                         return xnNodeInfoListClear(m_pList);
01435                 }
01436 
01440                 inline XnStatus Append(NodeInfoList& other)
01441                 {
01442                         return xnNodeInfoListAppend(m_pList, other.GetUnderlyingObject());
01443                 }
01444 
01448                 inline XnBool IsEmpty()
01449                 {
01450                         return xnNodeInfoListIsEmpty(m_pList);
01451                 }
01452 
01456                 inline XnStatus FilterList(Context& context, Query& query);
01457 
01458         private:
01459                 inline void FreeImpl()
01460                 {
01461                         if (m_bAllocated)
01462                         {
01463                                 xnNodeInfoListFree(m_pList);
01464                                 m_bAllocated = FALSE;
01465                                 m_pList = NULL;
01466                         }
01467                 }
01468 
01469                 XnNodeInfoList* m_pList;
01470                 XnBool m_bAllocated;
01471         };
01472 
01473         //---------------------------------------------------------------------------
01474         // Production Nodes Functionality
01475         //---------------------------------------------------------------------------
01476 
01481         class Capability
01482         {
01483         public:
01489                 Capability(XnNodeHandle hNode) : m_hNode(hNode) {}
01490 
01496                 inline void SetUnderlyingHandle(XnNodeHandle hNode)
01497                 {
01498                         m_hNode = hNode;
01499                 }
01500 
01501         protected:
01502                 XnNodeHandle m_hNode;
01503         };
01504 
01509         class ErrorStateCapability : public Capability
01510         {
01511         public:
01517                 ErrorStateCapability(XnNodeHandle hNode) : Capability(hNode) {}
01518 
01522                 inline XnStatus GetErrorState()
01523                 {
01524                         return xnGetNodeErrorState(m_hNode);
01525                 }
01526 
01530                 inline XnStatus RegisterToErrorStateChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
01531                 {
01532                         return _RegisterToStateChange(xnRegisterToNodeErrorStateChange, m_hNode, handler, pCookie, hCallback);
01533                 }
01534 
01538                 inline void UnregisterFromErrorStateChange(XnCallbackHandle hCallback)
01539                 {
01540                         _UnregisterFromStateChange(xnUnregisterFromNodeErrorStateChange, m_hNode, hCallback);
01541                 }
01542         };
01543 
01548         class ProductionNode : public NodeWrapper
01549         {
01550         public:
01556                 inline ProductionNode(XnNodeHandle hNode = NULL) : NodeWrapper(hNode) {}
01557 
01561                 inline NodeInfo GetInfo() const { return NodeInfo(xnGetNodeInfo(m_hNode)); }
01562 
01566                 inline XnStatus Ref() { return xnRefProductionNode(m_hNode); }
01567 
01571                 inline void Unref() 
01572                 { 
01573                         xnUnrefProductionNode(m_hNode); 
01574                         SetHandle(NULL);
01575                 }
01576 
01580                 inline XnStatus AddNeededNode(ProductionNode& needed)
01581                 {
01582                         return xnAddNeededNode(m_hNode, needed.m_hNode);
01583                 }
01584 
01588                 inline XnStatus RemoveNeededNode(ProductionNode& needed)
01589                 {
01590                         return xnRemoveNeededNode(m_hNode, needed.m_hNode);
01591                 }
01592 
01596                 inline void GetContext(Context& context);
01597 
01601                 inline XnBool IsCapabilitySupported(const XnChar* strCapabilityName) const
01602                 {
01603                         return xnIsCapabilitySupported(m_hNode, strCapabilityName);
01604                 }
01605 
01609                 inline XnStatus SetIntProperty(const XnChar* strName, XnUInt64 nValue)
01610                 {
01611                         return xnSetIntProperty(m_hNode, strName, nValue);
01612                 }
01613 
01617                 inline XnStatus SetRealProperty(const XnChar* strName, XnDouble dValue)
01618                 {
01619                         return xnSetRealProperty(m_hNode, strName, dValue);
01620                 }
01621 
01625                 inline XnStatus SetStringProperty(const XnChar* strName, const XnChar* strValue)
01626                 {
01627                         return xnSetStringProperty(m_hNode, strName, strValue);
01628                 }
01629 
01633                 inline XnStatus SetGeneralProperty(const XnChar* strName, XnUInt32 nBufferSize, const void* pBuffer)
01634                 {
01635                         return xnSetGeneralProperty(m_hNode, strName, nBufferSize, pBuffer);
01636                 }
01637 
01641                 inline XnStatus GetIntProperty(const XnChar* strName, XnUInt64& nValue) const
01642                 {
01643                         return xnGetIntProperty(m_hNode, strName, &nValue);
01644                 }
01645 
01649                 inline XnStatus GetRealProperty(const XnChar* strName, XnDouble &dValue) const
01650                 {
01651                         return xnGetRealProperty(m_hNode, strName, &dValue);
01652                 }
01653 
01657                 inline XnStatus GetStringProperty(const XnChar* strName, XnChar* csValue, XnUInt32 nBufSize) const
01658                 {
01659                         return xnGetStringProperty(m_hNode, strName, csValue, nBufSize);
01660                 }
01661 
01665                 inline XnStatus GetGeneralProperty(const XnChar* strName, XnUInt32 nBufferSize, void* pBuffer) const
01666                 {
01667                         return xnGetGeneralProperty(m_hNode, strName, nBufferSize, pBuffer);
01668                 }
01669 
01673                 inline XnStatus LockForChanges(XnLockHandle* phLock)
01674                 {
01675                         return xnLockNodeForChanges(m_hNode, phLock);
01676                 }
01677 
01681                 inline void UnlockForChanges(XnLockHandle hLock)
01682                 {
01683                         xnUnlockNodeForChanges(m_hNode, hLock);
01684                 }
01685 
01689                 inline XnStatus LockedNodeStartChanges(XnLockHandle hLock)
01690                 {
01691                         return xnLockedNodeStartChanges(m_hNode, hLock);
01692                 }
01693 
01697                 inline void LockedNodeEndChanges(XnLockHandle hLock)
01698                 {
01699                         xnLockedNodeEndChanges(m_hNode, hLock);
01700                 }
01701 
01707                 inline ErrorStateCapability GetErrorStateCap()
01708                 {
01709                         return ErrorStateCapability(m_hNode);
01710                 }
01711         };
01712 
01717         class Device : public ProductionNode
01718         {
01719         public:
01725                 inline Device(XnNodeHandle hNode = NULL) : ProductionNode(hNode) {}
01726         };
01727 
01732         class MirrorCapability : public Capability
01733         {
01734         public:
01740                 inline MirrorCapability(XnNodeHandle hNode) : Capability(hNode) {}
01741 
01745                 inline XnStatus SetMirror(XnBool bMirror)
01746                 {
01747                         return xnSetMirror(m_hNode, bMirror);
01748                 }
01749 
01753                 inline XnBool IsMirrored() const
01754                 {
01755                         return xnIsMirrored(m_hNode);
01756                 }
01757 
01761                 inline XnStatus RegisterToMirrorChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
01762                 {
01763                         return _RegisterToStateChange(xnRegisterToMirrorChange, m_hNode, handler, pCookie, hCallback);
01764                 }
01765 
01769                 inline void UnregisterFromMirrorChange(XnCallbackHandle hCallback)
01770                 {
01771                         _UnregisterFromStateChange(xnUnregisterFromMirrorChange, m_hNode, hCallback);
01772                 }
01773         };
01774 
01779         class AlternativeViewPointCapability : public Capability
01780         {
01781         public:
01787                 inline AlternativeViewPointCapability(XnNodeHandle hNode) : Capability(hNode) {}
01788 
01792                 inline XnBool IsViewPointSupported(ProductionNode& otherNode) const
01793                 {
01794                         return xnIsViewPointSupported(m_hNode, otherNode);
01795                 }
01796 
01800                 inline XnStatus SetViewPoint(ProductionNode& otherNode)
01801                 {
01802                         return xnSetViewPoint(m_hNode, otherNode);
01803                 }
01804 
01808                 inline XnStatus ResetViewPoint()
01809                 {
01810                         return xnResetViewPoint(m_hNode);
01811                 }
01812 
01816                 inline XnBool IsViewPointAs(ProductionNode& otherNode) const
01817                 {
01818                         return xnIsViewPointAs(m_hNode, otherNode);
01819                 }
01820 
01824                 inline XnStatus RegisterToViewPointChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
01825                 {
01826                         return _RegisterToStateChange(xnRegisterToViewPointChange, m_hNode, handler, pCookie, hCallback);
01827                 }
01828 
01832                 inline void UnregisterFromViewPointChange(XnCallbackHandle hCallback)
01833                 {
01834                         _UnregisterFromStateChange(xnUnregisterFromViewPointChange, m_hNode, hCallback);
01835                 }
01836         };
01837 
01842         class FrameSyncCapability : public Capability
01843         {
01844         public:
01850                 inline FrameSyncCapability(XnNodeHandle hNode) : Capability(hNode) {}
01851 
01855                 inline XnBool CanFrameSyncWith(Generator& other);
01856 
01860                 inline XnStatus FrameSyncWith(Generator& other);
01861 
01865                 inline XnStatus StopFrameSyncWith(Generator& other);
01866 
01870                 inline XnBool IsFrameSyncedWith(Generator& other);
01871 
01875                 inline XnStatus RegisterToFrameSyncChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
01876                 {
01877                         return _RegisterToStateChange(xnRegisterToFrameSyncChange, m_hNode, handler, pCookie, hCallback);
01878                 }
01879 
01883                 inline void UnregisterFromFrameSyncChange(XnCallbackHandle hCallback)
01884                 {
01885                         _UnregisterFromStateChange(xnUnregisterFromFrameSyncChange, m_hNode, hCallback);
01886                 }
01887         };
01888 
01893         class Generator : public ProductionNode
01894         {
01895         public:
01901                 inline Generator(XnNodeHandle hNode = NULL) : ProductionNode(hNode) {}
01902 
01906                 inline XnStatus StartGenerating()
01907                 {
01908                         return xnStartGenerating(m_hNode);
01909                 }
01910 
01914                 inline XnBool IsGenerating() const
01915                 {
01916                         return xnIsGenerating(m_hNode);
01917                 }
01918 
01922                 inline XnStatus StopGenerating()
01923                 {
01924                         return xnStopGenerating(m_hNode);
01925                 }
01926 
01930                 inline XnStatus RegisterToGenerationRunningChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle &hCallback)
01931                 {
01932                         return _RegisterToStateChange(xnRegisterToGenerationRunningChange, m_hNode, handler, pCookie, hCallback);
01933                 }
01934 
01938                 inline void UnregisterFromGenerationRunningChange(XnCallbackHandle hCallback)
01939                 {
01940                         _UnregisterFromStateChange(xnUnregisterFromGenerationRunningChange, m_hNode, hCallback);
01941                 }
01942 
01946                 inline XnStatus RegisterToNewDataAvailable(StateChangedHandler handler, void* pCookie, XnCallbackHandle &hCallback)
01947                 {
01948                         return _RegisterToStateChange(xnRegisterToNewDataAvailable, m_hNode, handler, pCookie, hCallback);
01949                 }
01950 
01954                 inline void UnregisterFromNewDataAvailable(XnCallbackHandle hCallback)
01955                 {
01956                         _UnregisterFromStateChange(xnUnregisterFromNewDataAvailable, m_hNode, hCallback);
01957                 }
01958 
01962                 inline XnBool IsNewDataAvailable(XnUInt64* pnTimestamp = NULL)
01963                 {
01964                         return xnIsNewDataAvailable(m_hNode, pnTimestamp);
01965                 }
01966 
01970                 inline XnStatus WaitAndUpdateData()
01971                 {
01972                         return xnWaitAndUpdateData(m_hNode);
01973                 }
01974 
01978                 inline XnBool IsDataNew() const
01979                 {
01980                         return xnIsDataNew(m_hNode);
01981                 }
01982 
01986                 inline XnUInt32 GetDataSize() const
01987                 {
01988                         return xnGetDataSize(m_hNode);
01989                 }
01990 
01994                 inline XnUInt64 GetTimestamp() const
01995                 {
01996                         return xnGetTimestamp(m_hNode);
01997                 }
01998 
02002                 inline XnUInt32 GetFrameID() const
02003                 {
02004                         return xnGetFrameID(m_hNode);
02005                 }
02006 
02012                 inline MirrorCapability GetMirrorCap()
02013                 { 
02014                         return MirrorCapability(m_hNode); 
02015                 }
02016 
02022                 inline AlternativeViewPointCapability GetAlternativeViewPointCap() 
02023                 { 
02024                         return AlternativeViewPointCapability(m_hNode); 
02025                 }
02026 
02032                 inline FrameSyncCapability GetFrameSyncCap()
02033                 {
02034                         return FrameSyncCapability(m_hNode);
02035                 }
02036         };
02037 
02042         class Recorder : public ProductionNode
02043         {
02044         public:
02050                 inline Recorder(XnNodeHandle hNode = NULL) : ProductionNode(hNode) {}
02051 
02055                 inline XnStatus Create(Context& context, const XnChar* strFormatName);
02056 
02060                 inline XnStatus SetDestination(XnRecordMedium destType, const XnChar* strDest)
02061                 {
02062                         return xnSetRecorderDestination(m_hNode, destType, strDest);
02063                 }
02064 
02068                 inline XnStatus AddNodeToRecording(ProductionNode& Node, XnCodecID compression = XN_CODEC_NULL)
02069                 {
02070                         return xnAddNodeToRecording(m_hNode, Node, compression);
02071                 }
02072 
02076                 inline XnStatus RemoveNodeFromRecording(ProductionNode& Node)
02077                 {
02078                         return xnRemoveNodeFromRecording(m_hNode, Node);
02079                 }
02080 
02084                 inline XnStatus Record()
02085                 {
02086                         return xnRecord(m_hNode);
02087                 }
02088         };
02089 
02094         class Player : public ProductionNode
02095         {
02096         public:
02102                 inline Player(XnNodeHandle hNode = NULL) : ProductionNode(hNode) {}
02103 
02107                 inline XnStatus Create(Context& context, const XnChar* strFormatName);
02108 
02112                 inline XnStatus SetRepeat(XnBool bRepeat)
02113                 {
02114                         return xnSetPlayerRepeat(m_hNode, bRepeat);
02115                 }
02116 
02120                 inline XnStatus SetSource(XnRecordMedium sourceType, const XnChar* strSource)
02121                 {
02122                         return xnSetPlayerSource(m_hNode, sourceType, strSource);
02123                 }
02124 
02128                 inline XnStatus GetSource(XnRecordMedium &sourceType, XnChar* strSource, XnUInt32 nBufSize)
02129                 {
02130                         return xnGetPlayerSource(m_hNode, &sourceType, strSource, nBufSize);
02131                 }
02132 
02136                 inline XnStatus ReadNext()
02137                 {
02138                         return xnPlayerReadNext(m_hNode);
02139                 }
02140 
02144                 inline XnStatus SeekToTimeStamp(XnInt64 nTimeOffset, XnPlayerSeekOrigin origin)
02145                 {
02146                         return xnSeekPlayerToTimeStamp(m_hNode, nTimeOffset, origin);
02147                 }
02148 
02152                 inline XnStatus SeekToFrame(const XnChar* strNodeName, XnInt32 nFrameOffset, XnPlayerSeekOrigin origin)
02153                 {
02154                         return xnSeekPlayerToFrame(m_hNode, strNodeName, nFrameOffset, origin);
02155                 }
02156 
02160                 inline XnStatus TellTimestamp(XnUInt64& nTimestamp)
02161                 {
02162                         return xnTellPlayerTimestamp(m_hNode, &nTimestamp);
02163                 }
02164 
02168                 inline XnStatus TellFrame(const XnChar* strNodeName, XnUInt32& nFrame)
02169                 {
02170                         return xnTellPlayerFrame(m_hNode, strNodeName, &nFrame);
02171                 }
02172 
02176                 inline XnStatus GetNumFrames(const XnChar* strNodeName, XnUInt32& nFrames)
02177                 {
02178                         return xnGetPlayerNumFrames(m_hNode, strNodeName, &nFrames);
02179                 }
02180 
02184                 inline const XnChar* GetSupportedFormat()
02185                 {
02186                         return xnGetPlayerSupportedFormat(m_hNode);
02187                 }
02188 
02192                 inline XnStatus EnumerateNodes(NodeInfoList& list)
02193                 {
02194                         XnNodeInfoList* pList;
02195                         XnStatus nRetVal = xnEnumeratePlayerNodes(m_hNode, &pList);
02196                         XN_IS_STATUS_OK(nRetVal);
02197 
02198                         list.ReplaceUnderlyingObject(pList);
02199 
02200                         return (XN_STATUS_OK);
02201                 }
02202 
02206                 inline XnBool IsEOF()
02207                 {
02208                         return xnIsPlayerAtEOF(m_hNode);
02209                 }
02210 
02214                 inline XnStatus RegisterToEndOfFileReached(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
02215                 {
02216                         return _RegisterToStateChange(xnRegisterToEndOfFileReached, m_hNode, handler, pCookie, hCallback);
02217                 }
02218 
02222                 inline void UnregisterFromEndOfFileReached(XnCallbackHandle hCallback)
02223                 {
02224                         _UnregisterFromStateChange(xnUnregisterFromEndOfFileReached, m_hNode, hCallback);
02225                 }
02226         };
02227 
02232         class CroppingCapability : public Capability
02233         {
02234         public:
02240                 inline CroppingCapability(XnNodeHandle hNode) : Capability(hNode) {}
02241 
02245                 inline XnStatus SetCropping(const XnCropping& Cropping)
02246                 {
02247                         return xnSetCropping(m_hNode, &Cropping);
02248                 }
02249 
02253                 inline XnStatus GetCropping(XnCropping& Cropping) const
02254                 {
02255                         return xnGetCropping(m_hNode, &Cropping);
02256                 }
02257 
02261                 inline XnStatus RegisterToCroppingChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
02262                 {
02263                         return _RegisterToStateChange(xnRegisterToCroppingChange, m_hNode, handler, pCookie, hCallback);
02264                 }
02265 
02269                 inline void UnregisterFromCroppingChange(XnCallbackHandle hCallback)
02270                 {
02271                         _UnregisterFromStateChange(xnUnregisterFromCroppingChange, m_hNode, hCallback);
02272                 }
02273         };
02274 
02279         class MapGenerator : public Generator
02280         {
02281         public:
02287                 inline MapGenerator(XnNodeHandle hNode = NULL) : Generator(hNode) {}
02288 
02292                 inline XnUInt32 GetSupportedMapOutputModesCount() const
02293                 {
02294                         return xnGetSupportedMapOutputModesCount(m_hNode);
02295                 }
02296 
02300                 inline XnStatus GetSupportedMapOutputModes(XnMapOutputMode* aModes, XnUInt32& nCount) const
02301                 {
02302                         return xnGetSupportedMapOutputModes(m_hNode, aModes, &nCount);
02303                 }
02304 
02308                 inline XnStatus SetMapOutputMode(const XnMapOutputMode& OutputMode)
02309                 {
02310                         return xnSetMapOutputMode(m_hNode, &OutputMode);
02311                 }
02312 
02316                 inline XnStatus GetMapOutputMode(XnMapOutputMode &OutputMode) const
02317                 {
02318                         return xnGetMapOutputMode(m_hNode, &OutputMode);
02319                 }
02320 
02324                 inline XnStatus RegisterToMapOutputModeChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
02325                 {
02326                         return _RegisterToStateChange(xnRegisterToMapOutputModeChange, m_hNode, handler, pCookie, hCallback);
02327                 }
02328 
02332                 inline void UnregisterFromMapOutputModeChange(XnCallbackHandle hCallback)
02333                 {
02334                         _UnregisterFromStateChange(xnUnregisterFromMapOutputModeChange, m_hNode, hCallback);
02335                 }
02336 
02342                 inline CroppingCapability GetCroppingCap()
02343                 {
02344                         return CroppingCapability(m_hNode);
02345                 }
02346         };
02347 
02352         class UserPositionCapability : public Capability
02353         {
02354         public:
02360                 inline UserPositionCapability(XnNodeHandle hNode = NULL) : Capability(hNode) {}
02361 
02365                 inline XnUInt32 GetSupportedUserPositionsCount() const
02366                 {
02367                         return xnGetSupportedUserPositionsCount(m_hNode);
02368                 }
02369 
02373                 inline XnStatus SetUserPosition(XnUInt32 nIndex, const XnBoundingBox3D& Position)
02374                 {
02375                         return xnSetUserPosition(m_hNode, nIndex, &Position);
02376                 }
02377 
02381                 inline XnStatus GetUserPosition(XnUInt32 nIndex, XnBoundingBox3D& Position) const
02382                 {
02383                         return xnGetUserPosition(m_hNode, nIndex, &Position);
02384                 }
02385 
02389                 inline XnStatus RegisterToUserPositionChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
02390                 {
02391                         return _RegisterToStateChange(xnRegisterToUserPositionChange, m_hNode, handler, pCookie, hCallback);
02392                 }
02393 
02397                 inline void UnregisterFromUserPositionChange(XnCallbackHandle hCallback)
02398                 {
02399                         _UnregisterFromStateChange(xnUnregisterFromUserPositionChange, m_hNode, hCallback);
02400                 }
02401         };
02402 
02407         class DepthGenerator : public MapGenerator
02408         {
02409         public:
02415                 inline DepthGenerator(XnNodeHandle hNode = NULL) : MapGenerator(hNode) {}
02416 
02420                 inline XnStatus Create(Context& context, Query* pQuery = NULL, EnumerationErrors* pErrors = NULL);
02421 
02425                 inline void GetMetaData(DepthMetaData& metaData) const 
02426                 {
02427                         return xnGetDepthMetaData(m_hNode, metaData.GetUnderlying());
02428                 }
02429 
02433                 inline const XnDepthPixel* GetDepthMap() const
02434                 {
02435                         return xnGetDepthMap(m_hNode);
02436                 }
02437 
02441                 inline XnDepthPixel GetDeviceMaxDepth() const
02442                 {
02443                         return xnGetDeviceMaxDepth(m_hNode);
02444                 }
02445 
02449                 inline XnStatus GetFieldOfView(XnFieldOfView& FOV) const
02450                 {
02451                         return xnGetDepthFieldOfView(m_hNode, &FOV);
02452                 }
02453 
02457                 inline XnStatus RegisterToFieldOfViewChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
02458                 {
02459                         return _RegisterToStateChange(xnRegisterToDepthFieldOfViewChange, m_hNode, handler, pCookie, hCallback);
02460                 }
02461 
02465                 inline void UnregisterFromFieldOfViewChange(XnCallbackHandle hCallback)
02466                 {
02467                         _UnregisterFromStateChange(xnUnregisterFromDepthFieldOfViewChange, m_hNode, hCallback);
02468                 }
02469 
02473                 inline XnStatus ConvertProjectiveToRealWorld(XnUInt32 nCount, const XnPoint3D aProjective[], XnPoint3D aRealWorld[]) const
02474                 {
02475                         return xnConvertProjectiveToRealWorld(m_hNode, nCount, aProjective, aRealWorld);
02476                 }
02477 
02481                 inline XnStatus ConvertRealWorldToProjective(XnUInt32 nCount, const XnPoint3D aRealWorld[], XnPoint3D aProjective[]) const
02482                 {
02483                         return xnConvertRealWorldToProjective(m_hNode, nCount, aRealWorld, aProjective);
02484                 }
02485 
02491                 inline UserPositionCapability GetUserPositionCap() 
02492                 {
02493                         return UserPositionCapability(m_hNode);
02494                 }
02495         };
02496 
02501         class MockDepthGenerator : public DepthGenerator
02502         {
02503         public:
02509                 inline MockDepthGenerator(XnNodeHandle hNode = NULL) : DepthGenerator(hNode) {}
02510 
02517                 XnStatus Create(Context& context, const XnChar* strName = NULL);
02518 
02525                 XnStatus CreateBasedOn(DepthGenerator& other, const XnChar* strName = NULL);
02526 
02530                 inline XnStatus SetData(XnUInt32 nFrameID, XnUInt64 nTimestamp, XnUInt32 nDataSize, const XnDepthPixel* pDepthMap)
02531                 {
02532                         return xnMockDepthSetData(m_hNode, nFrameID, nTimestamp, nDataSize, pDepthMap);
02533                 }
02534 
02542                 inline XnStatus SetData(DepthMetaData& depthMD, XnUInt32 nFrameID, XnUInt64 nTimestamp)
02543                 {
02544                         return SetData(nFrameID, nTimestamp, depthMD.DataSize(), depthMD.Data());
02545                 }
02546 
02552                 inline XnStatus SetData(DepthMetaData& depthMD)
02553                 {
02554                         return SetData(depthMD, depthMD.FrameID(), depthMD.Timestamp());
02555                 }
02556         };
02557 
02562         class ImageGenerator : public MapGenerator
02563         {
02564         public:
02570                 inline ImageGenerator(XnNodeHandle hNode = NULL) : MapGenerator(hNode) {}
02571 
02575                 inline XnStatus Create(Context& context, Query* pQuery = NULL, EnumerationErrors* pErrors = NULL);
02576 
02580                 inline void GetMetaData(ImageMetaData& metaData) const 
02581                 {
02582                         return xnGetImageMetaData(m_hNode, metaData.GetUnderlying());
02583                 }
02584 
02588                 inline const XnRGB24Pixel* GetRGB24ImageMap() const
02589                 {
02590                         return xnGetRGB24ImageMap(m_hNode);
02591                 }
02592 
02596                 inline const XnYUV422DoublePixel* GetYUV422ImageMap() const
02597                 {
02598                         return xnGetYUV422ImageMap(m_hNode);
02599                 }
02600 
02604                 inline const XnGrayscale8Pixel* GetGrayscale8ImageMap() const
02605                 {
02606                         return xnGetGrayscale8ImageMap(m_hNode);
02607                 }
02608 
02612                 inline const XnGrayscale16Pixel* GetGrayscale16ImageMap() const
02613                 {
02614                         return xnGetGrayscale16ImageMap(m_hNode);
02615                 }
02616 
02620                 inline const XnUInt8* GetImageMap() const
02621                 {
02622                         return xnGetImageMap(m_hNode);
02623                 }
02624 
02628                 inline XnBool IsPixelFormatSupported(XnPixelFormat Format) const
02629                 {
02630                         return xnIsPixelFormatSupported(m_hNode, Format);
02631                 }
02632 
02636                 inline XnStatus SetPixelFormat(XnPixelFormat Format)
02637                 {
02638                         return xnSetPixelFormat(m_hNode, Format);
02639                 }
02640 
02644                 inline XnPixelFormat GetPixelFormat() const
02645                 {
02646                         return xnGetPixelFormat(m_hNode);
02647                 }
02648 
02652                 inline XnStatus RegisterToPixelFormatChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
02653                 {
02654                         return _RegisterToStateChange(xnRegisterToPixelFormatChange, m_hNode, handler, pCookie, hCallback);
02655                 }
02656 
02660                 inline void UnregisterFromPixelFormatChange(XnCallbackHandle hCallback)
02661                 {
02662                         _UnregisterFromStateChange(xnUnregisterFromPixelFormatChange, m_hNode, hCallback);
02663                 }
02664         };
02665 
02670         class MockImageGenerator : public ImageGenerator
02671         {
02672         public:
02678                 inline MockImageGenerator(XnNodeHandle hNode = NULL) : ImageGenerator(hNode) {}
02679 
02686                 XnStatus Create(Context& context, const XnChar* strName = NULL);
02687 
02694                 XnStatus CreateBasedOn(ImageGenerator& other, const XnChar* strName = NULL);
02695 
02699                 inline XnStatus SetData(XnUInt32 nFrameID, XnUInt64 nTimestamp, XnUInt32 nDataSize, const XnUInt8* pImageMap)
02700                 {
02701                         return xnMockImageSetData(m_hNode, nFrameID, nTimestamp, nDataSize, pImageMap);
02702                 }
02703 
02711                 inline XnStatus SetData(ImageMetaData& imageMD, XnUInt32 nFrameID, XnUInt64 nTimestamp)
02712                 {
02713                         return SetData(nFrameID, nTimestamp, imageMD.DataSize(), imageMD.Data());
02714                 }
02715 
02721                 inline XnStatus SetData(ImageMetaData& imageMD)
02722                 {
02723                         return SetData(imageMD, imageMD.FrameID(), imageMD.Timestamp());
02724                 }
02725         };
02726 
02731         class IRGenerator : public MapGenerator
02732         {
02733         public:
02739                 inline IRGenerator(XnNodeHandle hNode = NULL) : MapGenerator(hNode) {}
02740 
02744                 inline XnStatus Create(Context& context, Query* pQuery = NULL, EnumerationErrors* pErrors = NULL);
02745 
02749                 inline void GetMetaData(IRMetaData& metaData) const 
02750                 { 
02751                         xnGetIRMetaData(m_hNode, metaData.GetUnderlying());
02752                 }
02753 
02757                 inline const XnIRPixel* GetIRMap() const
02758                 {
02759                         return xnGetIRMap(m_hNode);
02760                 }
02761         };
02762 
02767         class MockIRGenerator : public IRGenerator
02768         {
02769         public:
02775                 inline MockIRGenerator(XnNodeHandle hNode = NULL) : IRGenerator(hNode) {}
02776 
02783                 XnStatus Create(Context& context, const XnChar* strName = NULL);
02790                 XnStatus CreateBasedOn(IRGenerator& other, const XnChar* strName = NULL);
02791 
02795                 inline XnStatus SetData(XnUInt32 nFrameID, XnUInt64 nTimestamp, XnUInt32 nDataSize, const XnIRPixel* pIRMap)
02796                 {
02797                         return xnMockIRSetData(m_hNode, nFrameID, nTimestamp, nDataSize, pIRMap);
02798                 }
02799 
02807                 inline XnStatus SetData(IRMetaData& irMD, XnUInt32 nFrameID, XnUInt64 nTimestamp)
02808                 {
02809                         return SetData(nFrameID, nTimestamp, irMD.DataSize(), irMD.Data());
02810                 }
02811 
02817                 inline XnStatus SetData(IRMetaData& irMD)
02818                 {
02819                         return SetData(irMD, irMD.FrameID(), irMD.Timestamp());
02820                 }
02821         };
02822 
02827         class GestureGenerator : public Generator
02828         {
02829         public:
02835                 inline GestureGenerator(XnNodeHandle hNode = NULL) : Generator(hNode) {} 
02836 
02840                 inline XnStatus Create(Context& context, Query* pQuery = NULL, EnumerationErrors* pErrors = NULL);
02841 
02845                 inline XnStatus AddGesture(const XnChar* strGesture, XnBoundingBox3D* pArea)
02846                 {
02847                         return xnAddGesture(m_hNode, strGesture, pArea);
02848                 }
02849 
02853                 inline XnStatus RemoveGesture(const XnChar* strGesture)
02854                 {
02855                         return xnRemoveGesture(m_hNode, strGesture);
02856                 }
02857 
02861                 inline XnStatus GetActiveGestures(XnChar*& astrGestures, XnUInt16& nGestures) const
02862                 {
02863                         return xnGetActiveGestures(m_hNode, &astrGestures, &nGestures);
02864                 }
02865 
02869                 inline XnStatus EnumerateGestures(XnChar*& astrGestures, XnUInt16& nGestures)
02870                 {
02871                         return xnEnumerateGestures(m_hNode, &astrGestures, &nGestures);
02872                 }
02873 
02877                 inline XnBool IsGestureAvailable(const XnChar* strGesture)
02878                 {
02879                         return xnIsGestureAvailable(m_hNode, strGesture);
02880                 }
02881 
02885                 inline XnBool IsGestureProgressSupported(const XnChar* strGesture)
02886                 {
02887                         return xnIsGestureProgressSupported(m_hNode, strGesture);
02888                 }
02889 
02899                 typedef void (XN_CALLBACK_TYPE* GestureRecognized)(GestureGenerator& generator, const XnChar* strGesture, const XnPoint3D* pIDPosition, const XnPoint3D* pEndPosition, void* pCookie);
02909                 typedef void (XN_CALLBACK_TYPE* GestureProgress)(GestureGenerator& generator, const XnChar* strGesture, const XnPoint3D* pPosition, XnFloat fProgress, void* pCookie);
02910 
02914                 XnStatus RegisterGestureCallbacks(GestureRecognized RecognizedCB, GestureProgress ProgressCB, void* pCookie, XnCallbackHandle& hCallback)
02915                 {
02916                         XnStatus nRetVal = XN_STATUS_OK;
02917                         
02918                         GestureCookie* pGestureCookie;
02919                         XN_VALIDATE_ALLOC(pGestureCookie, GestureCookie);
02920                         pGestureCookie->recognizedHandler = RecognizedCB;
02921                         pGestureCookie->progressHandler = ProgressCB;
02922                         pGestureCookie->pUserCookie = pCookie;
02923 
02924                         nRetVal = xnRegisterGestureCallbacks(m_hNode, GestureRecognizedCallback, GestureProgressCallback, pGestureCookie, &pGestureCookie->hCallback);
02925                         if (nRetVal != XN_STATUS_OK)
02926                         {
02927                                 xnOSFree(pGestureCookie);
02928                                 return (nRetVal);
02929                         }
02930 
02931                         hCallback = pGestureCookie;
02932 
02933                         return (XN_STATUS_OK);
02934                 }
02935 
02939                 inline void UnregisterGestureCallbacks(XnCallbackHandle hCallback)
02940                 {
02941                         GestureCookie* pGestureCookie = (GestureCookie*)hCallback;
02942                         xnUnregisterGestureCallbacks(m_hNode, pGestureCookie->hCallback);
02943                         xnOSFree(pGestureCookie);
02944                 }
02945 
02949                 inline XnStatus RegisterToGestureChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
02950                 {
02951                         return _RegisterToStateChange(xnRegisterToPixelFormatChange, m_hNode, handler, pCookie, hCallback);
02952                 }
02953 
02957                 inline void UnregisterFromGestureChange(XnCallbackHandle hCallback)
02958                 {
02959                         _UnregisterFromStateChange(xnUnregisterFromGestureChange, m_hNode, hCallback);
02960                 }
02961 
02962         private:
02963                 typedef struct GestureCookie
02964                 {
02965                         GestureRecognized recognizedHandler;
02966                         GestureProgress progressHandler;
02967                         void* pUserCookie;
02968                         XnCallbackHandle hCallback;
02969                 } GestureCookie;
02970 
02971                 static void XN_CALLBACK_TYPE GestureRecognizedCallback(XnNodeHandle hNode, const XnChar* strGesture, const XnPoint3D* pIDPosition, const XnPoint3D* pEndPosition, void* pCookie)
02972                 {
02973                         GestureCookie* pGestureCookie = (GestureCookie*)pCookie;
02974                         GestureGenerator gen(hNode);
02975                         pGestureCookie->recognizedHandler(gen, strGesture, pIDPosition, pEndPosition, pGestureCookie->pUserCookie);
02976                 }
02977 
02978                 static void XN_CALLBACK_TYPE GestureProgressCallback(XnNodeHandle hNode, const XnChar* strGesture, const XnPoint3D* pPosition, XnFloat fProgress, void* pCookie)
02979                 {
02980                         GestureCookie* pGestureCookie = (GestureCookie*)pCookie;
02981                         GestureGenerator gen(hNode);
02982                         pGestureCookie->progressHandler(gen, strGesture, pPosition, fProgress, pGestureCookie->pUserCookie);
02983                 }
02984         };
02985 
02990         class SceneAnalyzer : public MapGenerator
02991         {
02992         public:
02998                 inline SceneAnalyzer(XnNodeHandle hNode = NULL) : MapGenerator(hNode) {}
02999 
03003                 inline XnStatus Create(Context& context, Query* pQuery = NULL, EnumerationErrors* pErrors = NULL);
03004 
03008                 inline void GetMetaData(SceneMetaData& metaData) const
03009                 {
03010                         xnGetSceneMetaData(m_hNode, metaData.GetUnderlying());
03011                 }
03012 
03016                 inline const XnLabel* GetLabelMap() const
03017                 {
03018                         return xnGetLabelMap(m_hNode);
03019                 }
03020 
03024                 inline XnStatus GetFloor(XnPlane3D& Plane) const
03025                 {
03026                         return xnGetFloor(m_hNode, &Plane);
03027                 }
03028         };
03029 
03034         class HandsGenerator : public Generator
03035         {
03036         public:
03042                 inline HandsGenerator(XnNodeHandle hNode = NULL) : Generator(hNode) {}
03043 
03047                 inline XnStatus Create(Context& context, Query* pQuery = NULL, EnumerationErrors* pErrors = NULL);
03048 
03058                 typedef void (XN_CALLBACK_TYPE* HandCreate)(HandsGenerator& generator, XnUserID user, const XnPoint3D* pPosition, XnFloat fTime, void* pCookie);
03068                 typedef void (XN_CALLBACK_TYPE* HandUpdate)(HandsGenerator& generator, XnUserID user, const XnPoint3D* pPosition, XnFloat fTime, void* pCookie);
03077                 typedef void (XN_CALLBACK_TYPE* HandDestroy)(HandsGenerator& generator, XnUserID user, XnFloat fTime, void* pCookie);
03078 
03082                 inline XnStatus RegisterHandCallbacks(HandCreate CreateCB, HandUpdate UpdateCB, HandDestroy DestroyCB, void* pCookie, XnCallbackHandle& hCallback)
03083                 {
03084                         XnStatus nRetVal = XN_STATUS_OK;
03085 
03086                         HandCookie* pHandCookie;
03087                         XN_VALIDATE_ALLOC(pHandCookie, HandCookie);
03088                         pHandCookie->createHandler = CreateCB;
03089                         pHandCookie->updateHandler = UpdateCB;
03090                         pHandCookie->destroyHandler = DestroyCB;
03091                         pHandCookie->pUserCookie = pCookie;
03092 
03093                         nRetVal = xnRegisterHandCallbacks(m_hNode, HandCreateCB, HandUpdateCB, HandDestroyCB, pHandCookie, &pHandCookie->hCallback);
03094                         if (nRetVal != XN_STATUS_OK)
03095                         {
03096                                 xnOSFree(pHandCookie);
03097                                 return (nRetVal);
03098                         }
03099 
03100                         hCallback = pHandCookie;
03101 
03102                         return (XN_STATUS_OK);
03103                 }
03104 
03108                 inline void UnregisterHandCallbacks(XnCallbackHandle hCallback)
03109                 {
03110                         HandCookie* pHandCookie = (HandCookie*)hCallback;
03111                         xnUnregisterHandCallbacks(m_hNode, pHandCookie->hCallback);
03112                         xnOSFree(pHandCookie);
03113                 }
03114 
03118                 inline XnStatus StopTracking(XnUserID user)
03119                 {
03120                         return xnStopTracking(m_hNode, user);
03121                 }
03122 
03126                 inline XnStatus StopTrackingAll()
03127                 {
03128                         return xnStopTrackingAll(m_hNode);
03129                 }
03130 
03134                 inline XnStatus StartTracking(const XnPoint3D& ptPosition)
03135                 {
03136                         return xnStartTracking(m_hNode, &ptPosition);
03137                 }
03138 
03142                 inline XnStatus SetSmoothing(XnFloat fSmoothingFactor)
03143                 {
03144                         return xnSetTrackingSmoothing(m_hNode, fSmoothingFactor);
03145                 }
03146 
03147         private:
03148                 typedef struct HandCookie
03149                 {
03150                         HandCreate createHandler;
03151                         HandUpdate updateHandler;
03152                         HandDestroy destroyHandler;
03153                         void* pUserCookie;
03154                         XnCallbackHandle hCallback;
03155                 } HandCookie;
03156 
03157                 static void XN_CALLBACK_TYPE HandCreateCB(XnNodeHandle hNode, XnUserID user, const XnPoint3D* pPosition, XnFloat fTime, void* pCookie)
03158                 {
03159                         HandCookie* pHandCookie = (HandCookie*)pCookie;
03160                         HandsGenerator gen(hNode);
03161                         pHandCookie->createHandler(gen, user, pPosition, fTime, pHandCookie->pUserCookie);
03162                 }
03163                 static void XN_CALLBACK_TYPE HandUpdateCB(XnNodeHandle hNode, XnUserID user, const XnPoint3D* pPosition, XnFloat fTime, void* pCookie)
03164                 {
03165                         HandCookie* pHandCookie = (HandCookie*)pCookie;
03166                         HandsGenerator gen(hNode);
03167                         pHandCookie->updateHandler(gen, user, pPosition, fTime, pHandCookie->pUserCookie);
03168                 }
03169                 static void XN_CALLBACK_TYPE HandDestroyCB(XnNodeHandle hNode, XnUserID user, XnFloat fTime, void* pCookie)
03170                 {
03171                         HandCookie* pHandCookie = (HandCookie*)pCookie;
03172                         HandsGenerator gen(hNode);
03173                         pHandCookie->destroyHandler(gen, user, fTime, pHandCookie->pUserCookie);
03174                 }
03175         };
03176 
03181         class SkeletonCapability : public Capability
03182         {
03183         public:
03189                 inline SkeletonCapability(XnNodeHandle hNode) : Capability(hNode) {}
03190 
03194                 inline XnBool IsJointAvailable(XnSkeletonJoint eJoint) const
03195                 {
03196                         return xnIsJointAvailable(m_hNode, eJoint);
03197                 }
03198 
03202                 inline XnBool IsProfileAvailable(XnSkeletonProfile eProfile) const
03203                 {
03204                         return xnIsProfileAvailable(m_hNode, eProfile);
03205                 }
03206 
03210                 inline XnStatus SetSkeletonProfile(XnSkeletonProfile eProfile)
03211                 {
03212                         return xnSetSkeletonProfile(m_hNode, eProfile);
03213                 }
03214 
03218                 inline XnStatus SetJointActive(XnSkeletonJoint eJoint, XnBool bState)
03219                 {
03220                         return xnSetJointActive(m_hNode, eJoint, bState);
03221                 }
03222 
03226                 inline XnBool IsJointActive(XnSkeletonJoint eJoint, XnBool bState)
03227                 {
03228                         return xnIsJointActive(m_hNode, eJoint);
03229                 }
03230 
03234                 inline XnStatus RegisterToJointConfigurationChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
03235                 {
03236                         return _RegisterToStateChange(xnRegisterToJointConfigurationChange, m_hNode, handler, pCookie, hCallback);
03237                 }
03238 
03242                 inline void UnregisterFromJointConfigurationChange(XnCallbackHandle hCallback)
03243                 {
03244                         _UnregisterFromStateChange(xnUnregisterFromJointConfigurationChange, m_hNode, hCallback);
03245                 }
03246 
03250                 inline XnStatus EnumerateActiveJoints(XnSkeletonJoint* pJoints, XnUInt16& nJoints)
03251                 {
03252                         return xnEnumerateActiveJoints(m_hNode, pJoints, &nJoints);
03253                 }
03254 
03258                 inline XnStatus GetSkeletonJoint(XnUserID user, XnSkeletonJoint eJoint, XnSkeletonJointTransformation& Joint) const
03259                 {
03260                         return xnGetSkeletonJoint(m_hNode, user, eJoint, &Joint);
03261                 }
03262 
03266                 inline XnStatus GetSkeletonJointPosition(XnUserID user, XnSkeletonJoint eJoint, XnSkeletonJointPosition& Joint) const
03267                 {
03268                         return xnGetSkeletonJointPosition(m_hNode, user, eJoint, &Joint);
03269                 }
03270 
03274                 inline XnStatus GetSkeletonJointOrientation(XnUserID user, XnSkeletonJoint eJoint, XnSkeletonJointOrientation& Joint) const
03275                 {
03276                         return xnGetSkeletonJointOrientation(m_hNode, user, eJoint, &Joint);
03277                 }
03278 
03282                 inline XnBool IsTracking(XnUserID user)
03283                 {
03284                         return xnIsSkeletonTracking(m_hNode, user);
03285                 }
03286 
03290                 inline XnBool IsCalibrated(XnUserID user)
03291                 {
03292                         return xnIsSkeletonCalibrated(m_hNode, user);
03293                 }
03294 
03298                 inline XnBool IsCalibrating(XnUserID user)
03299                 {
03300                         return xnIsSkeletonCalibrating(m_hNode, user);
03301                 }
03302 
03306                 inline XnStatus RequestCalibration(XnUserID user, XnBool bForce)
03307                 {
03308                         return xnRequestSkeletonCalibration(m_hNode, user, bForce);
03309                 }
03310 
03314                 inline XnStatus AbortCalibration(XnUserID user)
03315                 {
03316                         return xnAbortSkeletonCalibration(m_hNode, user);
03317                 }
03318 
03322                 inline XnStatus SaveCalibrationData(XnUserID user, XnUInt32 nSlot)
03323                 {
03324                         return xnSaveSkeletonCalibrationData(m_hNode, user, nSlot);
03325                 }
03326 
03330                 inline XnStatus LoadCalibrationData(XnUserID user, XnUInt32 nSlot)
03331                 {
03332                         return xnLoadSkeletonCalibrationData(m_hNode, user, nSlot);
03333                 }
03334 
03338                 inline XnStatus ClearCalibrationData(XnUInt32 nSlot)
03339                 {
03340                         return xnClearSkeletonCalibrationData(m_hNode, nSlot);
03341                 }
03342 
03346                 inline XnBool IsCalibrationData(XnUInt32 nSlot)
03347                 {
03348                         return xnIsSkeletonCalibrationData(m_hNode, nSlot);
03349                 }
03350 
03354                 inline XnStatus StartTracking(XnUserID user)
03355                 {
03356                         return xnStartSkeletonTracking(m_hNode, user);
03357                 }
03358 
03362                 inline XnStatus StopTracking(XnUserID user)
03363                 {
03364                         return xnStopSkeletonTracking(m_hNode, user);
03365                 }
03366 
03370                 inline XnStatus Reset(XnUserID user)
03371                 {
03372                         return xnResetSkeleton(m_hNode, user);
03373                 }
03374 
03378                 inline XnBool NeedPoseForCalibration()
03379                 {
03380                         return xnNeedPoseForSkeletonCalibration(m_hNode);
03381                 }
03382 
03386                 inline XnStatus GetCalibrationPose(XnChar* strPose)
03387                 {
03388                         return xnGetSkeletonCalibrationPose(m_hNode, strPose);
03389                 }
03390 
03394                 inline XnStatus SetSmoothing(XnFloat fSmoothingFactor)
03395                 {
03396                         return xnSetSkeletonSmoothing(m_hNode, fSmoothingFactor);
03397                 }
03398 
03406                 typedef void (XN_CALLBACK_TYPE* CalibrationStart)(SkeletonCapability& skeleton, XnUserID user, void* pCookie);
03415                 typedef void (XN_CALLBACK_TYPE* CalibrationEnd)(SkeletonCapability& skeleton, XnUserID user, XnBool bSuccess, void* pCookie);
03416 
03420                 inline XnStatus RegisterCalibrationCallbacks(CalibrationStart CalibrationStartCB, CalibrationEnd CalibrationEndCB, void* pCookie, XnCallbackHandle& hCallback)
03421                 {
03422                         XnStatus nRetVal = XN_STATUS_OK;
03423 
03424                         SkeletonCookie* pSkeletonCookie;
03425                         XN_VALIDATE_ALLOC(pSkeletonCookie, SkeletonCookie);
03426                         pSkeletonCookie->startHandler = CalibrationStartCB;
03427                         pSkeletonCookie->endHandler = CalibrationEndCB;
03428                         pSkeletonCookie->pUserCookie = pCookie;
03429 
03430                         nRetVal = xnRegisterCalibrationCallbacks(m_hNode, CalibrationStartCallback, CalibrationEndCallback, pSkeletonCookie, &pSkeletonCookie->hCallback);
03431                         if (nRetVal != XN_STATUS_OK)
03432                         {
03433                                 xnOSFree(pSkeletonCookie);
03434                                 return (nRetVal);
03435                         }
03436 
03437                         hCallback = pSkeletonCookie;
03438 
03439                         return (XN_STATUS_OK);
03440                 }
03441 
03445                 inline void UnregisterCalibrationCallbacks(XnCallbackHandle hCallback)
03446                 {
03447                         SkeletonCookie* pSkeletonCookie = (SkeletonCookie*)hCallback;
03448                         xnUnregisterCalibrationCallbacks(m_hNode, pSkeletonCookie->hCallback);
03449                         xnOSFree(pSkeletonCookie);
03450                 }
03451 
03452         private:
03453                 typedef struct SkeletonCookie
03454                 {
03455                         CalibrationStart startHandler;
03456                         CalibrationEnd endHandler;
03457                         void* pUserCookie;
03458                         XnCallbackHandle hCallback;
03459                 } SkeletonCookie;
03460 
03461                 static void XN_CALLBACK_TYPE CalibrationStartCallback(XnNodeHandle hNode, XnUserID user, void* pCookie)
03462                 {
03463                         SkeletonCookie* pGestureCookie = (SkeletonCookie*)pCookie;
03464                         SkeletonCapability cap(hNode);
03465                         pGestureCookie->startHandler(cap, user, pGestureCookie->pUserCookie);
03466                 }
03467 
03468                 static void XN_CALLBACK_TYPE CalibrationEndCallback(XnNodeHandle hNode, XnUserID user, XnBool bSuccess, void* pCookie)
03469                 {
03470                         SkeletonCookie* pGestureCookie = (SkeletonCookie*)pCookie;
03471                         SkeletonCapability cap(hNode);
03472                         pGestureCookie->endHandler(cap, user, bSuccess, pGestureCookie->pUserCookie);
03473                 }
03474         };
03475 
03480         class PoseDetectionCapability : public Capability
03481         {
03482         public:
03488                 inline PoseDetectionCapability(XnNodeHandle hNode) : Capability(hNode) {}
03489 
03498                 typedef void (XN_CALLBACK_TYPE* PoseDetection)(PoseDetectionCapability& pose, const XnChar* strPose, XnUserID user, void* pCookie);
03499 
03503                 inline XnUInt32 GetNumberOfPoses()
03504                 {
03505                         return xnGetNumberOfPoses(m_hNode);
03506                 }
03507 
03511                 inline XnStatus GetAvailablePoses(XnChar** pstrPoses, XnUInt32& nPoses)
03512                 {
03513                         return xnGetAvailablePoses(m_hNode, pstrPoses, &nPoses);
03514                 }
03515 
03519                 inline XnStatus StartPoseDetection(const XnChar* strPose, XnUserID user)
03520                 {
03521                         return xnStartPoseDetection(m_hNode, strPose, user);
03522                 }
03523 
03527                 inline XnStatus StopPoseDetection(XnUserID user)
03528                 {
03529                         return xnStopPoseDetection(m_hNode, user);
03530                 }
03531 
03535                 inline XnStatus RegisterToPoseCallbacks(PoseDetection PoseStartCB, PoseDetection PoseEndCB, void* pCookie, XnCallbackHandle& hCallback)
03536                 {
03537                         XnStatus nRetVal = XN_STATUS_OK;
03538 
03539                         PoseCookie* pPoseCookie;
03540                         XN_VALIDATE_ALLOC(pPoseCookie, PoseCookie);
03541                         pPoseCookie->startHandler = PoseStartCB;
03542                         pPoseCookie->endHandler = PoseEndCB;
03543                         pPoseCookie->pPoseCookie = pCookie;
03544 
03545                         nRetVal = xnRegisterToPoseCallbacks(m_hNode, PoseDetectionStartCallback, PoseDetectionStartEndCallback, pPoseCookie, &pPoseCookie->hCallback);
03546                         if (nRetVal != XN_STATUS_OK)
03547                         {
03548                                 xnOSFree(pPoseCookie);
03549                                 return (nRetVal);
03550                         }
03551 
03552                         hCallback = pPoseCookie;
03553 
03554                         return (XN_STATUS_OK);
03555                 }
03556 
03560                 inline void UnregisterFromPoseCallbacks(XnCallbackHandle hCallback)
03561                 {
03562                         PoseCookie* pPoseCookie = (PoseCookie*)hCallback;
03563                         xnUnregisterCalibrationCallbacks(m_hNode, pPoseCookie->hCallback);
03564                         xnOSFree(pPoseCookie);
03565                 }
03566         private:
03567                 typedef struct PoseCookie
03568                 {
03569                         PoseDetection startHandler;
03570                         PoseDetection endHandler;
03571                         void* pPoseCookie;
03572                         XnCallbackHandle hCallback;
03573                 } PoseCookie;
03574 
03575                 static void XN_CALLBACK_TYPE PoseDetectionStartCallback(XnNodeHandle hNode, const XnChar* strPose, XnUserID user, void* pCookie)
03576                 {
03577                         PoseCookie* pPoseCookie = (PoseCookie*)pCookie;
03578                         PoseDetectionCapability cap(hNode);
03579                         pPoseCookie->startHandler(cap, strPose, user, pPoseCookie->pPoseCookie);
03580                 }
03581 
03582                 static void XN_CALLBACK_TYPE PoseDetectionStartEndCallback(XnNodeHandle hNode, const XnChar* strPose, XnUserID user, void* pCookie)
03583                 {
03584                         PoseCookie* pPoseCookie = (PoseCookie*)pCookie;
03585                         PoseDetectionCapability cap(hNode);
03586                         pPoseCookie->endHandler(cap, strPose, user, pPoseCookie->pPoseCookie);
03587                 }
03588         };
03589 
03594         class UserGenerator : public Generator
03595         {
03596         public:
03602                 inline UserGenerator(XnNodeHandle hNode = NULL) : Generator(hNode) {}
03603 
03607                 inline XnStatus Create(Context& context, Query* pQuery = NULL, EnumerationErrors* pErrors = NULL);
03608 
03609                 typedef void (XN_CALLBACK_TYPE* UserHandler)(UserGenerator& generator, XnUserID user, void* pCookie);
03610 
03614                 inline XnUInt16 GetNumberOfUsers() const
03615                 {
03616                         return xnGetNumberOfUsers(m_hNode);
03617                 }
03618 
03622                 inline XnStatus GetUsers(XnUserID aUsers[], XnUInt16& nUsers) const
03623                 {
03624                         return xnGetUsers(m_hNode, aUsers, &nUsers);
03625                 }
03626 
03630                 inline XnStatus GetCoM(XnUserID user, XnPoint3D& com) const
03631                 {
03632                         return xnGetUserCoM(m_hNode, user, &com);
03633                 }
03634 
03638                 inline XnStatus GetUserPixels(XnUserID user, SceneMetaData& smd)
03639                 {
03640                         return xnGetUserPixels(m_hNode, user, smd.GetUnderlying());
03641                 }
03642                 
03646                 inline XnStatus RegisterUserCallbacks(UserHandler NewUserCB, UserHandler LostUserCB, void* pCookie, XnCallbackHandle& hCallback)
03647                 {
03648                         XnStatus nRetVal = XN_STATUS_OK;
03649 
03650                         UserCookie* pUserCookie;
03651                         XN_VALIDATE_ALLOC(pUserCookie, UserCookie);
03652                         pUserCookie->newHandler = NewUserCB;
03653                         pUserCookie->lostHandler = LostUserCB;
03654                         pUserCookie->pUserCookie = pCookie;
03655 
03656                         nRetVal = xnRegisterUserCallbacks(m_hNode, NewUserCallback, LostUserCallback, pUserCookie, &pUserCookie->hCallback);
03657                         if (nRetVal != XN_STATUS_OK)
03658                         {
03659                                 xnOSFree(pUserCookie);
03660                                 return (nRetVal);
03661                         }
03662 
03663                         hCallback = pUserCookie;
03664 
03665                         return (XN_STATUS_OK);
03666                 }
03667 
03671                 inline void UnregisterUserCallbacks(XnCallbackHandle hCallback)
03672                 {
03673                         UserCookie* pUserCookie = (UserCookie*)hCallback;
03674                         xnUnregisterUserCallbacks(m_hNode, pUserCookie->hCallback);
03675                         xnOSFree(pUserCookie);
03676                 }
03677 
03683                 inline SkeletonCapability GetSkeletonCap()
03684                 {
03685                         return SkeletonCapability(m_hNode);
03686                 }
03687 
03693                 inline PoseDetectionCapability GetPoseDetectionCap()
03694                 {
03695                         return PoseDetectionCapability(m_hNode);
03696                 }
03697 
03698         private:
03699                 typedef struct UserCookie
03700                 {
03701                         UserHandler newHandler;
03702                         UserHandler lostHandler;
03703                         void* pUserCookie;
03704                         XnCallbackHandle hCallback;
03705                 } UserCookie;
03706 
03707                 static void XN_CALLBACK_TYPE NewUserCallback(XnNodeHandle hNode, XnUserID user, void* pCookie)
03708                 {
03709                         UserCookie* pUserCookie = (UserCookie*)pCookie;
03710                         UserGenerator gen(hNode);
03711                         pUserCookie->newHandler(gen, user, pUserCookie->pUserCookie);
03712                 }
03713 
03714                 static void XN_CALLBACK_TYPE LostUserCallback(XnNodeHandle hNode, XnUserID user, void* pCookie)
03715                 {
03716                         UserCookie* pUserCookie = (UserCookie*)pCookie;
03717                         UserGenerator gen(hNode);
03718                         pUserCookie->lostHandler(gen, user, pUserCookie->pUserCookie);
03719                 }
03720         };
03721 
03726         class AudioGenerator : public Generator
03727         {
03728         public:
03734                 inline AudioGenerator(XnNodeHandle hNode = NULL) : Generator(hNode) {}
03735 
03739                 inline XnStatus Create(Context& context, Query* pQuery = NULL, EnumerationErrors* pErrors = NULL);
03740 
03744                 inline void GetMetaData(AudioMetaData& metaData) const
03745                 {
03746                         xnGetAudioMetaData(m_hNode, metaData.GetUnderlying());
03747                 }
03748 
03752                 inline const XnUChar* GetAudioBuffer() const
03753                 {
03754                         return xnGetAudioBuffer(m_hNode);
03755                 }
03756 
03760                 inline XnUInt32 GetSupportedWaveOutputModesCount() const
03761                 {
03762                         return xnGetSupportedWaveOutputModesCount(m_hNode);
03763                 }
03764 
03768                 inline XnStatus GetSupportedWaveOutputModes(XnWaveOutputMode* aSupportedModes, XnUInt32& nCount) const
03769                 {
03770                         return xnGetSupportedWaveOutputModes(m_hNode, aSupportedModes, &nCount);
03771                 }
03772 
03776                 inline XnStatus SetWaveOutputMode(const XnWaveOutputMode& OutputMode)
03777                 {
03778                         return xnSetWaveOutputMode(m_hNode, &OutputMode);
03779                 }
03780 
03784                 inline XnStatus GetWaveOutputMode(XnWaveOutputMode& OutputMode) const
03785                 {
03786                         return xnGetWaveOutputMode(m_hNode, &OutputMode);
03787                 }
03788 
03792                 inline XnStatus RegisterToWaveOutputModeChanges(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
03793                 {
03794                         return _RegisterToStateChange(xnRegisterToWaveOutputModeChanges, m_hNode, handler, pCookie, hCallback);
03795                 }
03796 
03800                 inline void UnregisterFromWaveOutputModeChanges(XnCallbackHandle hCallback)
03801                 {
03802                         _UnregisterFromStateChange(xnUnregisterFromWaveOutputModeChanges, m_hNode, hCallback);
03803                 }
03804         };
03805 
03810         class MockAudioGenerator : public AudioGenerator
03811         {
03812         public:
03818                 inline MockAudioGenerator(XnNodeHandle hNode = NULL) : AudioGenerator(hNode) {}
03819 
03826                 XnStatus Create(Context& context, const XnChar* strName = NULL);
03827 
03834                 XnStatus CreateBasedOn(AudioGenerator& other, const XnChar* strName = NULL);
03835 
03839                 inline XnStatus SetData(XnUInt32 nFrameID, XnUInt64 nTimestamp, XnUInt32 nDataSize, const XnUInt8* pAudioBuffer)
03840                 {
03841                         return xnMockAudioSetData(m_hNode, nFrameID, nTimestamp, nDataSize, pAudioBuffer);
03842                 }
03843 
03851                 inline XnStatus SetData(AudioMetaData& audioMD, XnUInt32 nFrameID, XnUInt64 nTimestamp)
03852                 {
03853                         return SetData(nFrameID, nTimestamp, audioMD.DataSize(), audioMD.Data());
03854                 }
03855 
03861                 inline XnStatus SetData(AudioMetaData& audioMD)
03862                 {
03863                         return SetData(audioMD, audioMD.FrameID(), audioMD.Timestamp());
03864                 }
03865         };
03866 
03867         //---------------------------------------------------------------------------
03868         // Codec
03869         //---------------------------------------------------------------------------
03874         class Codec : public ProductionNode
03875         {
03876         public:
03882                 inline Codec(XnNodeHandle hNode = NULL) : ProductionNode(hNode) {}
03883 
03887                 inline XnStatus Create(Context& context, XnCodecID codecID, ProductionNode& initializerNode);
03888 
03892                 inline XnCodecID GetCodecID() const
03893                 {
03894                         return xnGetCodecID(m_hNode);
03895                 }
03896 
03900                 inline XnStatus EncodeData(const void* pSrc, XnUInt32 nSrcSize, void* pDst, XnUInt32 nDstSize, XnUInt* pnBytesWritten) const
03901                 {
03902                         return xnEncodeData(m_hNode, pSrc, nSrcSize, pDst, nDstSize, pnBytesWritten);
03903                 }
03904 
03908                 inline XnStatus DecodeData(const void* pSrc, XnUInt32 nSrcSize, void* pDst, XnUInt32 nDstSize, XnUInt* pnBytesWritten) const
03909                 {
03910                         return xnDecodeData(m_hNode, pSrc, nSrcSize, pDst, nDstSize, pnBytesWritten);
03911                 }
03912         };
03913 
03914         //---------------------------------------------------------------------------
03915         // EnumerationErrors
03916         //---------------------------------------------------------------------------
03921         class EnumerationErrors
03922         {
03923         public:
03925                 inline EnumerationErrors() : m_bAllocated(TRUE), m_pErrors(NULL) { xnEnumerationErrorsAllocate(&m_pErrors); }
03926 
03933                 inline EnumerationErrors(XnEnumerationErrors* pErrors, XnBool bOwn = FALSE) : m_bAllocated(bOwn), m_pErrors(pErrors) {}
03934 
03936                 ~EnumerationErrors() { Free(); }
03937 
03939                 class Iterator
03940                 {
03941                 public:
03942                         friend class EnumerationErrors;
03943 
03949                         XnBool operator==(const Iterator& other) const
03950                         {
03951                                 return m_it == other.m_it;
03952                         }
03953 
03959                         XnBool operator!=(const Iterator& other) const
03960                         {
03961                                 return m_it != other.m_it;
03962                         }
03963 
03968                         inline Iterator& operator++()
03969                         {
03970                                 m_it = xnEnumerationErrorsGetNext(m_it);
03971                                 return *this;
03972                         }
03973 
03978                         inline Iterator operator++(int)
03979                         {
03980                                 return Iterator(xnEnumerationErrorsGetNext(m_it));
03981                         }
03982 
03984                         inline const XnProductionNodeDescription& Description() { return *xnEnumerationErrorsGetCurrentDescription(m_it); }
03986                         inline XnStatus Error() { return xnEnumerationErrorsGetCurrentError(m_it); }
03987 
03988                 private:
03989                         inline Iterator(XnEnumerationErrorsIterator it) : m_it(it) {}
03990 
03991                         XnEnumerationErrorsIterator m_it;
03992                 };
03993 
03995                 inline Iterator Begin() const { return Iterator(xnEnumerationErrorsGetFirst(m_pErrors)); } 
03997                 inline Iterator End() const { return Iterator(NULL); } 
03998 
04002                 inline XnStatus ToString(XnChar* csBuffer, XnUInt32 nSize)
04003                 {
04004                         return xnEnumerationErrorsToString(m_pErrors, csBuffer, nSize);
04005                 }
04006 
04010                 inline void Free()
04011                 {
04012                         if (m_bAllocated)
04013                         {
04014                                 xnEnumerationErrorsFree(m_pErrors);
04015                                 m_pErrors = NULL;
04016                                 m_bAllocated = FALSE;
04017                         }
04018                 }
04019 
04021                 inline XnEnumerationErrors* GetUnderlying() { return m_pErrors; }
04022 
04023         private:
04024                 XnEnumerationErrors* m_pErrors;
04025                 XnBool m_bAllocated;
04026         };
04027 
04028         //---------------------------------------------------------------------------
04029         // Context
04030         //---------------------------------------------------------------------------
04031 
04036         class Context
04037         {
04038         public:
04040                 inline Context() : m_pContext(NULL), m_bAllocated(FALSE) {}
04046                 inline Context(XnContext* pContext) : m_pContext(pContext), m_bAllocated(FALSE) {}
04053                 inline Context(const Context& other) : m_pContext(other.m_pContext), m_bAllocated(FALSE) {}
04054 
04056                 ~Context() 
04057                 { 
04058                         FreeImpl();
04059                 }
04060 
04062                 inline XnContext* GetUnderlyingObject() const { return m_pContext; }
04063 
04067                 inline XnStatus Init()
04068                 {
04069                         XnStatus nRetVal = xnInit(&m_pContext);
04070                         XN_IS_STATUS_OK(nRetVal);
04071                         m_bAllocated = TRUE;
04072                         return (XN_STATUS_OK);
04073                 }
04074 
04078                 inline XnStatus RunXmlScript(const XnChar* strScript, EnumerationErrors* pErrors = NULL)
04079                 {
04080                         return xnContextRunXmlScript(m_pContext, strScript, pErrors == NULL ? NULL : pErrors->GetUnderlying());
04081                 }
04082 
04086                 inline XnStatus RunXmlScriptFromFile(const XnChar* strFileName, EnumerationErrors* pErrors = NULL)
04087                 {
04088                         return xnContextRunXmlScriptFromFile(m_pContext, strFileName, pErrors == NULL ? NULL : pErrors->GetUnderlying());
04089                 }
04090 
04094                 inline XnStatus InitFromXmlFile(const XnChar* strFileName, EnumerationErrors* pErrors = NULL)
04095                 {
04096                         XnStatus nRetVal = xnInitFromXmlFile(strFileName, &m_pContext, pErrors == NULL ? NULL : pErrors->GetUnderlying());
04097                         XN_IS_STATUS_OK(nRetVal);
04098                         m_bAllocated = TRUE;
04099                         return (XN_STATUS_OK);
04100                 }
04101 
04105                 inline XnStatus OpenFileRecording(const XnChar* strFileName)
04106                 {
04107                         return xnContextOpenFileRecording(m_pContext, strFileName);
04108                 }
04109 
04113                 inline XnStatus CreateMockNode(XnProductionNodeType type, const XnChar* strName, ProductionNode& node)
04114                 {
04115                         return xnCreateMockNode(m_pContext, type, strName, &node.m_hNode);
04116                 }
04117 
04121                 inline XnStatus CreateMockNodeBasedOn(ProductionNode& originalNode, const XnChar* strName, ProductionNode& mockNode)
04122                 {
04123                         return xnCreateMockNodeBasedOn(m_pContext, originalNode.m_hNode, strName, &mockNode.m_hNode);
04124                 }
04125 
04129                 inline XnStatus CreateCodec(XnCodecID codecID, ProductionNode& initializerNode, Codec& codec)
04130                 {
04131                         return xnCreateCodec(m_pContext, codecID, initializerNode, &codec.m_hNode);
04132                 }
04133 
04137                 inline void Shutdown()
04138                 {
04139                         if (m_pContext != NULL)
04140                         {
04141                                 xnShutdown(m_pContext);
04142                                 m_pContext = NULL;
04143                         }
04144                 }
04145 
04149                 inline XnStatus AddLicense(const XnLicense& License)
04150                 {
04151                         return xnAddLicense(m_pContext, &License);
04152                 }
04153 
04157                 inline XnStatus EnumerateLicenses(XnLicense*& aLicenses, XnUInt32& nCount) const
04158                 {
04159                         return xnEnumerateLicenses(m_pContext, &aLicenses, &nCount);
04160                 }
04161 
04165                 inline static void FreeLicensesList(XnLicense aLicenses[])
04166                 {
04167                         return xnFreeLicensesList(aLicenses);
04168                 }
04169 
04173                 XnStatus EnumerateProductionTrees(XnProductionNodeType Type, Query* pQuery, NodeInfoList& TreesList, EnumerationErrors* pErrors = NULL) const
04174                 {
04175                         XnStatus nRetVal = XN_STATUS_OK;
04176 
04177                         XnNodeQuery* pInternalQuery = (pQuery != NULL) ? pQuery->GetUnderlyingObject() : NULL;
04178 
04179                         XnNodeInfoList* pList = NULL;
04180                         nRetVal = xnEnumerateProductionTrees(m_pContext, Type, pInternalQuery, &pList, pErrors == NULL ? NULL : pErrors->GetUnderlying());
04181                         XN_IS_STATUS_OK(nRetVal);
04182 
04183                         TreesList.ReplaceUnderlyingObject(pList);
04184 
04185                         return (XN_STATUS_OK);
04186                 }
04187 
04191                 XnStatus CreateAnyProductionTree(XnProductionNodeType type, Query* pQuery, ProductionNode& node, EnumerationErrors* pErrors = NULL)
04192                 {
04193                         XnStatus nRetVal = XN_STATUS_OK;
04194                         
04195                         XnNodeQuery* pInternalQuery = (pQuery != NULL) ? pQuery->GetUnderlyingObject() : NULL;
04196 
04197                         XnNodeHandle hNode;
04198                         nRetVal = xnCreateAnyProductionTree(m_pContext, type, pInternalQuery, &hNode, pErrors == NULL ? NULL : pErrors->GetUnderlying());
04199                         XN_IS_STATUS_OK(nRetVal);
04200 
04201                         node.SetHandle(hNode);
04202 
04203                         return (XN_STATUS_OK);
04204                 }
04205 
04209                 XnStatus CreateProductionTree(NodeInfo& Tree)
04210                 {
04211                         XnStatus nRetVal = XN_STATUS_OK;
04212 
04213                         XnNodeHandle hNode;
04214                         nRetVal = xnCreateProductionTree(m_pContext, Tree, &hNode);
04215                         XN_IS_STATUS_OK(nRetVal);
04216 
04217                         return (XN_STATUS_OK);
04218                 }
04219 
04223                 XnStatus EnumerateExistingNodes(NodeInfoList& list) const
04224                 {
04225                         XnNodeInfoList* pList;
04226                         XnStatus nRetVal = xnEnumerateExistingNodes(m_pContext, &pList);
04227                         XN_IS_STATUS_OK(nRetVal);
04228 
04229                         list.ReplaceUnderlyingObject(pList);
04230 
04231                         return (XN_STATUS_OK);
04232                 }
04233 
04237                 XnStatus EnumerateExistingNodes(NodeInfoList& list, XnProductionNodeType type) const
04238                 {
04239                         XnNodeInfoList* pList;
04240                         XnStatus nRetVal = xnEnumerateExistingNodesByType(m_pContext, type, &pList);
04241                         XN_IS_STATUS_OK(nRetVal);
04242 
04243                         list.ReplaceUnderlyingObject(pList);
04244 
04245                         return (XN_STATUS_OK);
04246                 }
04247 
04251                 XnStatus FindExistingNode(XnProductionNodeType type, ProductionNode& node) const
04252                 {
04253                         XnStatus nRetVal = XN_STATUS_OK;
04254 
04255                         XnNodeHandle hNode;
04256                         nRetVal = xnFindExistingNodeByType(m_pContext, type, &hNode);
04257                         XN_IS_STATUS_OK(nRetVal);
04258 
04259                         node.SetHandle(hNode);
04260 
04261                         return (XN_STATUS_OK);
04262                 }
04263 
04267                 XnStatus GetProductionNodeByName(const XnChar* strInstanceName, ProductionNode& node) const
04268                 {
04269                         XnStatus nRetVal = XN_STATUS_OK;
04270 
04271                         XnNodeHandle hNode;
04272                         nRetVal = xnGetNodeHandleByName(m_pContext, strInstanceName, &hNode);
04273                         XN_IS_STATUS_OK(nRetVal);
04274 
04275                         node.SetHandle(hNode);
04276 
04277                         return (XN_STATUS_OK);
04278                 }
04279 
04283                 XnStatus GetProductionNodeInfoByName(const XnChar* strInstanceName, NodeInfo& nodeInfo) const
04284                 {
04285                         XnStatus nRetVal = XN_STATUS_OK;
04286 
04287                         XnNodeHandle hNode;
04288                         nRetVal = xnGetNodeHandleByName(m_pContext, strInstanceName, &hNode);
04289                         XN_IS_STATUS_OK(nRetVal);
04290 
04291                         nodeInfo = NodeInfo(xnGetNodeInfo(hNode));
04292 
04293                         return (XN_STATUS_OK);
04294                 }
04295 
04299                 inline XnStatus StartGeneratingAll()
04300                 {
04301                         return xnStartGeneratingAll(m_pContext);
04302                 }
04303 
04307                 inline XnStatus StopGeneratingAll()
04308                 {
04309                         return xnStopGeneratingAll(m_pContext);
04310                 }
04311 
04315                 inline XnStatus SetGlobalMirror(XnBool bMirror)
04316                 {
04317                         return xnSetGlobalMirror(m_pContext, bMirror);
04318                 }
04319 
04323                 inline XnBool GetGlobalMirror()
04324                 {
04325                         return xnGetGlobalMirror(m_pContext);
04326                 }
04327 
04331                 inline XnStatus GetGlobalErrorState()
04332                 {
04333                         return xnGetGlobalErrorState(m_pContext);
04334                 }
04335 
04339                 inline XnStatus RegisterToErrorStateChange(XnErrorStateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
04340                 {
04341                         return xnRegisterToGlobalErrorStateChange(m_pContext, handler, pCookie, &hCallback);
04342                 }
04343 
04347                 inline void UnregisterFromErrorStateChange(XnCallbackHandle hCallback)
04348                 {
04349                         return xnUnregisterFromGlobalErrorStateChange(m_pContext, hCallback);
04350                 }
04351 
04355                 inline XnStatus WaitAndUpdateAll()
04356                 {
04357                         return xnWaitAndUpdateAll(m_pContext);
04358                 }
04359 
04363                 inline XnStatus WaitAnyUpdateAll()
04364                 {
04365                         return xnWaitAnyUpdateAll(m_pContext);
04366                 }
04367 
04371                 inline XnStatus WaitOneUpdateAll(ProductionNode& node)
04372                 {
04373                         return xnWaitOneUpdateAll(m_pContext, node);
04374                 }
04375 
04379                 inline XnStatus WaitNoneUpdateAll()
04380                 {
04381                         return xnWaitNoneUpdateAll(m_pContext);
04382                 }
04383 
04387                 inline XnStatus AutoEnumerateOverSingleInput(NodeInfoList& List, XnProductionNodeDescription& description, const XnChar* strCreationInfo, XnProductionNodeType InputType, EnumerationErrors* pErrors, Query* pQuery = NULL) const
04388                 {
04389                         return xnAutoEnumerateOverSingleInput(m_pContext, List.GetUnderlyingObject(), &description, strCreationInfo, InputType, pErrors == NULL ? NULL : pErrors->GetUnderlying(), pQuery == NULL ? NULL : pQuery->GetUnderlyingObject());
04390                 }
04391 
04393                 inline void SetHandle(XnContext* pContext)
04394                 {
04395                         if (m_pContext != pContext)
04396                         {
04397                                 FreeImpl();
04398                                 m_pContext = pContext;
04399                         }
04400                 }
04401 
04402         private:
04403                 void FreeImpl()
04404                 {
04405                         if (m_bAllocated)
04406                         {
04407                                 Shutdown();
04408                                 m_pContext = NULL;
04409                                 m_bAllocated = FALSE;
04410                         }
04411                 }
04412 
04413                 XnContext* m_pContext;
04414                 XnBool m_bAllocated;
04415         };
04416 
04421         class Resolution
04422         {
04423         public:
04429                 inline Resolution(XnResolution res) : m_Res(res)
04430                 {
04431                         m_nXRes = xnResolutionGetXRes(res);
04432                         m_nYRes = xnResolutionGetYRes(res);
04433                         m_strName = xnResolutionGetName(res);
04434                 }
04435 
04442                 inline Resolution(XnUInt32 xRes, XnUInt32 yRes) : m_nXRes(xRes), m_nYRes(yRes)
04443                 {
04444                         m_Res = xnResolutionGetFromXYRes(xRes, yRes);
04445                         m_strName = xnResolutionGetName(m_Res);
04446                 }
04447 
04453                 inline Resolution(const XnChar* strName)
04454                 {
04455                         m_Res = xnResolutionGetFromName(strName);
04456                         m_nXRes = xnResolutionGetXRes(m_Res);
04457                         m_nYRes = xnResolutionGetYRes(m_Res);
04458                         m_strName = xnResolutionGetName(m_Res);
04459                 }
04460 
04462                 inline XnResolution GetResolution() const { return m_Res; }
04464                 inline XnUInt32 GetXResolution() const { return m_nXRes; }
04466                 inline XnUInt32 GetYResolution() const { return m_nYRes; }
04468                 inline const XnChar* GetName() const { return m_strName; }
04469 
04470         private:
04471                 XnResolution m_Res;
04472                 XnUInt32 m_nXRes;
04473                 XnUInt32 m_nYRes;
04474                 const XnChar* m_strName;
04475         };
04476 
04477         //---------------------------------------------------------------------------
04478         // Functions Implementation
04479         //---------------------------------------------------------------------------
04480         inline XnStatus NodeInfoList::FilterList(Context& context, Query& query)
04481         {
04482                 return xnNodeQueryFilterList(context.GetUnderlyingObject(), query.GetUnderlyingObject(), m_pList);
04483         }
04484 
04485         inline void ProductionNode::GetContext(Context& context)
04486         {
04487                 context.SetHandle(xnGetContextFromNodeHandle(m_hNode));
04488         }
04489 
04490         inline NodeInfoList& NodeInfo::GetNeededNodes() const
04491         {
04492                 if (m_pNeededNodes == NULL)
04493                 {
04494                         XnNodeInfoList* pList = xnNodeInfoGetNeededNodes(m_pInfo);
04495                         m_pNeededNodes = XN_NEW(NodeInfoList, pList);
04496                 }
04497 
04498                 return *m_pNeededNodes;
04499         }
04500 
04501         inline void NodeInfo::SetUnderlyingObject(XnNodeInfo* pInfo)
04502         {
04503                 if (m_pNeededNodes != NULL)
04504                 {
04505                         XN_DELETE(m_pNeededNodes);
04506                 }
04507 
04508                 m_pInfo = pInfo;
04509                 m_pNeededNodes = NULL;
04510         }
04511 
04512         inline XnBool FrameSyncCapability::CanFrameSyncWith(Generator& other)
04513         {
04514                 return xnCanFrameSyncWith(m_hNode, other);
04515         }
04516 
04517         inline XnStatus FrameSyncCapability::FrameSyncWith(Generator& other)
04518         {
04519                 return xnFrameSyncWith(m_hNode, other);
04520         }
04521 
04522         inline XnStatus FrameSyncCapability::StopFrameSyncWith(Generator& other)
04523         {
04524                 return xnStopFrameSyncWith(m_hNode, other);
04525         }
04526 
04527         inline XnBool FrameSyncCapability::IsFrameSyncedWith(Generator& other)
04528         {
04529                 return xnIsFrameSyncedWith(m_hNode, other);
04530         }
04531 
04532         inline XnStatus NodeInfo::GetInstance(ProductionNode& node) const
04533         {
04534                 XnStatus nRetVal = XN_STATUS_OK;
04535 
04536                 if (m_pInfo == NULL)
04537                 {
04538                         return XN_STATUS_INVALID_OPERATION;
04539                 }
04540 
04541                 node.SetHandle(xnNodeInfoGetHandle(m_pInfo));
04542 
04543                 return (XN_STATUS_OK);
04544         }
04545 
04546 
04547 
04548         //---------------------------------------------------------------------------
04549         // Node creation functions
04550         //---------------------------------------------------------------------------
04551 
04552         inline XnStatus Recorder::Create(Context& context, const XnChar* strFormatName = NULL)
04553         {
04554                 return xnCreateRecorder(context.GetUnderlyingObject(), strFormatName, &m_hNode);
04555         }
04556 
04557         inline XnStatus Player::Create(Context& context, const XnChar* strFormatName)
04558         {
04559                 return xnCreatePlayer(context.GetUnderlyingObject(), strFormatName, &m_hNode);
04560         }
04561 
04562         inline XnStatus DepthGenerator::Create(Context& context, Query* pQuery/*=NULL*/, EnumerationErrors* pErrors/*=NULL*/)
04563         {
04564                 return xnCreateDepthGenerator(context.GetUnderlyingObject(), &m_hNode, pQuery == NULL ? NULL : pQuery->GetUnderlyingObject(), pErrors == NULL ? NULL : pErrors->GetUnderlying());
04565         }
04566 
04567         inline XnStatus MockDepthGenerator::Create(Context& context, const XnChar* strName /* = NULL */)
04568         {
04569                 return xnCreateMockNode(context.GetUnderlyingObject(), XN_NODE_TYPE_DEPTH, strName, &m_hNode);
04570         }
04571 
04572         inline XnStatus MockDepthGenerator::CreateBasedOn(DepthGenerator& other, const XnChar* strName /* = NULL */)
04573         {
04574                 Context context;
04575                 other.GetContext(context);
04576                 return xnCreateMockNodeBasedOn(context.GetUnderlyingObject(), other, strName, &m_hNode);
04577         }
04578 
04579         inline XnStatus ImageGenerator::Create(Context& context, Query* pQuery/*=NULL*/, EnumerationErrors* pErrors/*=NULL*/)
04580         {
04581                 return xnCreateImageGenerator(context.GetUnderlyingObject(), &m_hNode, pQuery == NULL ? NULL : pQuery->GetUnderlyingObject(), pErrors == NULL ? NULL : pErrors->GetUnderlying());
04582         }
04583 
04584         inline XnStatus MockImageGenerator::Create(Context& context, const XnChar* strName /* = NULL */)
04585         {
04586                 return xnCreateMockNode(context.GetUnderlyingObject(), XN_NODE_TYPE_IMAGE, strName, &m_hNode);
04587         }
04588 
04589         inline XnStatus MockImageGenerator::CreateBasedOn(ImageGenerator& other, const XnChar* strName /* = NULL */)
04590         {
04591                 Context context;
04592                 other.GetContext(context);
04593                 return xnCreateMockNodeBasedOn(context.GetUnderlyingObject(), other, strName, &m_hNode);
04594         }
04595 
04596         inline XnStatus IRGenerator::Create(Context& context, Query* pQuery/*=NULL*/, EnumerationErrors* pErrors/*=NULL*/)
04597         {
04598                 return xnCreateIRGenerator(context.GetUnderlyingObject(), &m_hNode, pQuery == NULL ? NULL : pQuery->GetUnderlyingObject(), pErrors == NULL ? NULL : pErrors->GetUnderlying());
04599         }
04600         
04601         inline XnStatus MockIRGenerator::Create(Context& context, const XnChar* strName /* = NULL */)
04602         {
04603                 return xnCreateMockNode(context.GetUnderlyingObject(), XN_NODE_TYPE_IR, strName, &m_hNode);
04604         }
04605 
04606         inline XnStatus MockIRGenerator::CreateBasedOn(IRGenerator& other, const XnChar* strName /* = NULL */)
04607         {
04608                 Context context;
04609                 other.GetContext(context);
04610                 return xnCreateMockNodeBasedOn(context.GetUnderlyingObject(), other, strName, &m_hNode);
04611         }
04612 
04613         inline XnStatus GestureGenerator::Create(Context& context, Query* pQuery/*=NULL*/, EnumerationErrors* pErrors/*=NULL*/)
04614         {
04615                 return xnCreateGestureGenerator(context.GetUnderlyingObject(), &m_hNode, pQuery == NULL ? NULL : pQuery->GetUnderlyingObject(), pErrors == NULL ? NULL : pErrors->GetUnderlying());
04616         }
04617 
04618         inline XnStatus SceneAnalyzer::Create(Context& context, Query* pQuery/*=NULL*/, EnumerationErrors* pErrors/*=NULL*/)
04619         {
04620                 //You're creating a scene!
04621                 return xnCreateSceneAnalyzer(context.GetUnderlyingObject(), &m_hNode, pQuery == NULL ? NULL : pQuery->GetUnderlyingObject(), pErrors == NULL ? NULL : pErrors->GetUnderlying());
04622         }
04623 
04624         inline XnStatus HandsGenerator::Create(Context& context, Query* pQuery/*=NULL*/, EnumerationErrors* pErrors/*=NULL*/)
04625         {
04626                 return xnCreateHandsGenerator(context.GetUnderlyingObject(), &m_hNode, pQuery == NULL ? NULL : pQuery->GetUnderlyingObject(), pErrors == NULL ? NULL : pErrors->GetUnderlying());
04627         }
04628 
04629         inline XnStatus UserGenerator::Create(Context& context, Query* pQuery/*=NULL*/, EnumerationErrors* pErrors/*=NULL*/)
04630         {
04631                 return xnCreateUserGenerator(context.GetUnderlyingObject(), &m_hNode, pQuery == NULL ? NULL : pQuery->GetUnderlyingObject(), pErrors == NULL ? NULL : pErrors->GetUnderlying());
04632         }
04633 
04634         inline XnStatus AudioGenerator::Create(Context& context, Query* pQuery/*=NULL*/, EnumerationErrors* pErrors/*=NULL*/)
04635         {
04636                 return xnCreateAudioGenerator(context.GetUnderlyingObject(), &m_hNode, pQuery == NULL ? NULL : pQuery->GetUnderlyingObject(), pErrors == NULL ? NULL : pErrors->GetUnderlying());
04637         }
04638 
04639         inline XnStatus MockAudioGenerator::Create(Context& context, const XnChar* strName /* = NULL */)
04640         {
04641                 return xnCreateMockNode(context.GetUnderlyingObject(), XN_NODE_TYPE_AUDIO, strName, &m_hNode);
04642         }
04643 
04644         inline XnStatus MockAudioGenerator::CreateBasedOn(AudioGenerator& other, const XnChar* strName /* = NULL */)
04645         {
04646                 Context context;
04647                 other.GetContext(context);
04648                 return xnCreateMockNodeBasedOn(context.GetUnderlyingObject(), other, strName, &m_hNode);
04649         }
04650 
04651         inline XnStatus Codec::Create(Context& context, XnCodecID codecID, ProductionNode& initializerNode)
04652         {
04653                 return xnCreateCodec(context.GetUnderlyingObject(), codecID, initializerNode, &m_hNode);
04654         }
04655 
04656         //---------------------------------------------------------------------------
04657         // Global Helper Functions
04658         //---------------------------------------------------------------------------
04659 
04663         inline void GetVersion(XnVersion& Version)
04664         {
04665                 xnGetVersion(&Version);
04666         }
04667 
04668         //---------------------------------------------------------------------------
04669         // Internal Helper Classes and Functions
04670         //---------------------------------------------------------------------------
04671 
04672         class StateChangedCallbackTranslator
04673         {
04674         public:
04675                 StateChangedCallbackTranslator(StateChangedHandler handler, void* pCookie) : m_UserHandler(handler), m_pUserCookie(pCookie), m_hCallback(NULL) {}
04676 
04677                 XnStatus Register(_XnRegisterStateChangeFuncPtr xnFunc, XnNodeHandle hNode)
04678                 {
04679                         return xnFunc(hNode, StateChangedCallback, this, &m_hCallback);
04680                 }
04681 
04682                 void Unregister(_XnUnregisterStateChangeFuncPtr xnFunc, XnNodeHandle hNode)
04683                 {
04684                         xnFunc(hNode, m_hCallback);
04685                 }
04686 
04687                 static XnStatus RegisterToUnderlying(_XnRegisterStateChangeFuncPtr xnFunc, XnNodeHandle hNode, StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
04688                 {
04689                         XnStatus nRetVal = XN_STATUS_OK;
04690                         
04691                         StateChangedCallbackTranslator* pTrans;
04692                         XN_VALIDATE_NEW(pTrans, StateChangedCallbackTranslator, handler, pCookie);
04693 
04694                         nRetVal = pTrans->Register(xnFunc, hNode);
04695                         if (nRetVal != XN_STATUS_OK)
04696                         {
04697                                 XN_DELETE(pTrans);
04698                                 return (nRetVal);
04699                         }
04700 
04701                         hCallback = pTrans;
04702                         
04703                         return (XN_STATUS_OK);
04704                 }
04705 
04706                 static XnStatus UnregisterFromUnderlying(_XnUnregisterStateChangeFuncPtr xnFunc, XnNodeHandle hNode, XnCallbackHandle hCallback)
04707                 {
04708                         StateChangedCallbackTranslator* pTrans = (StateChangedCallbackTranslator*)hCallback;
04709                         pTrans->Unregister(xnFunc, hNode);
04710                         XN_DELETE(pTrans);
04711                         return XN_STATUS_OK;
04712                 }
04713 
04714         private:
04715                 typedef struct StateChangeCookie
04716                 {
04717                         StateChangedHandler userHandler;
04718                         void* pUserCookie;
04719                         XnCallbackHandle hCallback;
04720                 } StateChangeCookie;
04721 
04722                 static void XN_CALLBACK_TYPE StateChangedCallback(XnNodeHandle hNode, void* pCookie)
04723                 {
04724                         StateChangedCallbackTranslator* pTrans = (StateChangedCallbackTranslator*)pCookie;
04725                         ProductionNode node(hNode);
04726                         pTrans->m_UserHandler(node, pTrans->m_pUserCookie);
04727                 }
04728 
04729                 StateChangedHandler m_UserHandler;
04730                 void* m_pUserCookie;
04731                 XnCallbackHandle m_hCallback;
04732         };
04733 
04734         static XnStatus _RegisterToStateChange(_XnRegisterStateChangeFuncPtr xnFunc, XnNodeHandle hNode, StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
04735         {
04736                 return StateChangedCallbackTranslator::RegisterToUnderlying(xnFunc, hNode, handler, pCookie, hCallback);
04737         }
04738 
04739         static void _UnregisterFromStateChange(_XnUnregisterStateChangeFuncPtr xnFunc, XnNodeHandle hNode, XnCallbackHandle hCallback)
04740         {
04741                 StateChangedCallbackTranslator::UnregisterFromUnderlying(xnFunc, hNode, hCallback);
04742         }
04743 
04745 };
04746 
04747 #endif // __XN_CPP_WRAPPER_H__


nao_openni
Author(s): Bener SUAY
autogenerated on Mon Jan 6 2014 11:27:51