NITE 1.5.1 - API Reference

XnVMessageListener Class Reference

#include <XnVMessageListener.h>

Inheritance diagram for XnVMessageListener:

List of all members.

Public Types

typedef void(XN_CALLBACK_TYPE * MessageUpdateCB )(XnVMessage *pMessage, void *cxt)
typedef void(XN_CALLBACK_TYPE * ActivateCB )(void *cxt)
typedef void(XN_CALLBACK_TYPE * DeactivateCB )(void *cxt)

Public Member Functions

 XnVMessageListener (const XnChar *strName="XnVMessageListener")
virtual ~XnVMessageListener ()
void BaseUpdate (XnVMessage *pMessage)
virtual void Update (XnVMessage *pMessage)=0
virtual void HandleCCMessages (XnVMessage *pMessage)
virtual void Activate (XnBool bActive)
const XnChar * GetListenerName () const
void Run (XnUInt32 nSessionMaxLength=ms_nSessionDefaultLength)
XnStatus RunAsThread ()
void SetThreadId (XN_THREAD_ID hThread)
void SetCurrentThread ()
XnCallbackHandle RegisterUpdate (void *cxt, MessageUpdateCB CB)
XnCallbackHandle RegisterActivate (void *cxt, ActivateCB CB)
XnCallbackHandle RegisterDeactivate (void *cxt, DeactivateCB CB)
void UnregisterUpdate (XnCallbackHandle hCB)
void UnregisterActivate (XnCallbackHandle hCB)
void UnregisterDeactivate (XnCallbackHandle hCB)
void SetThreadProtectionQueueMode (XnBool bMode)
XnBool GetThreadProtectecionQueueMode () const
virtual void ClearQueue ()

Protected Member Functions

XnBool IsInActivityThread () const
void MainLoop ()

Static Protected Member Functions

static XN_THREAD_PROC MessageListenerThread (XN_THREAD_PARAM param)

Protected Attributes

XN_THREAD_ID m_hActivityThreadId
XN_THREAD_HANDLE m_hActivityThread
XnBool m_bInternalThreadAlive
XnBool m_bInternalThreadKill
XnBool m_bThreadProtectionQueueMode
XnVMessageQueue * m_pMessageQueue
XnVMessageSpecificEvent * m_pUpdateCBs
XnVEvent * m_pActivateCBs
XnVEvent * m_pDeactivateCBs
XnChar * m_strListenerName

Static Protected Attributes

static const XnUInt32 ms_nSessionDefaultLength

Detailed Description

A XnVMessageListener is a general listener, that received Messages and handles them. It supports Multi-Threaded work, by knowing the thread it works in, and putting Messages in a Queue when accessed from other threads.

Definition at line 24 of file XnVMessageListener.h.

Member Typedef Documentation

typedef void(XN_CALLBACK_TYPE* XnVMessageListener::ActivateCB)(void *cxt)

Type for callbacks on activation

Definition at line 34 of file XnVMessageListener.h.

typedef void(XN_CALLBACK_TYPE* XnVMessageListener::DeactivateCB)(void *cxt)

Type for callbacks on deactivation

Definition at line 38 of file XnVMessageListener.h.

typedef void(XN_CALLBACK_TYPE* XnVMessageListener::MessageUpdateCB)(XnVMessage *pMessage, void *cxt)

Type for callbacks after a Message is handled

Definition at line 30 of file XnVMessageListener.h.

Constructor & Destructor Documentation

XnVMessageListener::XnVMessageListener ( const XnChar *  strName = "XnVMessageListener")

Constructor. Create a new Message Listener

[in]strNameName of the control, for log purposes.
virtual XnVMessageListener::~XnVMessageListener ( ) [virtual]

Member Function Documentation

virtual void XnVMessageListener::Activate ( XnBool  bActive) [inline, virtual]

This method is called (by the default HandleCCMessages) when an Activation Message is received.

[in]bActiveTRUE if this listener is now active, FALSE if it is now inactive

Definition at line 76 of file XnVMessageListener.h.

void XnVMessageListener::BaseUpdate ( XnVMessage pMessage)

This method handles multi-thread support, calling Update only when run from the proper thread and copying the Message to a Queue when not.

[in]pMessageThe Message that should be handled
virtual void XnVMessageListener::ClearQueue ( ) [virtual]

Clear the Multi-thread queue

Reimplemented in XnVContextFilter, XnVFilter, XnVFlowRouter, XnVPointFilter, and XnVSessionManager.

const XnChar* XnVMessageListener::GetListenerName ( ) const

Get the listener's name. Mostly for Log use.

The current Listener's name
XnBool XnVMessageListener::GetThreadProtectecionQueueMode ( ) const

