58#define FROM_WHITEBOARD_CC_
65#pragma clang diagnostic push
66#pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
68#ifndef DISPATCH_QUEUE_SERIAL
69#define DISPATCH_QUEUE_SERIAL NULLPTR
75extern const char *wbname_prefixed_with_path(
const char *wbname);
77#define init_ios_whiteboard_name();
91Whiteboard::Whiteboard(
const char *name,
bool ,
int number)
97 else name = wbname_prefixed_with_path(name);
99 if (!(callback_group = dispatch_group_create()))
101 cerr <<
"Unable to create dispatch group " << number <<
": '" << name <<
"'" << endl;
102 throw "Whiteboard cannot create callback queue";
106 cerr <<
"Unable to create dispatch queue " << number <<
": '" << name <<
"'" << endl;
107 throw "Whiteboard cannot create dispatch queue";
111 cerr <<
"Unable to create whiteboard " << number <<
": '" << name <<
"'" << endl;
112 throw "Cannot create whiteboard";
122 dispatch_group_wait(callback_group, DISPATCH_TIME_FOREVER);
125 dispatch_release(callback_queue);
126 dispatch_release(callback_group);
135 if (nonatomic < 0 || nonatomic > 1)
136 cerr <<
" *** Nonatomic parameter " << nonatomic <<
" not bool (are you using a life span?) ***" << endl;
176 m->
wbmsg.
len =
static_cast<unsigned char>(k);
183 m->
wbmsg.
len =
static_cast<unsigned char>(len);
212 return new gsw_hash_info(getTypeOffset_private(type.c_str()));
215int Whiteboard::getTypeOffset_private(std::string type)
225#pragma mark - subscription and callbacks
232 int offs = -1, current = -1;
257static void do_callback(
void *m)
271 for (vector<callback_descr>::iterator i = _sub.begin(); i != _sub.end(); i++)
274 int offs = descr.
type;
280 if (offs == -1)
for (offs = 0; offs < wb->
num_types; offs++)
282 curr = cball_indexes[offs];
283 while (curr != wb->
indexes[offs])
287 cball_indexes[offs] =
static_cast<uint8_t
>(curr);
289 dispatch_group_async_f(callback_group, callback_queue, h, do_callback);
292 else while (curr != wb->
indexes[offs])
298 dispatch_group_async_f(callback_group, callback_queue, h, do_callback);
310 for (vector<callback_descr>::iterator i = _sub.begin(); i != _sub.end(); i++)
313 int offs = descr.
type;
326#pragma mark - functions NOT using hash container
331 addMessage(&tmp, msg, nonatomic, notifySubscribers);
352#pragma clang diagnostic pop
#define DISPATCH_QUEUE_SERIAL
const char * gsw_global_whiteboard_name
global whiteboard name
#define init_ios_whiteboard_name()
Base class for WBFunctor.
virtual void call(std::string s, WBMsg *m)=0
Call method for the OLD whiteboard callbacks that used WBMsg - Deprecated.
Old WB class for storing shared data.
const std::string & getStringValue() const
getStringValue.
int getIntValue() const
getIntValue.
const std::vector< int > & getArrayValue() const
getArrayValue.
float getFloatValue() const
getFloatValue.
WBType getType() const
getType.
const void * getBinaryValue() const
getBinaryValue.
int getSizeInBytes() const
getSizeInBytes.
bool getBoolValue() const
getBoolValue.
compatibility API for accessing the whiteboard
WBMsg getMessage(gsw_hash_info *hashinfo, WBResult *result=NULLPTR)
Get Message Gets a message from a simple whiteboard.
void unsubscribeToMessage(gsw_hash_info *hashinfo, WBResult &result)
Unsubscribe To Message (sic!) Unsubscribes from a message type on a whiteboard or whiteboards.
gu_simple_whiteboard_descriptor * _wbd
underlying whiteboard
virtual void subscribeToMessage(gsw_hash_info *hashinfo, WBFunctorBase *func, WBResult &result)
Subscribe To Message Subscribes to a message type on a whiteboard or whiteboards.
static WBMsg getWBMsg(gu_simple_message *m)
convert the new 'simple' whiteboard data structure into the old WBMsg format
gsw_hash_info * getTypeOffset(std::string type)
create a hash offset from message type, needed for adding, getting from WB
@ METHOD_OK
No errors detected.
@ METHOD_FAIL
Errors detected.
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.
enum guWhiteboard::Whiteboard::wb_method_result WBResult
Return Type Enum.
void subscriptionCallback(void)
subscription callback: not really public!
virtual ~Whiteboard()
Destructor.
gu_simple_message * gsw_next_message(gu_simple_whiteboard *wb, int i)
get the next shared memory location for the given whiteboard message type i
void gsw_add_wbd_signal_handler(gu_simple_whiteboard_descriptor *wbd)
add subscription signal handler
void gsw_free_whiteboard(gu_simple_whiteboard_descriptor *wbd)
free the given whiteboard descriptor
void gsw_increment(gu_simple_whiteboard *wb, int i)
get the next shared memory location for the given whiteboard message type i
void gsw_increment_event_counter(gu_simple_whiteboard *wb, int i)
add to a messages event counter on the wb
gu_simple_message * gsw_current_message(gu_simple_whiteboard *wb, int i)
get the current shared memory location for the given whiteboard message type i
int gsw_procure(gsw_sema_t sem, enum gsw_semaphores s)
grab a whiteboard semaphore
int gsw_offset_for_message_type(gu_simple_whiteboard_descriptor *wbd, const char *name)
get the numerical index of a whiteboard message type
gu_simple_whiteboard_descriptor * gsw_new_numbered_whiteboard(const char *name, int n)
access a named whiteboard: this is the designated standard wb constructor for C programs that want to...
void gsw_remove_process(gu_simple_whiteboard_descriptor *wbd, const pid_t proc)
remove process for subscription signalling
int gsw_vacate(gsw_sema_t sem, enum gsw_semaphores s)
release a whiteboard semaphore
void gsw_add_process(gu_simple_whiteboard_descriptor *wbd, const pid_t proc)
add process for subscription signalling
void gsw_signal_subscribers(gu_simple_whiteboard *wb)
signal all subscribing processes
#define GU_SIMPLE_WHITEBOARD_GENERATIONS
lifespan (max)
const char ** WBTypes_stringValues
allow whiteboard to use old functions for whiteboard initialisation and choose which messages and con...
#define GSW_NUM_TYPES_DEFINED
allow whiteboard to use old functions for whiteboard initialisation and choose which messages and con...
@ GSW_SEM_CALLBACK
semaphore for callback data
@ GSW_SEM_PUTMSG
semaphore for adding to the whiteboard
struct guWhiteboard::gsw_hash_info gsw_hash_info
Message offset holder.
An internal stuct for passing callback information to dispatch queues.
callback_helper(Whiteboard *s, gu_simple_whiteboard *w, int o, int c, const Whiteboard::callback_descr &d)
int offs
type offset in shared memory, aka type enum value
gu_simple_whiteboard * wb
wb pointer
Whiteboard::callback_descr descr
the actual whiteboard in shared mem
gu_simple_message typenames[512]
message types for numbers
uint8_t indexes[512]
ring buffer indexes
uint16_t num_types
total number of current, registered types
gu_simple_message messages[512][4]
the actual messages stored in the whiteboard
uint16_t subscribed
subscribed processes
the underlying whiteboard object
gsw_subscription_f callback
subscription callback function
void * context
callback context
gsw_sema_t sem
semaphore to use
gu_simple_whiteboard * wb
the actual whiteboard in shared mem
WBFunctorBase * func
functor to call
int current
last message index
int msg_offset
the index value to store
union type that is used to store data in shared memory
char string[128]
string type
struct gsw_simple_message::@3 hash
whiteboard hash type
int ivec[128/sizeof(int)]
int array
struct gsw_simple_message::@4 wbmsg
compatibility WBMsg type