diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-10-18 15:48:14 +0200 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-10-18 15:48:14 +0200 |
commit | d8289105193707daede1a5b59137f18e20f20aeb (patch) | |
tree | 939908b9c4c6f7aaef8aa61ee2e04be3e85610b6 /TileBehaviorFactory.cpp | |
parent | 76e61d68bbf568ec0d7fc4632e52d4de5496b003 (diff) |
(2/2) rename
Diffstat (limited to 'TileBehaviorFactory.cpp')
-rw-r--r-- | TileBehaviorFactory.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/TileBehaviorFactory.cpp b/TileBehaviorFactory.cpp new file mode 100644 index 0000000..99301ac --- /dev/null +++ b/TileBehaviorFactory.cpp @@ -0,0 +1,20 @@ +#include "TileBehaviorFactory.h" +#include "Exception.h" + +using namespace std; + +TileBehavior & TileBehaviorFactory::get_strategy(string type) { + auto & type_map = TileBehaviorFactory::get_collection(); + + if (type_map.contains(type)) + return *type_map.at(type); + + throw Exception("unknown behavior for tile type \"%s\"", type.c_str()); +} + +void TileBehaviorFactory::register_strategy(string type, TileBehavior * strategy) { + auto & type_map = TileBehaviorFactory::get_collection(); + + type_map[type] = strategy; +} + |