AndroMeta  2.0.0
Public Types | Public Member Functions | Friends
Meta::MMessageHandler Class Reference

Message handler that responds to messages received from a message buffer. More...

#include <MMessageHandler.h>

List of all members.

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 mvarstartIndex () const
const mvarendIndex () 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_

Detailed Description

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.


Member Enumeration Documentation

Actions returned by handleMessage().


Constructor & Destructor Documentation

Constructor.

Destructor.


Member Function Documentation

Subscribe to a message buffer.

Get whether to allow interrupts.

Wait for a message to be delivered to message buffer for this handler's response. Note: handleMessages() must then be called.

Returns:
true on success, fails if interrupted.
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).

Returns:
true on success, fails if interrupted or timed out.

Unsubscribe from all buffers.

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.

Returns:
An action: ReleaseContinue, SaveContinue, SaveStop, or ReleaseStop. Releasing a message will instruct the buffer not present this message again, while saving it, saves it for a subsequent call to handleMessages(). Stop halts the presentation of messages in this handleMessages() session.

Begin handling messages if any. Messages are successively presented to the handler by calling handleMessage().

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.

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().

Get the starting index of messages presented to the handler in handleMessages().


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