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 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348
|
/****************************************************************************
* *
* 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 __IXN_DEVICE_BASE_H__
#define __IXN_DEVICE_BASE_H__
//---------------------------------------------------------------------------
// Includes
//---------------------------------------------------------------------------
#include <XnDevice.h>
//---------------------------------------------------------------------------
// Types
//---------------------------------------------------------------------------
class XN_DDK_CPP_API IXnDevice
{
public:
IXnDevice() {}
virtual ~IXnDevice() {}
inline XnDeviceHandle GetDeviceHandle() const { return (XnDeviceHandle)this; }
static inline IXnDevice* GetFromDeviceHandle(XnDeviceHandle DeviceHandle) { return (IXnDevice*)(DeviceHandle); }
virtual XnStatus Init(const XnDeviceConfig* pDeviceConfig) = 0;
virtual XnStatus Destroy() = 0;
/**
* Returns the types of the streams supported by this device.
*
* @param aStreamName [in/out] An array of stream names. Will be filled by the function.
* @param pnStreamNamesCount [in/out] The size of the array. Upon successful return, will contain the number of elements written to the array.
*/
virtual XnStatus GetSupportedStreams(const XnChar** aStreamNames, XnUInt32* pnStreamNamesCount) = 0;
/**
* Creates a new stream in the device.
*
* @param StreamType [in] The type of the stream to create (one of the types returned by XnDeviceEnumerateStreams).
* @param StreamName [in] [Optional] A name for the new stream.
* @param pInitialValues [in] [Optional] A set of initial values for properties.
*/
virtual XnStatus CreateStream(const XnChar* StreamType, const XnChar* StreamName = NULL, const XnPropertySet* pInitialValues = NULL) = 0;
/**
* Destroys a previously created stream.
*
* @param StreamName [in] The name of the stream to destroy.
*/
virtual XnStatus DestroyStream(const XnChar* StreamName) = 0;
/**
* Opens a stream for I/O operations.
*
* @param StreamName [in] The name of the stream to open.
*/
virtual XnStatus OpenStream(const XnChar* StreamName) = 0;
/**
* Closes an open stream.
*
* @param StreamName [in] The name of the stream to close.
*/
virtual XnStatus CloseStream(const XnChar* StreamName) = 0;
/**
* Get a list of all the streams that exist in the device.
*
* @param pstrStreamNames [in/out] An array of stream names. Will be filled by the function.
* @param pnNamesCount [in/out] The size of the array. Upon successful return, will contain the number of elements written to the array.
*/
virtual XnStatus GetStreamNames(const XnChar** pstrNames, XnUInt32* pnNamesCount) = 0;
/**
* Checks if a specific module exists in this device.
*
* @param ModuleName [in] The name of the module to look for.
* @param pbDoesExist [out] TRUE if the module exists, FALSE otherwise.
*/
virtual XnStatus DoesModuleExist(const XnChar* ModuleName, XnBool* pbDoesExist) = 0;
/**
* Opens all closed streams.
*/
virtual XnStatus OpenAllStreams() = 0;
/**
* Closes all open streams.
*/
virtual XnStatus CloseAllStreams() = 0;
/**
* Registers to the event of streams change (stream created / destroyed)
*
* @param Handler [in] A pointer to the function that will handle the event.
* @param pCookie [in] User cookie that will be passed as an argument to the event handler.
* @param phCallback [out] A handle for unregister.
*/
virtual XnStatus RegisterToStreamsChange(XnDeviceOnStreamsChangedEventHandler Handler, void* pCookie, XnCallbackHandle* phCallback) = 0;
/**
* Unregisters from the event of streams change (stream created / destroyed)
*
* @param hCallback [in] The handle returned from RegisterToStreamsChange.
*/
virtual XnStatus UnregisterFromStreamsChange(XnCallbackHandle hCallback) = 0;
/**
* Creates a stream data object for the requested stream.
*
* @param StreamName [in] The requested stream.
* @param ppStreamData [out] The created stream data object.
*/
virtual XnStatus CreateStreamData(const XnChar* StreamName, XnStreamData** ppStreamData) = 0;
/**
* Registers to the event of new data from a stream.
*
* @param Handler [in] A pointer to the function that will handle the event.
* @param pCookie [in] User cookie that will be passed as an argument to the event handler.
* @param phCallback [out] A handle for unregister.
*/
virtual XnStatus RegisterToNewStreamData(XnDeviceOnNewStreamDataEventHandler Handler, void* pCookie, XnCallbackHandle* phCallback) = 0;
/**
* Unregisters from the event of new data from a stream.
*
* @param hCallback [in] The handle returned from RegisterToNewStreamData.
*/
virtual XnStatus UnregisterFromNewStreamData(XnCallbackHandle hCallback) = 0;
/**
* Checks if new data is available from stream.
*
* @param StreamName [in] The name of the stream to check.
* @param pbNewDataAvailable [out] TRUE if new data is available, FALSE otherwise.
*/
virtual XnStatus IsNewDataAvailable(const XnChar* StreamName, XnBool* pbNewDataAvailable, XnUInt64* pnTimestamp) = 0;
/**
* Waits for new data to be available from requested stream, and then return it.
*
* @param pStreamOutput [in/out] A stream output object. The function will use the stream output object to determine which stream to read.
*/
virtual XnStatus ReadStream(XnStreamData* pStreamOutput) = 0;
/**
* Waits for new data from the primary stream to be available, and then reads all requested streams.
*
* @param pStreamOutputSet [in/out] A set of stream output objects.
*/
virtual XnStatus Read(XnStreamDataSet* pStreamOutputSet) = 0;
/**
* Writes a single stream data to the device.
*
* @param pStreamOutput [in] A stream output object.
*/
virtual XnStatus WriteStream(XnStreamData* pStreamOutput) = 0;
/**
* Writes multiple streams to the device.
*
* @param pStreamOutputSet [in] A set of stream output objects.
*/
virtual XnStatus Write(XnStreamDataSet* pStreamOutputSet) = 0;
/**
* Gets current position of the device.
*
* @param pnTimestamp [out] Current device timestamp.
*/
virtual XnStatus Tell(XnUInt64* pnTimestamp) = 0;
/**
* Seeks the device to the requested position.
*
* @param nTimestamp [in] Requested device timestamp.
*/
virtual XnStatus Seek(XnUInt64 nTimestamp) = 0;
/**
* Gets current frame position of the device.
*
* @param DeviceHandle [in] The requested device handle.
* @param pnFrameID [out] Current device frame.
*/
virtual XnStatus TellFrame(XnUInt32* pnFrameID) = 0;
/**
* Seeks the device to the requested frame position.
*
* @param DeviceHandle [in] The requested device handle.
* @param nFrameID [in] Requested device frame.
*/
virtual XnStatus SeekFrame(XnUInt32 nFrameID) = 0;
/**
* Checks if a specific property exists in a module.
*
* @param ModuleName [in] Name of the module.
* @param PropertyName [in] Name of the property to change.
* @param pbDoesExist [out] TRUE if the property exists, FALSE otherwise.
*/
virtual XnStatus DoesPropertyExist(const XnChar* ModuleName, const XnChar* PropertyName, XnBool* pbDoesExist) = 0;
/**
* Returns the type of a specific property.
*
* @param ModuleName [in] Name of the module.
* @param PropertyName [in] Name of the property to change.
* @param pnType [out] Type of this property.
*/
virtual XnStatus GetPropertyType(const XnChar* ModuleName, const XnChar* PropertyName, XnPropertyType* pnType) = 0;
/**
* Sets the value of an int property.
*
* @param ModuleName [in] Name of the module.
* @param PropertyName [in] Name of the property to change.
* @param nValue [in] New requested value.
*/
virtual XnStatus SetProperty(const XnChar* ModuleName, const XnChar* PropertyName, XnUInt64 nValue) = 0;
/**
* Sets the value of a real property.
*
* @param ModuleName [in] Name of the module.
* @param PropertyName [in] Name of the property to change.
* @param dValue [in] New requested value.
*/
virtual XnStatus SetProperty(const XnChar* ModuleName, const XnChar* PropertyName, XnDouble dValue) = 0;
/**
* Sets the value of a string property.
*
* @param ModuleName [in] Name of the module.
* @param PropertyName [in] Name of the property to change.
* @param csValue [in] New requested value.
*/
virtual XnStatus SetProperty(const XnChar* ModuleName, const XnChar* PropertyName, const XnChar* csValue) = 0;
/**
* Sets the value of a general property.
*
* @param ModuleName [in] Name of the module.
* @param PropertyName [in] Name of the property to change.
* @param gbValue [in] New requested value.
*/
virtual XnStatus SetProperty(const XnChar* ModuleName, const XnChar* PropertyName, const XnGeneralBuffer& gbValue) = 0;
/**
* Gets the value of an int property.
*
* @param ModuleName [in] Name of the module.
* @param PropertyName [in] Name of the property to change.
* @param pnValue [out] Current value.
*/
virtual XnStatus GetProperty(const XnChar* ModuleName, const XnChar* PropertyName, XnUInt64* pnValue) = 0;
/**
* Gets the value of a real property.
*
* @param ModuleName [in] Name of the module.
* @param PropertyName [in] Name of the property to change.
* @param pdValue [out] Current value.
*/
virtual XnStatus GetProperty(const XnChar* ModuleName, const XnChar* PropertyName, XnDouble* pdValue) = 0;
/**
* Gets the value of a string property.
*
* @param ModuleName [in] Name of the module.
* @param PropertyName [in] Name of the property to change.
* @param csValue [in/out] Current value. The passed buffer should be of size XN_DEVICE_MAX_STRING_LENGTH.
*/
virtual XnStatus GetProperty(const XnChar* ModuleName, const XnChar* PropertyName, XnChar* csValue) = 0;
/**
* Gets the value of a general property.
*
* @param ModuleName [in] Name of the module.
* @param PropertyName [in] Name of the property to change.
* @param gbValue [out] A buffer to fill.
*/
virtual XnStatus GetProperty(const XnChar* ModuleName, const XnChar* PropertyName, const XnGeneralBuffer& gbValue) = 0;
/**
* Loads configuration from INI file.
*
* @param csINIFilePath [in] A path to the INI file.
* @param csSectionName [in] The name of the section containing configuration.
*/
virtual XnStatus LoadConfigFromFile(const XnChar* csINIFilePath, const XnChar* csSectionName) = 0;
/**
* Batch-Configures device. All the properties in the set will be set as a single transaction.
*
* @param pChangeSet [in] A set of properties to be changed.
*/
virtual XnStatus BatchConfig(const XnPropertySet* pChangeSet) = 0;
/**
* Gets all the properties of a device.
*
* @param pSet [in] The property set to be filled.
*/
virtual XnStatus GetAllProperties(XnPropertySet* pSet, XnBool bNoStreams = FALSE, const XnChar* strModule = NULL) = 0;
/**
* Registers an event handler to the Property Changed event of a specific property.
*
* @param Module [in] Name of the module.
* @param PropertyName [in] Name of the property to register to.
* @param Handler [in] A pointer to the function that will handle the event.
* @param pCookie [in] User cookie that will be passed as an argument to the event handler.
* @param phCallback [out] A handle for unregister.
*/
virtual XnStatus RegisterToPropertyChange(const XnChar* Module, const XnChar* PropertyName, XnDeviceOnPropertyChangedEventHandler Handler, void* pCookie, XnCallbackHandle* phCallback) = 0;
/**
* Unregisters an event handler from the Property Changed event.
*
* @param Module [in] Name of the module.
* @param PropertyName [in] Name of the property to register to.
* @param hCallback [in] The handle returned from RegisterToNewStreamData.
*/
virtual XnStatus UnregisterFromPropertyChange(const XnChar* Module, const XnChar* PropertyName, XnCallbackHandle hCallback) = 0;
};
#endif //__IXN_DEVICE_BASE_H__
|