aboutsummaryrefslogtreecommitdiff
path: root/src/bootstrap.cpp
blob: ce07621111d196796270d6ea61fbb0f4695d1f59 (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
43
44
45
46
47
48
#include "bootstrap.hpp"

// Interfaces
#include "interfaces/argument_parser.hpp"
#include "interfaces/game.hpp"
#include "interfaces/randomization.hpp"
#include "interfaces/vector2.hpp"

// Implementations
#include "argument_parser.hpp"
#include "engine/graphics/vector2.hpp"
#include "game/game.hpp"
#include "randomization/generator.hpp"
#include "randomization/seed_generator.hpp"

#include <memory>
#include <random>

Container bootstrap()
{
	auto container = Container();

	container.bind<IArgumentParser>().to<ArgumentParser>();
	container.bind<IGame>().to<Game>();

	container.bind<IRandomNumberGeneratorFactory>().to_factory(
		[](const unsigned int &seed)
		{
			return std::dynamic_pointer_cast<IRandomNumberGenerator>(
				std::make_shared<RandomNumberGenerator>(seed));
		});

	container.bind<ISeedGeneratorFactory>().to_factory(
		[]()
		{
			return std::dynamic_pointer_cast<ISeedGenerator>(
				std::make_shared<SeedGenerator>(std::make_unique<std::random_device>()));
		});

	container.bind<IVector2Factory>().to_factory(
		[](const IVector2Options &options)
		{
			return std::dynamic_pointer_cast<IVector2>(
				std::make_shared<Vector2>(options));
		});

	return container;
}