|
NuriaProject Framework
0.1
The NuriaProject Framework
|
Smart pointer class for dependency injection. More...
#include <dependencymanager.hpp>
Public Member Functions | |
| Dependency (const QByteArray &objectName=QByteArray()) | |
| T * | get () const |
| operator bool () const | |
| bool | operator!= (const Dependency< T > &other) const |
| T * | operator-> () const |
| bool | operator== (const Dependency< T > &other) const |
Smart pointer class for dependency injection.
Smart pointer which lazy-loads a referenced dependency from DependencyManager.
For objects with the default name, it's sufficient to use the default constructor:
If you're using a different object name, you can pass it:
To access the instance, use operator-> as you'd any other pointer:
Dependency offers operators for equality (==) and inequality (!=). Both operators only compare the object name.
A operator for implicit conversion to bool is offered for compatibility with raw pointers. This operator fetches the instance (If not already done) and returns true, if the instance is not nullptr.
|
inline |
Constructor. Takes an optional argument objectName. If not set, the name of the type of T is used.
|
inline |
Returns the referenced instance. On first invocation, it will be fetched from the DependencyManager.
|
inline |
Raw-pointer compatibility bool operator.
|
inline |
Inequality operator.
|
inline |
Convenience accessor. See get().
|
inline |
Equality operator.
1.8.9.1