Lumiera  0.pre.03
»edit your freedom«
DependencyFactory< OBJ > Class Template Reference

#include "lib/depend.hpp"

Description

template<class OBJ>
class lib::DependencyFactory< OBJ >

Helper to abstract creation and lifecycle of a dependency.

Holds a configurable constructor function and optionally an automatically invoked deleter function.

Note
DependencyFactory can be declared friend to indicate the expected way to invoke an otherwise private ctor. This is a classical idiom for singletons.
See also
lib::Depend
lib::DependInject

Definition at line 134 of file depend.hpp.

Public Member Functions

template<typename FUN >
void atDestruction (FUN &&additionalAction)
 
OBJ * buildTarget ()
 
template<typename FUN >
void defineCreator (FUN &&ctor)
 
template<typename FUN >
void defineCreatorAndManage (FUN &&ctor)
 
void disable ()
 
void transferDefinition (DependencyFactory &&source)
 

Public Attributes

ZombieCheck zombieCheck {util::typeStr<OBJ>()}
 

Classes

struct  canDefaultConstruct
 metafunction: can we instantiate the desired object here? More...
 

Private Types

using Creator = std::function< OBJ *()>
 
using Deleter = std::function< void()>
 

Private Member Functions

OBJ * buildAndManage ()
 
- Private Member Functions inherited from NonCopyable
 NonCopyable (NonCopyable const &)=delete
 
NonCopyableoperator= (NonCopyable const &)=delete
 

Static Private Member Functions

template<class X , typename = decltype(X())>
static std::true_type __try_instantiate (int)
 
template<class >
static std::false_type __try_instantiate (...)
 
template<class TAR >
static meta::enable_if< canDefaultConstruct< TAR >, TAR *> buildInstance ()
 
template<class ABS >
static meta::enable_if< std::is_abstract< ABS >, ABS *> buildInstance ()
 
template<class ABS >
static meta::disable_if< std::__or_< std::is_abstract< ABS >, canDefaultConstruct< ABS > >, ABS *> buildInstance ()
 

Private Attributes

Creator creator_
 
Deleter deleter_
 
+ Inheritance diagram for DependencyFactory< OBJ >:
+ Collaboration diagram for DependencyFactory< OBJ >:

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