ServiceCollection

class ServiceCollection

Subclassed by sb::di::GlobalServices

Public Types

using Iterator = std::vector<ServiceDescriptor>::iterator
using ConstIterator = std::vector<ServiceDescriptor>::const_iterator
using ReverseIterator = std::vector<ServiceDescriptor>::reverse_iterator
using ConstReverseIterator = std::vector<ServiceDescriptor>::const_reverse_iterator
using Ptr = std::unique_ptr<ServiceCollection>

Public Functions

ServiceCollection() = default
inline ServiceCollection(const std::initializer_list<ServiceDescriptor> list)
template<class InputIt>
inline ServiceCollection(InputIt first, InputIt last)
ServiceCollection(const ServiceCollection&) = default
ServiceCollection(ServiceCollection&&) = default
ServiceCollection &operator=(const ServiceCollection&) = default
ServiceCollection &operator=(ServiceCollection&&) = default
ServiceProvider buildServiceProvider(ServiceProviderOptions options = {})

Builds service provider with specified options.

might throw exceptions

Throws:

sb::di::ServiceRegisterException – if an error occurs during service registration registered with the same base type

ServiceProvider::Ptr buildServiceProviderAsPtr(ServiceProviderOptions options = {})

Builds service provider as unique_ptr with specified options.

might throw exceptions

Throws:

sb::di::ServiceRegisterException – if an error occurs during service registration registered with the same base type

inline Iterator begin()
inline Iterator end()
inline ConstIterator cBegin() const
inline ConstIterator cEnd() const
inline ConstIterator begin() const
inline ConstIterator end() const
inline ReverseIterator rBegin()
inline ReverseIterator rEnd()
inline ConstReverseIterator crBegin() const
inline ConstReverseIterator crEnd() const
inline ConstReverseIterator rBegin() const
inline ConstReverseIterator rEnd() const
inline std::vector<ServiceDescriptor> &getInnerVector()

Returns inner vector container.

inline const std::vector<ServiceDescriptor> &getInnerVector() const

Returns inner vector container.

inline ServiceDescriptor &at(const std::size_t index)

Returns service descriptor at giver position.

might throw exception

Throws:

std::out_of_range – if index >= size()

inline const ServiceDescriptor &at(const std::size_t index) const

Returns service descriptor at giver position.

might throw exception

Throws:

std::out_of_range – if index >= size()

inline ServiceDescriptor &first()

Returns first descriptor.

might throw exception

Throws:

std::out_of_range – if empty()

inline const ServiceDescriptor &first() const

Returns first descriptor.

might throw exception

Throws:

std::out_of_range – if empty()

inline ServiceDescriptor &last()

Returns last descriptor.

might throw exception

Throws:

std::out_of_range – if empty()

inline const ServiceDescriptor &last() const

Returns last descriptor.

might throw exception

Throws:

std::out_of_range – if empty()

inline ServiceDescriptor &operator[](const std::size_t index)

Returns service descriptor at giver position.

might throw exception

Throws:

std::out_of_range – if index >= size()

inline const ServiceDescriptor &operator[](const std::size_t index) const

Returns service descriptor at giver position.

might throw exception

Throws:

std::out_of_range – if index >= size()

inline std::size_t maxSize() const

Returns the maximum possible number of stored descriptors.

inline std::size_t size() const

Returns number of stored descriptors.

inline std::size_t count() const

Returns number of stored descriptors.

inline bool empty() const

Returns true if there are no descriptors.

inline std::size_t capacity() const

Returns capacity.

inline void reserve(const std::size_t space)

Reserves space for descriptors.

inline void shrinkToFit()

Shrinks to fit current size of descriptors.

inline void clear()

Removes all descriptors.

template<class TPred>
inline Iterator findIf(TPred pred)

Find first descriptor meeting TPred requirement.

Template Parameters:

TPred – is functor with this scheme: (const ServiceDescriptor&) -> bool

template<class TPred>
inline ConstIterator findIf(TPred pred) const

Find first descriptor meeting TPred requirement.

Template Parameters:

TPred – is functor with this scheme: (const ServiceDescriptor&) -> bool

template<class TPred>
inline bool containsIf(TPred pred) const

Checks if contains descriptor meeting TPred requirement.

Template Parameters:

TPred – is functor with this scheme: (const ServiceDescriptor&) -> bool

