aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/politics/Rule.hpp
diff options
context:
space:
mode:
author zaaarf <80046572+zaaarf@users.noreply.github.com>2023-12-27 00:12:17 +0100
committer GitHub <noreply@github.com>2023-12-27 00:12:17 +0100
commitcc808c115d8ec6c7b6e47db47f81395b4d52941f (patch)
tree1ac5bbac53d493682de60d1285c80b9be0ea40c0 /src/openvic-simulation/politics/Rule.hpp
parentbff91f78f9c5339079c10adfbf8232e5159c1a2d (diff)
parentdfa42bc38ebc34904b2325a88cdd16514044cfcb (diff)
Merge pull request #106 from OpenVicProject/rules
Added political/policy rules
Diffstat (limited to 'src/openvic-simulation/politics/Rule.hpp')
-rw-r--r--src/openvic-simulation/politics/Rule.hpp57
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;
+ };
+}