Lumiera 0.pre.04~rc.1
»edit your freedom«
Loading...
Searching...
No Matches
DependInject< SRV >::Local< MOC > Class Template Reference

#include "lib/depend-inject.hpp"

Description

template<class SRV>
template<class MOC = SRV>
class lib::DependInject< SRV >::Local< MOC >

Configuration handle for temporarily shadowing a dependency by a test mock instance.

This non-copyable (but movable) handle shall be planted within the immediate test context. It immediately stashes away the existing state and configuration from Depend<SRV>, but waits for actual invocation of the Depend<SRV>-front-end to create a heap-allocated instance of the MOC subclass, which it manages and exposes like a smart-ptr. When the handle goes out of scope, the original state and configuration is restored

Definition at line 281 of file depend-inject.hpp.

Public Member Functions

 Local ()
 
template<class FUN >
 Local (FUN &&_buildInstance)
 
 ~Local ()
 
 operator bool () const
 
MOC & triggerCreate ()
 trigger lazy service object instantiation
 
MOC & operator* () const
 
MOC * operator-> () const
 

Private Attributes

std::unique_ptr< MOC > mock_
 
SRV * origInstance_
 
Factory origFactory_
 

Additional Inherited Members

- Private Member Functions inherited from MoveOnly
 ~MoveOnly ()=default
 
 MoveOnly ()=default
 
 MoveOnly (MoveOnly &&)=default
 
 MoveOnly (MoveOnly const &)=delete
 
MoveOnlyoperator= (MoveOnly &&)=delete
 
MoveOnlyoperator= (MoveOnly const &)=delete
 

Constructor & Destructor Documentation

◆ Local() [1/2]

template<class SRV >
template<class MOC = SRV>
Local ( )
inline

Definition at line 290 of file depend-inject.hpp.

◆ Local() [2/2]

template<class SRV >
template<class MOC = SRV>
template<class FUN >
Local ( FUN &&  _buildInstance)
inlineexplicit

Definition at line 296 of file depend-inject.hpp.

References DependInject< SRV >::Local< MOC >::mock_, DependInject< SRV >::Local< MOC >::origFactory_, DependInject< SRV >::Local< MOC >::origInstance_, and DependInject< SRV >::temporarilyInstallAlternateFactory().

+ Here is the call graph for this function:

◆ ~Local()

template<class SRV >
template<class MOC = SRV>
~Local ( )
inline

Definition at line 308 of file depend-inject.hpp.

References DependInject< SRV >::Local< MOC >::origFactory_, DependInject< SRV >::Local< MOC >::origInstance_, and DependInject< SRV >::restoreOriginalFactory().

+ Here is the call graph for this function:

Member Function Documentation

◆ operator bool()

template<class SRV >
template<class MOC = SRV>
operator bool ( ) const
inlineexplicit

Definition at line 314 of file depend-inject.hpp.

References DependInject< SRV >::Local< MOC >::mock_.

◆ triggerCreate()

template<class SRV >
template<class MOC = SRV>
MOC & triggerCreate ( )
inline

trigger lazy service object instantiation

Definition at line 321 of file depend-inject.hpp.

References DependInject< SRV >::Local< MOC >::mock_.

Referenced by ViewSpecDSL_test::verify_genericInvocation(), ElementAccess_test::verify_simpleAccess(), and ElementAccess_test::verify_standardUsage().

+ Here is the caller graph for this function:

◆ operator*()

template<class SRV >
template<class MOC = SRV>
MOC & operator* ( ) const
inline

Definition at line 329 of file depend-inject.hpp.

References DependInject< SRV >::Local< MOC >::mock_.

◆ operator->()

template<class SRV >
template<class MOC = SRV>
MOC * operator-> ( ) const
inline

Definition at line 336 of file depend-inject.hpp.

References DependInject< SRV >::Local< MOC >::mock_.

Member Data Documentation

◆ mock_

◆ origInstance_

template<class SRV >
template<class MOC = SRV>
SRV* origInstance_
private

◆ origFactory_

template<class SRV >
template<class MOC = SRV>
Factory origFactory_
private
+ Inheritance diagram for DependInject< SRV >::Local< MOC >:
+ Collaboration diagram for DependInject< SRV >::Local< MOC >:

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