From 5864e5abc43b201c3801fa39a2fcaf9e3a9e8914 Mon Sep 17 00:00:00 2001 From: HampusM Date: Sun, 27 Feb 2022 12:54:10 +0100 Subject: refactor: use dependency injection --- src/bootstrap.cpp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/bootstrap.cpp (limited to 'src/bootstrap.cpp') diff --git a/src/bootstrap.cpp b/src/bootstrap.cpp new file mode 100644 index 0000000..85498bc --- /dev/null +++ b/src/bootstrap.cpp @@ -0,0 +1,36 @@ +#include "bootstrap.hpp" + +// Interfaces +#include "interfaces/argument_parser.hpp" +#include "interfaces/randomization.hpp" + +// Implementations +#include "argument_parser.hpp" +#include "randomization/generator.hpp" +#include "randomization/seed_generator.hpp" + +#include +#include + +Container bootstrap() +{ + auto container = Container(); + + container.bind().to(); + + container.bind().to_factory( + [](const unsigned int &seed) + { + return std::dynamic_pointer_cast( + std::make_shared(seed)); + }); + + container.bind().to_factory( + []() + { + return std::dynamic_pointer_cast( + std::make_shared(std::make_unique())); + }); + + return container; +} -- cgit v1.2.3-18-g5258