Sauce-0.10.1
A C++ Dependency Injection Framework
Public Member Functions | List of all members
sauce::Modules Class Reference

A factory that accepts Modules and creates Injectors. More...

#include <sauce/modules.h>

Public Member Functions

 Modules ()
 Create an empty Modules. More...
 
Modulesadd (void(*module)(Binder &))
 Add the bindings defined by the given module function. More...
 
template<typename Module >
Modulesadd ()
 Add the bindings defined by the given Module type. More...
 
template<typename Module >
Modulesadd (Module &module)
 Add the bindings defined by the given Module instance. More...
 
sauce::shared_ptr< InjectorcreateInjector () const
 Create an Injector that can provide dependencies specified by all added Modules. More...
 
template<typename Locker , typename Lockable >
sauce::shared_ptr< InjectorcreateInjector (Lockable &lockable) const
 Create an Injector that can provide dependencies specified by all added Modules. More...
 

Detailed Description

A factory that accepts Modules and creates Injectors.

Constructor & Destructor Documentation

◆ Modules()

sauce::Modules::Modules ( )
inline

Create an empty Modules.

94 :
95 bindings(),
96 binder(bindings) {}

Member Function Documentation

◆ add() [1/3]

template<typename Module >
Modules & sauce::Modules::add ( )
inline

Add the bindings defined by the given Module type.

The module here is any default constructable type providing operator()(Binding & bindings).

An Injector created after adding a module will understand how to provide dependencies specified by that module.

119 {
120 Module module;
121 module(binder);
122 binder.throwAnyPending();
123 return *this;
124 }
void throwAnyPending()
Throw and clear any saved exception.
Definition: pending_thrower.h:46
Here is the call graph for this function:

◆ add() [2/3]

template<typename Module >
Modules & sauce::Modules::add ( Module &  module)
inline

Add the bindings defined by the given Module instance.

The module here is any value providing operator()(Binding & bindings).

An Injector created after adding a module will understand how to provide dependencies specified by that module.

135 {
136 module(binder);
137 binder.throwAnyPending();
138 return *this;
139 }
Here is the call graph for this function:

◆ add() [3/3]

Modules & sauce::Modules::add ( void(*)(Binder &)  module)
inline

Add the bindings defined by the given module function.

An Injector created after adding a module will understand how to provide dependencies specified by that module.

104 {
105 module(binder);
106 binder.throwAnyPending();
107 return *this;
108 }
Here is the call graph for this function:

◆ createInjector() [1/2]

sauce::shared_ptr< Injector > sauce::Modules::createInjector ( ) const
inline

Create an Injector that can provide dependencies specified by all added Modules.

Any modules added after an Injector is created will have no effect on that Injector.

147 {
148 sauce::auto_ptr<i::LockFactory> lockFactory(new i::NullLockFactory());
149 return createInjector(lockFactory);
150 }
sauce::shared_ptr< Injector > createInjector() const
Create an Injector that can provide dependencies specified by all added Modules.
Definition: modules.h:147
Definition: locker_factory.h:50
Here is the call graph for this function:

◆ createInjector() [2/2]

template<typename Locker , typename Lockable >
sauce::shared_ptr< Injector > sauce::Modules::createInjector ( Lockable &  lockable) const
inline

Create an Injector that can provide dependencies specified by all added Modules.

Any modules added after an Injector is created will have no effect on that Injector.

159 {
160 sauce::auto_ptr<i::LockFactory> lockFactory(new i::LockerLockFactory<Locker, Lockable>(lockable));
161 return createInjector(lockFactory);
162 }
Definition: locker_factory.h:59
Here is the call graph for this function:

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