F´ Flight Software - C/C++ Documentation  devel
A framework for building embedded system applications to NASA flight quality standards.
Queue.hpp
Go to the documentation of this file.
1 /*
2  * Queue.hpp:
3  *
4  * FIFO queue of fixed size messages. For use generally where non-concurrent, non-OS backed based FIFO queues are
5  * necessary. Message size is defined at construction time and all messages enqueued and dequeued must be of that fixed
6  * size. Wraps circular buffer to perform actual storage of messages. This implementation is not thread safe and the
7  * expectation is that the user will wrap it in concurrency constructs where necessary.
8  *
9  * Created on: July 5th, 2022
10  * Author: lestarch
11  *
12  */
13 #ifndef _UTILS_TYPES_QUEUE_HPP
14 #define _UTILS_TYPES_QUEUE_HPP
15 #include <FpConfig.hpp>
16 #include <Fw/Types/BasicTypes.hpp>
19 
20 namespace Types {
21 
22 class Queue {
23  public:
27  Queue();
28 
40  void setup(U8* const storage, const FwSizeType storage_size, const FwSizeType depth, const FwSizeType message_size);
41 
56  Fw::SerializeStatus enqueue(const U8* const message, const FwSizeType size);
57 
71  Fw::SerializeStatus dequeue(U8* const message, const FwSizeType size);
72 
77 
81  void clear_high_water_mark();
82 
84 
85  private:
86  CircularBuffer m_internal;
87  FwSizeType m_message_size;
88 };
89 } // namespace Types
90 #endif // _UTILS_TYPES_QUEUE_HPP
uint8_t U8
8-bit unsigned integer
Definition: BasicTypes.h:26
PlatformUIntType NATIVE_UINT_TYPE
Definition: BasicTypes.h:52
C++ header for working with basic fprime types.
PlatformSizeType FwSizeType
Definition: FpConfig.h:30
C++-compatible configuration header for fprime configuration.
NATIVE_UINT_TYPE getQueueSize() const
Definition: Queue.cpp:60
void setup(U8 *const storage, const FwSizeType storage_size, const FwSizeType depth, const FwSizeType message_size)
setup the queue object to setup storage
Definition: Queue.cpp:17
Fw::SerializeStatus dequeue(U8 *const message, const FwSizeType size)
pops a fixed-size message off the front of the queue
Definition: Queue.cpp:38
Queue()
constructs an uninitialized queue
Definition: Queue.cpp:15
Fw::SerializeStatus enqueue(const U8 *const message, const FwSizeType size)
pushes a fixed-size message onto the back of the queue
Definition: Queue.cpp:29
NATIVE_UINT_TYPE get_high_water_mark() const
Definition: Queue.cpp:51
void clear_high_water_mark()
Definition: Queue.cpp:56
SerializeStatus
forward declaration for string