Autowiring  1.0.3
A C++ Inversion of Control Framework
AutoRequired< T > Class Template Reference

Autowires the specified dependency, creating a new instance if one does not already exist. More...

#include <Autowired.h>

Inherits shared_ptr< T >.

Public Member Functions

template<class... Args>
 AutoRequired (const std::shared_ptr< CoreContext > &ctxt, Args &&...args)
 AutoRequired overload that forwards constructor arguments to the type being wired. More...
 

Detailed Description

template<class T>
class AutoRequired< T >

Autowires the specified dependency, creating a new instance if one does not already exist.

Autowiring searches for a suitable instance to satisfy this dependency in the current context or any of its ancestors. If that search fails, a new instance of the specified type is created.

If type T has a static member function called New, Autowiring calls this function instead of the default constructor, even if the default constructor has been supplied, and even if the arity of the New routine is not zero. To prevent this behavior, use a name other than New.

If you get a compile error when using AutoRequire, ensure that class T is fully defined at the point in the program where the type is autorequired.

Examples:
AutoFilterExample.cpp, AutoNetExample.cpp, ContextExample.cpp, and ThreadExample.cpp.

Constructor & Destructor Documentation

template<class T>
template<class... Args>
AutoRequired< T >::AutoRequired ( const std::shared_ptr< CoreContext > &  ctxt,
Args &&...  args 
)
inline

AutoRequired overload that forwards constructor arguments to the type being wired.


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