|
AndroMeta
2.0.0
|
Message handler that responds to messages received from a message buffer. More...
#include <MMessageHandler.h>
Public Types | |
| enum | Action { ReleaseContinue, SaveContinue, SaveStop, ReleaseStop } |
Public Member Functions | |
| MMessageHandler () | |
| virtual | ~MMessageHandler () |
| void | addBuffer (MMessageBuffer *buf) |
| void | removeBuffer (MMessageBuffer *buf, bool all=true) |
| void | clearBuffers () |
| void | setStartIndex (const mvar &index) |
| void | setEndIndex (const mvar &index) |
| const mvar & | startIndex () const |
| const mvar & | endIndex () const |
| bool | await (MMessageBuffer *buf) |
| bool | await (MMessageBuffer *buf, const mtime &timeout) |
| void | interrupt () |
| void | setAllowInterrupt (bool flag) |
| bool | allowInterrupt () |
| void | handleMessages () |
| virtual Action | handleMessage (const MMessage *msg)=0 |
Friends | |
| class | MMessageHandler_ |
Message handler that responds to messages received from a message buffer.
Message handlers process messages queued for them at a message buffer. This class provides a way to specify the the means by which a handler responds to a message. Of course the actions a message handler takes given a message is application specific, but as far as the buffer is concerned, the message is either released or saved for later presentation to the handler. Message handlers may block, optionally with a timeout, until a message arrives at the designated buffer. If it is allowed by the handler, the handler may be interrupted from awaiting a message, however the default behavior is not to allow interruptions. MMessageHandler is fully thread-safe.
Actions returned by handleMessage().
Constructor.
| virtual Meta::MMessageHandler::~MMessageHandler | ( | ) | [virtual] |
Destructor.
| void Meta::MMessageHandler::addBuffer | ( | MMessageBuffer * | buf | ) |
Subscribe to a message buffer.
Get whether to allow interrupts.
| bool Meta::MMessageHandler::await | ( | MMessageBuffer * | buf | ) |
Wait for a message to be delivered to message buffer for this handler's response. Note: handleMessages() must then be called.
| bool Meta::MMessageHandler::await | ( | MMessageBuffer * | buf, |
| const mtime & | timeout | ||
| ) |
Block with timeout until a message is delivered to the designated message buffer. Note: handleMessages() must then be called to respond to the newly received message(s).
| void Meta::MMessageHandler::clearBuffers | ( | ) |
Unsubscribe from all buffers.
| const mvar& Meta::MMessageHandler::endIndex | ( | ) | const |
Get the ending index of messages presented to the handler in handleMessages().
| virtual Action Meta::MMessageHandler::handleMessage | ( | const MMessage * | msg | ) | [pure virtual] |
Reimplement to provide application-specific responses to a messages.
Begin handling messages if any. Messages are successively presented to the handler by calling handleMessage().
| void Meta::MMessageHandler::interrupt | ( | ) |
Interrupt this handler. A no-op if interrupts are not allowed.
| void Meta::MMessageHandler::removeBuffer | ( | MMessageBuffer * | buf, |
| bool | all = true |
||
| ) |
Unsubscribe from a message buffer. A count keep tracks of the number of times the buffer was added, if 'all' is true the buffer is removed regardless of the number of times it was added, else the count is decremented and removed when 0 is reached.
| void Meta::MMessageHandler::setAllowInterrupt | ( | bool | flag | ) |
Set whether to allow interrupts.
| void Meta::MMessageHandler::setEndIndex | ( | const mvar & | index | ) |
Set the ending index of messages presented to the handler in handleMessages().
| void Meta::MMessageHandler::setStartIndex | ( | const mvar & | index | ) |
Set the starting index of messages presented to the handler in handleMessages().
| const mvar& Meta::MMessageHandler::startIndex | ( | ) | const |
Get the starting index of messages presented to the handler in handleMessages().
1.7.6.1