iceoryx_posh 2.0.3
Public Member Functions | Protected Member Functions | Friends | List of all members
iox::roudi::GenericMemoryBlock< T > Class Template Referencefinal

The GenericMemoryBlock is an implementation of a MemoryBlock for a common use case. More...

#include <iceoryx_posh/roudi/memory/generic_memory_block.hpp>

Inheritance diagram for iox::roudi::GenericMemoryBlock< T >:
Inheritance graph
[legend]
Collaboration diagram for iox::roudi::GenericMemoryBlock< T >:
Collaboration graph
[legend]

Public Member Functions

 GenericMemoryBlock (const GenericMemoryBlock &)=delete
 
 GenericMemoryBlock (GenericMemoryBlock &&)=delete
 
GenericMemoryBlockoperator= (const GenericMemoryBlock &)=delete
 
GenericMemoryBlockoperator= (GenericMemoryBlock &&)=delete
 
uint64_t size () const noexcept override
 This function provides the size of the required memory for the underlying data. It is needed for the MemoryProvider to calculate the total size of memory. More...
 
uint64_t alignment () const noexcept override
 This function provides the alignment of the memory for the underlying data. This information is needed for the MemoryProvider. More...
 
template<typename... Targs>
cxx::optional< T * > emplace (Targs &&... args) noexcept
 A new element is constructed by forwarding the arguments to the constructor of T. If the MemoryBlock has a value then the destructor of T is called. More...
 
cxx::optional< T * > value () const noexcept
 This function enables the access to the underlying type. More...
 
- Public Member Functions inherited from iox::roudi::MemoryBlock
 MemoryBlock (const MemoryBlock &)=delete
 
 MemoryBlock (MemoryBlock &&)=delete
 
MemoryBlockoperator= (const MemoryBlock &)=delete
 
MemoryBlockoperator= (MemoryBlock &&)=delete
 
virtual uint64_t size () const noexcept=0
 This function provides the size of the required memory for the underlying data. It is needed for the MemoryProvider to calculate the total size of memory. More...
 
virtual uint64_t alignment () const noexcept=0
 This function provides the alignment of the memory for the underlying data. This information is needed for the MemoryProvider. More...
 
cxx::optional< void * > memory () const noexcept
 This function provides the pointer to the requested memory. More...
 

Protected Member Functions

void destroy () noexcept override
 The MemoryProvider calls this either when MemoryProvider::destroy is called or in its destructor. More...
 
- Protected Member Functions inherited from iox::roudi::MemoryBlock
virtual void destroy () noexcept=0
 The MemoryProvider calls this either when MemoryProvider::destroy is called or in its destructor. More...
 
virtual void onMemoryAvailable (cxx::not_null< void * > memory) noexcept
 This function is called once the memory is available and is therefore the earliest possibility to use the memory. More...
 

Friends

class MemoryProvider
 

Detailed Description

template<typename T>
class iox::roudi::GenericMemoryBlock< T >

The GenericMemoryBlock is an implementation of a MemoryBlock for a common use case.

Member Function Documentation

◆ alignment()

template<typename T >
uint64_t iox::roudi::GenericMemoryBlock< T >::alignment ( ) const
overridevirtualnoexcept

This function provides the alignment of the memory for the underlying data. This information is needed for the MemoryProvider.

Returns
the alignment of the underlying data.
Note
The alignment of the underlying type T

Implements iox::roudi::MemoryBlock.

◆ destroy()

template<typename T >
void iox::roudi::GenericMemoryBlock< T >::destroy ( )
overrideprotectedvirtualnoexcept

The MemoryProvider calls this either when MemoryProvider::destroy is called or in its destructor.

Note
This function can be called multiple times. Make sure that the implementation can handle this.
This will destroy the underlying type T

Implements iox::roudi::MemoryBlock.

◆ emplace()

template<typename T >
template<typename... Targs>
cxx::optional< T * > iox::roudi::GenericMemoryBlock< T >::emplace ( Targs &&...  args)
noexcept

A new element is constructed by forwarding the arguments to the constructor of T. If the MemoryBlock has a value then the destructor of T is called.

Parameters
[in]argsare perfectly forwarded to the constructor of T to perform a placement new
Returns
an optional pointer to the underlying type, cxx::nullopt_t if memory was not yet available

◆ size()

template<typename T >
uint64_t iox::roudi::GenericMemoryBlock< T >::size ( ) const
overridevirtualnoexcept

This function provides the size of the required memory for the underlying data. It is needed for the MemoryProvider to calculate the total size of memory.

Returns
the required memory as multiple of the alignment
Note
The size of the underlying type T

Implements iox::roudi::MemoryBlock.

◆ value()

template<typename T >
cxx::optional< T * > iox::roudi::GenericMemoryBlock< T >::value ( ) const
noexcept

This function enables the access to the underlying type.

Returns
an optional pointer to the underlying type, cxx::nullopt_t if value is not initialized

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