Lumiera  0.pre.03
»edit your freedom«
LazyInit< PAR > Class Template Reference

#include "lib/lazy-init.hpp"

Description

template<class PAR = EmptyBase>
class lib::LazyInit< PAR >

Mix-in for lazy/delayed initialisation of an embedded functor.

This allows to keep the overall object (initially) copyable, while later preventing copy once the functor was »engaged«. Initially, only a »trap« is installed into the functor, invoking an initialisation closure on first use.

Definition at line 215 of file lazy-init.hpp.

Public Member Functions

template<class SIG , class INI , typename... ARGS>
 LazyInit (std::function< SIG > &targetFunctor, INI &&initialiser, ARGS &&...parentCtorArgs)
 prepare an initialiser to be activated on first use
 
 LazyInit (LazyInit const &ref)
 
 LazyInit (LazyInit &&rref)
 
template<class SIG >
void installEmptyInitialiser ()
 
template<class SIG , class INI >
void installInitialiser (std::function< SIG > &targetFunctor, INI &&initialiser)
 
bool isInit () const
 
LazyInitoperator= (LazyInit const &ref)
 
LazyInitoperator= (LazyInit &&rref)
 

Classes

struct  MarkDisabled
 

Protected Member Functions

template<typename... ARGS>
 LazyInit (MarkDisabled, ARGS &&...parentCtorArgs)
 

Private Types

template<class SIG >
using DelegateType = std::function< std::function< SIG > &(RawAddr)>
 
using HeapStorage = InPlaceBuffer< PlaceholderType >
 
using PendingInit = std::shared_ptr< HeapStorage >
 
using PlaceholderType = DelegateType< void(void)>
 

Private Member Functions

PendingInit const & __trapLocked (PendingInit const &init)
 
PendingInit && __trapLocked (PendingInit &&init)
 
template<class SIG , class INI >
DelegateType< SIG > buildInitialiserDelegate (std::function< SIG > &targetFunctor, INI &&initialiser)
 
template<class SIG >
DelegateType< SIG > emptyInitialiser ()
 
template<class SIG , class INI >
PendingInit prepareInitialiser (std::function< SIG > &targetFunctor, INI &&initialiser)
 

Static Private Member Functions

template<class SIG >
static DelegateType< SIG > * getPointerToDelegate (HeapStorage &buffer)
 
template<class SIG >
static std::function< SIG > maybeInvoke (PendingInit const &pendingInit, RawAddr location)
 

Private Attributes

PendingInit pendingInit_
 manage heap storage for a pending initialisation closure
 

Class Documentation

◆ lib::LazyInit::MarkDisabled

struct lib::LazyInit::MarkDisabled
+ Collaboration diagram for LazyInit< PAR >::MarkDisabled:

Constructor & Destructor Documentation

◆ LazyInit()

LazyInit ( MarkDisabled  ,
ARGS &&...  parentCtorArgs 
)
inlineprotected

allows derived classes to leave the initialiser deliberately disabled

Definition at line 256 of file lazy-init.hpp.

+ Inheritance diagram for LazyInit< PAR >:
+ Collaboration diagram for LazyInit< PAR >:

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