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.
 
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.

Member Function Documentation

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  }
void throwAnyPending()
Throw and clear any saved exception.
Definition: pending_thrower.h:46
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
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  }
void throwAnyPending()
Throw and clear any saved exception.
Definition: pending_thrower.h:46
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
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
sauce::shared_ptr< Injector > createInjector() const
Create an Injector that can provide dependencies specified by all added Modules.
Definition: modules.h:147

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