gusimplewhiteboard
guWhiteboard::Whiteboard Class Reference

compatibility API for accessing the whiteboard More...

#include <Whiteboard.h>

Inheritance diagram for guWhiteboard::Whiteboard:
Collaboration diagram for guWhiteboard::Whiteboard:

Classes

struct  callback_descr
 

Public Types

enum  wb_method_result { METHOD_OK , METHOD_FAIL }
 Return Type Enum. More...
 
typedef enum guWhiteboard::Whiteboard::wb_method_result WBResult
 Return Type Enum. More...
 

Public Member Functions

 Whiteboard (const char *sharedMemoryObjectName=gsw_global_whiteboard_name, bool checkVersion=true, int number=0)
 API Constructor This sets up the API and the callback soap server. More...
 
virtual ~Whiteboard ()
 Destructor. More...
 
void addMessage (gsw_hash_info *hashinfo, const WBMsg &msg, bool nonatomic=false, bool notifySubscribers=true)
 Add Message Adds a message to the whiteboard that the API is connected to. More...
 
WBMsg getMessage (gsw_hash_info *hashinfo, WBResult *result=NULLPTR)
 Get Message Gets a message from a simple whiteboard. More...
 
void subscriptionCallback (void)
 subscription callback: not really public! More...
 
virtual void subscribeToMessage (gsw_hash_info *hashinfo, WBFunctorBase *func, WBResult &result)
 Subscribe To Message Subscribes to a message type on a whiteboard or whiteboards. More...
 
void unsubscribeToMessage (gsw_hash_info *hashinfo, WBResult &result)
 Unsubscribe To Message (sic!) Unsubscribes from a message type on a whiteboard or whiteboards. More...
 
gsw_hash_infogetTypeOffset (std::string type)
 create a hash offset from message type, needed for adding, getting from WB More...
 
void addMessage (const std::string &type, const WBMsg &msg, bool nonatomic=false, bool notifySubscribers=true)
 Add Message Adds a message to the whiteboard that the API is connected to. More...
 
WBMsg getMessage (std::string type, WBResult *result=NULLPTR)
 Get Message Gets a message from a simple whiteboard. More...
 
virtual void subscribeToMessage (const std::string &type, WBFunctorBase *func, WBResult &result)
 Subscribe To Message Subscribes to a message type on a whiteboard or whiteboards. More...
 
void unsubscribeToMessage (std::string type, WBResult &result)
 Unsubscribe To Message (sic!) Unsubscribes from a message type on a whiteboard or whiteboards. More...
 

Static Public Member Functions

static WBMsg getWBMsg (gu_simple_message *m)
 convert the new 'simple' whiteboard data structure into the old WBMsg format More...
 

Public Attributes

gu_simple_whiteboard_descriptor_wbd
 underlying whiteboard
More...
 

Detailed Description

compatibility API for accessing the whiteboard

Definition at line 115 of file Whiteboard.h.

Member Typedef Documentation

◆ WBResult

Return Type Enum.

Allows the user to test if an error has occured

Member Enumeration Documentation

◆ wb_method_result

Return Type Enum.

Allows the user to test if an error has occured

Enumerator
METHOD_OK 

No errors detected.

METHOD_FAIL 

Errors detected.

Definition at line 166 of file Whiteboard.h.

Constructor & Destructor Documentation

◆ Whiteboard()

Whiteboard::Whiteboard ( const char *  sharedMemoryObjectName = gsw_global_whiteboard_name,
bool  checkVersion = true,
int  number = 0 
)

API Constructor This sets up the API and the callback soap server.

Parameters
[in]sharedMemoryObjectName(optional) Allows the user to specify a local shared-memory whiteboard to use.
[in]checkVersionindicate whether to check wb version (default: true)
[in]numberwhiteboard number (0 = local, 1..4 = reserved for robots)

Definition at line 91 of file Whiteboard.cc.

References _wbd, gsw_whiteboard_s::callback, gsw_whiteboard_s::context, DISPATCH_QUEUE_SERIAL, gsw_global_whiteboard_name, gsw_new_numbered_whiteboard(), and init_ios_whiteboard_name.

Referenced by guWhiteboard::RemoteWhiteboard::RemoteWhiteboard().

◆ ~Whiteboard()

Whiteboard::~Whiteboard ( )
virtual

Destructor.

shuts down the whiteboard

Definition at line 119 of file Whiteboard.cc.

References _wbd, gsw_whiteboard_s::callback, and gsw_free_whiteboard().

Member Function Documentation

◆ addMessage() [1/2]

void Whiteboard::addMessage ( const std::string &  type,
const WBMsg msg,
bool  nonatomic = false,
bool  notifySubscribers = true 
)

Add Message Adds a message to the whiteboard that the API is connected to.

Parameters
[in]typeThe string type associated with the message object
[in]msgThe message object to post to the whiteboard
[in]nonatomicAdd quickly without grabbing the semaphore
[in]notifySubscribersSignal subscribers (default: true)

