Module value_container

Aedi, a dependency injection library.

Aedi is a dependency injection library. It does provide a set of containers that do IoC, and an interface to configure application components (structs, objects, etc.)


The aim of library is to provide a dependency injection solution that is feature rich, easy to use, easy to learn, and easy to extend up to your needs.

Having a framework that creates and wire components is quite good. In previous tutorials, was explained how to inject compile time known data, and how to reference dependent components, but while designing a framework, or a library in conjunction with AEDI framework, exposing a set of parameters might be desired. To expose a set of configuration parameters, framework provides a special version of container, that stores in those parameters, and serves them to the requestor. To use this container it should be attached to a composite container along the rest of containers, as in previous tutorial and used along them. The process of adding parameters into container is easy as with rest of shown containers, the only difference is, that register method doesn’t require an explicit component type, since it is inferred from passed value. Example below shows basic usage of value container:

auto container = aggregate( // Create a joint container hosting other two containers
    singleton(), "singleton", // Create singleton container, and store it in joint container by "singleton" identity
    prototype(), "prototype", // Create prototype container, and store it in joint container by "prototype" identity
    values(), "parameters"  // Create value container, and store it in joint container by "prototype" identity

with (container.configure("singleton")) {

    // ...


with (container.configure("prototype")) {

    // ...

with (container.locate!ValueContainer("parameters").configure) {

    register(Size(200, 150, 300), "size.smarty");

As seen the configuration for value containers differs from other containers. In case of value containers configure method should know exactly what kind of configuration context to create.

Try running example. Add, modify it to understand usage of containers for already available values.


drive(car, name)


Engine Interface for engines.


Car A class representing a car.
CarManufacturer A manufacturer of cars.
DieselEngine A concrete implementation of Engine that uses diesel for propelling.
ElectricEngine A concrete implementation of Engine that uses electricity for propelling.
GasolineEngine A concrete implementation of Engine that uses gasoline for propelling.
Tire Tire, what it can represent else?


Color A struct that should be managed by container.
Size Size of a car.