F´ Flight Software - C/C++ Documentation  devel
A framework for building embedded system applications to NASA flight quality standards.
Os::QueueInterface Class Referenceabstract

base queue interface More...

#include <Os/Queue.hpp>

Inheritance diagram for Os::QueueInterface:
Os::Generic::PriorityQueue Os::Queue Os::Stub::Queue::StubQueue

Public Types

enum  Status {
  OP_OK , ALREADY_CREATED , EMPTY , UNINITIALIZED ,
  SIZE_MISMATCH , SEND_ERROR , RECEIVE_ERROR , INVALID_PRIORITY ,
  FULL , UNKNOWN_ERROR
}
 status returned from the queue send function More...
 
enum  BlockingType { BLOCKING , NONBLOCKING }
 message type More...
 

Public Member Functions

 QueueInterface ()=default
 default queue interface constructor More...
 
virtual ~QueueInterface ()=default
 default queue destructor More...
 
 QueueInterface (const QueueInterface &other)=delete
 copy constructor is forbidden More...
 
 QueueInterface (const QueueInterface *other)=delete
 copy constructor is forbidden More...
 
virtual QueueInterfaceoperator= (const QueueInterface &other)=delete
 assignment operator is forbidden More...
 
virtual Status create (const Fw::StringBase &name, FwSizeType depth, FwSizeType messageSize)=0
 create queue storage More...
 
virtual Status send (const U8 *buffer, FwSizeType size, FwQueuePriorityType priority, BlockingType blockType)=0
 send a message into the queue More...
 
virtual Status receive (U8 *destination, FwSizeType capacity, BlockingType blockType, FwSizeType &actualSize, FwQueuePriorityType &priority)=0
 receive a message from the queue More...
 
virtual FwSizeType getMessagesAvailable () const =0
 get number of messages available More...
 
virtual FwSizeType getMessageHighWaterMark () const =0
 get maximum messages stored at any given time More...
 
virtual QueueHandlegetHandle ()=0
 return the underlying queue handle (implementation specific) More...
 

Static Public Member Functions

static QueueInterfacegetDelegate (QueueHandleStorage &aligned_placement_new_memory)
 provide a pointer to a queue delegate object More...
 

Detailed Description

base queue interface

Queues are used internally to fprime in order to support the messaging between components. The QueueInterface is used to abstract away from the standard OS-based queue, allowing F prime support multiple OSes in a consistent way.

Definition at line 27 of file Queue.hpp.

Member Enumeration Documentation

◆ BlockingType

message type

Enumerator
BLOCKING 

Message will block until space is available.

NONBLOCKING 

Message will return with status when space is unavailable.

Definition at line 44 of file Queue.hpp.

◆ Status

status returned from the queue send function

Enumerator
OP_OK 

message sent/received okay

ALREADY_CREATED 

creating an already created queue

EMPTY 

If non-blocking, all the messages have been drained.

UNINITIALIZED 

Queue wasn't initialized successfully.

SIZE_MISMATCH 

attempted to send or receive with buffer too large, too small

SEND_ERROR 

message send error

RECEIVE_ERROR 

message receive error

INVALID_PRIORITY 

invalid priority requested

FULL 

queue was full when attempting to send a message

UNKNOWN_ERROR 

Unexpected error; can't match with returns.

Definition at line 30 of file Queue.hpp.

Constructor & Destructor Documentation

◆ QueueInterface() [1/3]

Os::QueueInterface::QueueInterface ( )
default

default queue interface constructor

◆ ~QueueInterface()

virtual Os::QueueInterface::~QueueInterface ( )
virtualdefault

default queue destructor

◆ QueueInterface() [2/3]

Os::QueueInterface::QueueInterface ( const QueueInterface other)
delete

copy constructor is forbidden

◆ QueueInterface() [3/3]

Os::QueueInterface::QueueInterface ( const QueueInterface other)
delete

copy constructor is forbidden

Member Function Documentation

◆ create()

virtual Status Os::QueueInterface::create ( const Fw::StringBase name,
FwSizeType  depth,
FwSizeType  messageSize 
)
pure virtual

create queue storage

Creates a queue ensuring sufficient storage to hold depth messages of messageSize size each. Resource allocation is dependent on the underlying implementation and users should assume that resource allocation is possible.

Parameters
namename of queue
depthdepth of queue in number of messages
messageSizesize of an individual message
Returns
: status of the creation

