S3FC project page S3FC home page

Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

s3_message Class Reference

An implementation of a Message. More...

#include <s3_message.h>

Inheritance diagram for s3_message:

Inheritance graph
[legend]
Collaboration diagram for s3_message:

Collaboration graph
[legend]
List of all members.

Public Types

typedef std::string msg_id_t
enum  msg_class_t { NORMAL, PRIORITY, CONTROL }
 Message class enumeration. More...


Public Methods

 s3_message ()
 Default contructor - instantiate an empty message. More...

 s3_message (const std::string &n_from, const std::string &n_to, const std::string &n_body, const msg_class_t &n_mc, const msg_id_t &n_id)
 Initialising contructor - instantiate a message with the supplied values. More...

 s3_message (const std::string &n_from, const s3_message &msg, const std::string &n_body, const msg_id_t &n_id)
 Instantiate and return a reply message with the supplied values. More...

virtual ~s3_message ()
 Destructor - deallocate all resources. More...

virtual void pack (s3_pack_buffer &b) const
 Pack contents into s3_pack_buffer. More...

virtual void unpack (const s3_pack_buffer &b)
 Unpack contents from s3_pack_buffer. More...

bool is_empty () const
 Test whether this is an empty message. More...

bool is_reply (const msg_id_t &n_id) const
 Test whether this message is a reply to a message with the supplied message ID. More...

std::string get_from () const
 Return the sender name. More...

std::string get_to () const
 Return the destination name. More...

std::string get_body () const
 Return the message body. More...

msg_class_t get_class () const
 Return the message class. More...

std::string get_debug_str () const

Public Attributes

 S3_DECLARE_MAGIC_STRING

Protected Attributes

bool empty
 true if this is an empty message. More...

std::string from
 The sender. More...

std::string to
 The destination. More...

std::string body
 Message content. More...

msg_class_t mc
 Message class. More...

msg_id_t id
 Message ID. More...

msg_id_t reply_id
 ID of message to which is being replied if this is a reply message. More...


Detailed Description

An implementation of a Message.

The from, to and body attributes are represented by string instances. The message class, class, is of a nested enumerated type: s3_message::msg_class_t. This instance is derived from s3_streamable and can therefore be packed and transported across a network.

See also:
Postal System

Definition at line 338 of file s3_message.h.


Member Typedef Documentation

typedef std::string s3_message::msg_id_t
 

Definition at line 341 of file s3_message.h.

Referenced by s3_message_box::reply_msg, and s3_message_box::send_msg.


Member Enumeration Documentation

enum s3_message::msg_class_t
 

Message class enumeration.

Enumeration values:
NORMAL  A normal message.
PRIORITY  A high priority message.
CONTROL  An error message from the post office.

Definition at line 345 of file s3_message.h.

Referenced by get_class.


Constructor & Destructor Documentation

s3_message::s3_message  
 

Default contructor - instantiate an empty message.

Postcondition:
is_empty() == true

Definition at line 42 of file s3_message.cc.

s3_message::s3_message const std::string &    n_from,
const std::string &    n_to,
const std::string &    n_body,
const msg_class_t   n_mc,
const msg_id_t   n_id
 

Initialising contructor - instantiate a message with the supplied values.

Parameters:
n_from  Sender.
n_to  Destination.
n_body  Message body.
n_mc  Message class.
n_id  Message ID.
n_reply_id  Reply ID.
Postcondition:
is_empty() == false
get_from() == n_from
get_to() == n_to
get_body() == n_body
get_class() == n_mc

Definition at line 54 of file s3_message.cc.

s3_message::s3_message const std::string &    n_from,
const s3_message &    msg,
const std::string &    n_body,
const msg_id_t   n_id
 

Instantiate and return a reply message with the supplied values.

This is equivalent to: s3_message(n_from, msg.from, n_body, msg.mc, n_id, msg.reply_id)

Parameters:
n_from  Sender.
msg  Message that is replied to. This is used to obtain the reciepient (the originator of msg), the message class and the reply ID (the ID of msg).
n_from  Sender
n_body  Message body
n_id  Message ID
Postcondition:
is_empty() == false
get_from() == n_from
get_to() == msg.get_from()
get_body() == n_body
get_class() == msg.get_class()
is_reply(msg.id) == true

