diff options
author | hop311 <hop3114@gmail.com> | 2023-12-26 23:40:50 +0100 |
---|---|---|
committer | hop311 <hop3114@gmail.com> | 2023-12-26 23:40:50 +0100 |
commit | dfa42bc38ebc34904b2325a88cdd16514044cfcb (patch) | |
tree | 1ac5bbac53d493682de60d1285c80b9be0ea40c0 /src/openvic-simulation/politics/Rule.hpp | |
parent | bff91f78f9c5339079c10adfbf8232e5159c1a2d (diff) |
Added political/policy rules
Diffstat (limited to 'src/openvic-simulation/politics/Rule.hpp')
-rw-r--r-- | src/openvic-simulation/politics/Rule.hpp | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/src/openvic-simulation/politics/Rule.hpp b/src/openvic-simulation/politics/Rule.hpp new file mode 100644 index 0000000..260fb9e --- /dev/null +++ b/src/openvic-simulation/politics/Rule.hpp @@ -0,0 +1,57 @@ +#pragma once + +#include "openvic-simulation/types/IdentifierRegistry.hpp" + +namespace OpenVic { + struct RuleManager; + + struct Rule : HasIdentifier { + friend struct RuleManager; + + private: + Rule(std::string_view new_identifier); + + public: + Rule(Rule&&) = default; + }; + + struct RuleSet { + friend struct RuleManager; + + using rule_map_t = std::map<Rule const*, bool>; + + private: + rule_map_t rules; + + public: + RuleSet() = default; + RuleSet(rule_map_t&& new_rules); + RuleSet(RuleSet const&) = default; + RuleSet(RuleSet&&) = default; + + RuleSet& operator=(RuleSet const&) = default; + RuleSet& operator=(RuleSet&&) = default; + + size_t get_rule_count() const; + + bool get_rule(Rule const* rule, bool* successful = nullptr); + bool has_rule(Rule const* rule) const; + + RuleSet& operator|=(RuleSet const& right); + RuleSet operator|(RuleSet const& right) const; + + friend std::ostream& operator<<(std::ostream& stream, RuleSet const& value); + }; + + struct RuleManager { + private: + IdentifierRegistry<Rule> IDENTIFIER_REGISTRY(rule); + + public: + bool add_rule(std::string_view identifier); + + bool setup_rules(); + + NodeTools::node_callback_t expect_rule_set(NodeTools::callback_t<RuleSet&&> ruleset_callback) const; + }; +} |