Welcome to DiLite.
DiLite allows developers to perform constructor injection of dependencies by creating a binding between a pair of types I
and T
such that T
is a concrete implementation of I
. This is based on the idea of interfaces from other object-oriented languages, and is achieved in C++ and DiLite using pure abstract classes.
The bindings can be used to resolve objects in either transient- or Singleton scope, thus freeing the developer to focus on business logic instead.
Please add some Samurais!
int main()
{
DI::GetInstance().Bind<IWeapon, Shuriken>();
DI::GetInstance().Bind<IWarrior>(&CreateSamurai);
IWarrior* w1 = DI::GetInstance().Resolve<IWarrior>();
IWarrior* w2 = DI::GetInstance().Resolve<IWarrior>();
w1->Attack(w2);
return 0;
}
IWarrior* CreateSamurai()
{
return new Samurai(DI::GetInstance().Resolve<IWeapon>());
}
Authors and Contributors
DiLite was initiated in 2012 during an Advanced Programming course in C++ at Aalborg University, Denmark. After hand-in, the project has been released as open-source.
Original project owners are:
- Jeppe Pihl (@jpihl)
- Lasse Linnerup Christiansen (@sw_lasse)
- Kenneth Fuglsang Christensen (@kfuglsang)