FountainMessage Class Reference
[Message Building and Parsing]

Base class for building all messages exchanged between Fountain nodes, server, and clients. More...

#include <FountainMessage.h>

Inheritance diagram for FountainMessage:

BambooLib::BuildMsg ClientRequest< T > NodeMessage ServerMessage NodeRequest NodeResponse ServerRequest ServerResponse List of all members.

Public Types

enum  MessageAction
 enumeration that specifies the action attribute of a FountainMessage object More...

Public Member Functions

virtual ~FountainMessage ()=0
 Pure virtual destructor so FountainMessage objects cannot be instantiated directly.
void buildStandardError (bool status=true, FountainErrorCode code=generalSuccess, const char *msg=NULL)
 This method adds Status, Code, and Message elements to a FountainMessage using the given parameters.
void buildStandardError (bool status, FountainErrorCode code, const std::string &msg)
 Same as the c-string equivalent method above.
void buildStandardSuccess (const std::string &msg=std::string())
 Same as caling buildStandardError(true).
BambooLib::XMLElementgetDataElement () const
 Get the pointer to the Data element of the message.

Static Public Member Functions

static const char * fountain_convert (FountainMessage::MessageAction m)
 Convert a MessageAction into a c-string.
static bool fountain_convert (const char *s, FountainMessage::MessageAction &a)
 Convert a c-string into a MessageAction enum.

Protected Member Functions

 FountainMessage (Loki::Int2Type< BambooLib::requestElement >, MessageAction a)
 Constructor for building request FountainMessage objects.
 FountainMessage (Loki::Int2Type< BambooLib::responseElement >, MessageAction a)
 Constructor for building response FountainMessage objects.

Protected Attributes

MessageAction action_

Private Member Functions

void create (BambooLib::SSS_Element_type type)
 Create a FountainMessage object.
 FountainMessage (const FountainMessage &rhs)
 Private copy constructor so FountainMessage objects cannot be sliced.
const FountainMessageoperator= (const FountainMessage &rhs)
 Private assignment operator so FountainMessage objects cannot be sliced.

Detailed Description

Base class for building all messages exchanged between Fountain nodes, server, and clients.

This class inherits publicly from the Bamboo library's BuildMsg class. It adds additional functionality in the form of Source and Destination elements, explicit Request or Response message types, and explicity action attributes. These additions are in place to prevent malformed messages from being sent between Fountain components.

The constructor for this class uses a traits class so its only defined for two values of the BambooLib::SSS_Element_type enum, the requestElement and responseElement values. I did this since it does not make sense for any future child or grandchild class of FountainMessage to use different base element type. In the context of Fountain and its associated components, each message is either a request or a response. I used this design since I tend to prefer compile time errors instead of runtime errors in the event a future child class tries to use a different base element type. Instead of using the overloaded constructor with a traits class, I could have used the SSS_Element_type as a normal constructor parameter and performed a typical runtime check on its value. The options in this case are rather liberal, return an error code, throw an exception, allow a zombie object, or some other drastic measure that could promote program instability. In summary, I felt using the traits class combined with an overloaded constructor presents the easiest possible interface to this class.


Constructor & Destructor Documentation

FountainMessage::FountainMessage Loki::Int2Type< BambooLib::requestElement >  ,
MessageAction  a
[inline, protected]
 

Constructor for building request FountainMessage objects.

Parameters:
[in] a The MessageAction enum for this message
Exceptions:
FountainException If building the message was not possible

FountainMessage::FountainMessage Loki::Int2Type< BambooLib::responseElement >  ,
MessageAction  a
[inline, protected]
 

Constructor for building response FountainMessage objects.

Parameters:
[in] a The MessageAction enum for this message
Exceptions:
FountainException If building the message was not possible


Member Function Documentation

void FountainMessage::buildStandardError bool  status = true,
FountainErrorCode  code = generalSuccess,
const char *  msg = NULL
 

This method adds Status, Code, and Message elements to a FountainMessage using the given parameters.

Parameters:
[in] status true or false f the request was processed with or without errors
[in] code an integer error code specifying what caused the error
[in] msg a string specifying the optional Message element of the Status element

void FountainMessage::create BambooLib::SSS_Element_type  type  )  [private]
 

Create a FountainMessage object.

Parameters:
[in] type The SSS_Element_type
Precondition:
type is either requestElement or responseElement
This method performs the following actions:
  1. create the Master element according to the type parameter
  2. create the action attribute according to our action member
  3. create the Data element

bool FountainMessage::fountain_convert const char *  s,
FountainMessage::MessageAction a
[static]
 

Convert a c-string into a MessageAction enum.

Precondition:
Assigned(s), Assigned(t)
Parameters:
[in] s The string to convert
[out] a The MessageAction enum converted from the string
Return values:
bool true if the conversion was successful, false otherwise

const char * FountainMessage::fountain_convert FountainMessage::MessageAction  m  )  [static]
 

Convert a MessageAction into a c-string.

Return values:
char* A c-string containing the MessageAction

BambooLib::XMLElement* FountainMessage::getDataElement  )  const [inline]
 

Get the pointer to the Data element of the message.

Return values:
BambooLib::XMLElement* A pointer to the Data element of the message


Member Data Documentation

MessageAction FountainMessage::action_ [protected]
 

The action of this message, defined by one of the MessageAction enumerated types


The documentation for this class was generated from the following files:
Generated on Wed Mar 8 14:43:32 2006 for Fountain by  doxygen 1.4.6