template<class TService>
inline bool contains() const

Checks if contains descriptor matching requirement.

descriptor.getServiceTypeId() == typeid(TService)
bool contains(TypeId serviceTypeId) const

Checks if contains descriptor matching requirement.

descriptor.getServiceTypeId() == serviceTypeId
template<class TService>
inline bool containsKeyed(const std::string_view serviceKey) const

Checks if contains descriptor matching requirement.

descriptor.getServiceTypeId() == typeid(TService) && *descriptor.getServiceKey() == serviceKey
bool containsKeyed(TypeId serviceTypeId, std::string_view serviceKey) const

Checks if contains descriptor matching requirement.

descriptor.getServiceTypeId() == serviceTypeId && *descriptor.getServiceKey() == serviceKey
template<class TService, class TImplementation = TService>
inline bool containsExact() const

Checks if contains descriptor matching requirement.

descriptor.getImplementationTypeId() == typeid(TImplementation) && descriptor.getServiceTypeId() ==
typeid(TService)
bool containsExact(TypeId serviceTypeId, TypeId implementationTypeId) const

Checks if contains descriptor matching requirement.

descriptor.getImplementationTypeId() == implementationTypeId && descriptor.getServiceTypeId() ==
serviceTypeId
template<class TService, class TImplementation = TService>
inline bool containsKeyedExact(const std::string_view serviceKey) const

Checks if contains descriptor matching requirement.

descriptor.getImplementationTypeId() == typeid(TImplementation) && descriptor.getServiceTypeId() ==
typeid(TService) && *descriptor.getServiceKey() == serviceKey
bool containsKeyedExact(TypeId serviceTypeId, TypeId implementationTypeId, std::string_view serviceKey) const

Checks if contains descriptor matching requirement.

descriptor.getImplementationTypeId() == implementationTypeId && descriptor.getServiceTypeId() ==
serviceTypeId && *descriptor.getServiceKey() == serviceKey
inline Iterator insert(ConstIterator pos, ServiceDescriptor descriptor)

Inserts descriptor before giver iterator.

Returns iterator pointing to the inserted

ServiceCollection &add(ServiceDescriptor descriptor)

Adds descriptor to the end of the list.

ServiceCollection &add(const ServiceCollection &collection)

Adds descriptors from collection to the end of list.

template<class TFilter>
inline ServiceCollection &addWithFilter(const ServiceCollection &collection, TFilter filter)

Adds descriptors from collection to the end of list, that matches filter functor.

inline Iterator remove(Iterator pos)

Removes descriptor with given iterator.

Returns iterator following the last removed element

inline Iterator remove(ConstIterator pos)

Removes descriptor with given iterator.

Returns iterator following the last removed element

inline Iterator removeRange(Iterator begin, Iterator end)

Removes descriptors between given iterators.

Returns iterator following the last removed element

inline Iterator removeRange(ConstIterator begin, ConstIterator end)

Removes descriptors between given iterators.

Returns iterator following the last removed element

template<class TPred>
inline std::size_t removeIf(TPred pred)

Removes all descriptors meeting TPred requirement.

Returns number of removed elements

Template Parameters:

TPred – is functor with this scheme: (const ServiceDescriptor&) -> bool

template<class TService>
inline std::size_t removeAll()

Removes all descriptors meeting requirement.

descriptor.getServiceTypeId() == typeid(TService)

Returns number of removed elements

std::size_t removeAll(TypeId serviceTypeId)

Removes all descriptors meeting requirement.

descriptor.getServiceTypeId() == serviceTypeId

Returns number of removed elements

template<class TService>
inline std::size_t removeAllKeyed(const std::string_view serviceKey)

Removes all descriptors meeting requirements.

descriptor.getServiceTypeId() == typeid(TService) && *descriptor.getServiceKey() == serviceKey

Returns number of removed elements

std::size_t removeAllKeyed(TypeId serviceTypeId, std::string_view serviceKey)

Removes all descriptors meeting requirement.

descriptor.getServiceTypeId() == serviceTypeId && *descriptor.getServiceKey() == serviceKey

Returns number of removed elements

template<class TService, class TImplementation = TService>
inline std::size_t remove()

Removes all descriptors meeting requirement.

descriptor.getImplementationTypeId() == typeid(TImplementation) && descriptor.getServiceTypeId() ==
typeid(TService)

Returns number of removed elements

