gusimplewhiteboard
|
This class provides a subscription implementation for the 'simple' whiteboard, aka the 'typed' whiteboard. More...
#include <guwhiteboardwatcher.h>
Public Member Functions | |
whiteboard_watcher (gu_simple_whiteboard_descriptor *wbd=NULLPTR) | |
Constructor, sets up the dispatch queues for handling callbacks. More... | |
~whiteboard_watcher () | |
Destructor, release whiteboard objects and dispatch queues. More... | |
void | subscribe (WBFunctorBase *func) |
Allows you to subscribe to a specific whiteboard type and get callbacks when that type is updated. More... | |
void | unsubscribe (guWhiteboard ::wb_types t) |
Stop getting callbacks for a particular whiteboard type. More... | |
void | receive_callback () |
Internal function, this is what gets triggered by the underlying whiteboard, it then checks its list of subscribed types and issues callback functions to subscribed modules. More... | |
This class provides a subscription implementation for the 'simple' whiteboard, aka the 'typed' whiteboard.
This class allows you to 'subscribe' to changes on the Whiteboard. Specifically call you can call the subscribe method, with the desired 'type' and a callback pointer. This class will monitor any subscribed 'types' and call the callback functions when the data related to those 'types' is updated. To be clear, callbacks will be issued if the data is updated on the Whiteboard, even if it is the same data. The act of the data being posted to the Whiteboard is what triggers callbacks. This is designed for event-triggered systems and different data fetching methods should be used for time-triggered systems.
wb = new whiteboard_watcher(); //create the watcher object //wb = whiteboard_watcher //Say = the WB type to subscribe to //GUNaoSpeech = the class the callback belongs to //GUNaoSpeech::whiteboard_callback = the callback function SUBSCRIBE(wb, Say, GUNaoSpeech, GUNaoSpeech::whiteboard_callback);
wb = new whiteboard_watcher(); //create the watcher object ((wb)->subscribe(Say_WBFunctor<GUNaoSpeech>::bind(this, &GUNaoSpeech::whiteboard_callback, kSay_v)));
Definition at line 104 of file guwhiteboardwatcher.h.
|
inline |
Constructor, sets up the dispatch queues for handling callbacks.
wbd | You can pass a specific pointer to a whiteboard object if you wish. By default a pointer to the default whiteboard is used. |
Definition at line 117 of file guwhiteboardwatcher.h.
References gsw_whiteboard_s::callback, gsw_whiteboard_s::context, DISPATCH_QUEUE_NAME_WB, DISPATCH_QUEUE_SERIAL, and get_local_singleton_whiteboard().
|
inline |
Destructor, release whiteboard objects and dispatch queues.
Definition at line 144 of file guwhiteboardwatcher.h.
References gsw_whiteboard_s::callback, gsw_whiteboard_s::exit_monitor, and gsw_free_whiteboard().
|
inline |
Internal function, this is what gets triggered by the underlying whiteboard, it then checks its list of subscribed types and issues callback functions to subscribed modules.
Definition at line 219 of file guwhiteboardwatcher.h.
References gsw_simple_whiteboard_s::event_counters, WBFunctorBase::get_event_count(), gsw_procure(), GSW_SEM_CALLBACK, GSW_TOTAL_MESSAGE_TYPES, gsw_simple_whiteboard_s::indexes, kwb_reserved_SubscribeToAllTypes_v, gsw_whiteboard_s::sem, WBFunctorBase::type(), and gsw_whiteboard_s::wb.
|
inline |
Allows you to subscribe to a specific whiteboard type and get callbacks when that type is updated.
You will still get a callback if the type is updated and the data didn't change.
func | the callback container object. I suggest using the macro SUBSCRIBE (see example at the top of this file) |
Definition at line 166 of file guwhiteboardwatcher.h.
References gsw_simple_whiteboard_s::event_counters, gsw_add_process(), gsw_add_wbd_signal_handler(), gsw_procure(), GSW_SEM_CALLBACK, GSW_TOTAL_MESSAGE_TYPES, gsw_vacate(), WBFunctorBase::is_simple_wb_version(), kwb_reserved_SubscribeToAllTypes_v, gsw_whiteboard_s::sem, WBFunctorBase::set_event_count(), WBFunctorBase::type(), and gsw_whiteboard_s::wb.
Referenced by WBSubscriber::WBSubscriber().
|
inline |
Stop getting callbacks for a particular whiteboard type.
t | the type to unsubscribe from |
Definition at line 197 of file guwhiteboardwatcher.h.
References gsw_procure(), gsw_remove_process(), GSW_SEM_CALLBACK, gsw_vacate(), gsw_whiteboard_s::sem, WBFunctorBase::type(), and WBTYPES_NS.
Referenced by WBSubscriber::~WBSubscriber().