diff options
Diffstat (limited to 'TileBehavior.cpp')
-rw-r--r-- | TileBehavior.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/TileBehavior.cpp b/TileBehavior.cpp new file mode 100644 index 0000000..6cabd40 --- /dev/null +++ b/TileBehavior.cpp @@ -0,0 +1,20 @@ +#include "TileBehavior.h" +#include "Exception.h" + +using namespace std; + +TileBehaviorStrategy & TileBehavior::get_strategy(string type) { + auto & type_map = TileBehavior::get_collection(); + + if (type_map.contains(type)) + return *type_map.at(type); + + throw Exception("unknown behavior for tile type \"%s\"", type.c_str()); +} + +void TileBehavior::register_strategy(string type, TileBehaviorStrategy * strategy) { + auto & type_map = TileBehavior::get_collection(); + + type_map[type] = strategy; +} + |