std::size_t remove(TypeId serviceTypeId, TypeId implementationTypeId)

Removes all descriptors meeting requirement.

descriptor.getImplementationTypeId() == implementationTypeId && descriptor.getServiceTypeId() ==
serviceTypeId

Returns number of removed elements

template<class TService, class TImplementation = TService>
inline std::size_t removeKeyed(const std::string_view serviceKey)

Removes all descriptors meeting requirement.

descriptor.getImplementationTypeId() == typeid(TImplementation) && descriptor.getServiceTypeId() ==
typeid(TService) && *descriptor.getServiceKey() == serviceKey

Returns number of removed elements

std::size_t removeKeyed(TypeId serviceTypeId, TypeId implementationTypeId, std::string_view serviceKey)

Removes all descriptors meeting requirement.

descriptor.getImplementationTypeId() == implementationTypeId && descriptor.getServiceTypeId() ==
serviceTypeId && *descriptor.getServiceKey() == serviceKey

Returns number of removed elements

inline void pop()

Removes last descriptor.

template<class TService, class TImplementation = TService>
inline ServiceCollection &add(const ServiceLifeTime lifeTime)

Adds service descriptor.

Example:

ServiceCollection{}.add<TestClass>(ServiceLifeTimes::Scoped);
ServiceCollection{}.add<BaseClass, ImplementationClass>(ServiceLifeTimes::Transient);

See also

Constructor requirements

Template Parameters:
  • TService – base service type

  • TImplementation – service implementation type must inherit from TService and must have one constructor

Parameters:

lifeTime – service lifetime Singleton Scoped or Transient

template<class TService, class TImplementation = TService>
inline ServiceCollection &addKeyed(const ServiceLifeTime lifeTime, std::string serviceKey)

Adds keyed service descriptor.

Example:

ServiceCollection{}.addKeyed<TestClass>(ServiceLifeTimes::Scoped, "key");
ServiceCollection{}.addKeyed<BaseClass, ImplementationClass>(ServiceLifeTimes::Transient, "key");

See also

Constructor requirements

Template Parameters:
  • TService – base service type

  • TImplementation – service implementation type must inherit from TService and must have one constructor

Parameters:
  • lifeTime – service lifetime Singleton Scoped or Transient

  • serviceKey – service key can be empty to describe default service

template<class TService, class TImplementation = TService>
inline ServiceCollection &addSingleton()

Adds singleton service descriptor.

Example:

ServiceCollection{}.addSingleton<TestClass>();
ServiceCollection{}.addSingleton<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>
inline ServiceCollection &addKeyedSingleton(std::string serviceKey)

Adds keyed singleton service descriptor.

Example:

ServiceCollection{}.addKeyedSingleton<TestClass>("key");
ServiceCollection{}.addKeyedSingleton<BaseClass, ImplementationClass>("key");

See also

Constructor requirements

Template Parameters:
  • TService – base service type

  • TImplementation – service implementation type must inherit from TService and must have one constructor

Parameters:

serviceKey – service key can be empty to describe default service

template<class TService, class TImplementation = TService>
inline ServiceCollection &addScoped()

Adds scoped service descriptor.

Example:

ServiceCollection{}.addScoped<TestClass>();
ServiceCollection{}.addScoped<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>
inline ServiceCollection &addKeyedScoped(std::string serviceKey)

Adds keyed scoped service descriptor.

Example:

ServiceCollection{}.addKeyedScoped<TestClass>("key");
ServiceCollection{}.addKeyedScoped<BaseClass, ImplementationClass>("key");

See also

Constructor requirements

Template Parameters:
  • TService – base service type

  • TImplementation – service implementation type must inherit from TService and must have one constructor

Parameters:

serviceKey – service key can be empty to describe default service

template<class TService, class TImplementation = TService>
inline ServiceCollection &addTransient()

Adds transient service descriptor.

Example:

ServiceCollection{}.addTransient<TestClass>();
ServiceCollection{}.addTransient<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>
inline ServiceCollection &addKeyedTransient(std::string serviceKey)

Adds keyed transient service descriptor.

Example:

ServiceCollection{}.addKeyedTransient<TestClass>("key");
ServiceCollection{}.addKeyedTransient<BaseClass, ImplementationClass>("key");

See also

Constructor requirements

Template Parameters:
  • TService – base service type

  • TImplementation – service implementation type must inherit from TService and must have one constructor

