Savarese Software Research Corporation
Message Class Reference

Message is a reusable and resizable data buffer for sending and receiving messages. More...

#include <Message.h>

Inheritance diagram for Message:
Inheritance graph
[legend]

Public Types

enum   { DefaultCapacity = 4096 }
 
enum   Service {
  Unreliable = UNRELIABLE_MESS, Reliable = RELIABLE_MESS, FIFO = FIFO_MESS, Causal = CAUSAL_MESS,
  Agreed = AGREED_MESS, Safe = SAFE_MESS, SelfDiscard = SELF_DISCARD, DropReceive = DROP_RECV,
  UnreliableSelfDiscard = Unreliable | SelfDiscard, ReliableSelfDiscard = Reliable | SelfDiscard, FIFOSelfDiscard = FIFO | SelfDiscard, CausalSelfDiscard = Causal | SelfDiscard,
  AgreedSelfDiscard = Agreed | SelfDiscard, SafeSelfDiscard = Safe | SelfDiscard
}
  Service is not a proper enumeration, but rather a specification of constants corresponding to the Spread service type flags. More...
 
typedef Spread::int16  message_type
  Defines the type for 16-bit message type identifiers. More...
 
typedef Spread::service  service_type
  Defines the type for specifying service types. More...
 

Public Member Functions

  Message (const unsigned int capacity=DefaultCapacity)
  Creates a Message with the specified initial capacity (or DefaultCapacity if no parameter is provided). More...
 
virtual unsigned int  size () const
  Returns the number of bytes in the message. More...
 
virtual void  clear ()
  Clears the message for reuse, resetting its size to zero. More...
 
void  set_service (const service_type service)
  Sets the service type of the message. More...
 
service_type  service () const
  Returns the service type requested (for sends) or sent under (for receives) of the message. More...
 
void  set_type (const message_type type)
  Sets the message type identifier. More...
 
message_type  type () const
  Returns the type of the message. More...
 
void  set_sender (const string &sender)
  Sets the message sender. More...
 
const string &  sender () const
  Returns the message sender. More...
 
void  set_endian_mismatch (const bool mismatch=true)
  Sets the endian mismatch flag to the specified value. More...
 
bool  endian_mismatch () const
  Returns true if there is an endian mismatch between sender and receiver, false otherwise. More...
 
void  set_agreed ()
  Sets the service type to BaseMessage::Agreed. More...
 
bool  is_agreed () const
  Returns true if service type is BaseMessage::Agreed, false otherwise. More...
 
void  set_causal ()
  Sets the service type to BaseMessage::Causal. More...
 
bool  is_causal () const
  Returns true if service type is BaseMessage::Causal, false otherwise. More...
 
void  set_fifo ()
  Sets the service type to BaseMessage::FIFO. More...
 
bool  is_fifo () const
  Returns true if service type is BaseMessage::FIFO, false otherwise. More...
 
void  set_reliable ()
  Sets the service type to BaseMessage::Reliable. More...
 
bool  is_reliable () const
  Returns true if service type is BaseMessage::Reliable, false otherwise. More...
 
void  set_unreliable ()
  Sets the service type to BaseMessage::Unreliable. More...
 
bool  is_unreliable () const
  Returns true if service type is BaseMessage::Unreliable, false otherwise. More...
 
void  set_safe ()
  Sets the service type to BaseMessage::Safe. More...
 
bool  is_safe () const
  Returns true if service type is BaseMessage::Safe, false otherwise. More...
 
void  set_self_discard (const bool discard=true)
  Adds or removes the BaseMessage::SelfDiscard flag to or from the service type. More...
 
bool  is_self_discard () const
  Returns true if service type has the BaseMessage::SelfDiscard flag set, false otherwise. More...
 
bool  is_regular () const
  Returns true if this is a regular data (as opposed to membership) message, false otherwise. More...
 
bool  is_membership () const
  Returns true if this is a membership message, false otherwise. More...
 

Protected Attributes

message_type  _type
 
service_type  _service_type
 
bool  _endian_mismatch
 
string  _sender
 

Detailed Description

Message is a reusable and resizable data buffer for sending and receiving messages.

We do not document its protected members because they are intended only for internal library use. All of its useful public methods are inherited from BaseMessage and detail::ByteBuffer.

Please note that you can directly access the message data via indexing with detail::Buffer::operator[] or obtaining a pointer to the data via:

&message[0]

Therefore, you will find you do not have to use detail::ByteBuffer::read unless you really have to make a copy of the data instead of using it directly. However, you should use detail::ByteBuffer::write to avoid overrunning the buffer.

Definition at line 47 of file Message.h.

Member Typedef Documentation

typedef Spread::int16 BaseMessage::message_type
inherited

Defines the type for 16-bit message type identifiers.

Definition at line 63 of file BaseMessage.h.

