#include <utils/ipc/msg.h>
Public Member Functions | |
IPCMessageQueue (const char *path, char id, bool create=false, bool destroy_on_delete=false) | |
Create or open a message queue If a message key with the given identification criteria exists it is opened for sending and receiving. | |
IPCMessageQueue (int id, bool create=false, bool destroy_on_delete=false) | |
Create or open a message queue This is a simplified version of the above function. | |
~IPCMessageQueue () | |
Destructor. | |
bool | isValid () |
Check if the message queue is valid If the queue could not be opened yet (for example if you gave create=false to the constructor) isValid() will try to open the queue. | |
bool | recv (long mtype, MessageStruct *msg, unsigned int data_size) |
Receive messages from this queue of the given message type. | |
bool | recvNext (MessageStruct *msg, unsigned int max_data_size, int *data_size) |
Receive messages from this queue of any type. | |
bool | send (MessageStruct *msg, unsigned int data_size) |
Receive messages from this queue of the given message type. | |
Static Public Member Functions | |
static long | mtype (char *buffer) |
Get the message type. | |
Static Public Attributes | |
static const int | MaxMessageSize = 8192 |
Maximum size of a message. | |
Protected Attributes | |
bool | destroy_on_delete |
destroy this message queue on delete? | |
Classes | |
struct | MessageStruct |
This is the struct of the messages that has to be fed to send and receive methods. More... |
This class gives access to IPC message queues. You can use this to send messages between different applications running on the same host.
Definition at line 32 of file msg.h.
fawkes::IPCMessageQueue::IPCMessageQueue | ( | const char * | path, | |
char | id, | |||
bool | create = false , |
|||
bool | destroy_on_delete = false | |||
) |
Create or open a message queue If a message key with the given identification criteria exists it is opened for sending and receiving.
If no such queue exists a new one is create. Use isValid() to check success.
path | path given to ftok to create the message queue identifier | |
id | id given to ftok to create the message queue identifier | |
destroy_on_delete | destroy the message queue if the dtor is called? | |
create | Create the queue if it does not exist, do not create the queue otherwise, use isValid() to check if queue was opened |
fawkes::IPCMessageQueue::IPCMessageQueue | ( | int | id, | |
bool | create = false , |
|||
bool | destroy_on_delete = false | |||
) |
Create or open a message queue This is a simplified version of the above function.
The path is omitted and . (dot, the current working directory) is used instead.
id | id give to ftok to create the message queue identifier, preferably use an id from msg_registry.h | |
destroy_on_delete | set to true to destroy the message queue if the dtor is called | |
create | if true create the queue if it does not exist, do not create the queue otherwise, use isValid() to check if queue was opened successfully. |
fawkes::IPCMessageQueue::~IPCMessageQueue | ( | ) |
bool fawkes::IPCMessageQueue::isValid | ( | ) |
Check if the message queue is valid If the queue could not be opened yet (for example if you gave create=false to the constructor) isValid() will try to open the queue.
static long fawkes::IPCMessageQueue::mtype | ( | char * | buffer | ) | [inline, static] |
bool fawkes::IPCMessageQueue::recv | ( | long | mtype, | |
MessageStruct * | msg, | |||
unsigned int | data_size | |||
) |
Receive messages from this queue of the given message type.
mtype | the message type | |
msg | The place where the received data will be copied on success. You _must_ have the mtype long field as described for MessageStruct. On recv the struct does not have to be inialized, but the memory has to be allocated already. See the note about the data_size! | |
data_size | The size of the _whole_ struct, including the mtype field. NOT just the size of the mtext field as for msgrcv! |
MessageTooBigException | Message was too big and did not fit into buffer. Message remains on queue and needs to be fetched with a bigger buffer. |
bool fawkes::IPCMessageQueue::recvNext | ( | MessageStruct * | msg, | |
unsigned int | max_data_size, | |||
int * | data_size | |||
) |
Receive messages from this queue of any type.
msg | a pointer to a message struct of the appropriate size. This is most likely your own incarnation. It must point to a chunk of memory which has at least max_data_size bytes. | |
max_data_size | The maximum size the data may have. | |
data_size | after successfuly recv will contain the number of bytes actually copied into data including the size of the mtype field! |
bool fawkes::IPCMessageQueue::send | ( | MessageStruct * | msg, | |
unsigned int | data_size | |||
) |
Receive messages from this queue of the given message type.
msg | The data to be sent, see note for recv() | |
data_size | the full data size (sizeof(typeof(data))), NOT just the size of the mtext field (see recv()). |
fawkes::IPCMessageQueue::destroy_on_delete [protected] |
destroy this message queue on delete?
Definition at line 73 of file msg.h.
Referenced by ~IPCMessageQueue().
const int fawkes::IPCMessageQueue::MaxMessageSize = 8192 [static] |