aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/history
diff options
context:
space:
mode:
author zaaarf <zaaarf@proton.me>2023-11-22 17:16:34 +0100
committer zaaarf <zaaarf@proton.me>2023-11-22 17:16:34 +0100
commit1683859e333f98fb63f1c72d926bb366a3b89f0b (patch)
treee11dde918a7f1f228d3383ba8f9287385e43b4f5 /src/openvic-simulation/history
parent5c6caf6fbb7c606f4ebe0c397cc15c97d776f13d (diff)
chore: use PROPERTY and its variants when possible
Diffstat (limited to 'src/openvic-simulation/history')
-rw-r--r--src/openvic-simulation/history/Bookmark.cpp20
-rw-r--r--src/openvic-simulation/history/Bookmark.hpp16
-rw-r--r--src/openvic-simulation/history/DiplomaticHistory.cpp72
-rw-r--r--src/openvic-simulation/history/DiplomaticHistory.hpp64
4 files changed, 23 insertions, 149 deletions
diff --git a/src/openvic-simulation/history/Bookmark.cpp b/src/openvic-simulation/history/Bookmark.cpp
index 92d8de5..483b49b 100644
--- a/src/openvic-simulation/history/Bookmark.cpp
+++ b/src/openvic-simulation/history/Bookmark.cpp
@@ -17,26 +17,6 @@ Bookmark::Bookmark(
) : HasIdentifier { std::to_string(new_index) }, name { new_name }, description { new_description }, date { new_date },
initial_camera_x { new_initial_camera_x }, initial_camera_y { new_initial_camera_y } {}
-std::string_view Bookmark::get_name() const {
- return name;
-}
-
-std::string_view Bookmark::get_description() const {
- return description;
-}
-
-Date Bookmark::get_date() const {
- return date;
-}
-
-uint32_t Bookmark::get_initial_camera_x() const {
- return initial_camera_x;
-}
-
-uint32_t Bookmark::get_initial_camera_y() const {
- return initial_camera_y;
-}
-
BookmarkManager::BookmarkManager() : bookmarks { "bookmarks" } {}
bool BookmarkManager::add_bookmark(
diff --git a/src/openvic-simulation/history/Bookmark.hpp b/src/openvic-simulation/history/Bookmark.hpp
index d5253fe..18375fb 100644
--- a/src/openvic-simulation/history/Bookmark.hpp
+++ b/src/openvic-simulation/history/Bookmark.hpp
@@ -13,11 +13,11 @@ namespace OpenVic {
friend struct BookmarkManager;
private:
- const std::string name;
- const std::string description;
- const Date date;
- const uint32_t initial_camera_x;
- const uint32_t initial_camera_y;
+ const std::string PROPERTY(name);
+ const std::string PROPERTY(description);
+ const Date PROPERTY(date);
+ const uint32_t PROPERTY(initial_camera_x);
+ const uint32_t PROPERTY(initial_camera_y);
Bookmark(
size_t new_index, std::string_view new_name, std::string_view new_description, Date new_date,
@@ -26,12 +26,6 @@ namespace OpenVic {
public:
Bookmark(Bookmark&&) = default;
-
- std::string_view get_name() const;
- std::string_view get_description() const;
- Date get_date() const;
- uint32_t get_initial_camera_x() const;
- uint32_t get_initial_camera_y() const;
};
struct BookmarkManager {
diff --git a/src/openvic-simulation/history/DiplomaticHistory.cpp b/src/openvic-simulation/history/DiplomaticHistory.cpp
index 5cbafe7..5c560ea 100644
--- a/src/openvic-simulation/history/DiplomaticHistory.cpp
+++ b/src/openvic-simulation/history/DiplomaticHistory.cpp
@@ -15,48 +15,12 @@ WarHistory::added_wargoal_t::added_wargoal_t(
std::optional<Province const*> new_target
) : added { new_added }, actor { new_actor }, receiver { new_receiver }, wargoal { new_wargoal }, third_party { new_third_party }, target { new_target } {}
-Country const* WarHistory::added_wargoal_t::get_actor() const {
- return actor;
-}
-
-Country const* WarHistory::added_wargoal_t::get_receiver() const {
- return receiver;
-}
-
-WargoalType const* WarHistory::added_wargoal_t::get_wargoal_type() const {
- return wargoal;
-}
-
-std::optional<Country const*> const& WarHistory::added_wargoal_t::get_third_party() const {
- return third_party;
-}
-
-std::optional<Province const*> const& WarHistory::added_wargoal_t::get_target() const {
- return target;
-}
-
-Date WarHistory::added_wargoal_t::get_date_added() const {
- return added;
-}
-
WarHistory::war_participant_t::war_participant_t(
Country const* new_country,
Date new_joined,
std::optional<Date> new_exited
) : country { new_country }, joined { new_joined }, exited { new_exited } {}
-Country const* WarHistory::war_participant_t::get_country() const {
- return country;
-}
-
-Date WarHistory::war_participant_t::get_date_joined() const {
- return joined;
-}
-
-std::optional<Date> WarHistory::war_participant_t::get_date_exited() const {
- return exited;
-}
-
WarHistory::WarHistory(
std::string_view new_war_name,
std::vector<war_participant_t>&& new_attackers,
@@ -64,52 +28,16 @@ WarHistory::WarHistory(
std::vector<added_wargoal_t>&& new_wargoals
) : war_name { new_war_name }, attackers { std::move(new_attackers) }, defenders { std::move(new_defenders) }, wargoals { std::move(new_wargoals) } {}
-std::string_view WarHistory::get_war_name() const {
- return war_name;
-}
-
-std::vector<WarHistory::war_participant_t> const& WarHistory::get_attackers() const {
- return attackers;
-}
-
-std::vector<WarHistory::war_participant_t> const& WarHistory::get_defenders() const {
- return defenders;
-}
-
-std::vector<WarHistory::added_wargoal_t> const& WarHistory::get_wargoals() const {
- return wargoals;
-}
-
AllianceHistory::AllianceHistory(
Country const* new_first, Country const* new_second,
Date new_start, Date new_end
) : first { new_first }, second { new_second }, start { new_start }, end { new_end } {}
-Country const* AllianceHistory::get_first() const {
- return first;
-}
-
-Country const* AllianceHistory::get_second() const {
- return second;
-}
-
SubjectHistory::SubjectHistory(
Country const* new_overlord, Country const* new_subject,
const type_t new_type, const Date new_start, const Date new_end
) : overlord { new_overlord }, subject { new_subject }, type { new_type }, start { new_start }, end { new_end } {}
-Country const* SubjectHistory::get_overlord() const {
- return overlord;
-}
-
-Country const* SubjectHistory::get_subject() const {
- return subject;
-}
-
-const SubjectHistory::type_t SubjectHistory::get_subject_type() const {
- return type;
-}
-
void DiplomaticHistoryManager::lock_diplomatic_history() {
Logger::info("Locked diplomacy history registry after registering ", alliances.size() + subjects.size() + wars.size(), " items");
locked = true;
diff --git a/src/openvic-simulation/history/DiplomaticHistory.hpp b/src/openvic-simulation/history/DiplomaticHistory.hpp
index 64529c2..3ed253f 100644
--- a/src/openvic-simulation/history/DiplomaticHistory.hpp
+++ b/src/openvic-simulation/history/DiplomaticHistory.hpp
@@ -19,69 +19,46 @@ namespace OpenVic {
friend struct DiplomaticHistoryManager;
private:
- Date added;
- Country const* actor;
- Country const* receiver;
- WargoalType const* wargoal;
- std::optional<Country const*> third_party;
- std::optional<Province const*> target;
+ Date PROPERTY_CUSTOM_NAME(added, get_date_added);
+ Country const* PROPERTY(actor);
+ Country const* PROPERTY(receiver);
+ WargoalType const* PROPERTY(wargoal);
+ std::optional<Country const*> PROPERTY(third_party);
+ std::optional<Province const*> PROPERTY(target);
added_wargoal_t(Date new_added, Country const* new_actor, Country const* new_receiver, WargoalType const* new_wargoal, std::optional<Country const*> new_third_party, std::optional<Province const*> new_target);
-
- public:
- Date get_date_added() const;
- Country const* get_actor() const;
- Country const* get_receiver() const;
- WargoalType const* get_wargoal_type() const;
- std::optional<Country const*> const& get_third_party() const;
- std::optional<Province const*> const& get_target() const;
};
struct war_participant_t {
friend struct DiplomaticHistoryManager;
private:
- Country const* country;
- Date joined;
- std::optional<Date> exited;
+ Country const* PROPERTY(country);
+ Date PROPERTY_CUSTOM_NAME(joined, get_date_joined);
+ std::optional<Date> PROPERTY_CUSTOM_NAME(exited, get_date_exited);
war_participant_t(Country const* new_country, Date new_joined, std::optional<Date> new_exited);
-
- public:
- Country const* get_country() const;
- Date get_date_joined() const;
- std::optional<Date> get_date_exited() const;
};
private:
- std::string war_name; // edge cases where this is empty/undef for some reason, probably need to just generate war names like usual for that.
- std::vector<war_participant_t> attackers;
- std::vector<war_participant_t> defenders;
- std::vector<added_wargoal_t> wargoals;
+ std::string PROPERTY(war_name); // edge cases where this is empty/undef for some reason, probably need to just generate war names like usual for that.
+ std::vector<war_participant_t> PROPERTY(attackers);
+ std::vector<war_participant_t> PROPERTY(defenders);
+ std::vector<added_wargoal_t> PROPERTY(wargoals);
WarHistory(std::string_view new_war_name, std::vector<war_participant_t>&& new_attackers, std::vector<war_participant_t>&& new_defenders, std::vector<added_wargoal_t>&& new_wargoals);
-
- public:
- std::string_view get_war_name() const;
- std::vector<war_participant_t> const& get_attackers() const;
- std::vector<war_participant_t> const& get_defenders() const;
- std::vector<added_wargoal_t> const& get_wargoals() const;
};
struct AllianceHistory {
friend struct DiplomaticHistoryManager;
private:
- Country const* first;
- Country const* second;
+ Country const* PROPERTY(first);
+ Country const* PROPERTY(second);
const Date start;
const Date end;
AllianceHistory(Country const* new_first, Country const* new_second, const Date new_start, const Date new_end);
-
- public:
- Country const* get_first() const;
- Country const* get_second() const;
};
struct SubjectHistory {
@@ -94,18 +71,13 @@ namespace OpenVic {
};
private:
- Country const* overlord;
- Country const* subject;
- const type_t type;
+ Country const* PROPERTY(overlord);
+ Country const* PROPERTY(subject);
+ const type_t PROPERTY_CUSTOM_NAME(type, get_subject_type);
const Date start;
const Date end;
SubjectHistory(Country const* new_overlord, Country const* new_subject, const type_t new_type, const Date new_start, const Date new_end);
-
- public:
- Country const* get_overlord() const;
- Country const* get_subject() const;
- const type_t get_subject_type() const;
};
struct DiplomaticHistoryManager {