typedef Spread::service BaseMessage::service_type
inherited

Defines the type for specifying service types.

Definition at line 66 of file BaseMessage.h.

Member Enumeration Documentation

anonymous enum
Enumerator
DefaultCapacity 

The default capacity used to construct a Message.

Definition at line 80 of file Message.h.

enum BaseMessage::Service
inherited

Service is not a proper enumeration, but rather a specification of constants corresponding to the Spread service type flags.

We do not document the meaning of these flags here. See the Spread C API documentation to understand their meaning. We will note, however, that DropReceive is not a service type, but rather a flag instructing the Spread receive functions to truncate messages and group lists if the buffers are too small. There should be no need to use this constant in the API as it is handled by Mailbox::set_drop_receive.

Enumerator
Unreliable 
Reliable 
FIFO 
Causal 
Agreed 
Safe 
SelfDiscard 
DropReceive 
UnreliableSelfDiscard 
ReliableSelfDiscard 
FIFOSelfDiscard 
CausalSelfDiscard 
AgreedSelfDiscard 
SafeSelfDiscard 

Definition at line 81 of file BaseMessage.h.

Constructor & Destructor Documentation

Message::Message ( const unsigned int  capacity = DefaultCapacity )
inlineexplicit

Creates a Message with the specified initial capacity (or DefaultCapacity if no parameter is provided).

See BaseMessage() for the default values of various properties, including service type.

Parameters
capacity The initial capacity of the message.

Definition at line 93 of file Message.h.

Member Function Documentation

virtual void Message::clear ( )
inlinevirtual

Clears the message for reuse, resetting its size to zero.

Implements BaseMessage.

Definition at line 100 of file Message.h.

References __END_NS_SSRC_SPREAD.

bool BaseMessage::endian_mismatch ( ) const
inlineinherited

Returns true if there is an endian mismatch between sender and receiver, false otherwise.

This only has meaning for received messages.

Returns
true if there is an endian mismatch between sender and receiver, false otherwise.

Definition at line 227 of file BaseMessage.h.

References BaseMessage::_endian_mismatch.

bool BaseMessage::is_agreed ( ) const
inlineinherited

Returns true if service type is BaseMessage::Agreed, false otherwise.

Returns
true if service type is BaseMessage::Agreed, false otherwise.

Definition at line 240 of file BaseMessage.h.

References BaseMessage::service().

bool BaseMessage::is_causal ( ) const
inlineinherited

Returns true if service type is BaseMessage::Causal, false otherwise.

Returns
true if service type is BaseMessage::Causal, false otherwise.

Definition at line 253 of file BaseMessage.h.

References BaseMessage::service().

bool BaseMessage::is_fifo ( ) const
inlineinherited

Returns true if service type is BaseMessage::FIFO, false otherwise.

Returns
true if service type is BaseMessage::FIFO, false otherwise.

Definition at line 266 of file BaseMessage.h.

References BaseMessage::service().

bool BaseMessage::is_membership ( ) const
inlineinherited

Returns true if this is a membership message, false otherwise.

Returns
true if this is a membership message, false otherwise.

Definition at line 345 of file BaseMessage.h.

References __END_NS_SSRC_SPREAD, and BaseMessage::service().

bool BaseMessage::is_regular ( ) const
inlineinherited

Returns true if this is a regular data (as opposed to membership) message, false otherwise.

Returns
true if this is a regular message, false otherwise.

Definition at line 337 of file BaseMessage.h.

References BaseMessage::service().

bool BaseMessage::is_reliable ( ) const
inlineinherited

Returns true if service type is BaseMessage::Reliable, false otherwise.

Returns
true if service type is BaseMessage::Reliable, false otherwise.

Definition at line 279 of file BaseMessage.h.

References BaseMessage::service().

bool BaseMessage::is_safe ( ) const
inlineinherited

Returns true if service type is BaseMessage::Safe, false otherwise.

Returns
true if service type is BaseMessage::Safe, false otherwise.

Definition at line 305 of file BaseMessage.h.

References BaseMessage::service().

bool BaseMessage::is_self_discard ( ) const
inlineinherited

Returns true if service type has the BaseMessage::SelfDiscard flag set, false otherwise.

Returns
true if service type has the BaseMessage::SelfDiscard flag set, false otherwise.

Definition at line 328 of file BaseMessage.h.

References BaseMessage::service().

bool BaseMessage::is_unreliable ( ) const
inlineinherited

Returns true if service type is BaseMessage::Unreliable, false otherwise.

Returns
true if service type is BaseMessage::Unreliable, false otherwise.

Definition at line 292 of file BaseMessage.h.

References BaseMessage::service().

const string& BaseMessage::sender ( ) const
inlineinherited

Returns the message sender.

This only has meaning for received messages.

Returns
The message sender.

Definition at line 209 of file BaseMessage.h.

