Improve autowire module documentation

This commit is contained in:
Mike Bierlee 2015-02-21 01:18:07 +01:00
parent 50e754f429
commit f6a809c54a

View file

@ -30,12 +30,9 @@ struct UseMemberType {};
/** /**
* UDA for annotating class members as candidates for autowiring. * UDA for annotating class members as candidates for autowiring.
* *
* Annotate member declarations in classes with this UDA to make them eligable for autowiring. * Optionally a template parameter can be supplied to specify the type of a qualified class. The qualified type
* * of a concrete class is used to autowire members declared by supertype. If no qualifier is supplied, the type
* Optionally a type as template parameter can be suplied to specify a qualifier. Qualifiers are used * of the member is used as qualifier.
* to autowire members according the the type given. If class X, which inherits class Y, is given a qualifier
* of type Y, then only class X's members inherited from type Y are autowired. If no qualifier is supplied, the
* type of the member is used as qualifier.
* *
* Examples: * Examples:
* Annotate member of class to be autowired: * Annotate member of class to be autowired:
@ -48,15 +45,20 @@ struct UseMemberType {};
* *
* Annotate member of class with qualifier: * Annotate member of class with qualifier:
* --- * ---
* class V8Engine : Engine { ... } * class FuelEngine : Engine { ... }
* class ElectricEngine : Engine { ... }
* *
* class Car { * class HybridCar {
* @Autowire!V8Engine * @Autowire!FuelEngine
* public Engine engine; * public Engine fuelEngine;
*
* @Autowire!ElectricEngine
* public Engine electricEngine;
* } * }
* --- * ---
* The members of member "engine" will now be autowired properly, because the autowire mechanism will * The members of an instance of "HybridCar" will now be autowired properly, because the autowire mechanism will
* autowire member "engine" as if it's of type "V8Engine". * autowire member "fuelEngine" as if it's of type "FuelEngine". This means that the members of instance "fuelEngine"
* will also be autowired because the autowire mechanism knows that member "fuelEngine" is an instance of "FuelEngine"
*/ */
struct Autowire(QualifierType = UseMemberType) { struct Autowire(QualifierType = UseMemberType) {
QualifierType qualifier; QualifierType qualifier;
@ -128,7 +130,7 @@ public void autowire(Type)(DependencyContainer container, Type instance) {
} }
/** /**
* Autowire the given instance using the global dependency container. * Autowire the given instance using the globally available dependency container.
* *
* See_Also: DependencyContainer * See_Also: DependencyContainer
*/ */