Implemented in Os::Stub::Queue::StubQueue, Os::Queue, and Os::Generic::PriorityQueue.

◆ getDelegate()

QueueInterface * Os::QueueInterface::getDelegate ( QueueHandleStorage aligned_placement_new_memory)
static

provide a pointer to a queue delegate object

This function must return a pointer to a QueueInterface object that contains the real implementation of the queue functions as defined by the implementor. This function must do several things to be considered correctly implemented:

  1. Assert that the supplied memory is non-null. e.g FW_ASSERT(aligned_placement_new_memory != NULL);
  2. Assert that their implementation fits within FW_HANDLE_MAX_SIZE. e.g. static_assert(sizeof(PosixQueueImplementation) <= sizeof Os::Queue::m_handle_storage, "FW_HANDLE_MAX_SIZE to small");
  3. Assert that their implementation aligns within FW_HANDLE_ALIGNMENT. e.g. static_assert((FW_HANDLE_ALIGNMENT % alignof(PosixQueueImplementation)) == 0, "Bad handle alignment");
  4. Placement new their implementation into aligned_placement_new_memory e.g. TaskInterface* interface = new (aligned_placement_new_memory) PosixQueueImplementation;
  5. Return the result of the placement new e.g. return interface;
Returns
result of placement new, must be equivalent to aligned_placement_new_memory

Definition at line 10 of file DefaultPriorityQueue.cpp.

◆ getHandle()

virtual QueueHandle* Os::QueueInterface::getHandle ( )
pure virtual

return the underlying queue handle (implementation specific)

Returns
internal task handle representation

Implemented in Os::Stub::Queue::StubQueue, Os::Queue, and Os::Generic::PriorityQueue.

◆ getMessageHighWaterMark()

virtual FwSizeType Os::QueueInterface::getMessageHighWaterMark ( ) const
pure virtual

get maximum messages stored at any given time

Returns the maximum number of messages in this queue at any given time. This is the high-water mark for this queue.

Returns
queue message high-water mark

Implemented in Os::Stub::Queue::StubQueue, Os::Queue, and Os::Generic::PriorityQueue.

◆ getMessagesAvailable()

virtual FwSizeType Os::QueueInterface::getMessagesAvailable ( ) const
pure virtual

get number of messages available

Returns the number of messages currently available in the queue.

Returns
number of messages available

Implemented in Os::Stub::Queue::StubQueue, Os::Queue, and Os::Generic::PriorityQueue.

◆ operator=()

virtual QueueInterface& Os::QueueInterface::operator= ( const QueueInterface other)
virtualdelete

assignment operator is forbidden

Reimplemented in Os::Stub::Queue::StubQueue, Os::Queue, and Os::Generic::PriorityQueue.

◆ receive()

virtual Status Os::QueueInterface::receive ( U8 destination,
FwSizeType  capacity,
BlockingType  blockType,
FwSizeType actualSize,
FwQueuePriorityType priority 
)
pure virtual

receive a message from the queue

Receive a message from the queue, providing the message destination, capacity, priority, and blocking type. When blockType is set to BLOCKING, this call will block on queue empty. Otherwise, this will return an error status on queue empty. Actual size received and priority of message is set on success status.

It is invalid to send a null buffer. This method will block if the queue is empty and blockType is set to BLOCKING

Parameters
destinationdestination for message data
capacitymaximum size of message data
blockTypeBLOCKING to wait for message or NONBLOCKING to return error when queue is empty
actualSize(output) actual size of message read
priority(output) priority of message read
Returns
: status of the send

Implemented in Os::Stub::Queue::StubQueue, Os::Queue, and Os::Generic::PriorityQueue.

◆ send()

virtual Status Os::QueueInterface::send ( const U8 buffer,
FwSizeType  size,
FwQueuePriorityType  priority,
BlockingType  blockType 
)
pure virtual

send a message into the queue

Send a message into the queue, providing the message data, size, priority, and blocking type. When blockType is set to BLOCKING, this call will block on queue full. Otherwise, this will return an error status on queue full.

It is invalid to send a null buffer. This method will block if the queue is full and blockType is set to BLOCKING

Parameters
buffermessage data
sizesize of message data
prioritypriority of the message
blockTypeBLOCKING to block for space or NONBLOCKING to return error when queue is full
Returns
: status of the send

Implemented in Os::Stub::Queue::StubQueue, Os::Queue, and Os::Generic::PriorityQueue.


The documentation for this class was generated from the following files: