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

Functions

template<class Interface , class Implementation , class StorageType >
Interface * makeDelegate (StorageType &aligned_new_memory)
 Make a delegate of type Interface using Implementation without copy-constructor support (generic function) More...
 
template<class Interface , class Implementation , class StorageType >
Interface * makeDelegate (StorageType &aligned_new_memory, const Interface *to_copy)
 Make a delegate of type Interface using Implementation with copy-constructor support (generic function) More...
 

Function Documentation

◆ makeDelegate() [1/2]

template<class Interface , class Implementation , class StorageType >
Interface* Os::Delegate::makeDelegate ( StorageType &  aligned_new_memory)
inline

Make a delegate of type Interface using Implementation without copy-constructor support (generic function)

This function is a generic implementation of the getDelegate functions provided for each function within Os. This is templated over two types: Interface (e.g. TaskInterface) the interface the delegate supports, and Implementation the implementation of the interface. This function takes care of the critical requirements of the getDelegate function:

  1. Ensure Implementation is derived from Interface
  2. Ensure Implementation fits within FW_HANDLE_MAX_SIZE
  3. Ensure Implementation alignment fits within FW_HANDLE_ALIGNMENT
  4. Performs the correct placement new for normal constructors
  5. Ensure the returned pointer is not nullptr

Implementors of a getDelegate function may use this function by calling it and returning the result.

Neither Interface nor Implementation is allowed to support copy-constructors

Example: TaskInterface getDelegate (Without Copy-Constructor)

{c++}
#include "Os/Delegate.hpp"
namespace Os {
TaskInterface* TaskInterface::getDelegate(HandleStorage& aligned_new_memory) {
return Os::Delegate::makeDelegate<TaskInterface, Os::Posix::Task::PosixTask>(aligned_new_memory);
}
}
static TaskInterface * getDelegate(TaskHandleStorage &aligned_placement_new_memory)
provide a pointer to a task delegate object
Definition: DefaultTask.cpp:11
Template Parameters
Interfaceinterface the delegate supports (e.g. TaskInterface)
Implementationimplementation class of the delegate (e.g. PosixTask)
Parameters
aligned_new_memorymemory to be filled via placement new call
Returns
pointer to implementation result of placement new

Definition at line 46 of file Delegate.hpp.

◆ makeDelegate() [2/2]

template<class Interface , class Implementation , class StorageType >
Interface* Os::Delegate::makeDelegate ( StorageType &  aligned_new_memory,
const Interface *  to_copy 
)
inline

Make a delegate of type Interface using Implementation with copy-constructor support (generic function)

This function is a generic implementation of the getDelegate functions provided for each function within Os. This is templated over two types: Interface (e.g. TaskInterface) the interface the delegate supports, and Implementation the implementation of the interface. This function takes care of the critical requirements of the getDelegate function:

  1. Ensure Implementation is derived from Interface
  2. Ensure Implementation fits within FW_HANDLE_MAX_SIZE
  3. Ensure Implementation alignment fits within FW_HANDLE_ALIGNMENT
  4. Performs the correct placement new for normal and copy constructors
  5. Ensure the returned pointer is not nullptr

Implementors of a getDelegate function may use this function by calling it and returning the result.

Example: FileInterface getDelegate Supporting Copy-Constructor

{c++}
#include "Os/Delegate.hpp"
namespace Os {
FileInterface* FileInterface::getDelegate(HandleStorage& aligned_new_memory, const FileInterface* to_copy) {
return Os::Delegate::makeDelegate<FileInterface, Os::Posix::File::PosixFile>(aligned_new_memory, to_copy);
}
}
static FileInterface * getDelegate(FileHandleStorage &aligned_placement_new_memory, const FileInterface *to_copy=nullptr)
provide a pointer to a file delegate object
Definition: DefaultFile.cpp:14
Template Parameters
Interfaceinterface the delegate supports (e.g. FileInterface)
Implementationimplementation class of the delegate (e.g. PosixFile)
Parameters
aligned_new_memorymemory to be filled via placement new call
Returns
pointer to implementation result of placement new
Parameters
to_copypointer to Interface to be copied by copy constructor
Returns
pointer to implementation result of placement new

Definition at line 89 of file Delegate.hpp.