aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation
diff options
context:
space:
mode:
Diffstat (limited to 'src/openvic-simulation')
-rw-r--r--src/openvic-simulation/economy/Good.cpp19
-rw-r--r--src/openvic-simulation/economy/Good.hpp3
2 files changed, 22 insertions, 0 deletions
diff --git a/src/openvic-simulation/economy/Good.cpp b/src/openvic-simulation/economy/Good.cpp
index f1da8bd..027fb5f 100644
--- a/src/openvic-simulation/economy/Good.cpp
+++ b/src/openvic-simulation/economy/Good.cpp
@@ -1,6 +1,11 @@
#include "Good.hpp"
#include <cassert>
+#include <map>
+#include <string_view>
+#include "dataloader/NodeTools.hpp"
+#include "openvic-dataloader/v2script/AbstractSyntaxTree.hpp"
+#include "types/fixed_point/FixedPoint.hpp"
using namespace OpenVic;
using namespace OpenVic::NodeTools;
@@ -132,3 +137,17 @@ bool GoodManager::load_goods_file(ast::NodeCPtr root) {
lock_goods();
return ret;
}
+
+node_callback_t GoodManager::expect_goods_map(callback_t<std::map<Good const*, fixed_point_t>> cb) {
+ return [this, cb](ast::NodeCPtr node) -> bool {
+ std::map<Good const*, fixed_point_t> goods_map;
+ bool res = expect_good_dictionary([&goods_map](const Good & key, ast::NodeCPtr value) -> bool {
+ fixed_point_t good_value;
+ bool res = expect_fixed_point((assign_variable_callback(good_value)))(value);
+ goods_map.emplace(&key, good_value);
+ return res;
+ })(node);
+ res &= cb(goods_map);
+ return res;
+ };
+} \ No newline at end of file
diff --git a/src/openvic-simulation/economy/Good.hpp b/src/openvic-simulation/economy/Good.hpp
index 6c237b1..df92525 100644
--- a/src/openvic-simulation/economy/Good.hpp
+++ b/src/openvic-simulation/economy/Good.hpp
@@ -2,6 +2,7 @@
#include "openvic-simulation/dataloader/NodeTools.hpp"
#include "openvic-simulation/types/IdentifierRegistry.hpp"
+#include "openvic-dataloader/v2script/AbstractSyntaxTree.hpp"
namespace OpenVic {
struct GoodManager;
@@ -75,5 +76,7 @@ namespace OpenVic {
void reset_to_defaults();
bool load_goods_file(ast::NodeCPtr root);
+
+ NodeTools::node_callback_t expect_goods_map(NodeTools::callback_t<std::map<Good const*, fixed_point_t>> cb);
};
}