Neo  0.5.0
Developer Documentation
Neo::Messenger Class Reference

The Messenger class is the host of all inboxes for all threads. More...

#include <Messenger.h>

Public Member Functions

 Messenger ()
 
void addInbox (const char *name, unsigned int id)
 Creates a new inbox with the given name for the current thread. More...
 
unsigned int getMessagesCount (const char *name)
 Retrieves the current number of messages in the inbox with the given name. More...
 
void sendMessage (const char *message, unsigned int messageId, void *data, const char *dest, const char *from)
 Sends a message to a thread. More...
 
Message getNextMessage (const char *threadName)
 Returns the next message in the message queue. More...
 
Message getNextMessage (const char *threadName, const char *sender)
 Returns the next message from the given sender in the message queue. More...
 

Static Public Member Functions

static MessengergetInstance ()
 

Detailed Description

The Messenger class is the host of all inboxes for all threads.

You can create a new inbox for your thread and request messages from it. This class also handles sending messages to other threads as well.

Constructor & Destructor Documentation

Neo::Messenger::Messenger ( )
inline

Member Function Documentation

void Neo::Messenger::addInbox ( const char *  name,
unsigned int  id 
)

Creates a new inbox with the given name for the current thread.

Parameters
nameThe thread name.
idThe thread ID.
static Messenger* Neo::Messenger::getInstance ( )
inlinestatic
unsigned int Neo::Messenger::getMessagesCount ( const char *  name)

Retrieves the current number of messages in the inbox with the given name.

Parameters
nameThe thread name.
Returns
The count of unhandled messages.
Message Neo::Messenger::getNextMessage ( const char *  threadName)

Returns the next message in the message queue.

Parameters
threadNameThe thread name to retrieve the message for.
Returns
The next message.
Message Neo::Messenger::getNextMessage ( const char *  threadName,
const char *  sender 
)

Returns the next message from the given sender in the message queue.

Parameters
threadNameThe thread name to retrieve the message for.
senderThe sender to retrieve the message from.
Returns
The next message.
void Neo::Messenger::sendMessage ( const char *  message,
unsigned int  messageId,
void *  data,
const char *  dest,
const char *  from 
)

Sends a message to a thread.

Adds the new message to the inbox of the receiving thread.

Parameters
messageA string containing the message.
messageIdThe messageId (can be used to send simple signals)
dataA pointer to some sort of data.
destThe name of the receiver.
fromThe ID of the sender.

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