Message Class Reference

#include <message.h>

Collaboration diagram for Message:

Collaboration graph
[legend]
List of all members.

Detailed Description

Reference-counted message objects.

All Player messages are transferred between drivers as pointers to Message objects. These objects are reference-counted so that messages can be delivered to multiple recipients with minimal memory overhead.

Messages are not usually manipulated directly in driver code. The details of allocating, filling, parsing, and deleting Message objects are handled by the Driver and MessageQueue classes.

The only method of interest to driver authors is the helper MatchMessage(), which can be used in a Driver::ProcessMessage method to determine if a message header matches a given signature.

Definition at line 120 of file message.h.


Public Member Functions

 Message (const struct player_msghdr &Header, void *data, bool copy=true)
 Create a new message.
 Message (const struct player_msghdr &Header, void *data, QueuePointer &_queue, bool copy=true)
 Create a new message with an associated queue.
 Message (const Message &rhs)
 Copy pointers from existing message and increment refcount.
 ~Message ()
 Destroy message, dec ref counts and delete data if ref count == 0.
player_msghdr_tGetHeader ()
 Get pointer to header.
void * GetPayload ()
 Get pointer to payload.
unsigned int GetDataSize ()
 Size of message data.
bool Compare (Message &other)
 Compare type, subtype, device, and device_index.
void DecRef ()
 Decrement ref count.

Static Public Member Functions

static bool MatchMessage (player_msghdr_t *hdr, int type, int subtype, player_devaddr_t addr)
 Helper for message processing.
static bool MatchMessage (player_msghdr_t *hdr, int type, int subtype)
 Helper for message processing.

Public Attributes

QueuePointer Queue
 queue to which any response to this message should be directed
unsigned int * RefCount
 Reference count.

Private Member Functions

void CreateMessage (const struct player_msghdr &Header, void *data, bool copy=true)

Private Attributes

player_msghdr_t Header
 message header
uint8_t * Data
 Pointer to the message data.
pthread_mutex_t * Lock
 Used to lock access to Data.

Constructor & Destructor Documentation

Message::Message ( const struct player_msghdr Header,
void *  data,
bool  copy = true 
)

Create a new message.

If copy is set to false then the pointer is claimed by the message, otherwise it is copied.

Message::Message ( const struct player_msghdr Header,
void *  data,
QueuePointer _queue,
bool  copy = true 
)

Create a new message with an associated queue.

If copy is set to false then the pointer is claimed by the message, otherwise it is copied.


Member Function Documentation

static bool Message::MatchMessage ( player_msghdr_t hdr,
int  type,
int  subtype,
player_devaddr_t  addr 
) [inline, static]

static bool Message::MatchMessage ( player_msghdr_t hdr,
int  type,
int  subtype 
) [inline, static]

Helper for message processing.

This version matches for any message destination (i.e. all a drivers reigstered interfaces) Returns true if hdr matches the supplied type, subtype. Set type and/or subtype to -1 for don't care.

Definition at line 165 of file message.h.

References player_msghdr::subtype, and player_msghdr::type.


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

Last updated 12 September 2005 21:38:45