blob: 507cde74095ce42d06f76331e3cce96c8b2627fb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
#include "bootstrap.hpp"
// Interfaces
#include "interfaces/enemy.hpp"
#include "interfaces/enemy_creator.hpp"
#include "interfaces/hero.hpp"
#include "interfaces/weapon.hpp"
// Concretes
#include "enemy.hpp"
#include "enemy_creator.hpp"
#include "hero.hpp"
#include "sword.hpp"
auto bootstrap() -> yacppdic::DIContainer
{
auto di_container = yacppdic::DIContainer();
di_container.bind<IHero>().to<Hero>();
di_container.bind<IWeapon>().to<Sword>();
di_container.bind<IEnemyCreator>().to<EnemyCreator>();
di_container.bind<IEnemyFactory>()
.to_factory(
[]()
{
return std::make_unique<Enemy>(SMALL_ENEMY_HEALTH);
}
)
.when_tagged<SMALL_ENEMY_TAG>();
di_container.bind<IEnemyFactory>()
.to_factory(
[]()
{
return std::make_unique<Enemy>(BIG_ENEMY_HEALTH);
}
)
.when_tagged<BIG_ENEMY_TAG>();
return di_container;
}
|