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 std::recursive_mutex *tryGetSyncMutex() = 0¶
Get sync mutex.
Mutex can be used to synchronize service accesses between threads, can be null if synchronization is unnecessary
-
virtual const ServiceInstance &getInstance(TypeId serviceTypeId) = 0¶
Returns service instance reference, might throw exception.
If the 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 the 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 the 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 the 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 the 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 the 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 the 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 the service was not registered or was registered as scoped/singleton, method returns invalid instance
-
virtual OneOrList<ServiceInstance> tryCreateInstances(TypeId serviceTypeId) = 0¶
Creates service instances.
If the service was not registered or was registered as scoped/singleton, method returns null option
-
virtual OneOrList<ServiceInstance> tryCreateKeyedInstances(TypeId serviceTypeId, std::string_view serviceKey) = 0¶
Creates service instances.
If the 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 the 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 the 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 the 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 the service was not registered or was registered as scoped/singleton, method returns invalid instance
-
virtual ~IServiceInstanceProvider() = default¶
-
using Ptr = std::unique_ptr<IServiceInstanceProvider>¶