diff options
author | HampusM <hampus@hampusmat.com> | 2022-05-06 18:23:42 +0200 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2022-05-06 18:23:55 +0200 |
commit | 3957dfb9361e864f6362e59655c885f52b39371f (patch) | |
tree | 5ef55a5eb418664b4a5c0d2d9328ff4ca99a74a7 /examples/basic/src/bootstrap.cpp | |
parent | d8ea3721d83254e91c5617d83f2aac5a897107fb (diff) |
docs: add tagging to basic examplev0.1.3
Diffstat (limited to 'examples/basic/src/bootstrap.cpp')
-rw-r--r-- | examples/basic/src/bootstrap.cpp | 26 |
1 files changed, 20 insertions, 6 deletions
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<IHero>().to<Hero>(); container.bind<IWeapon>().to<Sword>(); + container.bind<IEnemyCreator>().to<EnemyCreator>(); - container.bind<IEnemyFactory>().to_factory( - []() - { - return std::make_unique<Enemy>(); - } - ); + container.bind<IEnemyFactory>() + .to_factory( + []() + { + return std::make_unique<Enemy>(65); + } + ) + .when_tagged(SMALL_ENEMY_TAG); + + container.bind<IEnemyFactory>() + .to_factory( + []() + { + return std::make_unique<Enemy>(130); + } + ) + .when_tagged(BIG_ENEMY_TAG); return container; } |