F´ Flight Software - C/C++ Documentation  NASA-v2.1.0
A framework for building embedded system applications to NASA flight quality standards.
Queue.hpp
Go to the documentation of this file.
1 
12 #ifndef _Queue_hpp_
13 #define _Queue_hpp_
14 
15 #include <Fw/Types/BasicTypes.hpp>
16 #include <Fw/Obj/ObjBase.hpp>
18 #include <Os/QueueString.hpp>
19 
20 namespace Os {
21  // forward declaration for registry
22  class QueueRegistry;
23 
24  class Queue {
25  public:
26 
27  typedef enum {
38  } QueueStatus;
39 
40  typedef enum {
43  } QueueBlocking;
44 
45  Queue();
46  virtual ~Queue();
47  QueueStatus create(const Fw::StringBase &name, NATIVE_INT_TYPE depth, NATIVE_INT_TYPE msgSize);
48 
49  // Send serialized buffers
50  QueueStatus send(const Fw::SerializeBufferBase &buffer, NATIVE_INT_TYPE priority, QueueBlocking block);
52 
53  // Send raw buffers
54  QueueStatus send(const U8* buffer, NATIVE_INT_TYPE size, NATIVE_INT_TYPE priority, QueueBlocking block);
55  QueueStatus receive(U8* buffer, NATIVE_INT_TYPE capacity, NATIVE_INT_TYPE &actualSize, NATIVE_INT_TYPE &priority, QueueBlocking block);
56 
57  NATIVE_INT_TYPE getNumMsgs(void) const;
58  NATIVE_INT_TYPE getMaxMsgs(void) const;
59  NATIVE_INT_TYPE getQueueSize(void) const;
60  NATIVE_INT_TYPE getMsgSize(void) const;
61  const QueueString& getName(void);
62  static NATIVE_INT_TYPE getNumQueues(void);
63 #if FW_QUEUE_REGISTRATION
64  static void setQueueRegistry(QueueRegistry* reg); // !< set the queue registry
65 #endif
66 
67  protected:
75  POINTER_CAST m_handle;
77 #if FW_QUEUE_REGISTRATION
78  static QueueRegistry* s_queueRegistry;
79 #endif
81 
82  private:
83  Queue(Queue&);
84  Queue(Queue*);
85  };
86 
87  class QueueRegistry {
88  public:
89  virtual void regQueue(Queue* obj)=0;
90  virtual ~QueueRegistry();
91  };
92 }
93 
94 #endif
Os::Queue::getName
const QueueString & getName(void)
get the queue name
Definition: QueueCommon.cpp:61
Os
Definition: File.cpp:7
Os::Queue::create
QueueStatus create(const Fw::StringBase &name, NATIVE_INT_TYPE depth, NATIVE_INT_TYPE msgSize)
create a message queue
Definition: QueueCommon.cpp:41
Os::Queue::QUEUE_FULL
@ QUEUE_FULL
queue was full when attempting to send a message
Definition: Queue.hpp:36
Fw::SerializeBufferBase
Definition: Serializable.hpp:43
Serializable.hpp
Fw::StringBase
Definition: StringType.hpp:23
U8
uint8_t U8
8-bit unsigned integer
Definition: BasicTypes.hpp:76
Os::Queue::QueueStatus
QueueStatus
Definition: Queue.hpp:27
Os::Queue::getQueueSize
NATIVE_INT_TYPE getQueueSize(void) const
get the queue depth (maximum number of messages queue can hold)
Definition: Queue.cpp:232
Os::Queue::m_handle
POINTER_CAST m_handle
handle for implementation specific queue
Definition: Queue.hpp:75
Os::QueueRegistry::~QueueRegistry
virtual ~QueueRegistry()
virtual destructor for registry object
Os::Queue::QUEUE_EMPTY_BUFFER
@ QUEUE_EMPTY_BUFFER
supplied buffer is empty
Definition: Queue.hpp:35
Os::Queue::QUEUE_INVALID_PRIORITY
@ QUEUE_INVALID_PRIORITY
invalid priority requested
Definition: Queue.hpp:34
Os::Queue::send
QueueStatus send(const Fw::SerializeBufferBase &buffer, NATIVE_INT_TYPE priority, QueueBlocking block)
send a message
Definition: QueueCommon.cpp:13
Os::Queue::Queue
Queue()
Definition: Queue.cpp:37
QueueString.hpp
Os::Queue::QUEUE_SIZE_MISMATCH
@ QUEUE_SIZE_MISMATCH
attempted to send or receive with buffer too large, too small
Definition: Queue.hpp:31
Os::Queue::QueueBlocking
QueueBlocking
Definition: Queue.hpp:40
Os::Queue::receive
QueueStatus receive(Fw::SerializeBufferBase &buffer, NATIVE_INT_TYPE &priority, QueueBlocking block)
receive a message
Definition: QueueCommon.cpp:22
Os::QueueRegistry
Definition: Queue.hpp:87
Os::QueueString
Definition: QueueString.hpp:10
Os::Queue::QUEUE_UNINITIALIZED
@ QUEUE_UNINITIALIZED
Queue wasn't initialized successfully.
Definition: Queue.hpp:30
Os::Queue::m_name
QueueString m_name
queue name
Definition: Queue.hpp:76
Os::Queue::QUEUE_NO_MORE_MSGS
@ QUEUE_NO_MORE_MSGS
If non-blocking, all the messages have been drained.
Definition: Queue.hpp:29
Os::Queue::getMsgSize
NATIVE_INT_TYPE getMsgSize(void) const
get the message size (maximum message size queue can hold)
Definition: Queue.cpp:243
Os::Queue::getNumMsgs
NATIVE_INT_TYPE getNumMsgs(void) const
get the number of messages in the queue
Definition: Queue.cpp:210
Os::Queue::QUEUE_OK
@ QUEUE_OK
message sent/received okay
Definition: Queue.hpp:28
Os::Queue::s_numQueues
static NATIVE_INT_TYPE s_numQueues
tracks number of queues in the system
Definition: Queue.hpp:80
Os::QueueRegistry::regQueue
virtual void regQueue(Queue *obj)=0
method called by queue init() methods to register a new queue
Os::Queue::QUEUE_RECEIVE_ERROR
@ QUEUE_RECEIVE_ERROR
message receive error
Definition: Queue.hpp:33
Os::Queue::QUEUE_UNKNOWN_ERROR
@ QUEUE_UNKNOWN_ERROR
Unexpected error; can't match with returns.
Definition: Queue.hpp:37
Os::Queue::QUEUE_NONBLOCKING
@ QUEUE_NONBLOCKING
Queue receive always returns even if there is no message.
Definition: Queue.hpp:42
Os::Queue::getNumQueues
static NATIVE_INT_TYPE getNumQueues(void)
get the number of queues in the system
Definition: QueueCommon.cpp:57
Os::Queue::QUEUE_SEND_ERROR
@ QUEUE_SEND_ERROR
message send error
Definition: Queue.hpp:32
ObjBase.hpp
Declarations for Fw::ObjBase and Fw::ObjRegistry.
Os::Queue::getMaxMsgs
NATIVE_INT_TYPE getMaxMsgs(void) const
get the maximum number of messages (high watermark)
Definition: Queue.cpp:221
Os::Queue::createInternal
QueueStatus createInternal(const Fw::StringBase &name, NATIVE_INT_TYPE depth, NATIVE_INT_TYPE msgSize)
create a message queue
Definition: Queue.cpp:41
BasicTypes.hpp
Declares ISF basic types.
Os::Queue::~Queue
virtual ~Queue()
Definition: Queue.cpp:64
NATIVE_INT_TYPE
int NATIVE_INT_TYPE
native integer type declaration
Definition: BasicTypes.hpp:29
Os::Queue
Definition: Queue.hpp:24
Os::Queue::QUEUE_BLOCKING
@ QUEUE_BLOCKING
Queue receive blocks until a message arrives.
Definition: Queue.hpp:41