F´ Flight Software - C/C++ Documentation NASA-v1.6.0
A framework for building embedded system applications to NASA flight quality standards.
Loading...
Searching...
No Matches
BufferQueue.hpp
Go to the documentation of this file.
1// ======================================================================
2// \title BufferQueue.hpp
3// \author dinkel
4// \brief A generic buffer queue data structure.
5//
6// \copyright
7// Copyright 2009-2015, by the California Institute of Technology.
8// ALL RIGHTS RESERVED. United States Government Sponsorship
9// acknowledged.
10//
11// ======================================================================
12
13#ifndef OS_PTHREADS_BUFFER_QUEUE_HPP
14#define OS_PTHREADS_BUFFER_QUEUE_HPP
15
16#include <FpConfig.hpp>
17
18// This is a generic buffer queue interface.
19namespace Os {
20
27 // Public interface:
28 public:
49 bool create(NATIVE_UINT_TYPE depth, NATIVE_UINT_TYPE msgSize);
59 bool push(const U8* buffer, NATIVE_UINT_TYPE size, NATIVE_INT_TYPE priority);
72 bool pop(U8* buffer, NATIVE_UINT_TYPE& size, NATIVE_INT_TYPE &priority);
77 bool isFull();
82 bool isEmpty();
104
105 // Internal member functions:
106 private:
107 // Initialize data structures necessary for the queue:
108 bool initialize(NATIVE_UINT_TYPE depth, NATIVE_UINT_TYPE msgSize);
109 // Destroy queue data structures:
110 void finalize();
111 // Enqueue a message into the data structure:
112 bool enqueue(const U8* buffer, NATIVE_UINT_TYPE size, NATIVE_INT_TYPE priority);
113 // Dequeue a message from the data structure:
114 bool dequeue(U8* buffer, NATIVE_UINT_TYPE& size, NATIVE_INT_TYPE &priority);
115 // Low level enqueue which does the copying onto the queue:
116 void enqueueBuffer(const U8* buffer, NATIVE_UINT_TYPE size, U8* data, NATIVE_UINT_TYPE index);
117 // Low level dequeue which does the copying from the queue:
118 bool dequeueBuffer(U8* buffer, NATIVE_UINT_TYPE& size, U8* data, NATIVE_UINT_TYPE index);
119 // Helper function to get the buffer index into the queue for particular
120 // queue index.
121 NATIVE_UINT_TYPE getBufferIndex(NATIVE_INT_TYPE index);
122
123 // Member variables:
124 void* queue; // The queue can be implemented in various ways
125 NATIVE_UINT_TYPE msgSize; // Max size of message on the queue
126 NATIVE_UINT_TYPE depth; // Max number of messages on the queue
127 NATIVE_UINT_TYPE count; // Current number of messages on the queue
128 NATIVE_UINT_TYPE maxCount; // Maximum number of messages ever seen on the queue
129 };
130}
131
132#endif // OS_PTHREADS_BUFFER_QUEUE_HPP
PlatformIntType NATIVE_INT_TYPE
Definition BasicTypes.h:51
uint8_t U8
8-bit unsigned integer
Definition BasicTypes.h:26
PlatformUIntType NATIVE_UINT_TYPE
Definition BasicTypes.h:52
C++-compatible configuration header for fprime configuration.
A generic buffer queue data structure.
bool create(NATIVE_UINT_TYPE depth, NATIVE_UINT_TYPE msgSize)
BufferQueue creation.
NATIVE_UINT_TYPE getCount()
Get the current number of items on the queue.
NATIVE_UINT_TYPE getMsgSize()
Get the maximum message size.
bool pop(U8 *buffer, NATIVE_UINT_TYPE &size, NATIVE_INT_TYPE &priority)
pop an item off the queue
NATIVE_UINT_TYPE getDepth()
Get the queue depths.
bool isEmpty()
check if the queue is empty
~BufferQueue()
BufferQueue deconstructor.
bool push(const U8 *buffer, NATIVE_UINT_TYPE size, NATIVE_INT_TYPE priority)
push an item onto the queue
BufferQueue()
BufferQueue constructor.
bool isFull()
check if the queue is full
NATIVE_UINT_TYPE getMaxCount()
Get the maximum number of items seen on the queue.
Definition File.cpp:6