Sauce-0.10.1 A C++ Dependency Injection Framework

- Main Page
- Classes
- Files

- File List

provider_binding.h
1 #ifndef SAUCE_INTERNAL_PROVIDER_BINDING_H_
2 #define SAUCE_INTERNAL_PROVIDER_BINDING_H_
3
4 #include <cassert>
5
6 #include <sauce/injector.h>
7 #include <sauce/memory.h>
8 #include <sauce/internal/binding.h>
9 #include <sauce/internal/key.h>
10
11 namespace sauce {
12 namespace internal {
13
17 template<typename Dependency, typename Scope, typename Provider>
18 class ProviderBinding: public Binding<Dependency, Scope> {
19 public:
20 typedef typename ResolvedBinding<Dependency>::BindingPtr BindingPtr;
21
22 void validateAcyclic(InjectorPtr injector, TypeIds & ids) const {
23 this->template validateAcyclicHelper<Provider>(injector, ids, this->getName());
24 }
25
26 void inject(typename Key<Dependency>::Ptr & injected, BindingPtr binding, InjectorPtr injector) const {
27 typename Key<Provider>::Ptr provider;
28 this->template injectHelper<Provider>(provider, injector, binding->getName());
29 injected = provider->get();
30 }
31 };
32
33 }
34
35 namespace i = ::sauce::internal;
36
37 }
38
39 #endif // SAUCE_INTERNAL_PROVIDER_BINDING_H_
sauce::internal
Definition: binder.h:317
sauce::internal::Binding< Dependency, Scope >::getName
std::string getName() const
The dynamic name of this binding.
Definition: binding.h:103
sauce::internal::ProviderBinding
An injection that provides from the configured provider.
Definition: provider_binding.h:18
sauce::internal::Binding
The base class of all actual binding implementations.
Definition: binding.h:22
sauce
Definition: binder.h:21
sauce::internal::Key
A complete specification of a dependency request.
Definition: key.h:15