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_
sauce::internal::InstanceBinding::inject
void inject(IfacePtr &injected, BindingPtr, InjectorPtr) const
Inject the instance passed at construction.
Definition: instance_binding.h:34
sauce::internal
Definition: binder.h:317
sauce::internal::InstanceBinding
An injection that provides the value passed at construction.
Definition: instance_binding.h:17
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