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

#include "lib/depend-inject.hpp"

Description

template<class SRV>
template<class IMP = SRV>
class lib::DependInject< SRV >::ServiceInstance< IMP >

Configuration handle to expose a service implementation through the Depend<SRV> front-end.

This non-copyable (but movable) handle shall be planted within the context operating the service to be exposed. It will immediately create (in RAII style) and manage a heap-allocated instance of the subclass IMP and expose a baseclass pointer to this specific instance through Depend<SRV>. Moreover, the implementation subclass can be accessed through this handle, which acts as smart-ptr. When the handle goes out of scope, the implementation instance is destroyed and the access through Depend<SRV> is closed and inhibited, to prevent on-demand creation of a baseclass SRV singleton.

Template Parameters
IMPconcrete service implementation subclass to build, manage and expose.
Exceptions
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 202 of file depend-inject.hpp.

Public Types

enum  StartMode { NOT_YET_STARTED }
 

Public Member Functions

template<typename... ARGS>
 ServiceInstance (ARGS &&...ctorArgs)
 
 ServiceInstance (StartMode)
 create in deactivated state.
 
 ~ServiceInstance ()
 
template<typename... ARGS>
IMP & createInstance (ARGS &&...ctorArgs)
 
void shutdown () noexcept
 
 operator bool () const
 
IMP & operator* () const
 
IMP * operator-> () const
 

Private Attributes

std::unique_ptr< IMP > instance_
 

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

◆ ServiceInstance() [1/2]

template<class SRV >
template<class IMP = SRV>
template<typename... ARGS>
ServiceInstance ( ARGS &&...  ctorArgs)
inline

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

References DependInject< SRV >::activateServiceAccess(), and DependInject< SRV >::ServiceInstance< IMP >::instance_.

+ Here is the call graph for this function:

◆ ServiceInstance() [2/2]

template<class SRV >
template<class IMP = SRV>
ServiceInstance ( StartMode  )
inline

create in deactivated state.

Can be activated later

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

◆ ~ServiceInstance()

template<class SRV >
template<class IMP = SRV>
~ServiceInstance ( )
inline

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

References DependInject< SRV >::ServiceInstance< IMP >::shutdown().

+ Here is the call graph for this function:

Member Enumeration Documentation

◆ StartMode

template<class SRV >
template<class IMP = SRV>
enum StartMode
Enumerator
NOT_YET_STARTED 

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

Member Function Documentation

◆ createInstance()

template<class SRV >
template<class IMP = SRV>
template<typename... ARGS>
IMP & createInstance ( ARGS &&...  ctorArgs)
inline

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

References DependInject< SRV >::activateServiceAccess(), and DependInject< SRV >::ServiceInstance< IMP >::instance_.

Referenced by OutputDirector::connectUp().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ shutdown()

template<class SRV >
template<class IMP = SRV>
void shutdown ( )
inlinenoexcept

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

References DependInject< SRV >::deactivateServiceAccess(), and DependInject< SRV >::ServiceInstance< IMP >::instance_.

Referenced by DispatcherLoop::~DispatcherLoop(), DependInject< SRV >::ServiceInstance< IMP >::~ServiceInstance(), OutputDirector::bringDown(), and DispatcherLoop::requestStop().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator bool()

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

◆ operator*()

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

◆ operator->()

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

Member Data Documentation

◆ instance_

+ Inheritance diagram for DependInject< SRV >::ServiceInstance< IMP >:
+ Collaboration diagram for DependInject< SRV >::ServiceInstance< IMP >:

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