Message Class Reference

An object that contains messages or data to be passed. More...

#include <message.h>

Inheritance diagram for Message:

Inheritance graph
[legend]
Collaboration diagram for Message:

Collaboration graph
[legend]

List of all members.

Public Types

enum  MsgType { M_Data = 0, M_Command = 1, M_Request = 2, M_Response = 3 }
 The type of message being dealt with. More...
enum  CmdCode { C_None = 0, C_Exit, C_Disconnected }
 For command and status messages, the command/information being sent. More...
enum  ReqVal { R_None = 0, R_Status, R_History }
 For request messages, what value/data is being requested? More...

Public Member Functions

 Message (CmdCode)
 Used for Commands.
 Message (MsgType, ReqVal, u_char *, size_t)
 Used for Request/Response.
virtual ~Message ()
const MsgType type (void) const
const CmdCode code (void) const
const char * name (void) const
void Lock (void)
void Unlock (void)

Protected Member Functions

 Message (const u_char *, size_t)
 A special-purpse constructor only used by Data's constructors.
void alloc_data (const size_t size)
 Allocate empty space of the specified size.

Protected Attributes

unsigned char * privdata
 A block of data.
size_t length
 The length of privdata.

Private Member Functions

 Message (const Message &)
Messageoperator= (const Message &)

Private Attributes

MsgType msg_type
CmdCode cmd_code
ReqVal req_class
pthread_mutex_t mutex

Static Private Attributes

static const char *const MT_names []
 String names to be used for display purposes.


Detailed Description

An object that contains messages or data to be passed.

This class is meant to be allocated and referenced solely via Loki::SmartPtr so that the data does not have to be copied, and merely a reference-counted pointer to the data exists.

Definition at line 56 of file message.h.


Member Enumeration Documentation

The type of message being dealt with.

Enumerator:
M_Data  Just plain data.
M_Command  A command (and possible associated data).
M_Request  A request.
M_Response  A response (& associated data) to a request.

Definition at line 60 of file message.h.

For command and status messages, the command/information being sent.

Enumerator:
C_None 
C_Exit 
C_Disconnected 

Definition at line 68 of file message.h.

For request messages, what value/data is being requested?

Enumerator:
R_None 
R_Status 
R_History 

Definition at line 73 of file message.h.


Constructor & Destructor Documentation

Message::Message ( CmdCode  code  ) 

Used for Commands.

Construct a M_Command type of Message (effectively NULLing the Blob data).

Definition at line 64 of file message.cc.

References Guard::initialize_mutex(), and mutex.

Here is the call graph for this function:

Message::Message ( MsgType  type,
ReqVal  req,
u_char *  data = NULL,
size_t  len = 0 
)

Used for Request/Response.

Definition at line 71 of file message.cc.

References Guard::initialize_mutex(), and mutex.

Here is the call graph for this function:

Message::~Message ( void   )  [virtual]

Definition at line 78 of file message.cc.

Message::Message ( const u_char *  data,
size_t  len 
) [protected]

A special-purpse constructor only used by Data's constructors.

Construct a M_Data type of Message, given data and len as the chunk of data.

Definition at line 56 of file message.cc.

References Guard::initialize_mutex(), and mutex.

Here is the call graph for this function:

Message::Message ( const Message  )  [private]


Member Function Documentation

const MsgType Message::type ( void   )  const [inline]

Definition at line 81 of file message.h.

References msg_type.

const CmdCode Message::code ( void   )  const [inline]

Definition at line 82 of file message.h.

References cmd_code.

const char * Message::name ( void   )  const

Note:
This must be a const function, so that it can be called from const* pointers. It doesn't change the Message object any, so it's perfectly fine to have it declared const.

Definition at line 88 of file message.cc.

References msg_type, and MT_names.

Referenced by Messageable::handle_message().

Here is the caller graph for this function:

void Message::Lock ( void   ) 

Definition at line 121 of file message.cc.

References mutex, and PTHREAD_CHECK_AND_THROW.

void Message::Unlock ( void   ) 

Definition at line 131 of file message.cc.

References mutex, and PTHREAD_CHECK_AND_THROW.

void Message::alloc_data ( const size_t  size  )  [protected]

Allocate empty space of the specified size.

Definition at line 110 of file message.cc.

References length, and privdata.

Referenced by Data::Data().

Here is the caller graph for this function:

Message& Message::operator= ( const Message  )  [private]


Member Data Documentation

Definition at line 93 of file message.h.

Referenced by name(), and type().

Definition at line 94 of file message.h.

Referenced by code().

Definition at line 95 of file message.h.

unsigned char* Message::privdata [protected]

A block of data.

Definition at line 101 of file message.h.

Referenced by alloc_data(), Data::Data(), and Data::data().

size_t Message::length [protected]

The length of privdata.

Definition at line 102 of file message.h.

Referenced by alloc_data(), and Data::len().

pthread_mutex_t Message::mutex [private]

This mutex is locked by the Lock and Unlock methods that are called by Loki::Locker, which is used because we're using Loki::LockedStorage.

Definition at line 107 of file message.h.

Referenced by Lock(), Message(), and Unlock().

const char *const Message::MT_names [static, private]

Initial value:

 {
    "M_Data",
    "M_Command",
    "M_Request",
    "M_Response",
}
String names to be used for display purposes.

Definition at line 109 of file message.h.

Referenced by name().


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

Generated on Tue May 13 11:32:48 2008 for consmgr by  doxygen 1.5.5