blob: 104cf5195ce7a931a3866da243880ce31b6653f6 (
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::Container
{
auto container = yacppdic::Container();
container.bind<IHero>().to<Hero>();
container.bind<IWeapon>().to<Sword>();
container.bind<IEnemyCreator>().to<EnemyCreator>();
container.bind<IEnemyFactory>()
.to_factory(
[]()
{
return std::make_unique<Enemy>(SMALL_ENEMY_HEALTH);
}
)
.when_tagged<SMALL_ENEMY_TAG>();
container.bind<IEnemyFactory>()
.to_factory(
[]()
{
return std::make_unique<Enemy>(BIG_ENEMY_HEALTH);
}
)
.when_tagged<BIG_ENEMY_TAG>();
return container;
}
|