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

#include "alloc.h"

Detailed Description

template<typename TInterface, std::size_t TSize, typename TAllTypes = std::tuple<TInterface>>
class comms::util::alloc::InPlacePool< TInterface, TSize, TAllTypes >

In-place object pool allocator.

Similar to InPlaceSingle allocator, but allows multiple allocations at the same time, limited by TSize template parameter.

Template Parameters
TInterfaceCommon interface class for all objects being allocated with this allocator.
TSizeNumber of objects this allocator is allowed to allocate.
TAllTypesAll the possible types that can be allocated with this allocator bundled in std::tuple.

Public Types

using Ptr = typename PoolElem::Ptr
 Smart pointer (std::unique_ptr) to the allocated object.
 

Public Member Functions

template<typename TObj , typename... TArgs>
Ptr alloc (TArgs &&... args)
 Allocation function.
 
template<typename TObj >
Ptr wrap (TObj *obj)
 Function used to wrap raw pointer into a smart one.
 

Member Typedef Documentation

◆ Ptr

template<typename TInterface , std::size_t TSize, typename TAllTypes = std::tuple<TInterface>>
using comms::util::alloc::InPlacePool< TInterface, TSize, TAllTypes >::Ptr = typename PoolElem::Ptr

Smart pointer (std::unique_ptr) to the allocated object.

Same as InPlaceSingle::Ptr;

Member Function Documentation

◆ alloc()

template<typename TInterface , std::size_t TSize, typename TAllTypes = std::tuple<TInterface>>
template<typename TObj , typename... TArgs>
Ptr comms::util::alloc::InPlacePool< TInterface, TSize, TAllTypes >::alloc ( TArgs &&...  args)

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]argsExtra arguments to be passed to allocated object's constructor.
Returns
Smart pointer to the allocated object.
Precondition
If TObj is NOT the same as TInterface, i.e. TInterface is a base class of TObj, then TInterface must have virtual destructor.

◆ wrap()

template<typename TInterface , std::size_t TSize, typename TAllTypes = std::tuple<TInterface>>
template<typename TObj >
Ptr comms::util::alloc::InPlacePool< TInterface, TSize, TAllTypes >::wrap ( TObj *  obj)

Function used to wrap raw pointer into a smart one.

Template Parameters
Typeof the object, expected to be the same as or derived from TInterface.
Parameters
[in]objPointer to previously allocated object.
Returns
Smart pointer to the wrapped object.

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