Get the current multi-thread mode

TRUE if queues are used, FALSE if Update will be called from anywhere
virtual void XnVMessageListener::HandleCCMessages ( XnVMessage pMessage) [virtual]

Handle Control Messages. By default, it calls Activate for Activation Messages. Can be reimplemented to handle additional Message types. Is called from BaseUpdate, before Update.

[in]pMessageThe message to handle
XnBool XnVMessageListener::IsInActivityThread ( ) const [protected]
void XnVMessageListener::MainLoop ( ) [protected]
static XN_THREAD_PROC XnVMessageListener::MessageListenerThread ( XN_THREAD_PARAM  param) [static, protected]
XnCallbackHandle XnVMessageListener::RegisterActivate ( void *  cxt,
ActivateCB  CB 

Register for the activation event

[in]cxtUser's context
[in]CBThe Callback to call when the event is invoked.
A handle, to allow unregistration.
XnCallbackHandle XnVMessageListener::RegisterDeactivate ( void *  cxt,
DeactivateCB  CB 

Register for the deactivation event

[in]cxtUser's context
[in]CBThe Callback to call when the event is invoked.
A handle, to allow unregistration.
XnCallbackHandle XnVMessageListener::RegisterUpdate ( void *  cxt,
MessageUpdateCB  CB 

Register a callback to be called after the Message is handled

[in]cxtUser's context
[in]CBThe Callback to call when the event is invoked.
A handle, to allow unregistration.
void XnVMessageListener::Run ( XnUInt32  nSessionMaxLength = ms_nSessionDefaultLength)

Supply the Message Listener with run-time from its thread. Read from the Queue, and BaseUpdate.

[in]nSessionMaxLengthMaximum number of Messages to be handled in a single Run
XnStatus XnVMessageListener::RunAsThread ( )

Open a thread, and run the Listener in it.

XN_STATUS_OK if OK, other on error
void XnVMessageListener::SetCurrentThread ( )

Change the working thread to the one from which it is called

void XnVMessageListener::SetThreadId ( XN_THREAD_ID  hThread)

Change the working thread, in which actual work is done

[in]hThreadThe ID of the relevant thread
void XnVMessageListener::SetThreadProtectionQueueMode ( XnBool  bMode)

Change the multi-thread mode.

[in]bModeThe new mode
void XnVMessageListener::UnregisterActivate ( XnCallbackHandle  hCB)

Unregister from the activation event

[in]hCBThe handle provided on registration.
void XnVMessageListener::UnregisterDeactivate ( XnCallbackHandle  hCB)

Unregister from the deactivation event

[in]hCBThe handle provided on registration.
void XnVMessageListener::UnregisterUpdate ( XnCallbackHandle  hCB)

Unregister from the Message Update

[in]hCBThe handle provided on registration.
virtual void XnVMessageListener::Update ( XnVMessage pMessage) [pure virtual]

This method will be implemented by descendants, handling the Message

[in]pMessageThe Message that was received

Implemented in XnVBroadcaster, XnVDepthControl, XnVContextControl, XnVFlowRouter, XnVMessageMux, XnVPointArea, XnVPointControl, XnVPointDenoiser, XnVPointFilter, XnVSessionManager, and XnVVirtualCoordinates.

Member Data Documentation

Definition at line 181 of file XnVMessageListener.h.

Definition at line 182 of file XnVMessageListener.h.

Definition at line 184 of file XnVMessageListener.h.

XN_THREAD_HANDLE XnVMessageListener::m_hActivityThread [protected]

Definition at line 180 of file XnVMessageListener.h.

XN_THREAD_ID XnVMessageListener::m_hActivityThreadId [protected]

Definition at line 178 of file XnVMessageListener.h.

XN_CRITICAL_SECTION_HANDLE XnVMessageListener::m_hListenerCS [protected]

Definition at line 196 of file XnVMessageListener.h.

XnVEvent* XnVMessageListener::m_pActivateCBs [protected]

Definition at line 191 of file XnVMessageListener.h.

XnVEvent* XnVMessageListener::m_pDeactivateCBs [protected]

Definition at line 192 of file XnVMessageListener.h.

XnVMessageQueue* XnVMessageListener::m_pMessageQueue [protected]

Definition at line 188 of file XnVMessageListener.h.

XnVMessageSpecificEvent* XnVMessageListener::m_pUpdateCBs [protected]

Definition at line 190 of file XnVMessageListener.h.

Definition at line 194 of file XnVMessageListener.h.

const XnUInt32 XnVMessageListener::ms_nSessionDefaultLength [static, protected]

Definition at line 186 of file XnVMessageListener.h.

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