YAMI4 - C++ general-purpose interface
yami::incoming_message Class Reference

Incoming message. More...

#include <incoming_message.h>

List of all members.

Public Member Functions

 incoming_message (incoming_message &other)
 Moving constructor.
const std::string & get_source () const
 Returns the source of this incoming message.
const std::string & get_object_name () const
 Returns the destination object name.
const std::string & get_message_name () const
 Returns the message name.
const parametersget_parameters () const
 Provides access to the message content.
parametersextract_parameters ()
 Extracts the message content.
const std::vector< char > & get_raw_content () const
 Provides access to the raw buffer of message content.
void reply (const serializable &body=parameters(), std::size_t priority=0)
 Sends back the reply.
void reject (const std::string &reason=std::string(), std::size_t priority=0)
 Sends back the rejection (exception) notification.

Detailed Description

The handler allowing to inspect the details of the incoming message and sent back replies or rejection notifications.

The user code interacts with objects of this type mainly in the functors that are provided during object registration and that are later called back when the incoming message arrives. The handler objects can be stored aside for further processing even after the callback returns, but should not be kept alive longer than the agent itself.

Note: The objects of this class are not supposed to be used from multiple threads.


Constructor & Destructor Documentation

incoming_message::incoming_message ( incoming_message other)

This class was designed to be non-copyable, but allows "destructive copy" similar to that of std::auto_ptr. This functionality is enough for the user to store aside the handler for further processing, but the original object is no longer valid and all attempts to use it will result in the exception.


Member Function Documentation

const std::string & incoming_message::get_source ( ) const
Returns:
The name of the originating endpoint from where this incoming message has been sent.
parameters * incoming_message::extract_parameters ( )

The message content is moved to the caller and the caller becomes the owner of the parameters object. This object itself is no longer holding any references to the content and therefore any future attempts to access it will result in the exception.

const std::vector< char > & incoming_message::get_raw_content ( ) const

Note: this function can be called only if the messages are delivered in the form of raw (not already serialized) buffers.

void incoming_message::reply ( const serializable body = parameters(),
std::size_t  priority = 0 
)

Sends back the reply to the message identified by this object. The reply (or rejection) can be sent only once.

Parameters:
bodyThe content of the reply.
priorityThe priority of the reply.
void incoming_message::reject ( const std::string &  reason = std::string(),
std::size_t  priority = 0 
)

Sends back the rejection to the message identified by this object. The rejection (or reply) can be sent only once.

Parameters:
reasonArbitrary text that will be visible by the message sender as a reason for rejection.
priorityThe priority of the rejection.