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 
12 #ifndef _Queue_hpp_
13 #define _Queue_hpp_
14 
15 #include <FpConfig.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  enum QueueStatus {
38  };
39 
43  };
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() const;
58  NATIVE_INT_TYPE getMaxMsgs() const;
60  NATIVE_INT_TYPE getMsgSize() const;
61  const QueueString& getName();
62  static NATIVE_INT_TYPE getNumQueues();
63 #if FW_QUEUE_REGISTRATION
64  static void setQueueRegistry(QueueRegistry* reg); // !< set the queue registry
65 #endif
66 
67  protected:
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
PlatformPointerCastType POINTER_CAST
Definition: BasicTypes.h:53
PlatformIntType NATIVE_INT_TYPE
Definition: BasicTypes.h:51
uint8_t U8
8-bit unsigned integer
Definition: BasicTypes.h:26
C++-compatible configuration header for fprime configuration.
Declarations for Fw::ObjBase and Fw::ObjRegistry.
QueueString m_name
queue name
Definition: Queue.hpp:76
QueueStatus create(const Fw::StringBase &name, NATIVE_INT_TYPE depth, NATIVE_INT_TYPE msgSize)
create a message queue
Definition: QueueCommon.cpp:41
NATIVE_INT_TYPE getMsgSize() const
get the message size (maximum message size queue can hold)
Definition: Queue.cpp:244
QueueStatus
Definition: Queue.hpp:27
@ QUEUE_SIZE_MISMATCH
attempted to send or receive with buffer too large, too small
Definition: Queue.hpp:31
@ QUEUE_UNINITIALIZED
Queue wasn't initialized successfully.
Definition: Queue.hpp:30
@ QUEUE_SEND_ERROR
message send error
Definition: Queue.hpp:32
@ QUEUE_NO_MORE_MSGS
If non-blocking, all the messages have been drained.
Definition: Queue.hpp:29
@ QUEUE_INVALID_PRIORITY
invalid priority requested
Definition: Queue.hpp:34
@ QUEUE_EMPTY_BUFFER
supplied buffer is empty
Definition: Queue.hpp:35
@ QUEUE_UNKNOWN_ERROR
Unexpected error; can't match with returns.
Definition: Queue.hpp:37
@ QUEUE_OK
message sent/received okay
Definition: Queue.hpp:28
@ QUEUE_FULL
queue was full when attempting to send a message
Definition: Queue.hpp:36
@ QUEUE_RECEIVE_ERROR
message receive error
Definition: Queue.hpp:33
QueueStatus send(const Fw::SerializeBufferBase &buffer, NATIVE_INT_TYPE priority, QueueBlocking block)
send a message
Definition: QueueCommon.cpp:13
Queue()
Definition: Queue.cpp:38
QueueStatus createInternal(const Fw::StringBase &name, NATIVE_INT_TYPE depth, NATIVE_INT_TYPE msgSize)
create a message queue
Definition: Queue.cpp:42
QueueStatus receive(Fw::SerializeBufferBase &buffer, NATIVE_INT_TYPE &priority, QueueBlocking block)
receive a message
Definition: QueueCommon.cpp:22
const QueueString & getName()
get the queue name
Definition: QueueCommon.cpp:61
NATIVE_INT_TYPE getQueueSize() const
get the queue depth (maximum number of messages queue can hold)
Definition: Queue.cpp:233
NATIVE_INT_TYPE getMaxMsgs() const
get the maximum number of messages (high watermark)
Definition: Queue.cpp:222
QueueBlocking
Definition: Queue.hpp:40
@ QUEUE_BLOCKING
Queue receive blocks until a message arrives.
Definition: Queue.hpp:41
@ QUEUE_NONBLOCKING
Queue receive always returns even if there is no message.
Definition: Queue.hpp:42
NATIVE_INT_TYPE getNumMsgs() const
get the number of messages in the queue
Definition: Queue.cpp:211
virtual ~Queue()
Definition: Queue.cpp:65
static NATIVE_INT_TYPE getNumQueues()
get the number of queues in the system
Definition: QueueCommon.cpp:57
static NATIVE_INT_TYPE s_numQueues
tracks number of queues in the system
Definition: Queue.hpp:80
POINTER_CAST m_handle
handle for implementation specific queue
Definition: Queue.hpp:75
virtual ~QueueRegistry()
Definition: Queue.hpp:90
virtual void regQueue(Queue *obj)=0
method called by queue init() methods to register a new queue