FifoQueue
FifoQueue
is a final
class template
defined in Fw/DataStructures
.
It represents a FIFO queue with internal storage.
1. Template Parameters
FifoQueue
has the following template parameters.
Kind | Name | Purpose |
---|---|---|
typename |
T |
The type of a queue item |
FwSizeType |
C |
The queue capacity in items |
FifoQueue
statically asserts the following:
T
is default constructible.C > 0
.
2. Base Class
FifoQueue<T, C>
is publicly derived from
FifoQueueBase<T>
.
3. Private Member Variables
FifoQueue
has the following private member variables.
Name | Type | Purpose | Default Value |
---|---|---|---|
m_extQueue |
ExternalFifoQueue<T> |
The external queue implementation | C++ default initialization |
m_items |
T[C] |
The array providing the backing memory for m_extQueue |
C++ default initialization |
classDiagram
FifoQueue *-- ExternalFifoQueue
4. Public Constructors and Destructors
4.1. Zero-Argument Constructor
Initialize m_extQueue
with ExternalFifoQueue<T>(m_items, C)
.
Example:
4.2. Copy Constructor
-
Initialize
m_extQueue
withExternalFifoQueue<T>(m_items, C)
. -
Set
*this = queue
.
Example:
FifoQueue<U32, 10> q1;
auto status = q1.enqueue(3);
ASSERT_EQ(status, Success::SUCCESS);
FifoQueue<U32, 10> q2(q1);
ASSERT_EQ(q2.size(), 1);
U32 value = 0;
status = q2.dequeue(value);
ASSERT_EQ(status, Success::SUCCESS);
ASSERT_EQ(value, 3);
4.3. Destructor
Defined as = default
.
5. Public Member Functions
5.1. operator=
Return m_extQueue.copyDataFrom(queue)
.
Example:
FifoQueue<U32, 10> q1;
auto status = q1.enqueue(3);
ASSERT_EQ(status, Success::SUCCESS);
FifoQueue<U32, 10> q2;
ASSERT_EQ(q2.size(), 0);
q2 = q1;
ASSERT_EQ(q2.size(), 1);
U32 value = 0;
status = q2.dequeue(value);
ASSERT_EQ(status, Success::SUCCESS);
ASSERT_EQ(value, 3);
5.2. clear
Call m_extQueue.clear()
.
5.3. enqueue
Return m_extQueue.enqueue(e)
.
5.4. at
Return m_extQueue.at(index)
.
5.5. dequeue
Return m_extQueue.dequeue(e)
.
5.6. getSize
Return m_extQueue.getSize()
.
5.7. getCapacity
Return m_extQueue.getCapacity()
.
6. Public Static Functions
6.1. getStaticCapacity
Return the static capacity C
.
Example: