1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304
|
/****************************************************************************
* *
* PrimeSense Sensor 5.x Alpha *
* Copyright (C) 2011 PrimeSense Ltd. *
* *
* This file is part of PrimeSense Sensor. *
* *
* PrimeSense Sensor is free software: you can redistribute it and/or modify*
* it under the terms of the GNU Lesser General Public License as published *
* by the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* PrimeSense Sensor is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with PrimeSense Sensor. If not, see <http://www.gnu.org/licenses/>.*
* *
****************************************************************************/
#ifndef __XN_DEVICE_BASE_PROXY_H__
#define __XN_DEVICE_BASE_PROXY_H__
//---------------------------------------------------------------------------
// Includes
//---------------------------------------------------------------------------
#include "IXnDevice.h"
//---------------------------------------------------------------------------
// Defines
//---------------------------------------------------------------------------
#define XN_VALIDATE_ACTUAL_DEVICE \
if (m_pActual == NULL) return XN_STATUS_ERROR;
//---------------------------------------------------------------------------
// Types
//---------------------------------------------------------------------------
/**
* A base class for all proxies. By default, every call gets transfered to the actual device.
* Deriving classes may add additional behavior.
*/
class XN_DDK_CPP_API XnDeviceBaseProxy : public IXnDevice
{
public:
virtual XnStatus Init(const XnDeviceConfig* pDeviceConfig)
{
XN_VALIDATE_ACTUAL_DEVICE;
return m_pActual->Init(pDeviceConfig);
}
virtual XnStatus Destroy()
{
XN_VALIDATE_ACTUAL_DEVICE;
return m_pActual->Destroy();
}
virtual XnStatus GetSupportedStreams(const XnChar** aStreamNames, XnUInt32* pnStreamNamesCount)
{
XN_VALIDATE_ACTUAL_DEVICE;
return m_pActual->GetSupportedStreams(aStreamNames, pnStreamNamesCount);
}
virtual XnStatus CreateStream(const XnChar* StreamType, const XnChar* StreamName = NULL, const XnPropertySet* pInitialValues = NULL)
{
XN_VALIDATE_ACTUAL_DEVICE;
return m_pActual->CreateStream(StreamType, StreamName, pInitialValues);
}
virtual XnStatus DestroyStream(const XnChar* StreamName)
{
XN_VALIDATE_ACTUAL_DEVICE;
return m_pActual->DestroyStream(StreamName);
}
virtual XnStatus OpenStream(const XnChar* StreamName)
{
XN_VALIDATE_ACTUAL_DEVICE;
return m_pActual->OpenStream(StreamName);
}
virtual XnStatus CloseStream(const XnChar* StreamName)
{
XN_VALIDATE_ACTUAL_DEVICE;
return m_pActual->CloseStream(StreamName);
}
virtual XnStatus GetStreamNames(const XnChar** pstrNames, XnUInt32* pnNamesCount)
{
XN_VALIDATE_ACTUAL_DEVICE;
return m_pActual->GetStreamNames(pstrNames, pnNamesCount);
}
virtual XnStatus DoesModuleExist(const XnChar* ModuleName, XnBool* pbDoesExist)
{
XN_VALIDATE_ACTUAL_DEVICE;
return m_pActual->DoesModuleExist(ModuleName, pbDoesExist);
}
virtual XnStatus OpenAllStreams()
{
XN_VALIDATE_ACTUAL_DEVICE;
return m_pActual->OpenAllStreams();
}
virtual XnStatus CloseAllStreams()
{
XN_VALIDATE_ACTUAL_DEVICE;
return m_pActual->CloseAllStreams();
}
virtual XnStatus RegisterToStreamsChange(XnDeviceOnStreamsChangedEventHandler Handler, void* pCookie, XnCallbackHandle* phCallback)
{
XN_VALIDATE_ACTUAL_DEVICE;
return m_pActual->RegisterToStreamsChange(Handler, pCookie, phCallback);
}
virtual XnStatus UnregisterFromStreamsChange(XnCallbackHandle hCallback)
{
XN_VALIDATE_ACTUAL_DEVICE;
return m_pActual->UnregisterFromStreamsChange(hCallback);
}
virtual XnStatus CreateStreamData(const XnChar* StreamName, XnStreamData** ppStreamData)
{
XN_VALIDATE_ACTUAL_DEVICE;
return m_pActual->CreateStreamData(StreamName, ppStreamData);
}
virtual XnStatus RegisterToNewStreamData(XnDeviceOnNewStreamDataEventHandler Handler, void* pCookie, XnCallbackHandle* phCallback)
{
XN_VALIDATE_ACTUAL_DEVICE;
return m_pActual->RegisterToNewStreamData(Handler, pCookie, phCallback);
}
virtual XnStatus UnregisterFromNewStreamData(XnCallbackHandle hCallback)
{
XN_VALIDATE_ACTUAL_DEVICE;
return m_pActual->UnregisterFromNewStreamData(hCallback);
}
virtual XnStatus IsNewDataAvailable(const XnChar* StreamName, XnBool* pbNewDataAvailable, XnUInt64* pnTimestamp)
{
XN_VALIDATE_ACTUAL_DEVICE;
return m_pActual->IsNewDataAvailable(StreamName, pbNewDataAvailable, pnTimestamp);
}
virtual XnStatus ReadStream(XnStreamData* pStreamOutput)
{
XN_VALIDATE_ACTUAL_DEVICE;
return m_pActual->ReadStream(pStreamOutput);
}
virtual XnStatus Read(XnStreamDataSet* pStreamOutputSet)
{
XN_VALIDATE_ACTUAL_DEVICE;
return m_pActual->Read(pStreamOutputSet);
}
virtual XnStatus WriteStream(XnStreamData* pStreamOutput)
{
XN_VALIDATE_ACTUAL_DEVICE;
return m_pActual->WriteStream(pStreamOutput);
}
virtual XnStatus Write(XnStreamDataSet* pStreamOutputSet)
{
XN_VALIDATE_ACTUAL_DEVICE;
return m_pActual->Write(pStreamOutputSet);
}
virtual XnStatus Tell(XnUInt64* pnTimestamp)
{
XN_VALIDATE_ACTUAL_DEVICE;
return m_pActual->Tell(pnTimestamp);
}
virtual XnStatus Seek(XnUInt64 nTimestamp)
{
XN_VALIDATE_ACTUAL_DEVICE;
return m_pActual->Seek(nTimestamp);
}
virtual XnStatus TellFrame(XnUInt32* pnFrameID)
{
XN_VALIDATE_ACTUAL_DEVICE;
return m_pActual->TellFrame(pnFrameID);
}
virtual XnStatus SeekFrame(XnUInt32 nFrameID)
{
XN_VALIDATE_ACTUAL_DEVICE;
return m_pActual->SeekFrame(nFrameID);
}
virtual XnStatus DoesPropertyExist(const XnChar* ModuleName, const XnChar* PropertyName, XnBool* pbDoesExist)
{
XN_VALIDATE_ACTUAL_DEVICE;
return m_pActual->DoesPropertyExist(ModuleName, PropertyName, pbDoesExist);
}
virtual XnStatus GetPropertyType(const XnChar* ModuleName, const XnChar* PropertyName, XnPropertyType* pnType)
{
XN_VALIDATE_ACTUAL_DEVICE;
return m_pActual->GetPropertyType(ModuleName, PropertyName, pnType);
}
virtual XnStatus SetProperty(const XnChar* ModuleName, const XnChar* PropertyName, XnUInt64 nValue)
{
XN_VALIDATE_ACTUAL_DEVICE;
return m_pActual->SetProperty(ModuleName, PropertyName, nValue);
}
virtual XnStatus SetProperty(const XnChar* ModuleName, const XnChar* PropertyName, XnDouble dValue)
{
XN_VALIDATE_ACTUAL_DEVICE;
return m_pActual->SetProperty(ModuleName, PropertyName, dValue);
}
virtual XnStatus SetProperty(const XnChar* ModuleName, const XnChar* PropertyName, const XnChar* csValue)
{
XN_VALIDATE_ACTUAL_DEVICE;
return m_pActual->SetProperty(ModuleName, PropertyName, csValue);
}
virtual XnStatus SetProperty(const XnChar* ModuleName, const XnChar* PropertyName, const XnGeneralBuffer& Value)
{
XN_VALIDATE_ACTUAL_DEVICE;
return m_pActual->SetProperty(ModuleName, PropertyName, Value);
}
virtual XnStatus GetProperty(const XnChar* ModuleName, const XnChar* PropertyName, XnUInt64* pnValue)
{
XN_VALIDATE_ACTUAL_DEVICE;
return m_pActual->GetProperty(ModuleName, PropertyName, pnValue);
}
virtual XnStatus GetProperty(const XnChar* ModuleName, const XnChar* PropertyName, XnDouble* pdValue)
{
XN_VALIDATE_ACTUAL_DEVICE;
return m_pActual->GetProperty(ModuleName, PropertyName, pdValue);
}
virtual XnStatus GetProperty(const XnChar* ModuleName, const XnChar* PropertyName, XnChar* csValue)
{
XN_VALIDATE_ACTUAL_DEVICE;
return m_pActual->GetProperty(ModuleName, PropertyName, csValue);
}
virtual XnStatus GetProperty(const XnChar* ModuleName, const XnChar* PropertyName, const XnGeneralBuffer& gbValue)
{
XN_VALIDATE_ACTUAL_DEVICE;
return m_pActual->GetProperty(ModuleName, PropertyName, gbValue);
}
virtual XnStatus LoadConfigFromFile(const XnChar* csINIFilePath, const XnChar* csSectionName)
{
XN_VALIDATE_ACTUAL_DEVICE;
return m_pActual->LoadConfigFromFile(csINIFilePath, csSectionName);
}
virtual XnStatus BatchConfig(const XnPropertySet* pChangeSet)
{
XN_VALIDATE_ACTUAL_DEVICE;
return m_pActual->BatchConfig(pChangeSet);
}
virtual XnStatus GetAllProperties(XnPropertySet* pSet, XnBool bNoStreams = FALSE, const XnChar* strModule = NULL)
{
XN_VALIDATE_ACTUAL_DEVICE;
return m_pActual->GetAllProperties(pSet, bNoStreams, strModule);
}
virtual XnStatus RegisterToPropertyChange(const XnChar* Module, const XnChar* PropertyName, XnDeviceOnPropertyChangedEventHandler Handler, void* pCookie, XnCallbackHandle* phCallback)
{
XN_VALIDATE_ACTUAL_DEVICE;
return m_pActual->RegisterToPropertyChange(Module, PropertyName, Handler, pCookie, phCallback);
}
virtual XnStatus UnregisterFromPropertyChange(const XnChar* Module, const XnChar* PropertyName, XnCallbackHandle hCallback)
{
XN_VALIDATE_ACTUAL_DEVICE;
return m_pActual->UnregisterFromPropertyChange(Module, PropertyName, hCallback);
}
protected:
XnDeviceBaseProxy(IXnDevice* pActual)
{
ReplaceActualDevice(pActual);
}
IXnDevice* GetActual() { return m_pActual; }
void ReplaceActualDevice(IXnDevice* pActual)
{
m_pActual = pActual;
}
private:
IXnDevice* m_pActual;
};
#endif //__XN_DEVICE_BASE_PROXY_H__
|