Lumiera
0.pre.03
»edit your freedom«
|
#include "lib/depend-inject.hpp"
This framework allows to (re)configure the lib::Depend front-end for dependency-injection.
By default, Depend<TY>
will create a singleton instance of TY
lazily, on demand. When instantiating one of the configuration handles provided here – prior to anyone retrieving the instance through Depend<TY>
– this default (singleton) behaviour can be reconfigured in various ways, without the client being aware of it:
Depend<TY>
front-end. When the service is shut down, clients will receive an exception on access.TY
mentioned in Depend<TY>
, an implementation subclass can be specified, optionally with a closure for the actual creation of this subclass singleton type, which still happens lazily, on demandaccess point to reconfigure dependency injection on a per type base
Definition at line 148 of file depend-inject.hpp.
Static Public Member Functions | |
template<class SUB > | |
static void | useSingleton () |
configure dependency-injection for type SRV to build a subclass singleton. More... | |
template<class FUN > | |
static void | useSingleton (FUN &&ctor) |
configure dependency-injection for type SRV to manage a subclass singleton, which is created lazily on demand by invoking the given builder function. More... | |
Classes | |
class | Local |
Configuration handle for temporarily shadowing a dependency by a test mock instance. More... | |
class | ServiceInstance |
Configuration handle to expose a service implementation through the Depend<SRV> front-end. More... | |
struct | SubclassFactoryType |
Friends | |
template<class MOC > | |
class | Local |
template<class IMP > | |
class | ServiceInstance |
Private Types | |
using | Factory = typename Depend< SRV >::Factory |
using | Lock = typename Depend< SRV >::Lock |
struct lib::DependInject::SubclassFactoryType |
|
inlinestatic |
configure dependency-injection for type SRV to build a subclass singleton.
SUB | concrete subclass type to build on demand when invoking Depend<SRV> |
error::Logic | (LUMIERA_ERROR_LIFECYCLE) when the default factory has already been invoked at the point when calling this (re)configuration function. |
Definition at line 163 of file depend-inject.hpp.
|
inlinestatic |
configure dependency-injection for type SRV to manage a subclass singleton, which is created lazily on demand by invoking the given builder function.
Depend<Subclass>
is installed into Depend<SRV>
ctor | functor to create a heap allocated instance of the subclass |
error::Logic | (LUMIERA_ERROR_LIFECYCLE) when the default factory has already been invoked at the point when calling this (re)configuration function. |
Definition at line 179 of file depend-inject.hpp.