Parameters:

serviceKey – service key can be empty to describe default service

template<class TService>
inline ServiceCollection &addSingleton(TService *service)

Adds singleton service descriptor.

Example:

TestClass test;
ServiceCollection{}.addSingleton(&test);

Template Parameters:

TService – service type

Parameters:

service – external service pointer

template<class TService>
inline ServiceCollection &addKeyedSingleton(std::string serviceKey, TService *service)

Adds keyed singleton service descriptor.

Example:

TestClass test;
ServiceCollection{}.addKeyedSingleton("key", &test);

Template Parameters:

TService – service type

Parameters:
  • serviceKey – service key can be empty to describe default service

  • service – external service pointer

template<class TService, class TImplementation>
inline ServiceCollection &addSingleton(TImplementation *service)

Adds singleton service descriptor.

Example:

ImplementationClass implementation;
ServiceCollection{}.addSingleton<BaseClass>(&implementation);

See also

Constructor requirements

Template Parameters:
  • TService – base service type

  • TImplementation – service implementation type must inherit from TService

Parameters:

service – external service pointer

template<class TService, class TImplementation>
inline ServiceCollection &addKeyedSingleton(std::string serviceKey, TImplementation *service)

Adds keyed singleton service descriptor.

Example:

ImplementationClass implementation;
ServiceCollection{}.addKeyedSingleton<BaseClass>("key", &implementation);

See also

Constructor requirements

Template Parameters:
  • TService – base service type

  • TImplementation – service implementation type must inherit from TService

Parameters:
  • serviceKey – service key can be empty to describe default service

  • service – external service pointer

template<class TService, class FactoryFcn>
inline ServiceCollection &add(const ServiceLifeTime lifeTime, FactoryFcn factory)

Adds service descriptor.

Example:

ServiceCollection{}.add<BaseClass>(ServiceLifeTimes::Scoped,
      []() { return std::make_unique<ImplementationClass>(); });

Template Parameters:
  • TService – base service type

  • FactoryFcn – factory functor type

Parameters:
  • lifeTime – service lifetime Singleton Scoped or Transient

  • factory – service factory functor with this scheme: (Services…) -> std::unique_ptr<TImplementation> | TImplementation, where services are pointers, unique pointers, references, vectors with pointers or unique pointers

template<class TService, class FactoryFcn>
inline ServiceCollection &addKeyed(const ServiceLifeTime lifeTime, std::string serviceKey, FactoryFcn factory)

Adds keyed service descriptor.

Example:

ServiceCollection{}.addKeyed<BaseClass>(ServiceLifeTimes::Scoped, "key",
      []() { return std::make_unique<ImplementationClass>(); });

Template Parameters:
  • TService – base service type

  • FactoryFcn – factory functor type

Parameters:
  • lifeTime – service lifetime Singleton Scoped or Transient

  • serviceKey – service key can be empty to describe default service

  • factory – service factory functor with this scheme: (Services…) -> std::unique_ptr<TImplementation> | TImplementation, where services are pointers, unique pointers, references, vectors with pointers or unique pointers

template<class TService, class FactoryFcn>
inline ServiceCollection &addSingleton(FactoryFcn factory)

Adds singleton service descriptor.

Example:

ServiceCollection{}.addSingleton<BaseClass>([]() { return std::make_unique<ImplementationClass>(); });

Template Parameters:
  • TService – base service type

  • FactoryFcn – factory functor type

Parameters:

factory – service factory functor with this scheme: (Services…) -> std::unique_ptr<TImplementation> | TImplementation, where services are pointers, unique pointers, references, vectors with pointers or unique pointers

template<class TService, class FactoryFcn>
inline ServiceCollection &addKeyedSingleton(std::string serviceKey, FactoryFcn factory)

Adds keyed singleton service descriptor.

Example:

ServiceCollection{}.addKeyedSingleton<BaseClass>("key", []() { return
std::make_unique<ImplementationClass>(); });

Template Parameters:
  • TService – base service type

  • FactoryFcn – factory functor type

Parameters:
  • serviceKey – service key can be empty to describe default service

  • factory – service factory functor with this scheme: (Services…) -> std::unique_ptr<TImplementation> | TImplementation, where services are pointers, unique pointers, references, vectors with pointers or unique pointers

template<class TService, class FactoryFcn>
inline ServiceCollection &addScoped(FactoryFcn factory)

Adds scoped service descriptor.

Example:

ServiceCollection{}.addScoped<BaseClass>([]() { return std::make_unique<ImplementationClass>(); });

Template Parameters:
  • TService – base service type

  • FactoryFcn – factory functor type

Parameters:

factory – service factory functor with this scheme: (Services…) -> std::unique_ptr<TImplementation> | TImplementation, where services are pointers, unique pointers, references, vectors with pointers or unique pointers

template<class TService, class FactoryFcn>
inline ServiceCollection &addKeyedScoped(std::string serviceKey, FactoryFcn factory)

Adds keyed scoped service descriptor.

Example:

ServiceCollection{}.addKeyedScoped<BaseClass>("key", []() { return std::make_unique<ImplementationClass>();
});

Template Parameters:
  • TService – base service type

  • FactoryFcn – factory functor type

Parameters:
  • serviceKey – service key can be empty to describe default service

  • factory – service factory functor with this scheme: (Services…) -> std::unique_ptr<TImplementation> | TImplementation, where services are pointers, unique pointers, references, vectors with pointers or unique pointers

template<class TService, class FactoryFcn>
inline ServiceCollection &addTransient(FactoryFcn factory)

Adds transient service descriptor.

Example:

ServiceCollection{}.addTransient<BaseClass>([]() { return std::make_unique<ImplementationClass>(); });

Template Parameters:
  • TService – base service type

  • FactoryFcn – factory functor type

Parameters:

factory – service factory functor with this scheme: (Services…) -> std::unique_ptr<TImplementation> | TImplementation, where services are pointers, unique pointers, references, vectors with pointers or unique pointers

template<class TService, class FactoryFcn>
inline ServiceCollection &addKeyedTransient(std::string serviceKey, FactoryFcn factory)

Adds keyed transient service descriptor.

Example:

ServiceCollection{}.addKeyedTransient<BaseClass>("key", []() { return
std::make_unique<ImplementationClass>(); });

Template Parameters:
  • TService – base service type

  • FactoryFcn – factory functor type

Parameters:
  • serviceKey – service key can be empty to describe default service

  • factory – service factory functor with this scheme: (Services…) -> std::unique_ptr<TImplementation> | TImplementation, where services are pointers, unique pointers, references, vectors with pointers or unique pointers

template<class FactoryFcn>
inline ServiceCollection &add(const ServiceLifeTime lifeTime, FactoryFcn factory)

Adds service descriptor.

Example:

ServiceCollection{}.add(ServiceLifeTimes::Transient, []() { return std::make_unique<TestClass>(); });

Template Parameters:

FactoryFcn – factory functor type

Parameters:
  • lifeTime – service lifetime Singleton Scoped or Transient

  • factory – service factory functor with this scheme: (Services…) -> std::unique_ptr<TImplementation> | TImplementation, where services are pointers, unique pointers, references, vectors with pointers or unique pointers

template<class FactoryFcn>
inline ServiceCollection &addKeyed(const ServiceLifeTime lifeTime, std::string serviceKey, FactoryFcn factory)

Adds keyed service descriptor.

Example:

ServiceCollection{}.addKeyed(ServiceLifeTimes::Transient, "key", []() { return std::make_unique<TestClass>();
});

Template Parameters:

FactoryFcn – factory functor type

Parameters:
  • lifeTime – service lifetime Singleton Scoped or Transient

  • serviceKey – service key can be empty to describe default service

  • factory – service factory functor with this scheme: (Services…) -> std::unique_ptr<TImplementation> | TImplementation, where services are pointers, unique pointers, references, vectors with pointers or unique pointers

template<class FactoryFcn>
inline ServiceCollection &addSingleton(FactoryFcn factory)

Adds singleton service descriptor.

Example:

ServiceCollection{}.addSingleton([]() { return std::make_unique<TestClass>(); });

Template Parameters:

FactoryFcn – factory functor type

Parameters:

factory – service factory functor with this scheme: (Services…) -> std::unique_ptr<TImplementation> | TImplementation, where services are pointers, unique pointers, references, vectors with pointers or unique pointers

template<class FactoryFcn>
inline ServiceCollection &addKeyedSingleton(std::string serviceKey, FactoryFcn factory)

Adds keyed singleton service descriptor.

Example:

ServiceCollection{}.addKeyedSingleton("key", []() { return std::make_unique<TestClass>(); });

Template Parameters:

FactoryFcn – factory functor type

Parameters:
  • serviceKey – service key can be empty to describe default service

  • factory – service factory functor with this scheme: (Services…) -> std::unique_ptr<TImplementation> | TImplementation, where services are pointers, unique pointers, references, vectors with pointers or unique pointers

template<class FactoryFcn>
inline ServiceCollection &addScoped(FactoryFcn factory)

Adds scoped service descriptor.

Example:

ServiceCollection{}.addScoped([]() { return std::make_unique<TestClass>(); });

Template Parameters:

FactoryFcn – factory functor type

Parameters:

factory – service factory functor with this scheme: (Services…) -> std::unique_ptr<TImplementation> | TImplementation, where services are pointers, unique pointers, references, vectors with pointers or unique pointers

template<class FactoryFcn>
inline ServiceCollection &addKeyedScoped(std::string serviceKey, FactoryFcn factory)

Adds keyed scoped service descriptor.

Example:

ServiceCollection{}.addKeyedScoped("key", []() { return std::make_unique<TestClass>(); });

Template Parameters:

FactoryFcn – factory functor type

Parameters:
  • serviceKey – service key can be empty to describe default service

  • factory – service factory functor with this scheme: (Services…) -> std::unique_ptr<TImplementation> | TImplementation, where services are pointers, unique pointers, references, vectors with pointers or unique pointers

template<class FactoryFcn>
inline ServiceCollection &addTransient(FactoryFcn factory)

Adds transient service descriptor.

Example:

ServiceCollection{}.addTransient([]() { return std::make_unique<TestClass>(); });

Template Parameters:

FactoryFcn – factory functor type

Parameters:

factory – service factory functor with this scheme: (Services…) -> std::unique_ptr<TImplementation> | TImplementation, where services are pointers, unique pointers, references, vectors with pointers or unique pointers

template<class FactoryFcn>
inline ServiceCollection &addKeyedTransient(std::string serviceKey, FactoryFcn factory)

Adds keyed transient service descriptor.

Example:

ServiceCollection{}.addKeyedTransient("key", []() { return std::make_unique<TestClass>(); });

Template Parameters:

FactoryFcn – factory functor type

Parameters:
  • serviceKey – service key can be empty to describe default service

  • factory – service factory functor with this scheme: (Services…) -> std::unique_ptr<TImplementation> | TImplementation, where services are pointers, unique pointers, references, vectors with pointers or unique pointers

template<class TAlias, class TService>
inline ServiceCollection &addAlias()

Adds alias service descriptor.

Example:

ServiceCollection{}.addAlias<AliasClass, ServiceClass>();

Template Parameters:
  • TAlias – base service type - alias type

  • TService – service type must inherit from TAlias

template<class TAlias, class TService>
inline ServiceCollection &addAlias(std::string serviceKey)

Adds alias service descriptor.

Example:

ServiceCollection{}.addAlias<AliasClass, ServiceClass>("key");

Template Parameters:
  • TAlias – base service type - alias type

  • TService – service type must inherit from TAlias

Parameters:

serviceKey – service key can be empty for default service

template<class TAlias, class TService>
inline ServiceCollection &addKeyedAlias(std::string serviceAliasKey, std::string serviceKey)

Adds keyed alias service descriptor.

Example:

ServiceCollection{}.addKeyedAlias<AliasClass, ServiceClass>("aliasKey", "key");

Template Parameters:
  • TAlias – base service type - alias type

  • TService – service type must inherit from TAlias

Parameters:
  • serviceAliasKey – alias service key can be empty to describe default alias service

  • serviceKey – service key can be empty for default service

template<class TAlias, class TService>
inline ServiceCollection &addKeyedAlias(std::string serviceAliasKey)

Adds keyed alias service descriptor.

Example:

ServiceCollection{}.addKeyedAlias<AliasClass, ServiceClass>("aliasKey");

Template Parameters:
  • TAlias – base service type - alias type

  • TService – service type must inherit from TAlias

Parameters:

serviceAliasKey – alias service key can be empty to describe default alias service

Friends

inline friend bool operator==(const ServiceCollection &lhs, const ServiceCollection &rhs)
inline friend bool operator!=(const ServiceCollection &lhs, const ServiceCollection &rhs)