NITE 1.4.1 - API Reference
|
#include <XnVMessageListener.h>
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 | |
XN_DECLARE_THREAD_SAFE_QUEUE_DECL (XNV_NITE_API, XnVMessage *, XnVMessageQueue) | |
XN_DECLARE_EVENT_1ARG (XnVMessageSpecificEvent, XnVMessageEvent, XnVMessage *, pMessage) | |
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_MessageQueue |
XnVMessageSpecificEvent | m_UpdateCBs |
XnVEvent | m_ActivateCBs |
XnVEvent | m_DeactivateCBs |
XnChar * | m_strListenerName |
XN_CRITICAL_SECTION_HANDLE | m_hListenerCS |
Static Protected Attributes | |
static const XnUInt32 | ms_nSessionDefaultLength |
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 21 of file XnVMessageListener.h.
typedef void(XN_CALLBACK_TYPE* XnVMessageListener::ActivateCB)(void *cxt) |
Type for callbacks on activation
Definition at line 31 of file XnVMessageListener.h.
typedef void(XN_CALLBACK_TYPE* XnVMessageListener::DeactivateCB)(void *cxt) |
Type for callbacks on deactivation
Definition at line 35 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 27 of file XnVMessageListener.h.
XnVMessageListener::XnVMessageListener | ( | const XnChar * | strName = "XnVMessageListener" | ) |
Constructor. Create a new Message Listener
[in] | strName | Name of the control, for log purposes. |
virtual XnVMessageListener::~XnVMessageListener | ( | ) | [virtual] |
virtual void XnVMessageListener::Activate | ( | XnBool | bActive | ) | [inline, virtual] |
This method is called (by the default HandleCCMessages) when an Activation Message is received.
[in] | bActive | TRUE if this listener is now active, FALSE if it is now inactive |
Definition at line 73 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] | pMessage | The 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.
XnBool XnVMessageListener::GetThreadProtectecionQueueMode | ( | ) | const |
Get the current multi-thread mode
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] | pMessage | The 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] | cxt | User's context |
[in] | CB | The Callback to call when the event is invoked. |
XnCallbackHandle XnVMessageListener::RegisterDeactivate | ( | void * | cxt, |
DeactivateCB | CB | ||
) |
Register for the deactivation event
[in] | cxt | User's context |
[in] | CB | The Callback to call when the event is invoked. |
XnCallbackHandle XnVMessageListener::RegisterUpdate | ( | void * | cxt, |
MessageUpdateCB | CB | ||
) |
Register a callback to be called after the Message is handled
[in] | cxt | User's context |
[in] | CB | The Callback to call when the event is invoked. |
void XnVMessageListener::Run | ( | XnUInt32 | nSessionMaxLength = ms_nSessionDefaultLength | ) |
Supply the Message Listener with run-time from its thread. Read from the Queue, and BaseUpdate.
[in] | nSessionMaxLength | Maximum number of Messages to be handled in a single Run |
XnStatus XnVMessageListener::RunAsThread | ( | ) |
Open a thread, and run the Listener in it.
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] | hThread | The ID of the relevant thread |
void XnVMessageListener::SetThreadProtectionQueueMode | ( | XnBool | bMode | ) |
Change the multi-thread mode.
[in] | bMode | The new mode |
void XnVMessageListener::UnregisterActivate | ( | XnCallbackHandle | hCB | ) |
Unregister from the activation event
[in] | hCB | The handle provided on registration. |
void XnVMessageListener::UnregisterDeactivate | ( | XnCallbackHandle | hCB | ) |
Unregister from the deactivation event
[in] | hCB | The handle provided on registration. |
void XnVMessageListener::UnregisterUpdate | ( | XnCallbackHandle | hCB | ) |
Unregister from the Message Update
[in] | hCB | The handle provided on registration. |
virtual void XnVMessageListener::Update | ( | XnVMessage * | pMessage | ) | [pure virtual] |
This method will be implemented by descendants, handling the Message
[in] | pMessage | The Message that was received |
Implemented in XnVBroadcaster, XnVDepthControl, XnVContextControl, XnVFlowRouter, XnVMessageMux, XnVPointArea, XnVPointControl, XnVPointDenoiser, XnVPointFilter, XnVSessionManager, and XnVVirtualCoordinates.
XnVMessageListener::XN_DECLARE_EVENT_1ARG | ( | XnVMessageSpecificEvent | , |
XnVMessageEvent | , | ||
XnVMessage * | , | ||
pMessage | |||
) | [protected] |
XnVMessageListener::XN_DECLARE_THREAD_SAFE_QUEUE_DECL | ( | XNV_NITE_API | , |
XnVMessage * | , | ||
XnVMessageQueue | |||
) | [protected] |
XnVEvent XnVMessageListener::m_ActivateCBs [protected] |
Definition at line 190 of file XnVMessageListener.h.
XnBool XnVMessageListener::m_bInternalThreadAlive [protected] |
Definition at line 180 of file XnVMessageListener.h.
XnBool XnVMessageListener::m_bInternalThreadKill [protected] |
Definition at line 181 of file XnVMessageListener.h.
XnBool XnVMessageListener::m_bThreadProtectionQueueMode [protected] |
Definition at line 183 of file XnVMessageListener.h.
XnVEvent XnVMessageListener::m_DeactivateCBs [protected] |
Definition at line 191 of file XnVMessageListener.h.
XN_THREAD_HANDLE XnVMessageListener::m_hActivityThread [protected] |
Definition at line 179 of file XnVMessageListener.h.
XN_THREAD_ID XnVMessageListener::m_hActivityThreadId [protected] |
Definition at line 177 of file XnVMessageListener.h.
XN_CRITICAL_SECTION_HANDLE XnVMessageListener::m_hListenerCS [protected] |
Definition at line 195 of file XnVMessageListener.h.
XnVMessageQueue XnVMessageListener::m_MessageQueue [protected] |
Definition at line 187 of file XnVMessageListener.h.
XnChar* XnVMessageListener::m_strListenerName [protected] |
Definition at line 193 of file XnVMessageListener.h.
XnVMessageSpecificEvent XnVMessageListener::m_UpdateCBs [protected] |
Definition at line 189 of file XnVMessageListener.h.
const XnUInt32 XnVMessageListener::ms_nSessionDefaultLength [static, protected] |
Definition at line 185 of file XnVMessageListener.h.