Sauce-0.10.1
A C++ Dependency Injection Framework
Classes | Public Types | Public Member Functions | Friends | List of all members
sauce::internal::NewBinding< Dependency, Scope, Constructor, Allocator > Class Template Reference
Inheritance diagram for sauce::internal::NewBinding< Dependency, Scope, Constructor, Allocator >:
Inheritance graph
[legend]
Collaboration diagram for sauce::internal::NewBinding< Dependency, Scope, Constructor, Allocator >:
Collaboration graph
[legend]

Public Types

typedef ResolvedBinding< Dependency >::BindingPtr BindingPtr
 
- Public Types inherited from sauce::internal::Binding< Dependency, Scope >
typedef Key< Dependency >::Normalized Dependency
 
typedef Key< Dependency >::Ptr IfacePtr
 
typedef ResolvedBinding< Dependency >::BindingPtr BindingPtr
 
- Public Types inherited from sauce::internal::ResolvedBinding< Dependency >
typedef Key< Dependency >::Ptr IfacePtr
 
typedef sauce::shared_ptr< ResolvedBinding< Dependency > > BindingPtr
 

Public Member Functions

void inject (IfacePtr &injected, BindingPtr binding, InjectorPtr injector) const
 Inject an Iface. More...
 
void dispose (Iface *iface) const
 
- Public Member Functions inherited from sauce::internal::Binding< Dependency, Scope >
std::string getName () const
 The dynamic name of this binding. More...
 
void setName (std::string const name)
 Set the dynamic name of this binding. More...
 
- Public Member Functions inherited from sauce::internal::ResolvedBinding< Dependency >
NamedTypeId getKey () const
 The TypeId of the Dependency template parameter. More...
 
virtual void validateAcyclic (sauce::shared_ptr< Injector >, TypeIds &) const =0
 Establish that further dependencies do not introduce cycles with ones already accumulated. More...
 
virtual void get (IfacePtr &, BindingPtr, sauce::shared_ptr< Injector >) const =0
 Get an Iface, using the given injector to provide dependencies. More...
 
- Public Member Functions inherited from sauce::internal::OpaqueBinding
virtual std::string getName () const =0
 The dynamic name of this binding. More...
 
virtual void setName (std::string)=0
 Set the dynamic name of this binding. More...
 
virtual NamedTypeId getKey () const =0
 The NamedTypeId of the (hidden) provided interface. More...
 
virtual bool isModifier () const
 Does this binding modify an existing value? More...
 
virtual TypeId getScopeKey () const =0
 The TypeId of the (hidden) scope.
 
virtual void eagerlyInject (OpaqueBindingPtr, sauce::shared_ptr< Injector >) const =0
 Provide, but do not return the hidden interface. More...
 
virtual void setDynamicDependencyNames (std::vector< std::string > const &)=0
 Accept the list of dynamic dependency names this binding was created with.
 

Friends

class NewBindingFriend
 

Additional Inherited Members

- Protected Member Functions inherited from sauce::internal::InjectorFriend
template<typename Dependency >
void validateAcyclicHelper (InjectorPtr injector, TypeIds &ids, std::string const name) const
 
template<typename Dependency >
void injectHelper (typename Key< Dependency >::Ptr &injected, InjectorPtr injector, std::string const name) const
 
template<typename Dependency >
void cache (InjectorPtr injector, typename Key< Dependency >::Ptr injected, i::TypeId scope) const
 
template<typename Dependency >
bool probe (InjectorPtr injector, typename Key< Dependency >::Ptr &injected, i::TypeId scope) const
 

Constructor & Destructor Documentation

◆ NewBinding()

template<typename Dependency , typename Scope , typename Constructor , typename Allocator >
sauce::internal::NewBinding< Dependency, Scope, Constructor, Allocator >::NewBinding ( )
inline
113 :
114 dynamicDependencyNames(Inject::arity(), unnamed()) {}

Member Function Documentation

◆ dispose()

template<typename Dependency , typename Scope , typename Constructor , typename Allocator >
void sauce::internal::NewBinding< Dependency, Scope, Constructor, Allocator >::dispose ( Iface *  iface) const
inline
134 {
135 typedef typename Allocator::template rebind<Impl>::other ImplAllocator;
136 ImplAllocator allocator;
137 Impl * impl = static_cast<Impl *>(iface);
138 impl->~Impl(); // Must not throw
139 allocator.deallocate(impl, 1);
140 }

◆ inject()

template<typename Dependency , typename Scope , typename Constructor , typename Allocator >
void sauce::internal::NewBinding< Dependency, Scope, Constructor, Allocator >::inject ( IfacePtr &  injected,
BindingPtr  binding,
InjectorPtr  injector 
) const
inlinevirtual

Inject an Iface.

A naked instance pointer is allocated and wrapped in a shared_ptr. It is also given a custom deleter, to dispose of the naked pointer with dispose(Iface *).

Implements sauce::internal::Binding< Dependency, Scope >.

123 {
124 typename InjectParameters::Passed passed(*this, injector);
125 Deleter deleter(sauce::static_pointer_cast<NewBinding_>(binding));
126 ImplPtr impl(applyConstructor<InjectParameters, Constructor, Allocator>(passed), deleter);
127 SelfInjector<Impl> selfInjector;
128 selfInjector.setSelf(impl);
129 typedef Named<Impl, typename i::Key<Dependency>::Name> NormalizedImpl;
130 this->template injectHelper<NormalizedImpl>(impl, injector, this->getName());
131 injected = sauce::static_pointer_cast<Iface>(impl);
132 }
std::string getName() const
The dynamic name of this binding.
Definition: binding.h:103
Here is the call graph for this function:

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