From 1683859e333f98fb63f1c72d926bb366a3b89f0b Mon Sep 17 00:00:00 2001 From: zaaarf Date: Wed, 22 Nov 2023 17:16:34 +0100 Subject: chore: use PROPERTY and its variants when possible --- src/openvic-simulation/politics/Government.cpp | 20 ---------------- src/openvic-simulation/politics/Government.hpp | 14 ++++-------- src/openvic-simulation/politics/Ideology.cpp | 16 ------------- src/openvic-simulation/politics/Ideology.hpp | 12 ++++------ src/openvic-simulation/politics/Issue.cpp | 28 ----------------------- src/openvic-simulation/politics/Issue.hpp | 19 +++++---------- src/openvic-simulation/politics/NationalValue.cpp | 4 ---- src/openvic-simulation/politics/NationalValue.hpp | 4 +--- 8 files changed, 16 insertions(+), 101 deletions(-) (limited to 'src/openvic-simulation/politics') diff --git a/src/openvic-simulation/politics/Government.cpp b/src/openvic-simulation/politics/Government.cpp index 3b0f28d..0d1d063 100644 --- a/src/openvic-simulation/politics/Government.cpp +++ b/src/openvic-simulation/politics/Government.cpp @@ -16,26 +16,6 @@ bool GovernmentType::is_ideology_compatible(Ideology const* ideology) const { return std::find(ideologies.begin(), ideologies.end(), ideology) != ideologies.end(); } -std::vector const& GovernmentType::get_ideologies() const { - return ideologies; -} - -bool GovernmentType::holds_elections() const { - return elections; -} - -bool GovernmentType::can_appoint_ruling_party() const { - return appoint_ruling_party; -} - -Timespan GovernmentType::get_term_duration() const { - return term_duration; -} - -std::string_view GovernmentType::get_flag_type() const { - return flag_type_identifier; -} - GovernmentTypeManager::GovernmentTypeManager() : government_types { "government types" } {} bool GovernmentTypeManager::add_government_type( diff --git a/src/openvic-simulation/politics/Government.hpp b/src/openvic-simulation/politics/Government.hpp index 9fff111..fde7d32 100644 --- a/src/openvic-simulation/politics/Government.hpp +++ b/src/openvic-simulation/politics/Government.hpp @@ -9,10 +9,11 @@ namespace OpenVic { friend struct GovernmentTypeManager; private: - const std::vector ideologies; - const bool elections, appoint_ruling_party; - const Timespan term_duration; - const std::string flag_type_identifier; + const std::vector PROPERTY(ideologies); + const bool PROPERTY_CUSTOM_NAME(elections, holds_elections); + const bool PROPERTY_CUSTOM_NAME(appoint_ruling_party, can_appoint_ruling_party); + const Timespan PROPERTY(term_duration); + const std::string PROPERTY_CUSTOM_NAME(flag_type_identifier, get_flag_type); GovernmentType( std::string_view new_identifier, std::vector&& new_ideologies, bool new_elections, @@ -23,11 +24,6 @@ namespace OpenVic { GovernmentType(GovernmentType&&) = default; bool is_ideology_compatible(Ideology const* ideology) const; - std::vector const& get_ideologies() const; - bool holds_elections() const; - bool can_appoint_ruling_party() const; - Timespan get_term_duration() const; - std::string_view get_flag_type() const; }; struct GovernmentTypeManager { diff --git a/src/openvic-simulation/politics/Ideology.cpp b/src/openvic-simulation/politics/Ideology.cpp index 148d6ac..569f834 100644 --- a/src/openvic-simulation/politics/Ideology.cpp +++ b/src/openvic-simulation/politics/Ideology.cpp @@ -11,22 +11,6 @@ Ideology::Ideology( ) : HasIdentifierAndColour { new_identifier, new_colour, false, false }, group { new_group }, uncivilised { new_uncivilised }, can_reduce_militancy { new_can_reduce_militancy }, spawn_date { new_spawn_date } {} -IdeologyGroup const& Ideology::get_group() const { - return group; -} - -bool Ideology::is_uncivilised() const { - return uncivilised; -} - -bool Ideology::get_can_reduce_militancy() const { - return can_reduce_militancy; -} - -Date Ideology::get_spawn_date() const { - return spawn_date; -} - IdeologyManager::IdeologyManager() : ideology_groups { "ideology groups" }, ideologies { "ideologies" } {} bool IdeologyManager::add_ideology_group(std::string_view identifier) { diff --git a/src/openvic-simulation/politics/Ideology.hpp b/src/openvic-simulation/politics/Ideology.hpp index bdf9f91..47ae45b 100644 --- a/src/openvic-simulation/politics/Ideology.hpp +++ b/src/openvic-simulation/politics/Ideology.hpp @@ -19,9 +19,10 @@ namespace OpenVic { friend struct IdeologyManager; private: - IdeologyGroup const& group; - const bool uncivilised, can_reduce_militancy; - const Date spawn_date; + IdeologyGroup const& PROPERTY(group); + const bool PROPERTY_CUSTOM_NAME(uncivilised, is_uncivilised); + const bool PROPERTY(can_reduce_militancy); + const Date PROPERTY(spawn_date); // TODO - willingness to repeal/pass reforms (and its modifiers) @@ -32,11 +33,6 @@ namespace OpenVic { public: Ideology(Ideology&&) = default; - - IdeologyGroup const& get_group() const; - bool is_uncivilised() const; - bool get_can_reduce_militancy() const; - Date get_spawn_date() const; }; struct IdeologyManager { diff --git a/src/openvic-simulation/politics/Issue.cpp b/src/openvic-simulation/politics/Issue.cpp index cc3c12b..9164831 100644 --- a/src/openvic-simulation/politics/Issue.cpp +++ b/src/openvic-simulation/politics/Issue.cpp @@ -7,43 +7,15 @@ IssueGroup::IssueGroup(std::string_view new_identifier) : HasIdentifier { new_id Issue::Issue(std::string_view identifier, IssueGroup const& group) : HasIdentifier { identifier }, group { group } {} -IssueGroup const& Issue::get_group() const { - return group; -} - ReformType::ReformType(std::string_view new_identifier, bool uncivilised) : HasIdentifier { new_identifier }, uncivilised { uncivilised } {} ReformGroup::ReformGroup(std::string_view identifier, ReformType const& type, bool ordered, bool administrative) : IssueGroup { identifier }, type { type }, ordered { ordered }, administrative { administrative } {} -ReformType const& ReformGroup::get_type() const { - return type; -} - -bool ReformGroup::is_ordered() const { - return ordered; -} - -bool ReformGroup::is_administrative() const { - return administrative; -} - Reform::Reform(std::string_view identifier, ReformGroup const& group, size_t ordinal) : Issue { identifier, group }, ordinal { ordinal }, reform_group { group } {} -ReformGroup const& Reform::get_reform_group() const { - return reform_group; -} - -ReformType const& Reform::get_type() const { - return get_reform_group().get_type(); -} - -size_t Reform::get_ordinal() const { - return ordinal; -} - IssueManager::IssueManager() : issue_groups { "issue groups" }, issues { "issues" }, reform_types { "reform types" }, reform_groups { "reform groups" }, reforms { "reforms" } {} diff --git a/src/openvic-simulation/politics/Issue.hpp b/src/openvic-simulation/politics/Issue.hpp index 84aa886..0dceae9 100644 --- a/src/openvic-simulation/politics/Issue.hpp +++ b/src/openvic-simulation/politics/Issue.hpp @@ -25,7 +25,7 @@ namespace OpenVic { friend struct IssueManager; private: - IssueGroup const& group; + IssueGroup const& PROPERTY(group); // TODO: policy modifiers, policy rule changes @@ -34,7 +34,6 @@ namespace OpenVic { public: Issue(Issue&&) = default; - IssueGroup const& get_group() const; }; // Reform type (i.e. political_issues) @@ -56,17 +55,14 @@ namespace OpenVic { friend struct IssueManager; private: - ReformType const& type; - const bool ordered; // next_step_only - const bool administrative; + ReformType const& PROPERTY(type); + const bool PROPERTY_CUSTOM_NAME(ordered, is_ordered); // next_step_only + const bool PROPERTY_CUSTOM_NAME(administrative, is_administrative); ReformGroup(std::string_view identifier, ReformType const& type, bool ordered, bool administrative); public: ReformGroup(ReformGroup&&) = default; - ReformType const& get_type() const; - bool is_ordered() const; - bool is_administrative() const; }; // Reform (i.e. yes_slavery) @@ -74,8 +70,8 @@ namespace OpenVic { friend struct IssueManager; private: - ReformGroup const& reform_group; // stores an already casted reference - const size_t ordinal; // assigned by the parser to allow policy sorting + ReformGroup const& PROPERTY(reform_group); // stores an already casted reference + const size_t PROPERTY(ordinal); // assigned by the parser to allow policy sorting Reform(std::string_view new_identifier, ReformGroup const& group, size_t ordinal); @@ -83,9 +79,6 @@ namespace OpenVic { public: Reform(Reform&&) = default; - ReformGroup const& get_reform_group() const; - ReformType const& get_type() const; - size_t get_ordinal() const; }; // Issue manager - holds the registries diff --git a/src/openvic-simulation/politics/NationalValue.cpp b/src/openvic-simulation/politics/NationalValue.cpp index f1d8a3b..3760eec 100644 --- a/src/openvic-simulation/politics/NationalValue.cpp +++ b/src/openvic-simulation/politics/NationalValue.cpp @@ -6,10 +6,6 @@ using namespace OpenVic::NodeTools; NationalValue::NationalValue(std::string_view new_identifier, ModifierValue&& new_modifiers) : HasIdentifier { new_identifier }, modifiers { std::move(new_modifiers) } {} -ModifierValue const& NationalValue::get_modifiers() const { - return modifiers; -} - NationalValueManager::NationalValueManager() : national_values { "national values" } {} bool NationalValueManager::add_national_value(std::string_view identifier, ModifierValue&& modifiers) { diff --git a/src/openvic-simulation/politics/NationalValue.hpp b/src/openvic-simulation/politics/NationalValue.hpp index 625be36..824da7e 100644 --- a/src/openvic-simulation/politics/NationalValue.hpp +++ b/src/openvic-simulation/politics/NationalValue.hpp @@ -10,14 +10,12 @@ namespace OpenVic { friend struct NationalValueManager; private: - const ModifierValue modifiers; + const ModifierValue PROPERTY(modifiers); NationalValue(std::string_view new_identifier, ModifierValue&& new_modifiers); public: NationalValue(NationalValue&&) = default; - - ModifierValue const& get_modifiers() const; }; struct NationalValueManager { -- cgit v1.2.3-56-ga3b1