Definition at line 328 of file Whiteboard.cc.

References addMessage().

◆ addMessage() [2/2]

void Whiteboard::addMessage ( gsw_hash_info hashinfo,
const WBMsg msg,
bool  nonatomic = false,
bool  notifySubscribers = true 
)

◆ getMessage() [1/2]

WBMsg Whiteboard::getMessage ( gsw_hash_info hashinfo,
WBResult result = NULLPTR 
)

Get Message Gets a message from a simple whiteboard.

Parameters
[in]hashinfoContains the offset index to access a message
[out]resultA pointer (!) to WBResult to indicate whether a message existed or not
Returns
The message object

Definition at line 194 of file Whiteboard.cc.

References _wbd, getWBMsg(), gsw_current_message(), gsw_simple_message::len, METHOD_FAIL, METHOD_OK, guWhiteboard::gsw_hash_info::msg_offset, gsw_simple_message::type, gsw_whiteboard_s::wb, and gsw_simple_message::wbmsg.

Referenced by getMessage().

◆ getMessage() [2/2]

WBMsg Whiteboard::getMessage ( std::string  type,
WBResult result = NULLPTR 
)

Get Message Gets a message from a simple whiteboard.

Parameters
[in]typeThe string type associated with the message object
[out]resultA pointer (!) to WBResult to indicate whether a message existed or not
Returns
The message object

Definition at line 334 of file Whiteboard.cc.

References getMessage().

◆ getTypeOffset()

gsw_hash_info * Whiteboard::getTypeOffset ( std::string  type)

create a hash offset from message type, needed for adding, getting from WB

Parameters
[in]typeThe string type get the offset for
Returns
return a wrapped version of the message index

Definition at line 210 of file Whiteboard.cc.

◆ getWBMsg()

static WBMsg guWhiteboard::Whiteboard::getWBMsg ( gu_simple_message m)
inlinestatic

◆ subscribeToMessage() [1/2]

void Whiteboard::subscribeToMessage ( const std::string &  type,
WBFunctorBase func,
WBResult result 
)
virtual

Subscribe To Message Subscribes to a message type on a whiteboard or whiteboards.

Parameters
[in]typeThe string type to subscribe to
[in]funcThe function to call when a message of the type enter is added
[out]resultAn enum showing that either an error occured or the operation was completed successfully

Reimplemented in guWhiteboard::RemoteWhiteboard.

Definition at line 340 of file Whiteboard.cc.

References subscribeToMessage().

◆ subscribeToMessage() [2/2]

void Whiteboard::subscribeToMessage ( gsw_hash_info hashinfo,
WBFunctorBase func,
WBResult result 
)
virtual

Subscribe To Message Subscribes to a message type on a whiteboard or whiteboards.

Parameters
[in]hashinfoThe string type to subscribe to
[in]funcThe function to call when a message of the type enter is added
[out]resultAn enum showing that either an error occured or the operation was completed successfully

Definition at line 227 of file Whiteboard.cc.

References _wbd, GLOBAL_MSG_ID, gsw_add_process(), gsw_add_wbd_signal_handler(), gsw_procure(), GSW_SEM_CALLBACK, gsw_vacate(), gsw_simple_whiteboard_s::indexes, METHOD_OK, guWhiteboard::gsw_hash_info::msg_offset, gsw_simple_whiteboard_s::num_types, gsw_whiteboard_s::sem, and gsw_whiteboard_s::wb.

Referenced by guWhiteboard::RemoteWhiteboard::subscribeToMessage(), and subscribeToMessage().

◆ subscriptionCallback()

◆ unsubscribeToMessage() [1/2]

void Whiteboard::unsubscribeToMessage ( gsw_hash_info hashinfo,
WBResult result 
)

Unsubscribe To Message (sic!) Unsubscribes from a message type on a whiteboard or whiteboards.

Parameters
[in]hashinfoThe string type to unsubscribe from
[out]resultAn enum showing that either an error occured or the operation was completed successfully

Definition at line 305 of file Whiteboard.cc.

References _wbd, GLOBAL_MSG_ID, gsw_procure(), gsw_remove_process(), GSW_SEM_CALLBACK, gsw_vacate(), METHOD_FAIL, METHOD_OK, guWhiteboard::gsw_hash_info::msg_offset, gsw_whiteboard_s::sem, and guWhiteboard::Whiteboard::callback_descr::type.

Referenced by unsubscribeToMessage().

◆ unsubscribeToMessage() [2/2]

void Whiteboard::unsubscribeToMessage ( std::string  type,
WBResult result 
)

Unsubscribe To Message (sic!) Unsubscribes from a message type on a whiteboard or whiteboards.

Parameters
[in]typeThe string type to unsubscribe from
[out]resultAn enum showing that either an error occured or the operation was completed successfully

Definition at line 346 of file Whiteboard.cc.

References unsubscribeToMessage().

Member Data Documentation

◆ _wbd


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