COMMS
Template library intended to help with implementation of communication protocols.
Loading...
Searching...
No Matches
Public Types | Static Public Member Functions | List of all members
comms::util::alloc::DynMemoryNoVirtualDestructor< TInterface, TAllMessages, TId, TDefaultType > Class Template Reference

#include "alloc.h"

Detailed Description

template<typename TInterface, typename TAllMessages, typename TId, typename TDefaultType = void>
class comms::util::alloc::DynMemoryNoVirtualDestructor< TInterface, TAllMessages, TId, TDefaultType >

Dynamic memory allocator for message types without virtual destructor.

Uses standard operator "new" to allocate and initialise requested object while using custom deleter.

Template Parameters
TInterfaceCommon interface class for all objects being allocated with this allocator.
TAllMessagesTuple of all messages types, object of which could be allocated.
TIdType of message ID
TDefaultTypeMessage type to cast to when correct type cannot be recognised. void means does not exist.

Public Types

using Ptr = std::unique_ptr< TInterface, Deleter >
 Smart pointer (std::unique_ptr) to the allocated object.
 

Static Public Member Functions

template<typename TObj , typename... TArgs>
static Ptr alloc (TId id, unsigned idx, TArgs &&... args)
 Allocation function.
 
static constexpr bool canAllocate ()
 Inquiry whether allocation is possible.
 

Member Function Documentation

◆ alloc()

template<typename TInterface , typename TAllMessages , typename TId , typename TDefaultType = void>
template<typename TObj , typename... TArgs>
static Ptr comms::util::alloc::DynMemoryNoVirtualDestructor< TInterface, TAllMessages, TId, TDefaultType >::alloc ( TId  id,
unsigned  idx,
TArgs &&...  args 
)
static

Allocation function.

Template Parameters
TObjType of the object being allocated, expected to be the same as or derived from TInterface.
TArgstypes of arguments to be passed to the constructor.
Parameters
[in]idNumeric ID of the message
[in]idxIndex of the message type among types with same ID provided in TAllMessages tuple.
[in]argsExtra arguments to be passed to allocated object's constructor.
Returns
Smart pointer to the allocated object.

◆ canAllocate()

template<typename TInterface , typename TAllMessages , typename TId , typename TDefaultType = void>
static constexpr bool comms::util::alloc::DynMemoryNoVirtualDestructor< TInterface, TAllMessages, TId, TDefaultType >::canAllocate ( )
staticconstexpr

Inquiry whether allocation is possible.

Returns
Always true.

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