ServiceInstanceProvider¶
-
class ServiceInstanceProvider : public sb::di::IServiceInstanceProvider¶
Subclassed by sb::di::details::ServiceInstanceProviderRoot
Public Types
-
using Ptr = std::unique_ptr<ServiceInstanceProvider>¶
Public Functions
-
ServiceInstanceProvider(IServiceInstanceProviderRoot &root, ServiceProviderOptions options)¶
-
ServiceInstanceProvider(ServiceInstanceProvider&&) = delete¶
-
ServiceInstanceProvider(const ServiceInstanceProvider&) = delete¶
-
ServiceInstanceProvider &operator=(const ServiceInstanceProvider&) = delete¶
-
ServiceInstanceProvider &operator=(ServiceInstanceProvider&&) = delete¶
-
inline const ServiceProviderOptions &getOptions() const¶
-
virtual void init(ServiceProvider &serviceProvider) override¶
Initializes instance provider.
-
virtual IServiceInstanceProvider::Ptr createScope() const override¶
Create a scoped service instance provider.
Scoped service instance provider creates/holds its own scoped services
-
inline virtual std::recursive_mutex *tryGetSyncMutex() override¶
Get sync mutex.
Mutex can be used to synchronize service accesses between threads, can be null if synchronization is not needed
-
inline virtual const ServiceInstance &getInstance(const TypeId serviceTypeId) override¶
Returns service instance reference, might throw exception.
If service was not registered or was registered as transient, method throws exception
- Throws:
sb::di::ServiceNotFoundException –
-
inline virtual const ServiceInstance *tryGetInstance(const TypeId serviceTypeId) override¶
Returns service instance pointer.
If service was not registered or was registered as transient, method returns null
-
inline virtual const OneOrList<ServiceInstance> *tryGetInstances(const TypeId serviceTypeId) override¶
Returns service instances.
If service instance was not registered or was registered as transient, method returns null
-
inline virtual ServiceInstance createInstance(const TypeId serviceTypeId) override¶
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 –
-
inline virtual ServiceInstance tryCreateInstance(const TypeId serviceTypeId) override¶
Creates service instance unique pointer, might be null.
If service was not registered or was registered as scoped/singleton, method returns invalid instance
-
inline virtual OneOrList<ServiceInstance> tryCreateInstances(const TypeId serviceTypeId) override¶
Creates service instances.
If service was not registered or was registered as scoped/singleton, method returns null option
-
inline virtual ServiceInstance createInstanceInPlace(const TypeId serviceTypeId) override¶
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 –
-
inline virtual ServiceInstance tryCreateInstanceInPlace(const TypeId serviceTypeId) override¶
Creates service instance in place.
If service was not registered or was registered as scoped/singleton, method returns invalid instance
-
inline virtual const ServiceInstance &getKeyedInstance(const TypeId serviceTypeId, const std::string_view serviceKey) override¶
Returns service instance reference, might throw exception.
If service was not registered or was registered as transient, method throws exception
- Throws:
sb::di::ServiceNotFoundException –
-
inline virtual const ServiceInstance *tryGetKeyedInstance(const TypeId serviceTypeId, const std::string_view serviceKey) override¶
Returns service instance pointer.
If service was not registered or was registered as transient, method returns null
-
inline virtual const OneOrList<ServiceInstance> *tryGetKeyedInstances(const TypeId serviceTypeId, const std::string_view serviceKey) override¶
Returns service instances.
If service instance was not registered or was registered as transient, method returns null
-
inline virtual ServiceInstance createKeyedInstance(const TypeId serviceTypeId, const std::string_view serviceKey) override¶
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 –
-
inline virtual ServiceInstance tryCreateKeyedInstance(const TypeId serviceTypeId, const std::string_view serviceKey) override¶
Creates service instance unique pointer, might be null.
If service was not registered or was registered as scoped/singleton, method returns invalid instance
-
inline virtual OneOrList<ServiceInstance> tryCreateKeyedInstances(const TypeId serviceTypeId, const std::string_view serviceKey) override¶
Creates service instances.
If service was not registered or was registered as scoped/singleton, method returns null option
-
inline virtual ServiceInstance createKeyedInstanceInPlace(const TypeId serviceTypeId, const std::string_view serviceKey) override¶
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 –
-
inline virtual ServiceInstance tryCreateKeyedInstanceInPlace(const TypeId serviceTypeId, const std::string_view serviceKey) override¶
Creates service instance in place.
If service was not registered or was registered as scoped/singleton, method returns invalid instance
-
using Ptr = std::unique_ptr<ServiceInstanceProvider>¶