From 3957dfb9361e864f6362e59655c885f52b39371f Mon Sep 17 00:00:00 2001 From: HampusM Date: Fri, 6 May 2022 18:23:42 +0200 Subject: docs: add tagging to basic example --- examples/basic/src/bootstrap.cpp | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) (limited to 'examples/basic/src/bootstrap.cpp') diff --git a/examples/basic/src/bootstrap.cpp b/examples/basic/src/bootstrap.cpp index 38edcc3..7a78aec 100644 --- a/examples/basic/src/bootstrap.cpp +++ b/examples/basic/src/bootstrap.cpp @@ -2,11 +2,13 @@ // 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" @@ -16,13 +18,25 @@ yacppdic::Container bootstrap() container.bind().to(); container.bind().to(); + container.bind().to(); - container.bind().to_factory( - []() - { - return std::make_unique(); - } - ); + container.bind() + .to_factory( + []() + { + return std::make_unique(65); + } + ) + .when_tagged(SMALL_ENEMY_TAG); + + container.bind() + .to_factory( + []() + { + return std::make_unique(130); + } + ) + .when_tagged(BIG_ENEMY_TAG); return container; } -- cgit v1.2.3-18-g5258