1 #ifndef SAUCE_MODULES_H_
2 #define SAUCE_MODULES_H_
4 #include <sauce/binder.h>
5 #include <sauce/injector.h>
6 #include <sauce/memory.h>
7 #include <sauce/internal/base_injector.h>
8 #include <sauce/internal/resolved_binding.h>
9 #include <sauce/internal/bindings.h>
10 #include <sauce/internal/implicit_bindings.h>
11 #include <sauce/internal/locker_factory.h>
35 previousBinder(module->binder) {
36 module->binder = binder;
40 module->binder = previousBinder;
44 friend class BinderGuard;
59 template<
typename Iface>
61 return binder->
bind<Iface>();
68 void operator()(Binder & binder)
const {
69 BinderGuard guard(
this, &binder);
81 sauce::shared_ptr<Injector>
createInjector(sauce::auto_ptr<i::LockFactory> lockFactory)
const {
82 sauce::shared_ptr<i::BaseInjector<i::ImplicitBindings> > base(
84 sauce::shared_ptr<Injector> injector(
new Injector(base));
85 injector->setSelfPtr(injector);
118 template<
typename Module>
134 template<
typename Module>
158 template<
typename Locker,
typename Lockable>
168 #endif // SAUCE_MODULES_H_
BindClause< Iface > bind()
Begin binding the chosen interface.
Definition: binder.h:339
Modules()
Create an empty Modules.
Definition: modules.h:94
Modules & add(void(*module)(Binder &))
Add the bindings defined by the given module function.
Definition: modules.h:104
Passed to modules to create bindings.
Definition: binder.h:324
Definition: locker_factory.h:59
virtual void configure() const =0
Override in derived classes to declare bindings.
sauce::shared_ptr< Injector > createInjector() const
Create an Injector that can provide dependencies specified by all added Modules.
Definition: modules.h:147
A base class that modules implemented as classes might derive from.
Definition: modules.h:21
Definition: base_injector.h:22
Definition: locker_factory.h:50
A builder that creates a single binding.
Definition: binder.h:106
A factory that accepts Modules and creates Injectors.
Definition: modules.h:77
Modules & add(Module &module)
Add the bindings defined by the given Module instance.
Definition: modules.h:135
void throwAnyPending()
Throw and clear any saved exception.
Definition: pending_thrower.h:46
sauce::shared_ptr< Injector > createInjector(Lockable &lockable) const
Create an Injector that can provide dependencies specified by all added Modules.
Definition: modules.h:159
Definition: injector.h:27
Modules & add()
Add the bindings defined by the given Module type.
Definition: modules.h:119
BindClause< Iface > bind() const
Begin binding the chosen interface.
Definition: modules.h:60