aboutsummaryrefslogtreecommitdiff
path: root/src/openvic/dataloader/Dataloader.hpp
blob: 3c868a35482fe38c4dc9d72b9400d08e05b8506e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#pragma once

#include <filesystem>

#include "openvic/types/Return.hpp"

#include "openvic-dataloader/v2script/Parser.hpp"

namespace OpenVic {
   struct GameManager;
   struct PopManager;

   class Dataloader {
      std::vector<std::filesystem::path> roots;

      static ovdl::v2script::Parser parse_defines(std::filesystem::path const& path);
      ovdl::v2script::Parser parse_defines_lookup(std::filesystem::path const& path) const;

      return_t _load_pop_types(PopManager& pop_manager, std::filesystem::path const& pop_type_directory) const;

   public:
      Dataloader() = default;

      /* In reverse-load order, so base defines first and final loaded mod last */
      return_t 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;
      return_t apply_to_files_in_dir(std::filesystem::path const& path,
         std::function<return_t(std::filesystem::path const&)> callback,
         std::filesystem::path const* extension = &TXT) const;

      return_t load_defines(GameManager& game_manager) const;
      return_t load_pop_history(GameManager& game_manager, std::filesystem::path const& path) const;
   };
}