ServiceDescriber#
-
class ServiceDescriber#
This is helper factory class for constructing ServiceDescriptor.
Public Static Functions
-
template<class TService, class TImplementation = TService>
static inline ServiceDescriptor describeSingleton()# Creates ServiceDescriptor.
Creates service descriptor with: lifetime - singleton, serviceTypeId - typeid(TService), implementationTypeId - typeid(TImplementation), factory - default factory using TImplementation constructor
Example:
ServiceDescriptor descriptor1 = ServiceDescriber::describeSingleton<TestClass>(); ServiceDescriptor descriptor2 = ServiceDescriber::describeSingleton<BaseClass, ImplementationClass>();
See also
Constructor requirements
- Template Parameters:
TService – base service type
TImplementation – service implementation type must inherit from TService and must have one constructor
-
template<class TService, class TImplementation = TService>
static inline ServiceDescriptor describeScoped()# Creates ServiceDescriptor.
Creates service descriptor with: lifetime - scoped, serviceTypeId - typeid(TService), implementationTypeId - typeid(TImplementation), factory - default factory using TImplementation constructor
Example:
ServiceDescriptor descriptor1 = ServiceDescriber::describeScoped<TestClass>(); ServiceDescriptor descriptor2 = ServiceDescriber::describeScoped<BaseClass, ImplementationClass>();
See also
Constructor requirements
- Template Parameters:
TService – base service type
TImplementation – service implementation type must inherit from TService and must have one constructor
-
template<class TService, class TImplementation = TService>
static inline ServiceDescriptor describeTransient()# Creates ServiceDescriptor.
Creates service descriptor with: lifetime - transient, serviceTypeId - typeid(TService), implementationTypeId - typeid(TImplementation), factory - default factory using TImplementation constructor
Example:
ServiceDescriptor descriptor1 = ServiceDescriber::describeTransient<TestClass>(); ServiceDescriptor descriptor2 = ServiceDescriber::describeTransient<BaseClass, ImplementationClass>();
See also
Constructor requirements
- Template Parameters:
TService – base service type
TImplementation – service implementation type must inherit from TService and must have one constructor
-
template<class TService, class TImplementation = TService>
static inline ServiceDescriptor describe(ServiceLifeTime lifetime)# Creates ServiceDescriptor.
Creates service descriptor with: lifetime - given lifetime, serviceTypeId - typeid(TService), implementationTypeId - typeid(TImplementation), factory - default factory using TImplementation constructor
Example:
ServiceDescriptor descriptor1 = ServiceDescriber::describe<TestClass>(ServiceLifeTime::scoped()); ServiceDescriptor descriptor2 = ServiceDescriber::describe<BaseClass, ImplementationClass>(ServiceLifeTime::transient());
See also
Constructor requirements
- Template Parameters:
TService – base service type
TImplementation – service implementation type must inherit from TService and must have one constructor
-
template<class TService, class TImplementation = TService>
static inline ServiceDescriptor describeSingleton(TImplementation &service)# Creates ServiceDescriptor.
Creates service descriptor with: lifetime - singleton, serviceTypeId - typeid(TService), implementationTypeId - typeid(TImplementation), factory - factory with external service pointner
Example:
TestClass test; ServiceDescriptor descriptor1 = ServiceDescriber::describeSingleton<TestClass>(test); ImplementationClass implementation; ServiceDescriptor descriptor = ServiceDescriber::describeSingleton<BaseClass, ImplementationClass>(implementation);
- Template Parameters:
TService – base service type
TImplementation – service implementation type must inherit from TService and must have one constructor
-
template<class TService, class TImplementation = TService>
static inline ServiceDescriptor describeSingleton(TImplementation *service)# Creates ServiceDescriptor.
Creates service descriptor with: lifetime - singleton, serviceTypeId - typeid(TService), implementationTypeId - typeid(TImplementation), factory - factory with external service pointner
Example:
TestClass test; ServiceDescriptor descriptor1 = ServiceDescriber::describeSingleton<TestClass>(&test); ImplementationClass implementation; ServiceDescriptor descriptor = ServiceDescriber::describeSingleton<BaseClass, ImplementationClass>(&implementation);
- Template Parameters:
TService – base service type
TImplementation – service implementation type must inherit from TService and must have one constructor
-
template<class TService, class FactoryFcn>
static inline ServiceDescriptor describeSingletonFrom(FactoryFcn factory)# Creates ServiceDescriptor.
Creates service descriptor with: lifetime - singleton, serviceTypeId - typeid(TService), implementationTypeId - extracted from factory return type, factory - default factory using FactoryFcn factory functor
Example:
ServiceDescriptor descriptor = ServiceDescriber::describeSingletonFrom<BaseClass>( []() { return std::make_unique<ImplementationClass>(); });
See also
Constructor requirements
- Template Parameters:
TService – base service type
FactoryFcn – is factory functor with this sheme: (const ServiceDescriptor&) -> std::unique_ptr<TImplementation> (argument is optional), functor must be copyable and movable, implementation type must inherit from TService and must have one constructor
-
template<class TService, class FactoryFcn>
static inline ServiceDescriptor describeScopedFrom(FactoryFcn factory)# Creates ServiceDescriptor.
Creates service descriptor with: lifetime - scoped, serviceTypeId - typeid(TService), implementationTypeId - extracted from factory return type, factory - default factory using FactoryFcn factory functor
Example:
ServiceDescriptor descriptor = ServiceDescriber::describeScopedFrom<BaseClass>( []() { return std::make_unique<ImplementationClass>(); });
See also
Constructor requirements
- Template Parameters:
TService – base service type
FactoryFcn – is factory functor with this sheme: (const ServiceDescriptor&) -> std::unique_ptr<TImplementation> (argument is optional), functor must be copyable and movable, implementation type must inherit from TService and must have one constructor
-
template<class TService, class FactoryFcn>
static inline ServiceDescriptor describeTransientFrom(FactoryFcn factory)# Creates ServiceDescriptor.
Creates service descriptor with: lifetime - transient, serviceTypeId - typeid(TService), implementationTypeId - extracted from factory return type, factory - default factory using FactoryFcn factory functor
Example:
ServiceDescriptor descriptor = ServiceDescriber::describeTransientFrom<BaseClass>( []() { return std::make_unique<ImplementationClass>(); });
See also
Constructor requirements
- Template Parameters:
TService – base service type
FactoryFcn – is factory functor with this sheme: (const ServiceDescriptor&) -> std::unique_ptr<TImplementation> (argument is optional), functor must be copyable and movable, implementation type must inherit from TService and must have one constructor
-
template<class TService, class FactoryFcn>
static inline ServiceDescriptor describeFrom(ServiceLifeTime lifetime, FactoryFcn factoryFcn)# Creates ServiceDescriptor.
Creates service descriptor with: lifetime - given service lifetime, serviceTypeId - typeid(TService), implementationTypeId - extracted from factory return type, factory - default factory using FactoryFcn factory functor
Example:
ServiceDescriptor descriptor = ServiceDescriber::describeFrom<BaseClass>( []() { return std::make_unique<ImplementationClass>(); }, ServiceLifeTime::scoped());
See also
Constructor requirements
- Template Parameters:
TService – base service type
FactoryFcn – is factory functor with this sheme: (const ServiceDescriptor&) -> std::unique_ptr<TImplementation> (argument is optional), functor must be copyable and movable, implementation type must inherit from TService and must have one constructor
-
template<class FactoryFcn>
static inline ServiceDescriptor describeSingletonFrom(FactoryFcn factory)# Creates ServiceDescriptor.
Creates service descriptor with: lifetime - singleton, serviceTypeId - extracted from factory return type, implementationTypeId - extracted from factory return type, factory - default factory using FactoryFcn factory functor
Example:
ServiceDescriptor descriptor = ServiceDescriber::describeSingletonFrom( [](const ServiceDescriptor &) { return std::make_unique<TestClass>(); });
See also
Constructor requirements
- Template Parameters:
FactoryFcn – is factory functor with this sheme: (const ServiceDescriptor&) -> std::unique_ptr<TImplementation> (argument is optional), functor must be copyable and movable, implementation type must have one constructor
-
template<class FactoryFcn>
static inline ServiceDescriptor describeScopedFrom(FactoryFcn factory)# Creates ServiceDescriptor.
Creates service descriptor with: lifetime - scoped, serviceTypeId - extracted from factory return type, implementationTypeId - extracted from factory return type, factory - default factory using FactoryFcn factory functor
Example:
ServiceDescriptor descriptor = ServiceDescriber::describeScopedFrom( [](const ServiceDescriptor &) { return std::make_unique<TestClass>(); });
See also
Constructor requirements
- Template Parameters:
FactoryFcn – is factory functor with this sheme: (const ServiceDescriptor&) -> std::unique_ptr<TImplementation> (argument is optional), functor must be copyable and movable, implementation type must have one constructor
-
template<class FactoryFcn>
static inline ServiceDescriptor describeTransientFrom(FactoryFcn factory)# Creates ServiceDescriptor.
Creates service descriptor with: lifetime - transient, serviceTypeId - extracted from factory return type, implementationTypeId - extracted from factory return type, factory - default factory using FactoryFcn factory functor
Example:
ServiceDescriptor descriptor = ServiceDescriber::describeTransientFrom( [](const ServiceDescriptor &) { return std::make_unique<TestClass>(); });
See also
Constructor requirements
- Template Parameters:
FactoryFcn – is factory functor with this sheme: (const ServiceDescriptor&) -> std::unique_ptr<TImplementation> (argument is optional), functor must be copyable and movable, implementation type must have one constructor
-
template<class FactoryFcn>
static inline ServiceDescriptor describeFrom(ServiceLifeTime lifetime, FactoryFcn factoryFcn)# Creates ServiceDescriptor.
Creates service descriptor with: lifetime - given service lifetime, serviceTypeId - extracted from factory return type, implementationTypeId - extracted from factory return type, factory - default factory using FactoryFcn factory functor
Example:
ServiceDescriptor descriptor = ServiceDescriber::describeFrom( []() { return std::make_unique<TestClass>(); }, ServiceLifeTime::scoped());
See also
Constructor requirements
- Template Parameters:
FactoryFcn – is factory functor with this sheme: (const ServiceDescriptor&) -> std::unique_ptr<TImplementation> (argument is optional), functor must be copyable and movable, implementation type must have one constructor
-
template<class TService, class TImplementation = TService>