aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/dataloader/Dataloader.hpp
diff options
context:
space:
mode:
author Hop311 <hop3114@gmail.com>2023-09-08 18:12:22 +0200
committer Hop311 <hop3114@gmail.com>2023-09-08 18:12:22 +0200
commit7772f8871348b7b52cb0a478bb76df68d8799a07 (patch)
treefd8c4626b2cee69a9fe9250365af6b18eea63c70 /src/openvic-simulation/dataloader/Dataloader.hpp
parent7f9a9a8241ba81be9213e6606b8be4a48f1cbaab (diff)
More refactoring and duplicate code removal
Diffstat (limited to 'src/openvic-simulation/dataloader/Dataloader.hpp')
-rw-r--r--src/openvic-simulation/dataloader/Dataloader.hpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/openvic-simulation/dataloader/Dataloader.hpp b/src/openvic-simulation/dataloader/Dataloader.hpp
new file mode 100644
index 0000000..f723803
--- /dev/null
+++ b/src/openvic-simulation/dataloader/Dataloader.hpp
@@ -0,0 +1,35 @@
+#pragma once
+
+#include <filesystem>
+#include <functional>
+#include <vector>
+
+namespace OpenVic {
+ struct GameManager;
+ struct PopManager;
+ struct Map;
+
+ class Dataloader {
+ std::vector<std::filesystem::path> roots;
+
+ bool _load_pop_types(PopManager& pop_manager, std::filesystem::path const& pop_type_directory) const;
+ bool _load_map_dir(Map& map, std::filesystem::path const& map_directory) const;
+
+ public:
+ Dataloader() = default;
+
+ /* In reverse-load order, so base defines first and final loaded mod last */
+ bool set_roots(std::vector<std::filesystem::path> new_roots);
+
+ std::filesystem::path lookup_file(std::filesystem::path const& path) const;
+ static const std::filesystem::path TXT;
+ std::vector<std::filesystem::path> lookup_files_in_dir(std::filesystem::path const& path,
+ std::filesystem::path const* extension = &TXT) const;
+ bool apply_to_files_in_dir(std::filesystem::path const& path,
+ std::function<bool(std::filesystem::path const&)> callback,
+ std::filesystem::path const* extension = &TXT) const;
+
+ bool load_defines(GameManager& game_manager) const;
+ bool load_pop_history(GameManager& game_manager, std::filesystem::path const& path) const;
+ };
+}