blob: 343f01b49ee136780ac53dba68c8690d09b84135 (
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
#include "bootstrap.hpp"
// Interfaces
#include "interfaces/argument_parser.hpp"
#include "interfaces/bounds.hpp"
#include "interfaces/game.hpp"
#include "interfaces/game_initializer.hpp"
#include "interfaces/input.hpp"
#include "interfaces/input_configurator.hpp"
#include "interfaces/matrix.hpp"
#include "interfaces/randomization.hpp"
#include "interfaces/scene.hpp"
#include "interfaces/vector2.hpp"
// Implementations
#include "argument_parser.hpp"
#include "engine/game_initializer.hpp"
#include "engine/graphics/bounds.hpp"
#include "engine/graphics/scene.hpp"
#include "engine/graphics/string_matrix.hpp"
#include "engine/graphics/vector2.hpp"
#include "engine/user/cursor.hpp"
#include "engine/user/input.hpp"
#include "game/game.hpp"
#include "game/input_configurator.hpp"
#include "randomization/generator.hpp"
#include "randomization/seed_generator.hpp"
#include <memory>
#include <random>
#include <string_view>
Container bootstrap()
{
auto container = Container();
container.bind<IArgumentParser>().to<ArgumentParser>();
container.bind<IGame>().to<Game>();
container.bind<IScene>().to<Scene>();
container.bind<IInputHandler>().to<InputHandler>();
container.bind<CursorController>().to<CursorController>();
container.bind<IGameInitializer>().to<GameInitializer>();
container.bind<IInputConfigurator>().to<InputConfigurator>();
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));
});
container.bind<IMatrixFactory<std::string_view>>().to_factory(
[](const IBounds &bounds)
{
return std::dynamic_pointer_cast<IMatrix<std::string_view>>(
std::make_shared<StringMatrix>(bounds));
});
container.bind<IBoundsFactory>().to_factory(
[](const IBoundsOptions &options)
{
return std::dynamic_pointer_cast<IBounds>(std::make_shared<Bounds>(options));
});
return container;
}
|