Definition at line 70 of file s3_message.cc.

s3_message::~s3_message   [virtual]
 

Destructor - deallocate all resources.

Definition at line 85 of file s3_message.cc.


Member Function Documentation

std::string s3_message::get_body   const
 

Return the message body.

Returns:
msg

Definition at line 138 of file s3_message.cc.

References body.

Referenced by s3_post_office::add_dst_switch, s3_rpc_server::handle_message, s3_msgb_log_rx_thread::main_loop, s3_post_office::remove_dst_switch, and s3_rpc_server::reply_client.

s3_message::msg_class_t s3_message::get_class   const
 

Return the message class.

Returns:
mc

Definition at line 144 of file s3_message.cc.

References mc, and msg_class_t.

Referenced by s3_message_box::deliver_msg.

std::string s3_message::get_debug_str   const
 

Definition at line 150 of file s3_message.cc.

References body, CONTROL, from, id, is_empty, NORMAL, PRIORITY, reply_id, and to.

Referenced by s3_post_office::add_dst_switch, s3_post_office_switch::forward_msg, and s3_post_office::remove_dst_switch.

std::string s3_message::get_from   const
 

Return the sender name.

Returns:
from

Definition at line 126 of file s3_message.cc.

References from.

Referenced by s3_rpc_server::reply_client.

std::string s3_message::get_to   const
 

Return the destination name.

Returns:
to

Definition at line 132 of file s3_message.cc.

References to.

bool s3_message::is_empty   const
 

Test whether this is an empty message.

Return values:
c  true Empty message.
c  false Not an empty message.

Definition at line 114 of file s3_message.cc.

References empty.

Referenced by get_debug_str, s3_rpc_server::handle_message, and s3_msgb_log_rx_thread::main_loop.

bool s3_message::is_reply const msg_id_t   n_id const
 

Test whether this message is a reply to a message with the supplied message ID.

Parameters:
id  Message id.
Return values:
c  true Message is a reply to message with id id
c  false Message is not a reply to message with id id

Definition at line 120 of file s3_message.cc.

References reply_id.

void s3_message::pack s3_pack_buffer   b const [virtual]
 

Pack contents into s3_pack_buffer.

Parameters:
b  Buffer to pack into.

Implements s3_streamable.

Definition at line 90 of file s3_message.cc.

References body, empty, from, id, mc, s3_streamable::pack, reply_id, and to.

void s3_message::unpack const s3_pack_buffer   b [virtual]
 

Unpack contents from s3_pack_buffer.

Parameters:
b  Buffer to unpack from.

Implements s3_streamable.

Definition at line 102 of file s3_message.cc.

References body, empty, from, id, mc, reply_id, to, and s3_streamable::unpack.


Member Data Documentation

std::string s3_message::body [protected]
 

Message content.

Definition at line 376 of file s3_message.h.

Referenced by get_body, get_debug_str, pack, and unpack.

bool s3_message::empty [protected]
 

true if this is an empty message.

Definition at line 364 of file s3_message.h.

Referenced by is_empty, pack, and unpack.

std::string s3_message::from [protected]
 

The sender.

Definition at line 368 of file s3_message.h.

Referenced by get_debug_str, get_from, pack, and unpack.

msg_id_t s3_message::id [protected]
 

Message ID.

Definition at line 384 of file s3_message.h.

Referenced by get_debug_str, pack, and unpack.

msg_class_t s3_message::mc [protected]
 

Message class.

Definition at line 380 of file s3_message.h.

Referenced by get_class, pack, and unpack.

msg_id_t s3_message::reply_id [protected]
 

ID of message to which is being replied if this is a reply message.

Definition at line 388 of file s3_message.h.

Referenced by get_debug_str, is_reply, pack, and unpack.

s3_message::S3_DECLARE_MAGIC_STRING
 

Definition at line 390 of file s3_message.h.

std::string s3_message::to [protected]
 

The destination.

Definition at line 372 of file s3_message.h.

Referenced by get_debug_str, get_to, pack, and unpack.


The documentation for this class was generated from the following files:
Send comments to: s3fc@stonethree.com SourceForge Logo