Template Class GenericMemoryBlock
Defined in File generic_memory_block.hpp
Inheritance Relationships
Base Type
public iox::roudi::MemoryBlock(Class MemoryBlock)
Class Documentation
-
template<typename T>
class GenericMemoryBlock : public iox::roudi::MemoryBlock The GenericMemoryBlock is an implementation of a MemoryBlock for a common use case.
Public Functions
-
GenericMemoryBlock() noexcept = default
-
~GenericMemoryBlock() noexcept
-
GenericMemoryBlock(const GenericMemoryBlock&) = delete
-
GenericMemoryBlock(GenericMemoryBlock&&) = delete
-
GenericMemoryBlock &operator=(const GenericMemoryBlock&) = delete
-
GenericMemoryBlock &operator=(GenericMemoryBlock&&) = delete
-
virtual 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.
Note
The size of the underlying type T
- Returns:
the required memory as multiple of the alignment
-
virtual 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.
Note
The alignment of the underlying type T
- Returns:
the alignment of the underlying data.
-
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.
- Parameters:
args – [in] are 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
Protected Functions
-
virtual void destroy() noexcept override
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.
Note
This will destroy the underlying type T
-
GenericMemoryBlock() noexcept = default