In file /home/eternity/Source/Common/MessageQueue/H/messageQueue.h:

class MessageQueue : Debugable

Queue of message pointers

Inheritance:

MessageQueue < Debugable


Public Methods

Err MessageQueue::Append (GMessage *msg, int requestType = HARD)
Append message to queue
Size MessageQueue::FreeSlotsCount ()
Number of messages it is possible to append to queue
Err MessageQueue::GetMsg (GMessage **msg, Size number)
et message from queue
Err MessageQueue::GetRandomMsg (GMessage **msg)
Get random message from queue
bool MessageQueue::IsQueueFull ()
Is the queue full?
MessageQueue::MessageQueue (LogFile * queueLogFile, Size size)
Message queue constructor
Size MessageQueue::MsgCount ()
Returns the number of messages in queue
Err MessageQueue::ShowMsg (GMessage **msg, Size number)
Get message from queue
MessageQueue::~MessageQueue ()
Message queue destructor

Public

methods
MessageQueue (LogFile * queueLogFile, Size size = MSGQ_DEFAULT_BUFFER_LEN)
Creates a message that can store up to size messages
~MessageQueue ()
Destructor
Err Append (GMessage *msg, int requestType = HARD)
Appends a message to the end of queue
Err GetMsg (GMessage **msg, Size number = 0)
Returns the number-th message from queue (removes it from queue)
Err GetRandomMsg (GMessage **msg)
Returns a random message from queue (removes it from queue)
Err ShowMsg (GMessage **msg, Size number = 0)
Returns the number-th message from queue (leaves it in queue)
Size MsgCount ()
Returns the number of messages in queue
Size FreeSlotsCount ()
Returns the number of free slots in queue
bool IsQueueFull ()
Is the queue full ?

Private

attributes
Size size
Size firstMsg
Size lastMsg
Size msgCount
struct Semaphore semEmptysemFull
for synchronization
pthread_mutex_t mutex
for synchronization
GMessage** messages
array of pointers to messages

Inherited from Debugable:

Public Methods

string* Debugable::CreateString(char *firstStr, int firstInt, int secondInt)
Debugable::Debugable(LogFile * debugLogFile)
int Debugable::SetDebugOptions(int newLogOptions)
void Debugable::SetLogFile(LogFile *aLogFile)
void Debugable::WriteString(LogLevel debugLevel, char * format, ...)
Debugable::~Debugable()

Documentation

Queue of message pointers. Holds a queue of pointers to messages. It provides access to stored messages in FIFO order and even random access.
attributes

Size size

Size firstMsg

Size lastMsg

Size msgCount

struct Semaphore semEmpty semFull
for synchronization

pthread_mutex_t mutex
for synchronization

GMessage** messages
array of pointers to messages

methods

MessageQueue(LogFile * queueLogFile, Size size = MSGQ_DEFAULT_BUFFER_LEN)
Creates a message that can store up to size messages

~MessageQueue()
Destructor

Err Append(GMessage *msg, int requestType = HARD)
Appends a message to the end of queue

Err GetMsg(GMessage **msg, Size number = 0)
Returns the number-th message from queue (removes it from queue)

Err GetRandomMsg(GMessage **msg)
Returns a random message from queue (removes it from queue)

Err ShowMsg(GMessage **msg, Size number = 0)
Returns the number-th message from queue (leaves it in queue)

Size MsgCount()
Returns the number of messages in queue

Size FreeSlotsCount()
Returns the number of free slots in queue

bool IsQueueFull()
Is the queue full ?

Err MessageQueue::Append(GMessage *msg, int requestType = HARD)
Append message to queue. Appends GMessage to the end of messaage queue.
Returns:
If requestType is SOFT and queue is full then KO else OK.
Parameters:
msg - GMessage
requestType - Wheteher we should fall asleep when message queue is already full - default is yes.
Author:
Pechy
See Also:

Size MessageQueue::FreeSlotsCount()
Number of messages it is possible to append to queue.
Returns:
Number of free slots.
Author:
Pechy
See Also:

Err MessageQueue::GetMsg(GMessage **msg, Size number)
et message from queue. Returns the number-th message and removes it from queue, the 1st message has number 0 !!!!
Returns:
OK
Parameters:
msg - Gets filled with a pointer to the message.
number - Index of message we want from queue.
Author:
Pechy
See Also:

Err MessageQueue::GetRandomMsg(GMessage **msg)
Get random message from queue. Chooses a random message in queue and returns it. It also deletes the message from queue.
Returns:
OK
Parameters:
msg - Out - gets filled with pointer to a GMessage.
Author:
Pechy
See Also:

bool MessageQueue::IsQueueFull()
Is the queue full?. If number of messages is the same as number of slots then the queue is full.
Returns:
true if queue is full false otherwise.
Author:
Pechy
See Also:

MessageQueue::MessageQueue(LogFile * queueLogFile, Size size)
Message queue constructor. Implements a simle FIFO queue. Initializes semaphores and mutex for protecting its inner data and also initializes this inner data.
Parameters:
queueLogFile - Log file that is used for debug messages.
size - Maximum number of messages in queue.
Author:
Pechy
See Also:
semaphores

Size MessageQueue::MsgCount()
Returns the number of messages in queue
Returns:
Number of messages in queue.
Author:
Pechy
See Also:

Err MessageQueue::ShowMsg(GMessage **msg, Size number)
Get message from queue. Returns the number-th message from queue but leaves it in there.
Returns:
OK
Parameters:
msg - Gets filled with pointer to message retured.
number - Message offset in queue.
Author:
Pechy
See Also:

MessageQueue::~MessageQueue()
Message queue destructor. Deletes its internal data structures.
Author:
Pechy
See Also:


This class has no child classes.
Author:
Marek, Pechy, Venca
See Also:

alphabetic index hierarchy of classes


generated by doc++