diff options
author | zaaarf <zaaarf@proton.me> | 2023-09-20 14:03:25 +0200 |
---|---|---|
committer | zaaarf <zaaarf@proton.me> | 2023-09-20 14:03:25 +0200 |
commit | ad17b83930d83c3bbe5d58cf30c54fe88ac5d927 (patch) | |
tree | 1f1f1d395f7d120ab7a23c42827f6c20253d48ba /src/openvic-simulation/politics/Issue.cpp | |
parent | 63e5866381234d6627174869b7a27770daef20fd (diff) |
feat: merged PartyIssue and PoliticalReform into single Issue structure
Diffstat (limited to 'src/openvic-simulation/politics/Issue.cpp')
-rw-r--r-- | src/openvic-simulation/politics/Issue.cpp | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/src/openvic-simulation/politics/Issue.cpp b/src/openvic-simulation/politics/Issue.cpp new file mode 100644 index 0000000..da151a2 --- /dev/null +++ b/src/openvic-simulation/politics/Issue.cpp @@ -0,0 +1,71 @@ +#include "Issue.hpp" +#include "types/IdentifierRegistry.hpp" + +using namespace OpenVic; + +IssueType::IssueType(const std::string_view new_identifier) : HasIdentifier { new_identifier } {} + +IssueGroup::IssueGroup(const std::string_view new_identifier, IssueType const& new_type, bool ordered) + : HasIdentifier { new_identifier }, type { new_type }, ordered { ordered } {} + +IssueType const& IssueGroup::get_type() const { + return type; +} + +bool IssueGroup::is_ordered() const { + return ordered; +} + +Issue::Issue(const std::string_view new_identifier, IssueGroup const& new_group, size_t ordinal) + : HasIdentifier { new_identifier }, group { new_group }, ordinal { ordinal } {} + +IssueType const& Issue::get_type() const { + return group.get_type(); +} + +IssueGroup const& Issue::get_group() const { + return group; +} + +size_t Issue::get_ordinal() const { + return ordinal; +} + +IssueManager::IssueManager() : issue_types { "issue types" }, issue_groups { "issue groups" }, issues { "issues" } {} + +bool IssueManager::add_issue_type(const std::string_view identifier) { + if (identifier.empty()) { + Logger::error("Invalid issue type identifier - empty!"); + return false; + } + + return issue_types.add_item({ identifier }); +} + +bool IssueManager::add_issue_group(const std::string_view identifier, IssueType const* type, bool ordered) { + if (identifier.empty()) { + Logger::error("Invalid issue group identifier - empty!"); + return false; + } + + if (type == nullptr) { + Logger::error("Null issue type for ", identifier); + return false; + } + + return issue_groups.add_item({ identifier, *type, ordered }); +} + +bool IssueManager::add_issue(const std::string_view identifier, IssueGroup const* group, size_t ordinal) { + if (identifier.empty()) { + Logger::error("Invalid issue identifier - empty!"); + return false; + } + + if (group == nullptr) { + Logger::error("Null issue group for ", identifier); + return false; + } + + return issues.add_item({ identifier, *group, ordinal }); +}
\ No newline at end of file |