Fork Me on GitHub


Lightweight Dependency Injection Framework for C++

Download this project as a .zip file Download this project as a tar.gz file

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>();

    IWarrior* w1 = DI::GetInstance().Resolve<IWarrior>();
    IWarrior* w2 = DI::GetInstance().Resolve<IWarrior>();


    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: