Lumiera  0.pre.03
»edit your freedom«
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. More...
 
template<typename... ARGS>
IMP & createInstance (ARGS &&...ctorArgs)
 
 operator bool () const
 
IMP & operator* () const
 
IMP * operator-> () const
 
void shutdown () noexcept
 

Private Attributes

std::unique_ptr< IMP > instance_
 

Additional Inherited Members

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

Constructor & Destructor Documentation

◆ ServiceInstance()

ServiceInstance ( StartMode  )
inline

create in deactivated state.

Can be activated later

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

+ 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: