|
PiImageStreamer
|
Singleton that owns one CommandQueue per component and routes messages to them by internal queue ID. More...
#include <QueueManager.h>

Public Member Functions | |
| CommandQueue & | getQueueInstance (int queueID) |
| void | sendBroadcastMessage (CommandQueueEntry value) |
| bool | sendMessage (int destination, CommandQueueEntry value) |
Static Public Member Functions | |
| static QueueManager & | getSingleton () |
Static Protected Attributes | |
| static QueueManager * | singleton = nullptr |
Private Member Functions | |
| QueueManager (int numberOfQueues) | |
| virtual | ~QueueManager () |
Private Attributes | |
| int | queueCount |
| CommandQueue ** | queues |
| CommandQueue | dummyQueue |
Singleton that owns one CommandQueue per component and routes messages to them by internal queue ID.
|
private |
This will instantiate a new instance of the queue manager.
| numberOfQueues | This is the number of queues that are to be managed by this manager. |
| std::invalid_argument | if the number of queues is negative. |
This will instantiate a new instance of the queue manager.
| numberOfQueues | This is the number of queues that are to be managed by this manager. |
Check to make sure the number of queues is not negative. If it is negative, throw an invalid_argument exception indicating that the value can not be negative.
Continue with the constructor. Set the queue count accordingly and set the queues to be an array of pointers to number of queue instances.
Loop queuecount times, instantiating a new Command queue and placing a pointer to it in the array.
|
privatevirtual |
This is the destructor which will clean up.
Delete all of the queues that were allocated in the constructor, and then the array that held them.
| CommandQueue & QueueManager::getQueueInstance | ( | int | queueID | ) |
This method will obtain a reference to the desired queue. The queue ID is the numeric definition for the given component's queue (see QueueCfg.h).
| queueID | This is the queue that is to be communicated with. |
| std::invalid_argument | if the queue ID is out of range. |
Check to see if the queue ID is out of the range of 0 to queueCount - 1.
Check to see that the queue ID is in the range of 0 to queueCount - 1. Because of the check above, this is always true.
Return the dummyQueue if the code has not already returned. This is not reached, but keeps every path returning a value.

|
static |
This method will return a reference to the singleton instance of this class.
This method will return a reference to the singleton instance of this class. If there is no instance already, an instance will be created and then returned. The method used is referred to as double-checked locking. See https://en.wikipedia.org/wiki/Double-checked_locking for details.
Determine if the singleton is null.
Lock the mutex
Determine if the singleton is still null.
If the singleton is null, instantiate a new queue manager, with the NUMBER_OF_INTERNAL_QUEUES from QueueCfg.h as the parameter.
Unlock the mutex.
Return the reference.

| void QueueManager::sendBroadcastMessage | ( | CommandQueueEntry | value | ) |
This method will send a broadcast message. A broadcast message will be enqueued on all queues to be received by all components. Only broadcast, status report, and heartbeat message types are sent; any other type is ignored.
| value | This is the value to be enqueued as a broadcast message to all queues. |
This method will send a broadcast message. A broadcast message will be enqueued on all queues to be received by all components.
| value | This is the value to be enqueued as a broadcast message to all queues. Note that it must have a broadcast, status report, or heartbeat command type; any other type is ignored. |
If the type is a broadcast, status, or heartbeat message


| bool QueueManager::sendMessage | ( | int | destination, |
| CommandQueueEntry | value | ||
| ) |
This method will send a message to the given destination. Broadcast messages are not accepted; use sendBroadcastMessage().
| destination | This is the destination internal queue ID. |
| value | This is the message to be enqueued. |
This method will send a message to the given destination.
| destination | This is the destination queue. |
| value | This is the message to be enqueued. |
If the destination is in range and the message is not a broadcast message, enqueue it to the appropriate queue.


|
private |
This is a dummy queue. getQueueInstance() now throws for an invalid queue ID, so this queue is not normally returned.
|
private |
This integer stores the number of queues that are being managed.
|
private |
This is the array of pointers to queues. It will be used to properly dispatch queues to the components.
|
staticprotected |
This is the singleton instance for the queue manager.
This is the singleton instance, which is a nullptr if it has not yet been instantiated.