References BaseMessage::_sender.

Referenced by BaseMessage::set_sender().

service_type BaseMessage::service ( ) const
inlineinherited

Returns the service type requested (for sends) or sent under (for receives) of the message.

Returns
The service type of the message.

Definition at line 177 of file BaseMessage.h.

References BaseMessage::_service_type.

Referenced by BaseMessage::is_agreed(), BaseMessage::is_causal(), BaseMessage::is_fifo(), BaseMessage::is_membership(), BaseMessage::is_regular(), BaseMessage::is_reliable(), BaseMessage::is_safe(), BaseMessage::is_self_discard(), BaseMessage::is_unreliable(), and BaseMessage::set_service().

void BaseMessage::set_agreed ( )
inlineinherited

Sets the service type to BaseMessage::Agreed.

Definition at line 232 of file BaseMessage.h.

References BaseMessage::Agreed, and BaseMessage::set_service().

void BaseMessage::set_causal ( )
inlineinherited

Sets the service type to BaseMessage::Causal.

Definition at line 245 of file BaseMessage.h.

References BaseMessage::Causal, and BaseMessage::set_service().

void BaseMessage::set_endian_mismatch ( const bool  mismatch = true )
inlineinherited

Sets the endian mismatch flag to the specified value.

Parameters
mismatch The mismatch value.

Definition at line 217 of file BaseMessage.h.

Referenced by if().

void BaseMessage::set_fifo ( )
inlineinherited

Sets the service type to BaseMessage::FIFO.

Definition at line 258 of file BaseMessage.h.

References BaseMessage::FIFO, and BaseMessage::set_service().

void BaseMessage::set_reliable ( )
inlineinherited

Sets the service type to BaseMessage::Reliable.

Definition at line 271 of file BaseMessage.h.

References BaseMessage::Reliable, and BaseMessage::set_service().

void BaseMessage::set_safe ( )
inlineinherited

Sets the service type to BaseMessage::Safe.

Definition at line 297 of file BaseMessage.h.

References BaseMessage::Safe, and BaseMessage::set_service().

void BaseMessage::set_self_discard ( const bool  discard = true )
inlineinherited

Adds or removes the BaseMessage::SelfDiscard flag to or from the service type.

Parameters
discard true to set the BaseMessage::SelfDiscard flag, false to remove it.

Definition at line 316 of file BaseMessage.h.

References BaseMessage::SelfDiscard.

void BaseMessage::set_sender ( const string &  sender )
inlineinherited

Sets the message sender.

Parameters
sender The message sender.

Definition at line 201 of file BaseMessage.h.

References BaseMessage::sender().

Referenced by if().

void BaseMessage::set_service ( const service_type  service )
inlineinherited

Sets the service type of the message.

Parameters
service The service type of the message.

Definition at line 167 of file BaseMessage.h.

References BaseMessage::service().

Referenced by if(), Mailbox::send(), BaseMessage::set_agreed(), BaseMessage::set_causal(), BaseMessage::set_fifo(), BaseMessage::set_reliable(), BaseMessage::set_safe(), and BaseMessage::set_unreliable().

void BaseMessage::set_type ( const message_type  type )
inlineinherited

Sets the message type identifier.

Parameters
type The new message type.

Definition at line 185 of file BaseMessage.h.

References BaseMessage::type().

Referenced by if(), and Mailbox::send().

void BaseMessage::set_unreliable ( )
inlineinherited

Sets the service type to BaseMessage::Unreliable.

Definition at line 284 of file BaseMessage.h.

References BaseMessage::set_service(), and BaseMessage::Unreliable.

virtual unsigned int Message::size ( ) const
inlinevirtual

Returns the number of bytes in the message.

Returns
The number of bytes in the message.

Implements BaseMessage.

Definition at line 96 of file Message.h.

Referenced by ScatterMessage::add(), and if().

message_type BaseMessage::type ( ) const
inlineinherited

Returns the type of the message.

Returns
The type of the message.

Definition at line 193 of file BaseMessage.h.

References BaseMessage::_type.

Referenced by BaseMessage::set_type().

Member Data Documentation

bool BaseMessage::_endian_mismatch
protectedinherited

Definition at line 115 of file BaseMessage.h.

Referenced by BaseMessage::endian_mismatch().

string BaseMessage::_sender
protectedinherited

Definition at line 116 of file BaseMessage.h.

Referenced by BaseMessage::sender().

service_type BaseMessage::_service_type
protectedinherited

Definition at line 114 of file BaseMessage.h.

Referenced by BaseMessage::service().

message_type BaseMessage::_type
protectedinherited

Definition at line 113 of file BaseMessage.h.

Referenced by BaseMessage::type().


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

Savarese Software Research Corporation
Copyright © 2006-2015 Savarese Software Research Corporation. All rights reserved.