fawkes::IPCMessageQueue Class Reference
[Interprocess Communication (IPC)]
IPC message queue.
More...
#include <utils/ipc/msg.h>
Classes | |
| struct | MessageStruct |
| This is the struct of the messages that has to be fed to send and receive methods. More... | |
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? | |
Detailed Description
IPC message queue.This class gives access to IPC message queues. You can use this to send messages between different applications running on the same host.
- See also:
- qa_ipc_msg.cpp
Definition at line 32 of file msg.h.
Constructor & Destructor Documentation
| 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.
- Parameters:
-
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.
- Parameters:
-
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 | ( | ) |
Member Function Documentation
| 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.
- Returns:
- This method returns false if the message queue could not be opened or if it has been closed, it returns true if messages can be sent or received.
| 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.
- Parameters:
-
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!
- Returns:
- returns true, if a message of the appropriate type could be read that fitted the given memory size. The received data is stored in data.
- See also:
- MessageStruct
- Exceptions:
-
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.
- Parameters:
-
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!
- Returns:
- true, if a message could be read that fitted the given memory size. The received data is stored in data. False, if no message was in the queue or the queue has been removed.
- See also:
- MessageStruct
| bool fawkes::IPCMessageQueue::send | ( | MessageStruct * | msg, | |
| unsigned int | data_size | |||
| ) |
Receive messages from this queue of the given message type.
- Parameters:
-
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()).
- Returns:
- true, if the message could be sent, false otherwise.
- See also:
- MessageStruct
Member Data Documentation
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] |
The documentation for this class was generated from the following files:

