OpenNI 2.0
Public Member Functions | Friends
openni::OpenNI::Listener Class Reference

#include <OpenNI.h>

List of all members.

Public Member Functions

 Listener ()
virtual void onDeviceConnected (const DeviceInfo *)
virtual void onDeviceDisconnected (const DeviceInfo *)
virtual void onDeviceStateChanged (const DeviceInfo *, DeviceState)

Friends

class OpenNI

Detailed Description

The OpenNI::Listener class provides a means of registering for, and responding to three event types: onDeviceConnected, onDeviceDisconnected, and onDeviceStateChanged.

onDeviceConnected is called whenever a new device is connected to the system (ie this event would be triggered when a new sensor is manually plugged into the host system running the application)

onDeviceDisconnected is called when a device is removed from the system. Note that once a device is removed, if it was opened by a Device object, that object can no longer be used to access the device, even if it was reconnected. Once a device was reconnected, Device::open() should be called again in order to use this device.

onDeviceStateChanged is triggered whenever the state of a connected device is changed.

To use this class, you should write a new class that inherits from it, and override each event handler that you wish to act upon. Once you instantiate your class, use the OpenNI::addListener() function to add your listener object to OpenNI's list of listeners. Your handler functions will then be called whenever one of the defined events occurs. A removeListener() function is also provided, if you want to have your class stop listening to these events for any reason.


Constructor & Destructor Documentation


Member Function Documentation

virtual void openni::OpenNI::Listener::onDeviceConnected ( const DeviceInfo ) [inline, virtual]

Callback function for the onDeviceConnected event. This function will be called whenever this event occurs. When this happens, a pointer to the DeviceInfo object for the newly connected device will be supplied. Note that once a device is removed, if it was opened by a Device object, that object can no longer be used to access the device, even if it was reconnected. Once a device was reconnected, Device::open() should be called again in order to use this device.

If you wish to open the new device as it is connected, simply query the provided DeviceInfo object to obtain the URI of the device, and pass this URI to the Device.Open() function.

virtual void openni::OpenNI::Listener::onDeviceDisconnected ( const DeviceInfo ) [inline, virtual]

Callback function for the onDeviceDisconnected event. This function will be called whenever this event occurs. When this happens, a pointer to the DeviceInfo object for the newly disconnected device will be supplied. Note that once a device is removed, if it was opened by a Device object, that object can no longer be used to access the device, even if it was reconnected. Once a device was reconnected, Device::open() should be called again in order to use this device.

virtual void openni::OpenNI::Listener::onDeviceStateChanged ( const DeviceInfo ,
DeviceState   
) [inline, virtual]

Callback function for the onDeviceStateChanged event. This function will be called whenever this event occurs. When this happens, a pointer to a DeviceInfo object for the affected device will be supplied, as well as the new DeviceState value of that device.


Friends And Related Function Documentation

friend class OpenNI [friend]

The documentation for this class was generated from the following file: