Classes | Static Public Member Functions | Public Member Functions | List of all members
Injector Class Referencefinal

The main dependency injector class. More...

#include <Injector.hpp>

Inherits enable_shared_from_this< Injector >.

Classes

class  ValidationParent
 Encapsulates a validated parent injector for subsequent child validation calls. More...
 

Static Public Member Functions

template<typename ... Conf>
static std::shared_ptr< Injectorcreate (const Conf &... conf)
 Construct an injector with one or more injector configurations. More...
 
static std::shared_ptr< Injectorcreate (const std::vector< std::shared_ptr< InjectorConfiguration >> &conf)
 Construct an injector with one or more injector configurations supplied in a vector. More...
 
template<typename InstT >
static Impl::BindingKey createBindingKey (const std::string &name="")
 Used for binding error reporting. More...
 
template<typename ... Conf>
static ValidationParent validate (const Conf &... conf)
 Validate the runtime specified injector configuration. More...
 
static ValidationParent validate (const std::vector< std::shared_ptr< InjectorConfiguration >> &conf)
 Validate the runtime specified injector configuration. More...
 
template<typename ... Conf>
static ValidationParent validateChild (ValidationParent parent, const Conf &... conf)
 Validate the runtime specified child injector configuration. More...
 
static ValidationParent validateChild (const ValidationParent &parent, const std::vector< std::shared_ptr< InjectorConfiguration >> &conf)
 Validate the runtime specified child injector configuration. More...
 

Public Member Functions

template<typename ... Conf>
std::shared_ptr< InjectorcreateChild (const Conf &... conf) const
 Construct a child injector with one or more injector configurations. More...
 
std::shared_ptr< InjectorcreateChild (const std::vector< std::shared_ptr< InjectorConfiguration >> &conf) const
 Construct a child injector with one or more injector configurations supplied in a vector. More...
 
std::shared_ptr< InjectorcreateChild (const std::shared_ptr< Injector > &prototype) const
 Construct a child injector from the previously constructed prototype. More...
 
template<typename InstT >
InstT getInstance (std::string_view name=std::string_view()) const
 Get an instance, the meta-type of which is determined by the specified type. More...
 
template<typename BaseT >
BaseT & getReference (std::string_view name=std::string_view()) const
 Get-instance method for reference providers. More...
 
template<typename BaseT >
BaseT & getReference (BaseT &defaultValue) const
 Get-instance method for reference providers. More...
 
template<typename BaseT >
BaseT & getReference (std::string_view name, BaseT &defaultValue) const
 Get-instance method for reference providers. More...
 
template<typename BaseT >
std::shared_ptr< BaseT > getShared (std::string_view name=std::string_view()) const
 Get-instance method for shared pointers (polymorphic thread-local or non-thread-local singletons). More...
 
template<typename BaseT >
std::shared_ptr< BaseT > getShared (const std::shared_ptr< BaseT > &defaultValue) const
 Get-instance method for shared pointers (polymorphic thread-local or non-thread-local singletons). More...
 
template<typename BaseT >
std::shared_ptr< BaseT > getShared (std::string_view name, const std::shared_ptr< BaseT > &defaultValue) const
 Get-instance method for shared pointers (polymorphic thread-local or non-thread-local singletons). More...
 
template<typename BaseT >
std::shared_ptr< BaseT > getShared (const std::function< std::shared_ptr< BaseT >()> &defaultValueSupplier) const
 Get-instance method for shared pointers (polymorphic thread-local or non-thread-local singletons). More...
 
template<typename BaseT >
std::shared_ptr< BaseT > getShared (std::string_view name, const std::function< std::shared_ptr< BaseT >()> &defaultValueSupplier) const
 Get-instance method for shared pointers (polymorphic thread-local or non-thread-local singletons). More...
 
template<typename BaseT >
std::shared_ptr< BaseT > getSharedOrNull (std::string_view name=std::string_view()) const
 Get-instance method for shared pointers (polymorphic thread-local or non-thread-local singletons). More...
 
template<typename BaseT , typename DeleterT = std::default_delete<BaseT>>
std::unique_ptr< BaseT, DeleterT > getUnique (std::string_view name=std::string_view()) const
 Get-instance method for unique pointers (polymorphic new instances). More...
 
template<typename BaseT , typename DeleterT = std::default_delete<BaseT>>
std::unique_ptr< BaseT, DeleterT > getUnique (std::unique_ptr< BaseT > &&defaultValue) const
 Get-instance method for unique pointers (polymorphic new instances). More...
 
template<typename BaseT , typename DeleterT = std::default_delete<BaseT>>
std::unique_ptr< BaseT, DeleterT > getUnique (std::string_view name, std::unique_ptr< BaseT, DeleterT > &&defaultValue) const
 Get-instance method for unique pointers (polymorphic new instances). More...
 
template<typename BaseT , typename DeleterT = std::default_delete<BaseT>>
std::unique_ptr< BaseT, DeleterT > getUnique (std::function< std::unique_ptr< BaseT, DeleterT >()> &defaultValueSupplier) const
 Get-instance method for unique pointers (polymorphic new instances). More...
 
template<typename BaseT , typename DeleterT = std::default_delete<BaseT>>
std::unique_ptr< BaseT, DeleterT > getUnique (std::string_view name, std::function< std::unique_ptr< BaseT, DeleterT >()> &defaultValueSupplier) const
 Get-instance method for unique pointers (polymorphic new instances). More...
 
template<typename BaseT , typename DeleterT = std::default_delete<BaseT>>
std::unique_ptr< BaseT, DeleterT > getUniqueOrNull (std::string_view name=std::string_view()) const
 Get-instance method for unique pointers (polymorphic new instances). More...
 
template<typename ValueT >
ValueT getValue (std::string_view name=std::string_view()) const
 Get-instance method for values (non-polymorphic new instances). More...
 
template<typename ValueT >
ValueT getValue (const ValueT &defaultValue) const
 Get-instance method for values (non-polymorphic new instances). More...
 
template<typename ValueT >
ValueT getValue (std::string_view name, const ValueT &defaultValue) const
 Get-instance method for values (non-polymorphic new instances). More...
 
template<typename ValueT >
ValueT getValue (const std::function< ValueT()> &defaultValueSupplier) const
 Get-instance method for values (non-polymorphic new instances). More...
 
template<typename ValueT >
ValueT getValue (std::string_view name, const std::function< ValueT()> &defaultValueSupplier) const
 Get-instance method for values (non-polymorphic new instances). More...
 
template<typename InstT >
bool hasBinding (std::string_view name=std::string_view()) const
 Returns true if the injector or its parent has a binding matching the specified type and name. More...
 
template<typename BaseT >
void iterate (const std::function< void(std::shared_ptr< BaseT >)> &func, bool includeThreadLocal=false) const
 For all singleton bindings of the specified type, call the supplied function with the binding's singleton object. More...
 
template<typename BaseT >
void iterate (const std::function< void(std::shared_ptr< const BaseT >)> &func, bool includeThreadLocal=false) const
 For all singleton bindings of the specified type, call the supplied function with the binding's singleton object. More...
 
std::string printBindings (bool printAncestor=false) const
 Print the bindings of this injector and optionally the injector's ancestors. More...
 
std::string printBindingsDetailed () const
 Print detailed bindings of this injector and the injector's ancestors. More...
 
void registerPostConstructionCall (const std::function< void(const Injector &)> &call) const
 Register with the injector a callback that will be called by the injector at the end of construction. More...
 
void registerPreDestructionCall (const std::function< void()> &call) const
 Register with the injector a callback that will be called in the injector's destructor, before the bindings are deleted. More...
 
template<typename T >
void registerStaticSingleton (std::shared_ptr< T > *ptrPtr, std::string_view name=std::string_view()) const
 Register a static singleton pointer that the injector will set up post-construction and invalidate pre-destruction. More...
 

Detailed Description

The main dependency injector class.

Injectors are instantiated by passing one or more injector configuration instances.

An instantiated injector can be used by multiple threads without requiring any synchronisation.

See the injector manual page for detailed usage information and the injector unit tests for examples.

Member Function Documentation

◆ create() [1/2]

static std::shared_ptr<Injector> create ( const Conf &...  conf)
inlinestatic

Construct an injector with one or more injector configurations.

Template Parameters
Confthe first configuration type(s) (must derive from InjectorConfiguration)
Parameters
confthe runtime supplied InjectorConfiguration objects
Returns
a shared pointer to the newly created injector

◆ create() [2/2]

static std::shared_ptr<Injector> create ( const std::vector< std::shared_ptr< InjectorConfiguration >> &  conf)
inlinestatic

Construct an injector with one or more injector configurations supplied in a vector.

Parameters
confthe runtime supplied InjectorConfiguration objects
Returns
a shared pointer to the newly created injector

◆ createBindingKey()

static Impl::BindingKey createBindingKey ( const std::string &  name = "")
inlinestatic

Used for binding error reporting.

The supplied type InstT is ValueT, std::unique_ptr<BaseT>, BaseT &, or std::shared_ptr<BaseT>, and also determines the binding meta-type (Value, Unique, Reference or Shared).

Template Parameters
InstTthe full binding type (this also determines the meta-type)
Parameters
namethe name of the binding (default = empty)
Returns
a binding key

◆ createChild() [1/3]

std::shared_ptr<Injector> createChild ( const Conf &...  conf) const
inline

Construct a child injector with one or more injector configurations.

Template Parameters
Confthe first configuration type(s) (must derive from InjectorConfiguration)
Parameters
confthe runtime supplied InjectorConfiguration objects
Returns
a shared pointer to the newly created child injector

◆ createChild() [2/3]

std::shared_ptr<Injector> createChild ( const std::vector< std::shared_ptr< InjectorConfiguration >> &  conf) const
inline

Construct a child injector with one or more injector configurations supplied in a vector.

Parameters
confthe runtime supplied InjectorConfiguration objects
Returns
a shared pointer to the newly created child injector

◆ createChild() [3/3]

std::shared_ptr<Injector> createChild ( const std::shared_ptr< Injector > &  prototype) const
inline

Construct a child injector from the previously constructed prototype.

Constructing a prototype child injector and subsequently calling this function multiple times with the same prototype avoids running the construction and validation phases each time a child injector is required.

Note that the bindings of the prototype will be shared between all child injectors created from the prototype. This implies that singleton and thread-local singleton instances will be shared across the injectors. If this is not desired behaviour, then a new child injector must be created via the other createChildInjector functions that instantiate their own bindings.

Parameters
prototypethe prototype child injector to copy
Returns
a shared pointer to the newly created child injector

◆ getInstance()

InstT getInstance ( std::string_view  name = std::string_view()) const
inline

Get an instance, the meta-type of which is determined by the specified type.

If the type InstT is a std::shared_ptr<BaseT>, the getShared() method is implicitly called. If the type InstT is a BaseT &, the getReference() method is implicitly called. If the type InstT is a std::unique_ptr<BaseT>, the getUnique() method is implicitly called. Otherwise, the getValue() method is implicitly called.

Template Parameters
InstTthe complete type of the value, unique, reference, or shared binding
Parameters
namethe name of the binding
Returns
a value, unique_ptr, reference, or shared_ptr depending on the specified meta-type
Exceptions
NoBindingExceptionif no suitable binding was found

◆ getReference() [1/3]

BaseT& getReference ( std::string_view  name = std::string_view()) const
inline

Get-instance method for reference providers.

If no suitable binding is found, NoBindingException is thrown.

Template Parameters
BaseTthe base type of the reference binding
Parameters
namethe name of the binding
Returns
the reference supplied by the binding
Exceptions
NoBindingExceptionif no suitable binding was found

◆ getReference() [2/3]

BaseT& getReference ( BaseT &  defaultValue) const
inline

Get-instance method for reference providers.

If no suitable binding is found, the supplied default value is copied into the return value.

Template Parameters
BaseTthe base type of the reference binding
Parameters
defaultValuea default reference to return if no suitable binding was found
Returns
the reference supplied by the binding or the supplied default reference

◆ getReference() [3/3]

BaseT& getReference ( std::string_view  name,
BaseT &  defaultValue 
) const
inline

Get-instance method for reference providers.

If no suitable binding is found, the supplied default value is referenced instead.

Template Parameters
BaseTthe base type of the reference binding
Parameters
namethe name of the binding
defaultValuea default reference to return if no suitable binding was found
Returns
the reference supplied by the binding or the supplied default reference

◆ getShared() [1/5]

std::shared_ptr<BaseT> getShared ( std::string_view  name = std::string_view()) const
inline

Get-instance method for shared pointers (polymorphic thread-local or non-thread-local singletons).

If no suitable binding is found, NoBindingException is thrown.

A std::shared_ptr may be singleton or thread-local singleton sourced.

Template Parameters
BaseTthe base type of the shared binding
Parameters
namethe name of the binding
Returns
a shared pointer containing the instance
Exceptions
NoBindingExceptionif no suitable binding was found

◆ getShared() [2/5]

std::shared_ptr<BaseT> getShared ( const std::shared_ptr< BaseT > &  defaultValue) const
inline

Get-instance method for shared pointers (polymorphic thread-local or non-thread-local singletons).

If no suitable binding is found, the supplied default value is shared into the return value.

A std::shared_ptr may be singleton or thread-local singleton sourced.

Template Parameters
BaseTthe base type of the shared binding
Parameters
defaultValuea default pointer to copy if no suitable binding was found
Returns
a shared pointer containing the instance or the default pointer

◆ getShared() [3/5]

std::shared_ptr<BaseT> getShared ( std::string_view  name,
const std::shared_ptr< BaseT > &  defaultValue 
) const
inline

Get-instance method for shared pointers (polymorphic thread-local or non-thread-local singletons).

If no suitable binding is found, the supplied default value is shared into the return value.

A std::shared_ptr may be singleton or thread-local singleton sourced.

Template Parameters
BaseTthe base type of the shared binding
Parameters
namethe name of the binding
defaultValuea default pointer to copy if no suitable binding was found
Returns
a shared pointer containing the instance or the default pointer

◆ getShared() [4/5]

std::shared_ptr<BaseT> getShared ( const std::function< std::shared_ptr< BaseT >()> &  defaultValueSupplier) const
inline

Get-instance method for shared pointers (polymorphic thread-local or non-thread-local singletons).

If no suitable binding is found, a default value is obtained by the supplied function.

A std::shared_ptr may be singleton or thread-local singleton sourced.

Template Parameters
BaseTthe base type of the shared binding
Parameters
defaultValueSuppliera function that supplies a default value if no suitable binding is found
Returns
a shared pointer containing the instance or the default pointer

◆ getShared() [5/5]

std::shared_ptr<BaseT> getShared ( std::string_view  name,
const std::function< std::shared_ptr< BaseT >()> &  defaultValueSupplier 
) const
inline

Get-instance method for shared pointers (polymorphic thread-local or non-thread-local singletons).

If no suitable binding is found, a default value is obtained by the supplied function.

A std::shared_ptr may be singleton or thread-local singleton sourced.

Template Parameters
BaseTthe base type of the shared binding
Parameters
namethe name of the binding
defaultValueSuppliera function that supplies a default value if no suitable binding is found
Returns
a shared pointer containing the instance or the default pointer

◆ getSharedOrNull()

std::shared_ptr<BaseT> getSharedOrNull ( std::string_view  name = std::string_view()) const
inline

Get-instance method for shared pointers (polymorphic thread-local or non-thread-local singletons).

Return an empty shared_ptr if no suitable binding is found.

A std::shared_ptr may be singleton or thread-local singleton sourced.

Template Parameters
BaseTthe base type of the shared binding
Parameters
namethe name of the binding
Returns
a shared pointer containing the instance or nullptr

◆ getUnique() [1/5]

std::unique_ptr<BaseT, DeleterT> getUnique ( std::string_view  name = std::string_view()) const
inline

Get-instance method for unique pointers (polymorphic new instances).

If no suitable binding is found, NoBindingException is thrown.

A std::unique_ptr may be instance sourced.

Template Parameters
BaseTthe base type of the unique binding
Parameters
namethe name of the binding
Returns
a unique pointer containing the new instance
Exceptions
NoBindingExceptionif no suitable binding was found

◆ getUnique() [2/5]

std::unique_ptr<BaseT, DeleterT> getUnique ( std::unique_ptr< BaseT > &&  defaultValue) const
inline

Get-instance method for unique pointers (polymorphic new instances).

If no suitable binding is found, the supplied default value is moved into the return value.

A std::unique_ptr may be instance sourced.

Template Parameters
BaseTthe base type of the unique binding
Parameters
defaultValuea default value to move if no suitable binding was found
Returns
a unique pointer containing the new instance or the supplied default

◆ getUnique() [3/5]

std::unique_ptr<BaseT, DeleterT> getUnique ( std::string_view  name,
std::unique_ptr< BaseT, DeleterT > &&  defaultValue 
) const
inline

Get-instance method for unique pointers (polymorphic new instances).

If no suitable binding is found, the supplied default value is moved into the return value.

A std::unique_ptr may be instance sourced.

Template Parameters
BaseTthe base type of the unique binding
Parameters
namethe name of the binding
defaultValuea default value to move if no suitable binding was found
Returns
a unique pointer containing the new instance or the supplied default

◆ getUnique() [4/5]

std::unique_ptr<BaseT, DeleterT> getUnique ( std::function< std::unique_ptr< BaseT, DeleterT >()> &  defaultValueSupplier) const
inline

Get-instance method for unique pointers (polymorphic new instances).

If no suitable binding is found, a default value is obtained by the supplied function.

A std::unique_ptr may be instance sourced.

Template Parameters
BaseTthe base type of the unique binding
Parameters
defaultValueSuppliera function that supplies a default value if no suitable binding is found
Returns
a unique pointer containing the new instance or the supplied default

◆ getUnique() [5/5]

std::unique_ptr<BaseT, DeleterT> getUnique ( std::string_view  name,
std::function< std::unique_ptr< BaseT, DeleterT >()> &  defaultValueSupplier 
) const
inline

Get-instance method for unique pointers (polymorphic new instances).

If no suitable binding is found, a default value is obtained by the supplied function.

A std::unique_ptr may be instance sourced.

Template Parameters
BaseTthe base type of the unique binding
Parameters
namethe name of the binding
defaultValueSuppliera function that supplies a default value if no suitable binding is found
Returns
a unique pointer containing the new instance or the supplied default

◆ getUniqueOrNull()

std::unique_ptr<BaseT, DeleterT> getUniqueOrNull ( std::string_view  name = std::string_view()) const
inline

Get-instance method for unique pointers (polymorphic new instances).

Return an empty unique_ptr if there is no suitable binding.

A std::unique_ptr may be instance sourced.

Template Parameters
BaseTthe base type of the unique binding
Parameters
namethe name of the binding
Returns
a unique pointer containing the new instance or nullptr

◆ getValue() [1/5]

ValueT getValue ( std::string_view  name = std::string_view()) const
inline

Get-instance method for values (non-polymorphic new instances).

If no suitable binding is found, NoBindingException is thrown.

A value may be instance sourced (stack constructed or copied from a prototype).

Template Parameters
ValueTthe type of the value binding
Parameters
namethe name of the binding
Returns
a new value
Exceptions
NoBindingExceptionif no suitable binding was found

◆ getValue() [2/5]

ValueT getValue ( const ValueT &  defaultValue) const
inline

Get-instance method for values (non-polymorphic new instances).

If no suitable binding is found, the supplied default value is copied into the return value.

A value may be instance sourced (stack constructed or copied from a prototype).

Template Parameters
ValueTthe type of the value binding
Parameters
defaultValuea default value to copy if no suitable binding was found
Returns
a new value or a copy of the supplied default value

◆ getValue() [3/5]

ValueT getValue ( std::string_view  name,
const ValueT &  defaultValue 
) const
inline

Get-instance method for values (non-polymorphic new instances).

If no suitable binding is found, the supplied default value is copied into the return value.

A value may be instance sourced (stack constructed or copied from a prototype).

Template Parameters
ValueTthe type of the value binding
Parameters
namethe name of the binding
defaultValuea default value to copy if no suitable binding was found
Returns
a new value or a copy of the supplied default value

◆ getValue() [4/5]

ValueT getValue ( const std::function< ValueT()> &  defaultValueSupplier) const
inline

Get-instance method for values (non-polymorphic new instances).

If no suitable binding is found, a default value is obtained by the supplied function.

A value may be instance sourced (stack constructed or copied from a prototype).

Template Parameters
ValueTthe type of the value binding
Parameters
defaultValueSuppliera function that supplies a default value if no suitable binding is found
Returns
a new value or a default value from the function

◆ getValue() [5/5]

ValueT getValue ( std::string_view  name,
const std::function< ValueT()> &  defaultValueSupplier 
) const
inline

Get-instance method for values (non-polymorphic new instances).

If no suitable binding is found, a default value is obtained by the supplied function.

A value may be instance sourced (stack constructed or copied from a prototype).

Template Parameters
ValueTthe type of the value binding
Parameters
namethe name of the binding
defaultValueSuppliera function that supplies a default value if no suitable binding is found
Returns
a new value or a copy of the supplied default value

◆ hasBinding()

bool hasBinding ( std::string_view  name = std::string_view()) const
inline

Returns true if the injector or its parent has a binding matching the specified type and name.

The supplied type InstT is ValueT, std::unique_ptr<BaseT>, BaseT &, or std::shared_ptr<BaseT>, and also determines the binding meta-type (Value, Unique, Reference or Shared).

Template Parameters
InstTthe full binding type (this also determines the meta-type)
Parameters
namethe name of the binding (default = empty)
Returns
true if a binding with the specified key exists

◆ iterate() [1/2]

void iterate ( const std::function< void(std::shared_ptr< BaseT >)> &  func,
bool  includeThreadLocal = false 
) const
inline

For all singleton bindings of the specified type, call the supplied function with the binding's singleton object.

Template Parameters
BaseTthe base type of the shared binding
Parameters
functhe function to call
includeThreadLocalif true then thread local bindings will be include (default is false)

◆ iterate() [2/2]

void iterate ( const std::function< void(std::shared_ptr< const BaseT >)> &  func,
bool  includeThreadLocal = false 
) const
inline

For all singleton bindings of the specified type, call the supplied function with the binding's singleton object.

Template Parameters
BaseTthe base type of the shared binding
Parameters
functhe function to call
includeThreadLocalif true then thread local bindings will be include (default is false)

◆ printBindings()

std::string printBindings ( bool  printAncestor = false) const
inline

Print the bindings of this injector and optionally the injector's ancestors.

The bindings will be printed to the "balau.injector" logging namespace at info level.

Parameters
printAncestorprint ancestor bindings as well (default = false)
Returns
a string containing a the binding printout

◆ printBindingsDetailed()

std::string printBindingsDetailed ( ) const
inline

Print detailed bindings of this injector and the injector's ancestors.

This version of the print functions prints the bindings and their dependencies. This can be useful for examining cyclic dependency issues.

The bindings will be printed to the "balau.injector" logging namespace at info level.

Parameters
printAncestorprint ancestor bindings as well (default = false)
Returns
a string containing a the binding printout

◆ registerPostConstructionCall()

void registerPostConstructionCall ( const std::function< void(const Injector &)> &  call) const
inline

Register with the injector a callback that will be called by the injector at the end of construction.

In order to use this method, inject the injector into an eager singleton injectable via a weak pointer and call the method.

Alternatively, the same method is available to call in the ApplicationConfiguration base class. The ApplicationConfiguration method does not require an eager singleton to register the call.

Parameters
callthe callback

◆ registerPreDestructionCall()

