Autowiring  1.0.3
A C++ Inversion of Control Framework
autowiring::auto_out< T > Class Template Reference

The auto_out<T> class provides a way to implement deferred-output autofilters. More...

#include <auto_out.h>

Public Member Functions

void reset (void)
 Releases the internal implementatoin object More...
 

Detailed Description

template<class T>
class autowiring::auto_out< T >

The auto_out<T> class provides a way to implement deferred-output autofilters.

An auto_out<T> parameter in an autofilter is an output parameter equivalent to type T. It stores a std::shared_ptr to the AutoPacket from which the autofilter call was generated, and essentially just waits to be assigned to, at which point it decorates the packet with the assigned value. If the auto_out<T> instance (and all copies of it) is destroyed without being assigned to, then it marks T as unsatisfiable, which has particular consequences (see AutoPacket::MarkUnsatisfiable).

In particular, auto_out<T> allows one to define asynchronously processed autofilters by deferring output decoration until much later than the filter itself was called. For example, one could store the auto_out<T>, begin an asynchronous process on a different thread, and assign to the auto_out<T> once that process completes.

The auto_out<T> class has shared_ptr style semantics (pointer dereferencing), and additionally can be assigned to from various types, primary including T and its relatives (e.g. const T& and T&& and std::shared_ptr<T>. When assigned to from a T-like typed value, the packet is decorated with that value. Assignment can only happen once.

Note that auto_out<T> as an output parameter of an autofilter is conceptually less strict than T&. The former does not guarantee that T will be decorated onto the packet by the time the autofilter method returns, and the determination of which may require reasoning about the run-time state of the program. The latter guarantees that T will be decorated onto the packet by the time the autofilter method returns. Use T& if possible, and only use auto_out<T> when the deferred output behavior is required.

Member Function Documentation

template<class T >
void autowiring::auto_out< T >::reset ( void  )
inline

Releases the internal implementatoin object

If this auto_out is the last handle to this output instance, this method will cause the attached decoration to be assigned


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