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

IPC::Msg Class Reference

System V message queue. More...

#include <ipcplus.h>

List of all members.

Public Methods

 Msg ()
 Default constructor, creates a private IPC message queue.

 Msg (const unsigned int key, const bool createIfNotExist=true)
 Constructor, creates a non-private IPC message queue. More...

virtual ~Msg ()
 Destructor.

bool Snd ()
 Send the current message. More...

bool Snd (const void *data, const size_t size, const int mType=1)
 Simple send of a block of data. More...

bool Snd (const char *string, const int mType=1)
 Simple send of a C-type string. More...

bool Rcv (const int mType=0, const int mFlag=0)
 Receive any message. More...

bool RcvHigh ()
 Receive a priority message. More...

bool RcvType (const int mType)
 Receive a specific type of message. More...

virtual bool destroy ()
 Destroy the actual IPC queue. More...

unsigned int numMsg ()
 Return the number of messages in the queue. More...


Public Attributes

struct {
   long   mtype
   char   mdata [IPCPLUS_MAX_MESSAGE_SIZE]
msgbuf
 The current message.

unsigned int mSize
 The current message size.


Private Attributes

int qid
 The Sys V IPC message queue id.


Detailed Description

System V message queue.


Constructor & Destructor Documentation

IPC::Msg::Msg const unsigned int    key,
const bool    createIfNotExist = true
 

Constructor, creates a non-private IPC message queue.

Parameters:
key  This is the "name" of the queue. By using the same value, different processes can obtain access to the same message queue. Obviously, some method must be deployed to both insure that this key is unique in the system's shared queue space as well as known to those processes that wish to share a queue. See ftok() for one possible method to determine such a key value.
createIfNotExist  Should be pretty evident.


Member Function Documentation

bool IPC::Msg::destroy   [virtual]
 

Destroy the actual IPC queue.

Returns:
False if the destroy operation returned an error.

unsigned int IPC::Msg::numMsg  
 

Return the number of messages in the queue.

Returns:
The number of queued messages.

bool IPC::Msg::Rcv const int    mType = 0,
const int    mFlag = 0
 

Receive any message.

Blocks until a message is available.

Returns:
False if this didn't work.

bool IPC::Msg::RcvHigh   [inline]
 

Receive a priority message.

The messages in the queue may have different priorities. This method will return the message with a highest priority. Blocks until a message is available.

Parameters:
mType  Optionally a priority or message type may be specified. This must be a positive integer.
mFlag  See man msgrcv.
Returns:
False if this didn't work.

bool IPC::Msg::RcvType const int    mType [inline]
 

Receive a specific type of message.

The messages in the queue may be qualified to be of different types. This method will return only messages with the indicated message type code.

Parameters:
mType  Must be a positive integer.
Returns:
False if this didn't work.

bool IPC::Msg::Snd const char *    string,
const int    mType = 1
[inline]
 

Simple send of a C-type string.

Places a message in the queue with mSize==strlen(string) + 1 and mdata==string.

Parameters:
string  The zero terminated string to send.
mType  Optionally a priority or message type may be specified. This must be a positive integer.
Returns:
False if this didn't work.

bool IPC::Msg::Snd const void *    data,
const size_t    size,
const int    mType = 1
 

Simple send of a block of data.

Places a message in the queue with the passed data.

Parameters:
data  The bytes to send.
size  The number of bytes to send.
mType  Optionally a priority or message type may be specified. This must be a positive integer.
Returns:
False if this didn't work.

bool IPC::Msg::Snd  
 

Send the current message.

The caller is responsable for having set all the fields correctly.

Returns:
False if this didn't work.


The documentation for this class was generated from the following files:
Generated on Wed May 15 09:33:33 2002 for IPCPlus by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001