void registerPreDestructionCall ( const std::function< void()> &  call) const
inline

Register with the injector a callback that will be called in the injector's destructor, before the bindings are deleted.

Although pre-destruction callbacks must be noexcept(true), the pre-destruction function signature does not contain noexcept(true), as this is not yet handled by std::function in C++17. Despite this, functions registered as pre-destruction callbacks must nevertheless be noexcept(true).

In order to use this method, inject the injector into an injectable via a weak pointer and call the method.

Alternatively, the same method is available to call in the ApplicationConfiguration base class.

Parameters
callthe callback

◆ registerStaticSingleton()

void registerStaticSingleton ( std::shared_ptr< T > *  ptrPtr,
std::string_view  name = std::string_view() 
) const
inline

Register a static singleton pointer that the injector will set up post-construction and invalidate pre-destruction.

The static pointer will be valid immediately after injection construction up to the start of injector destruction.

This call is a convenience method for calling the registerPostConstructionCall and registerPreDestructionCall methods in order to set up and tear down the static singleton pointer.

In order to use this method, inject the injector into an eager singleton injectable via a weak pointer and call the method.

Alternatively, the same method is available to call in the ApplicationConfiguration base class. The ApplicationConfiguration method does not require an eager singleton to register the calls.

Template Parameters
Tthe binding type
Parameters
ptrPtra raw pointer to the statically allocated shared pointer
namean optional binding name

◆ validate() [1/2]

static ValidationParent validate ( const Conf &...  conf)
inlinestatic

Validate the runtime specified injector configuration.

Template Parameters
Confthe first configuration type(s) (must derive from InjectorConfiguration)
Parameters
confthe runtime supplied InjectorConfiguration objects
Returns
a ValidationParent instance representing the validated injector
Exceptions
MissingDependencyExceptionif a required dependency is missing
DuplicateBindingExceptionif duplicate bindings exist
CyclicDependencyExceptionif there is a cyclic dependency
SharedInjectorExceptionif one of the injectable classes specifies a shared pointer injector dependency

◆ validate() [2/2]

static ValidationParent validate ( const std::vector< std::shared_ptr< InjectorConfiguration >> &  conf)
inlinestatic

Validate the runtime specified injector configuration.

Parameters
confthe runtime supplied InjectorConfiguration objects
Returns
a ValidationParent instance representing the validated injector
Exceptions
MissingDependencyExceptionif a required dependency is missing
DuplicateBindingExceptionif duplicate bindings exist
CyclicDependencyExceptionif there is a cyclic dependency
SharedInjectorExceptionif one of the injectable classes specifies a shared pointer injector dependency

◆ validateChild() [1/2]

static ValidationParent validateChild ( ValidationParent  parent,
const Conf &...  conf 
)
inlinestatic

Validate the runtime specified child injector configuration.

Template Parameters
Confthe first configuration type(s) (must derive from InjectorConfiguration)
Parameters
parentthe ValidationParent object representing the parent of the child injector
confthe runtime supplied InjectorConfiguration objects
Returns
a ValidationParent instance representing the validated child injector
Exceptions
MissingDependencyExceptionif a required dependency is missing
DuplicateBindingExceptionif duplicate bindings exist
CyclicDependencyExceptionif there is a cyclic dependency
SharedInjectorExceptionif one of the injectable classes specifies a shared pointer injector dependency

◆ validateChild() [2/2]

static ValidationParent validateChild ( const ValidationParent parent,
const std::vector< std::shared_ptr< InjectorConfiguration >> &  conf 
)
inlinestatic

Validate the runtime specified child injector configuration.

Parameters
parentthe ValidationParent object representing the parent of the child injector
confthe runtime supplied InjectorConfiguration objects
Returns
a ValidationParent instance representing the validated child injector
Exceptions
MissingDependencyExceptionif a required dependency is missing
DuplicateBindingExceptionif duplicate bindings exist
CyclicDependencyExceptionif there is a cyclic dependency
SharedInjectorExceptionif one of the injectable classes specifies a shared pointer injector dependency

The documentation for this class was generated from the following file: