From 37cdd775ac738b2a1264e32471385376e5a34f3a Mon Sep 17 00:00:00 2001 From: hop311 Date: Mon, 3 Jun 2024 23:39:34 +0100 Subject: Province const/mutable separation + State cleanup --- src/openvic-simulation/map/Region.hpp | 36 +++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) (limited to 'src/openvic-simulation/map/Region.hpp') diff --git a/src/openvic-simulation/map/Region.hpp b/src/openvic-simulation/map/Region.hpp index f12e14a..f532400 100644 --- a/src/openvic-simulation/map/Region.hpp +++ b/src/openvic-simulation/map/Region.hpp @@ -1,22 +1,40 @@ #pragma once -#include "openvic-simulation/map/Province.hpp" +#include +#include +#include + +#include "openvic-simulation/misc/Modifier.hpp" namespace OpenVic { - struct ProvinceSet { - using provinces_t = std::vector; + struct ProvinceDefinition; + struct ProvinceSet { private: - provinces_t provinces; + std::vector PROPERTY(provinces); bool locked = false; public: /* Returns true if the province is successfully added, false if not (including if it's already in the set). */ - bool add_province(Province const* province); - bool add_provinces(provinces_t const& new_provinces); + bool add_province(ProvinceDefinition const* province); + + template + requires std::convertible_to, ProvinceDefinition const*> + bool add_provinces(Container const& new_provinces) { + reserve_more(new_provinces.size()); + + bool ret = true; + + for (ProvinceDefinition const* province : new_provinces) { + ret &= add_province(province); + } + + return ret; + } + /* Returns true if the province is successfully removed, false if not (including if it's not in the set). */ - bool remove_province(Province const* province); + bool remove_province(ProvinceDefinition const* province); void lock(bool log = false); bool is_locked() const; void reset(); @@ -24,9 +42,7 @@ namespace OpenVic { size_t size() const; void reserve(size_t size); void reserve_more(size_t size); - bool contains_province(Province const* province) const; - provinces_t const& get_provinces() const; - Pop::pop_size_t calculate_total_population() const; + bool contains_province(ProvinceDefinition const* province) const; }; struct ProvinceSetModifier : Modifier, ProvinceSet { -- cgit v1.2.3-56-ga3b1