|
Minimal Dependency Injection Framework for C++
Single file library for implementing the dependency injection pattern
|
Injected instance of a service. More...
#include <dip.hpp>
Public Types | |
| typedef Service * | service_type |
| Type of the injected instances. | |
| typedef const Service * | const_service_type |
| Const type of the injected instances. | |
Public Member Functions | |
| instance () | |
| Retrieve an instance providing the service. | |
| ~instance () noexcept | |
| Remove the instance providing the service. | |
| service_type | operator-> () const noexcept |
| Access the instance providing the service. More... | |
| Service & | operator* () const noexcept |
| Get the instance providing the service. More... | |
| instance (const instance &)=delete | |
| instance (instance &&)=delete | |
| instance & | operator= (const instance &)=delete |
| instance & | operator= (instance &&)=delete |
Static Public Member Functions | |
| static void | inject (const Injector< Service > &injector) noexcept |
| Inject a service provider using a custom injector. More... | |
| template<class Provider , typename... _Args> | |
| static void | inject_singleton (_Args &&...__args) |
| Inject a service provider with singleton life cycle. More... | |
| template<class Provider , typename... _Args> | |
| static void | inject_thread_singleton (_Args &&...__args) |
| Inject a service provider with per-thread singleton life cycle. More... | |
| template<class Provider , typename... _Args> | |
| static void | inject_transient (_Args &&...__args) |
| Inject a service provider with transient life cycle. More... | |
| static void | clear_injection () noexcept |
| Clear the injected dependency for testing purposes. More... | |
Injected instance of a service.
| Service | Service to be injected |
|
inlinestaticnoexcept |
Clear the injected dependency for testing purposes.
|
inlinestaticnoexcept |
Inject a service provider using a custom injector.
| injector | Service injector |
|
inlinestatic |
Inject a service provider with singleton life cycle.
| Provider | Service provider |
| _Args | Constructor parameter types |
| __args | Constructor parameters |
|
inlinestatic |
Inject a service provider with per-thread singleton life cycle.
| Provider | Service provider |
| _Args | Constructor parameter types |
| __args | Constructor parameters |
|
inlinestatic |
Inject a service provider with transient life cycle.
| Provider | Service provider |
| _Args | Constructor parameter types |
| __args | Constructor parameters |
|
inlinenoexcept |
Get the instance providing the service.
|
inlinenoexcept |
Access the instance providing the service.