IServiceInstanceProvider#
-
struct IServiceInstanceProvider#
Subclassed by sb::di::details::ServiceInstanceProvider
Public Types
-
using Ptr = std::unique_ptr<IServiceInstanceProvider>#
Public Functions
-
virtual void init(ServiceProvider &serviceProvider) = 0#
Initializes instance provider.
-
virtual Ptr createScope() const = 0#
Create a scoped service instance provider.
Scoped service instance provider creates/holds its own scoped services
-
virtual const ServiceInstance &getInstance(TypeId serviceTypeId) = 0#
Returns service instance reference, might throw exception.
If service was not registered or was registered as transient, method throws exception
- Throws:
sb::di::ServiceNotFoundException –
-
virtual const ServiceInstance &getKeyedInstance(TypeId serviceTypeId, std::string_view serviceKey) = 0#
Returns service instance reference, might throw exception.
If service was not registered or was registered as transient, method throws exception
- Throws:
sb::di::ServiceNotFoundException –
-
virtual const ServiceInstance *tryGetInstance(TypeId serviceTypeId) = 0#
Returns service instance pointer.
If service was not registered or was registered as transient, method returns null
-
virtual const ServiceInstance *tryGetKeyedInstance(TypeId serviceTypeId, std::string_view serviceKey) = 0#
Returns service instance pointer.
If service was not registered or was registered as transient, method returns null
-
virtual const OneOrList<ServiceInstance> *tryGetInstances(TypeId serviceTypeId) = 0#
Returns service instances.
If service instance was not registered or was registered as transient, method returns null
-
virtual const OneOrList<ServiceInstance> *tryGetKeyedInstances(TypeId serviceTypeId, std::string_view serviceKey) = 0#
Returns service instances.
If service instance was not registered or was registered as transient, method returns null
-
virtual ServiceInstance createInstance(TypeId serviceTypeId) = 0#
Creates service instance unique pointer, might throw exception.
If service was not registered or was registered as scoped/singleton, method throw exception
- Throws:
sb::di::ServiceNotFoundException –
-
virtual ServiceInstance createKeyedInstance(TypeId serviceTypeId, std::string_view serviceKey) = 0#
Creates service instance unique pointer, might throw exception.
If service was not registered or was registered as scoped/singleton, method throw exception
- Throws:
sb::di::ServiceNotFoundException –
-
virtual ServiceInstance tryCreateInstance(TypeId serviceTypeId) = 0#
Creates service instance unique pointer, might be null.
If service was not registered or was registered as scoped/singleton, method returns invalid instance
-
virtual ServiceInstance tryCreateKeyedInstance(TypeId serviceTypeId, std::string_view serviceKey) = 0#
Creates service instance unique pointer, might be null.
If service was not registered or was registered as scoped/singleton, method returns invalid instance
-
virtual std::optional<OneOrList<ServiceInstance>> tryCreateInstances(TypeId serviceTypeId) = 0#
Creates service instances.
If service was not registered or was registered as scoped/singleton, method returns null option
-
virtual std::optional<OneOrList<ServiceInstance>> tryCreateKeyedInstances(TypeId serviceTypeId, std::string_view serviceKey) = 0#
Creates service instances.
If service was not registered or was registered as scoped/singleton, method returns null option
-
virtual ServiceInstance createInstanceInPlace(TypeId serviceTypeId) = 0#
Creates service instance in place, might throw exception.
If service was not registered or was registered as scoped/singleton, method throws exception
- Throws:
sb::di::ServiceNotFoundException –
-
virtual ServiceInstance createKeyedInstanceInPlace(TypeId serviceTypeId, std::string_view serviceKey) = 0#
Creates service instance in place, might throw exception.
If service was not registered or was registered as scoped/singleton, method throws exception
- Throws:
sb::di::ServiceNotFoundException –
-
virtual ServiceInstance tryCreateInstanceInPlace(TypeId serviceTypeId) = 0#
Creates service instance in place.
If service was not registered or was registered as scoped/singleton, method returns invalid instance
-
virtual ServiceInstance tryCreateKeyedInstanceInPlace(TypeId serviceTypeId, std::string_view serviceKey) = 0#
Creates service instance in place.
If service was not registered or was registered as scoped/singleton, method returns invalid instance
-
virtual ~IServiceInstanceProvider() = default#
-
using Ptr = std::unique_ptr<IServiceInstanceProvider>#