diff options
Diffstat (limited to 'universe/src/SampleRepository.cpp')
-rw-r--r-- | universe/src/SampleRepository.cpp | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/universe/src/SampleRepository.cpp b/universe/src/SampleRepository.cpp new file mode 100644 index 0000000..66a3105 --- /dev/null +++ b/universe/src/SampleRepository.cpp @@ -0,0 +1,51 @@ +#include "SampleRepository.h" + +#include <stdexcept> +#include <string> +#include <unordered_map> + +#include <kurator/universe/NotFound.h> +#include <kurator/universe/ShipType.h> +#include <kurator/universe/TurretType.h> + + +namespace kurator +{ +namespace universe +{ + + +static const std::unordered_map<std::string, ShipType> ships { + {"cube", {"Cube", 10.0}}, + {"halo", {"Halo", 4.0}}, + {"bell", {"Bell", 18.0}}, +}; + + +static const std::unordered_map<std::string, TurretType> turrets { + {"cannon", {"Cannon", 1.0, 1.0, 0.5}}, +}; + + +ShipType +SampleRepository::ship_type(const std::string& id) const +try { + return ships.at(id); +} +catch (const std::out_of_range&) { + throw NotFound(id); +} + + +TurretType +SampleRepository::turret_type(const std::string& id) const +try { + return turrets.at(id); +} +catch (const std::out_of_range&) { + throw NotFound(id); +} + + +} // namespace universe +} // namespace kurator |