Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

rwil::Message Class Reference

Generic Message class. Uses strings to represent parameters and values. Additionally keeps a timestamp. More...

#include <Message.h>

Inheritance diagram for rwil::Message::

rwil::EncapsulatingMessage rwil::SetRetriesMessage rwil::FailedAfterRetryingMessage List of all members.

Public Methods

 Message (std::string deviceName, std::string command)
 Initialize a message with device and command parameters the default timestamp of now. More...

 Message (std::string deviceName, std::string command, time_t when)
 Initialize a message with device and command parameters with a specified timestamp. More...

 Message (std::map< std::string, std::string > params)
 Initialize a message with a map of parameters and the default timestamp of now. More...

 Message (std::map< std::string, std::string > params, time_t when)
 Initialize a message with a map of parameters and a specified timestamp. More...

 Message (const Message &msg)
 Copy constructor. More...

const std::string & GetDevice () const
 Get the value of the "device" parameter. More...

const std::string & GetCommand () const
 Get the value of the "command" parameter. More...

bool operator< (const Message &rhs)
 Less than operator used to maintain order in the MessageList class. More...

void SetParam (std::string n, std::string param)
 Sets the value of a parameter. More...

std::string GetParam (std::string n) const
 Gets the value of a parameter. More...

time_t GetWhen () const
 Gets the timestamp associated with the message. More...

const std::map< std::string,
std::string > & 
GetMap () const
 Gets the internal data structure used to maintain state. More...


Private Attributes

std::map< std::string, std::string > m_parameters
 The parameters of the message. More...

const time_t m_when
 The message timestamp. More...


Detailed Description

Generic Message class. Uses strings to represent parameters and values. Additionally keeps a timestamp.

Definition at line 9 of file Message.h.


Constructor & Destructor Documentation

rwil::Message::Message std::string    deviceName,
std::string    command
 

Initialize a message with device and command parameters the default timestamp of now.

Parameters:
deviceName  Device to send message to
command  The command to send

Definition at line 7 of file Message.cpp.

References m_parameters.

00007                                                           : m_when(time(0))
00008   {
00009     m_parameters["device"] = deviceName;
00010     m_parameters["command"] = command;
00011   }

rwil::Message::Message std::string    deviceName,
std::string    command,
time_t    when
 

Initialize a message with device and command parameters with a specified timestamp.

Parameters:
deviceName  Device to send message to.
command  The command to send.
when  The timestamp to give the message.

Definition at line 13 of file Message.cpp.

References m_parameters.

00013                                                                        : m_when(when)
00014   {
00015     m_parameters["device"] = deviceName;
00016     m_parameters["command"] = command;
00017   }

rwil::Message::Message std::map< std::string, std::string >    params
 

Initialize a message with a map of parameters and the default timestamp of now.

Parameters:
params  A map with the various parameters for the message specified.

Definition at line 19 of file Message.cpp.

00019                                                      : m_parameters(params), m_when(time(0))
00020   {
00021   }

rwil::Message::Message std::map< std::string, std::string >    params,
time_t    when
 

Initialize a message with a map of parameters and a specified timestamp.

Parameters:
params  A map with the various parameters for the message specified.
when  The timestamp to give the message

Definition at line 23 of file Message.cpp.

00023                                                                   : m_parameters(params), m_when(when)
00024   {
00025   }

rwil::Message::Message const Message &    msg
 

Copy constructor.

Parameters:
msg  The message to copy.

Definition at line 27 of file Message.cpp.

00027 : m_parameters(msg.m_parameters), m_when(msg.m_when) {}


Member Function Documentation

const std::string & rwil::Message::GetCommand   const
 

Get the value of the "command" parameter.

Returns:
The value of the "command" parameter.

Definition at line 31 of file Message.cpp.

References m_parameters.

00031 { return m_parameters["command"]; }

const std::string & rwil::Message::GetDevice   const
 

Get the value of the "device" parameter.

Returns:
The value of the "device" parameter.

Definition at line 30 of file Message.cpp.

References m_parameters.

00030 { return m_parameters["device"]; }

const std::map< std::string, std::string > & rwil::Message::GetMap   const
 

Gets the internal data structure used to maintain state.

Returns:
A constant reference to the internal structure.

Definition at line 42 of file Message.cpp.

References m_parameters.

00042 { return m_parameters; }

std::string rwil::Message::GetParam std::string    n const
 

Gets the value of a parameter.

If the parameter is not defined then returns ""

Parameters:
n  The name of the parameter
Returns:
The value of that named parameter. Returns "" for non-existant parameters.

Definition at line 39 of file Message.cpp.

References m_parameters.

00039 { return m_parameters[n]; }

time_t rwil::Message::GetWhen   const
 

Gets the timestamp associated with the message.

Get the value of the timestamp

Returns:
The timestamp as a time_t value

Definition at line 41 of file Message.cpp.

References m_when.

00041 { return m_when; }

bool rwil::Message::operator< const Message &    rhs
 

Less than operator used to maintain order in the MessageList class.

Return true if the timestamp is less than that of rhs's

Parameters:
rhs  The variable on the right hand side of the operation.
Returns:
Whether or not the timestamp is less.

Definition at line 33 of file Message.cpp.

References m_when.

00034   {
00035     return this->m_when < rhs.m_when;
00036   }

void rwil::Message::SetParam std::string    n,
std::string    param
 

Sets the value of a parameter.

Parameters:
n  The name of the parameter
param  The new value of the parameter

Definition at line 38 of file Message.cpp.

References m_parameters.

Referenced by rwil::EncapsulatingMessage::EncapsulatingMessage(), and rwil::SetRetriesMessage::SetRetriesMessage().

00038 { m_parameters[n] = param; }


Member Data Documentation

std::map<std::string,std::string> rwil::Message::m_parameters [private]
 

The parameters of the message.

Definition at line 89 of file Message.h.

Referenced by GetCommand(), GetDevice(), GetMap(), GetParam(), Message(), and SetParam().

const time_t rwil::Message::m_when [private]
 

The message timestamp.

Definition at line 91 of file Message.h.

Referenced by GetWhen(), and operator<().


The documentation for this class was generated from the following files:
Generated on Tue Apr 9 13:53:08 2002 for RWIL - Real World Interface Library by doxygen1.2.12 written by Dimitri van Heesch, © 1997-2001