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

Sauce-0.10.1 A C++ Dependency Injection Framework

- Main Page
- Classes
- Files

- File List

instance_binding.h
1 #ifndef SAUCE_INTERNAL_INSTANCE_BINDING_H_
2 #define SAUCE_INTERNAL_INSTANCE_BINDING_H_
3
4 #include <sauce/injector.h>
5 #include <sauce/internal/binding.h>
6 #include <sauce/internal/key.h>
7 #include <sauce/memory.h>
8 #include <sauce/scopes.h>
9
10 namespace sauce {
11 namespace internal {
12
16 template<typename Dependency>
17 class InstanceBinding: public Binding<Dependency, NoScope> {
18 typedef typename Key<Dependency>::Ptr IfacePtr;
19 IfacePtr iface;
20
21 void validateAcyclic(InjectorPtr, TypeIds &) const {}
22
23 public:
24
25 typedef typename ResolvedBinding<Dependency>::BindingPtr BindingPtr;
26
27 InstanceBinding(IfacePtr iface):
28 Binding<Dependency, NoScope>(),
29 iface(iface) {}
30
34 void inject(IfacePtr & injected, BindingPtr, InjectorPtr) const {
35 injected = iface;
36 }
37 };
38
39 }
40
41 namespace i = ::sauce::internal;
42
43 }
44
45 #endif // SAUCE_INTERNAL_INSTANCE_BINDING_H_