#pragma once #include #include #include "openvic-simulation/economy/BuildingType.hpp" #include "openvic-simulation/history/HistoryMap.hpp" #include "openvic-simulation/map/ProvinceInstance.hpp" #include "openvic-simulation/pop/Pop.hpp" #include "openvic-simulation/types/Date.hpp" #include "openvic-simulation/types/fixed_point/FixedPointMap.hpp" #include "openvic-simulation/types/OrderedContainers.hpp" #include "openvic-simulation/utility/Getters.hpp" namespace OpenVic { struct ProvinceHistoryMap; struct ProvinceDefinition; struct CountryDefinition; struct GoodDefinition; struct TerrainType; struct Ideology; struct DefinitionManager; struct ProvinceHistoryEntry : HistoryEntry { friend struct ProvinceHistoryMap; private: ProvinceDefinition const& PROPERTY(province); std::optional PROPERTY(owner); std::optional PROPERTY(controller); std::optional PROPERTY(colonial); std::optional PROPERTY(slave); ordered_map PROPERTY(cores); std::optional PROPERTY(rgo_production_type_nullable); std::optional PROPERTY(life_rating); std::optional PROPERTY(terrain_type); ordered_map PROPERTY(province_buildings); ordered_map PROPERTY(state_buildings); fixed_point_map_t PROPERTY(party_loyalties); std::vector PROPERTY(pops); ProvinceHistoryEntry(ProvinceDefinition const& new_province, Date new_date); bool _load_province_pop_history( DefinitionManager const& definition_manager, ast::NodeCPtr root, bool *non_integer_size ); }; struct ProvinceHistoryManager; struct ProvinceHistoryMap : HistoryMap { friend struct ProvinceHistoryManager; private: ProvinceDefinition const& PROPERTY(province); protected: ProvinceHistoryMap(ProvinceDefinition const& new_province); std::unique_ptr _make_entry(Date date) const override; bool _load_history_entry( DefinitionManager const& definition_manager, ProvinceHistoryEntry& entry, ast::NodeCPtr root ) override; private: bool _load_province_pop_history( DefinitionManager const& definition_manager, Date date, ast::NodeCPtr root, bool *non_integer_size ); }; struct MapDefinition; struct ProvinceHistoryManager { private: ordered_map province_histories; bool locked = false; ProvinceHistoryMap* _get_or_make_province_history(ProvinceDefinition const& province); public: ProvinceHistoryManager() = default; void reserve_more_province_histories(size_t size); void lock_province_histories(MapDefinition const& map_definition, bool detailed_errors); bool is_locked() const; ProvinceHistoryMap const* get_province_history(ProvinceDefinition const* province) const; bool load_province_history_file( DefinitionManager const& definition_manager, ProvinceDefinition const& province, ast::NodeCPtr root ); bool load_pop_history_file( DefinitionManager const& definition_manager, Date date, ast::NodeCPtr root, bool *non_integer_size ); }; }