#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; }