Sauce-0.10.1: sauce/internal/provider_binding.h Source File

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_