From 8a4e3e02f23fa1cf3e61f39fbdc8d3fc946a0473 Mon Sep 17 00:00:00 2001 From: zaaarf Date: Wed, 20 Sep 2023 22:06:29 +0200 Subject: feat: added expect_goods_map function to GoodsManager --- src/openvic-simulation/economy/Good.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/openvic-simulation/economy/Good.cpp') 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 +#include +#include +#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> cb) { + return [this, cb](ast::NodeCPtr node) -> bool { + std::map 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 -- cgit v1.2.3-56-ga3b1