aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/defines/Define.cpp
diff options
context:
space:
mode:
author hop311 <hop3114@gmail.com>2024-10-31 20:29:34 +0100
committer hop311 <hop3114@gmail.com>2024-10-31 20:54:50 +0100
commitdbf58b1b1d318b4a82cf22b5b8e720c753388f4b (patch)
treed6d2be10697d6fa320f7f8da14eda45111bd9399 /src/openvic-simulation/defines/Define.cpp
parentc763a0aedd834432b54b6e49c6bc7e1936be1131 (diff)
Load defines directly into named and typed variables rather than using an IdentifierRegistrydefines-variables
Diffstat (limited to 'src/openvic-simulation/defines/Define.cpp')
-rw-r--r--src/openvic-simulation/defines/Define.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/openvic-simulation/defines/Define.cpp b/src/openvic-simulation/defines/Define.cpp
new file mode 100644
index 0000000..8d910cb
--- /dev/null
+++ b/src/openvic-simulation/defines/Define.cpp
@@ -0,0 +1,25 @@
+#include "Define.hpp"
+
+#include "openvic-simulation/dataloader/NodeTools.hpp"
+
+using namespace OpenVic;
+using namespace OpenVic::NodeTools;
+
+DefineManager::DefineManager() : start_date {}, end_date {} {}
+
+bool DefineManager::load_defines_file(ast::NodeCPtr root) {
+ return expect_dictionary_keys(
+ "defines", ONE_EXACTLY, expect_dictionary_keys(
+ "start_date", ONE_EXACTLY, expect_date_identifier_or_string(assign_variable_callback(start_date)),
+ "end_date", ONE_EXACTLY, expect_date_identifier_or_string(assign_variable_callback(end_date)),
+
+ ai_defines.get_name(), ONE_EXACTLY, ai_defines.expect_defines(),
+ country_defines.get_name(), ONE_EXACTLY, country_defines.expect_defines(),
+ diplomacy_defines.get_name(), ONE_EXACTLY, diplomacy_defines.expect_defines(),
+ economy_defines.get_name(), ONE_EXACTLY, economy_defines.expect_defines(),
+ graphics_defines.get_name(), ONE_EXACTLY, graphics_defines.expect_defines(),
+ military_defines.get_name(), ONE_EXACTLY, military_defines.expect_defines(),
+ pops_defines.get_name(), ONE_EXACTLY, pops_defines.expect_defines()
+ )
+ )(root);
+}