Sauce-0.10.1: sauce::internal::Bindings< ImplicitBindings > Class Template Reference

Sauce-0.10.1 A C++ Dependency Injection Framework

- Main Page
- Classes
- Files

- Class List
- Class Hierarchy
- Class Members

Public Member Functions | List of all members
sauce::internal::Bindings< ImplicitBindings > Class Template Reference

A container for bindings. More...

`#include <sauce/internal/bindings.h>`

## Public Member Functions
void | put (OpaqueBindingPtr binding)
| Insert the given binding.
template<typename Dependency >
sauce::shared_ptr < ResolvedBinding< Dependency > > | getProvidingBinding (std::string const name) const
template<typename Dependency >
std::vector< sauce::shared_ptr < ResolvedBinding< Dependency > > > | getModifierBindings (std::string const name) const
template<typename Dependency >
void | validateAcyclic (bool validateProviding, InjectorPtr injector, TypeIds &ids, std::string const name) const
template<typename Dependency >
void | get (typename Key< Dependency >::Ptr &injected, InjectorPtr injector, std::string const name) const
| Inject the named Dependency.
template<typename Scope >
void | eagerlyInject (InjectorPtr injector) const

## Detailed Description

### template<typename ImplicitBindings>
class sauce::internal::Bindings< ImplicitBindings >

A container for bindings.

Each Modules objects creates a Bindings, and passes a const copy to each Injector it creates. The set of bindings an Injector uses is therefore read-only.

When providing instances (eagerly and not) the injector is passed in and the dependency is returned directly, instead of giving the binding to the injector (the binding details stay hidden.)

The template parameter is a strategy type that attempts to located unknown bindings dynamically (implicitly.) Due to the threat of circular dependencies (in Sauce's type space), Bindings itself can't be aware of concrete Binding implementations. The only time it needs to know about them is when resolving implicit bindings. So, this functionality is hidden behind the templated strategy.

## Member Function Documentation

template<typename ImplicitBindings>
template<typename Dependency >

void sauce::internal::Bindings< ImplicitBindings >::get | ( | typename Key< Dependency >::Ptr & | injected,
|  | InjectorPtr | injector,
|  | std::string const | name
| ) |  | const
| inline

Inject the named Dependency.

If no binding is found, the implicit bindings are checked.

{
typedef sauce::shared_ptr<ResolvedBinding<Dependency> > BindingPtr;
BindingPtr binding;
if (injected.get() == NULL) {
binding = getProvidingBinding<Dependency>(name);
binding->get(injected, binding, injector);
}
typedef std::vector<BindingPtr> BindingPtrs;
BindingPtrs bindings = getModifierBindings<Dependency>(name);
for (typename BindingPtrs::iterator i = bindings.begin(); i != bindings.end(); ++i) {
binding = *i;
binding->get(injected, binding, injector);
}
}

The documentation for this class was generated from the following file:

- sauce/internal/bindings.h