diff options
author | Hop311 <Hop3114@gmail.com> | 2024-02-05 20:38:23 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-05 20:38:23 +0100 |
commit | 6489da997cddb20667db0455fa4f38319dc7c883 (patch) | |
tree | 4e343f81b13f166ad4a478962348d4734ea7e11b /src/openvic-simulation/interface/LoadBase.hpp | |
parent | 068c13ede817d17df599ca3481261bf17ed95604 (diff) | |
parent | 87fa1c74281a651b23089079c4c1621d4fb66d73 (diff) |
Merge pull request #145 from OpenVicProject/gui-loading
Added support for loading all gui files
Diffstat (limited to 'src/openvic-simulation/interface/LoadBase.hpp')
-rw-r--r-- | src/openvic-simulation/interface/LoadBase.hpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/openvic-simulation/interface/LoadBase.hpp b/src/openvic-simulation/interface/LoadBase.hpp index 10b0169..29de165 100644 --- a/src/openvic-simulation/interface/LoadBase.hpp +++ b/src/openvic-simulation/interface/LoadBase.hpp @@ -23,6 +23,18 @@ namespace OpenVic { return ret; } + template<std::derived_from<LoadBase<Context...>> T> + static NodeTools::node_callback_t _expect_value( + NodeTools::callback_t<T&&> callback, Context... context + ) { + return [callback, &context...](ast::NodeCPtr node) -> bool { + T value {}; + bool ret = value.load(node, context...); + ret &= callback(std::move(value)); + return ret; + }; + } + template<std::derived_from<LoadBase<Context...>> T, std::derived_from<T> U> static NodeTools::node_callback_t _expect_instance( NodeTools::callback_t<std::unique_ptr<T>&&> callback, Context... context |