|
Minimal Dependency Injection Framework for C++
Single file library for implementing the dependency injection pattern
|
Set of injected instances of a service. More...
#include <dip.hpp>
Public Types | |
| typedef Service * | service_type |
| Type of the instances of the service provider. | |
| typedef const Service * | const_service_type |
| Const type of the instances of the service provider. | |
| using | iterator = std::vector< service_type >::iterator |
| Forward iterator. | |
| using | const_iterator = std::vector< service_type >::const_iterator |
| Const forward iterator. | |
| using | reverse_iterator = std::vector< service_type >::reverse_iterator |
| Reverse iterator. | |
| using | const_reverse_iterator = std::vector< service_type >::const_reverse_iterator |
| Const reverse iterator. | |
Public Member Functions | |
| instance_set () | |
| Retrieve a set of instances providing the service. | |
| ~instance_set () noexcept | |
| Remove the set of instances providing the service. | |
| instance_set (const instance_set &)=delete | |
| instance_set (instance_set &&)=delete | |
| instance_set & | operator= (const instance_set &)=delete |
| instance_set & | operator= (instance_set &&)=delete |
| constexpr std::size_t | size () const noexcept |
| Get the count of instances injected into the service. More... | |
| service_type | operator[] (std::size_t index) |
| Get a service provider instance in the set. More... | |
| const_service_type | operator[] (std::size_t index) const |
| Get a service provider instance in the set. More... | |
| service_type | at (std::size_t index) |
| Get a service provider instance in the set. More... | |
| const_service_type | at (std::size_t index) const |
| Get a service provider instance in the set. More... | |
| iterator | begin () |
| returns an iterator to the beginning More... | |
| const_iterator | begin () const |
| returns an iterator to the beginning More... | |
| const_iterator | cbegin () const noexcept |
| returns an iterator to the end More... | |
| iterator | end () |
| returns an iterator to the end More... | |
| const_iterator | end () const |
| returns an iterator to the end More... | |
| const_iterator | cend () const noexcept |
| returns an iterator to the end More... | |
| reverse_iterator | rbegin () |
| returns a reverse iterator to the beginning More... | |
| const_reverse_iterator | rbegin () const |
| returns a reverse iterator to the beginning More... | |
| const_reverse_iterator | crbegin () const noexcept |
| returns a reverse iterator to the beginning More... | |
| reverse_iterator | rend () |
| returns a reverse iterator to the end More... | |
| const_reverse_iterator | rend () const |
| returns a reverse iterator to the end More... | |
| const_reverse_iterator | crend () const noexcept |
| returns a reverse iterator to the end More... | |
Static Public Member Functions | |
| static void | add (const Injector< Service > &injector) noexcept |
| Inject a service provider using a custom injector. More... | |
| template<class Provider , typename... _Args> | |
| static void | add_singleton (_Args &&...__args) |
| Inject a service provider with singleton life cycle. More... | |
| template<class Provider , typename... _Args> | |
| static void | add_thread_singleton (_Args &&...__args) |
| Inject a service provider with per-thread singleton life cycle. More... | |
| template<class Provider , typename... _Args> | |
| static void | add_transient (_Args &&...__args) |
| Inject a service provider with transient life cycle. More... | |
| static void | clear_injections () noexcept |
| Clear all the injected dependencies for testing purposes. More... | |
Set of injected instances of a service.
| Service | Service to be injected |
|
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 |
|
inline |
Get a service provider instance in the set.
| index | Index of the service provider instance |
|
inline |
Get a service provider instance in the set.
| index | Index of the service provider instance |
|
inline |
returns an iterator to the beginning
|
inline |
returns an iterator to the beginning
|
inlinenoexcept |
returns an iterator to the end
|
inlinenoexcept |
returns an iterator to the end
|
inlinestaticnoexcept |
Clear all the injected dependencies for testing purposes.
|
inlinenoexcept |
returns a reverse iterator to the beginning
|
inlinenoexcept |
returns a reverse iterator to the end
|
inline |
returns an iterator to the end
|
inline |
returns an iterator to the end
|
inline |
Get a service provider instance in the set.
| index | Index of the service provider instance |
|
inline |
Get a service provider instance in the set.
| index | Index of the service provider instance |
|
inline |
returns a reverse iterator to the beginning
|
inline |
returns a reverse iterator to the beginning
|
inline |
returns a reverse iterator to the end
|
inline |
returns a reverse iterator to the end
|
inlineconstexprnoexcept |
Get the count of instances injected into the service.