|
solinject
1.0.0
C++17 Dependency Injection header-only library
|
Registered DI services collection. More...
#include <RegisteredServices.hpp>
Public Types | |
| template<class T > | |
| using | Factory = typename IServiceTyped< T >::Factory |
| Factory function that accepts a reference to a DI container and returns a pointer to an instance of a service. More... | |
| template<class T > | |
| using | ServicePtr = typename IServiceTyped< T >::ServicePtr |
| Pointer to an instance of a service. More... | |
| using | DIServicePtr = std::shared_ptr< IService > |
| Pointer to a DI service instance. | |
| using | RegisteredServicesMap = std::map< std::type_index, std::vector< DIServicePtr > > |
| Map of registered DI services. | |
Public Member Functions | |
| RegisteredServices () | |
| Default constructor. | |
| RegisteredServices (RegisteredServicesMap services) | |
| Constructor. More... | |
| RegisteredServices (const RegisteredServices &other) | |
| Copy constructor. | |
| RegisteredServices (RegisteredServices &&other) | |
| Move constructor. | |
| RegisteredServices & | operator= (RegisteredServices other) |
| Copy-assignment operator. | |
| RegisteredServices & | operator= (RegisteredServices &&other) |
| Move-assignment operator. | |
| void | Merge (RegisteredServices other) |
| Merges other RegisteredServices instance into this instance. More... | |
| template<class T > | |
| void | RegisterSingletonService (Factory< T > factory) |
| Registers a service with singleton lifetime. More... | |
| template<class T > | |
| void | RegisterSingletonService (ServicePtr< T > instance) |
| Registers a service with singleton lifetime. More... | |
| template<class T > | |
| void | RegisterTransientService (Factory< T > factory) |
| Registers a service with transient lifetime. More... | |
| template<class T > | |
| void | RegisterSharedService (Factory< T > factory) |
| Registers a service with shared lifetime. More... | |
| void | RegisterService (std::type_index type, DIServicePtr diService) |
| Registers a service. More... | |
| template<class T > | |
| ServicePtr< T > | GetRequiredService (const Container &container) const |
| Resolves a required service. More... | |
| template<class T > | |
| ServicePtr< T > | GetService (const Container &container) const |
| Resolves an optional service. More... | |
| template<class T > | |
| std::vector< ServicePtr< T > > | GetServices (const Container &container) const |
| Resolves services. More... | |
Friends | |
| void | swap (RegisteredServices &a, RegisteredServices &b) |
| Swaps two RegisteredServices instances. | |
Registered DI services collection.
| using sol::di::impl::RegisteredServices::Factory = typename IServiceTyped<T>::Factory |
Factory function that accepts a reference to a DI container and returns a pointer to an instance of a service.
| T | service type |
| using sol::di::impl::RegisteredServices::ServicePtr = typename IServiceTyped<T>::ServicePtr |
Pointer to an instance of a service.
| T | service type |
|
inline |
Constructor.
| services | map of DI services |
|
inline |
Resolves a required service.
| T | service type |
| [in] | container | DI container |
| sol::di::exc::ServiceNotRegisteredException |
|
inline |
Resolves an optional service.
| T | service type |
| [in] | container | DI container |
nullptr if the service is not registered
|
inline |
Resolves services.
| T | the service type |
| [in] | container | DI container |
|
inline |
Merges other RegisteredServices instance into this instance.
| other | other RegisteredServices instance |
|
inline |
Registers a service.
| type | service type |
| diService | pointer to a DI service instance |
|
inline |
Registers a service with shared lifetime.
| factory | factory function |
| T | service type |
|
inline |
Registers a service with singleton lifetime.
| factory | factory function |
| T | service type |
|
inline |
Registers a service with singleton lifetime.
| instance | pointer to an instance of the service |
| T | service type |
|
inline |
Registers a service with transient lifetime.
| factory | factory function |
| T | service type |