F´ Flight Software - C/C++ Documentation
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...
 
template<class Interface , class Implementation , class StorageType , class Argument >
Interface * makeDelegate (StorageType &aligned_new_memory, const Interface *to_copy, const Argument &argument)
 Make a delegate of type Interface using Implementation with copy-constructor and constructor-argument support. More...
 

Function Documentation

◆ makeDelegate() [1/3]

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);
}
}
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/3]

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);
}
}
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.

◆ makeDelegate() [3/3]

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

Make a delegate of type Interface using Implementation with copy-constructor and constructor-argument support.

As the copy-constructor overload, except a null to_copy constructs the Implementation from argument (e.g. RawTimeInterface selecting a RawTimeSource).

Template Parameters
Interfaceinterface the delegate supports (e.g. RawTimeInterface)
Implementationimplementation class of the delegate (e.g. PosixRawTime)
Argumenttype of the constructor argument
Parameters
aligned_new_memorymemory to be filled via placement new call
to_copypointer to Interface to be copied by copy constructor, or nullptr to construct from argument
argumentconstructor argument used when to_copy is nullptr
Returns
pointer to implementation result of placement new

Definition at line 119 of file Delegate.hpp.