diff options
author | Aki <please@ignore.pl> | 2023-01-04 01:07:59 +0100 |
---|---|---|
committer | Aki <please@ignore.pl> | 2023-01-04 01:07:59 +0100 |
commit | 5b779a1aa8e59f63f26ee2fd5cec908bf5ce1159 (patch) | |
tree | 78667120c141f7433630e7c7dd9a0be43d16442f /universe | |
parent | 27ebde39fda0fb18a63f8974aca36a6118a16322 (diff) | |
download | kurator-5b779a1aa8e59f63f26ee2fd5cec908bf5ce1159.zip kurator-5b779a1aa8e59f63f26ee2fd5cec908bf5ce1159.tar.gz kurator-5b779a1aa8e59f63f26ee2fd5cec908bf5ce1159.tar.bz2 |
Added stub Json repository
Diffstat (limited to 'universe')
-rw-r--r-- | universe/CMakeLists.txt | 1 | ||||
-rw-r--r-- | universe/include/kurator/universe.h | 1 | ||||
-rw-r--r-- | universe/src/JsonRepository.cpp | 49 | ||||
-rw-r--r-- | universe/src/JsonRepository.h | 29 | ||||
-rw-r--r-- | universe/src/universe.cpp | 8 |
5 files changed, 88 insertions, 0 deletions
diff --git a/universe/CMakeLists.txt b/universe/CMakeLists.txt index daf55bc..7e8a795 100644 --- a/universe/CMakeLists.txt +++ b/universe/CMakeLists.txt @@ -1,6 +1,7 @@ project(universe) add_library( ${PROJECT_NAME} + src/JsonRepository.cpp src/NotFound.cpp src/SampleRepository.cpp src/TurretType.cpp diff --git a/universe/include/kurator/universe.h b/universe/include/kurator/universe.h index 73d06ae..6a00804 100644 --- a/universe/include/kurator/universe.h +++ b/universe/include/kurator/universe.h @@ -11,6 +11,7 @@ namespace universe { +auto load_json(const char* path) -> std::shared_ptr<Repository>; auto load_sample() -> std::shared_ptr<Repository>; diff --git a/universe/src/JsonRepository.cpp b/universe/src/JsonRepository.cpp new file mode 100644 index 0000000..ddbbfcf --- /dev/null +++ b/universe/src/JsonRepository.cpp @@ -0,0 +1,49 @@ +#include "JsonRepository.h" + +#include <functional> +#include <string> + +#include <kurator/universe/NotFound.h> +#include <kurator/universe/ShipType.h> +#include <kurator/universe/TurretType.h> + + +namespace kurator +{ +namespace universe +{ + + +JsonRepository::JsonRepository(const char*) +{ +} + + +ShipType +JsonRepository::ship_type(const std::string& id) const +{ + throw NotFound(id); +} + + +TurretType +JsonRepository::turret_type(const std::string& id) const +{ + throw NotFound(id); +} + + +void +JsonRepository::for_ship_types(std::function<void(const ShipType&)>) const +{ +} + + +void +JsonRepository::for_turret_types(std::function<void(const TurretType&)>) const +{ +} + + +} // namespace universe +} // namespace kurator diff --git a/universe/src/JsonRepository.h b/universe/src/JsonRepository.h new file mode 100644 index 0000000..dc6e7f1 --- /dev/null +++ b/universe/src/JsonRepository.h @@ -0,0 +1,29 @@ +#pragma once + +#include <functional> +#include <string> + +#include <kurator/universe/Repository.h> +#include <kurator/universe/ShipType.h> +#include <kurator/universe/TurretType.h> + + +namespace kurator +{ +namespace universe +{ + + +class JsonRepository : public Repository +{ +public: + explicit JsonRepository(const char* path); + ShipType ship_type(const std::string& id) const override; + TurretType turret_type(const std::string& id) const override; + void for_ship_types(std::function<void(const ShipType&)> func) const; + void for_turret_types(std::function<void(const TurretType&)> func) const; +}; + + +} // namespace universe +} // namespace kurator diff --git a/universe/src/universe.cpp b/universe/src/universe.cpp index b77ce7c..649b553 100644 --- a/universe/src/universe.cpp +++ b/universe/src/universe.cpp @@ -4,6 +4,7 @@ #include <kurator/universe/Repository.h> +#include "JsonRepository.h" #include "SampleRepository.h" @@ -14,6 +15,13 @@ namespace universe std::shared_ptr<Repository> +load_json(const char* path) +{ + return std::make_shared<JsonRepository>(path); +} + + +std::shared_ptr<Repository> load_sample() { return std::make_shared<SampleRepository>(); |