aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/interface
diff options
context:
space:
mode:
author hop311 <hop3114@gmail.com>2024-01-13 21:14:06 +0100
committer hop311 <hop3114@gmail.com>2024-01-13 21:48:08 +0100
commit70948572ef0fb5c6dae453c410fdaedfab36741b (patch)
tree8e2f7f4de34ec3d62e55f9918ce26900c16a5d0f /src/openvic-simulation/interface
parent046e5619277c6f3dffbb29244b4b88029da31bee (diff)
Reworked UniqueKeyRegistry template params + added support for std::deque storage
Diffstat (limited to 'src/openvic-simulation/interface')
-rw-r--r--src/openvic-simulation/interface/LoadBase.hpp40
1 files changed, 21 insertions, 19 deletions
diff --git a/src/openvic-simulation/interface/LoadBase.hpp b/src/openvic-simulation/interface/LoadBase.hpp
index 3ee7c83..74aece9 100644
--- a/src/openvic-simulation/interface/LoadBase.hpp
+++ b/src/openvic-simulation/interface/LoadBase.hpp
@@ -5,27 +5,27 @@
namespace OpenVic {
- template<typename... _Context>
+ template<typename... Context>
class LoadBase {
protected:
LoadBase() = default;
- virtual bool _fill_key_map(NodeTools::key_map_t&, _Context...) = 0;
+ virtual bool _fill_key_map(NodeTools::key_map_t&, Context...) = 0;
public:
LoadBase(LoadBase&&) = default;
virtual ~LoadBase() = default;
- bool load(ast::NodeCPtr node, _Context... context) {
+ bool load(ast::NodeCPtr node, Context... context) {
NodeTools::key_map_t key_map;
bool ret = _fill_key_map(key_map, context...);
ret &= NodeTools::expect_dictionary_key_map(std::move(key_map))(node);
return ret;
}
- template<std::derived_from<LoadBase<_Context...>> T, std::derived_from<T> U>
+ 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
+ NodeTools::callback_t<std::unique_ptr<T>&&> callback, Context... context
) {
return [callback, &context...](ast::NodeCPtr node) -> bool {
std::unique_ptr<T> instance { std::make_unique<U>() };
@@ -38,14 +38,14 @@ namespace OpenVic {
OV_DETAIL_GET_TYPE_BASE_CLASS(LoadBase)
};
- template<typename... _Context>
- class Named : public LoadBase<_Context...> {
+ template<typename... Context>
+ class Named : public LoadBase<Context...> {
std::string PROPERTY(name);
protected:
Named() = default;
- virtual bool _fill_key_map(NodeTools::key_map_t& key_map, _Context...) override {
+ virtual bool _fill_key_map(NodeTools::key_map_t& key_map, Context...) override {
using namespace OpenVic::NodeTools;
return add_key_map_entries(key_map, "name", ONE_EXACTLY, expect_string(assign_variable_callback_string(name)));
}
@@ -64,19 +64,21 @@ namespace OpenVic {
OV_DETAIL_GET_TYPE
};
- template<typename T, typename... _Context>
- requires std::derived_from<T, Named<_Context...>>
- struct _get_name {
- constexpr std::string_view operator()(T const* item) const {
- return item->get_name();
+ template<typename Value, typename... Context>
+ requires std::derived_from<Value, Named<Context...>>
+ struct RegistryValueInfoNamed {
+ using value_type = Value;
+
+ static constexpr std::string_view get_identifier(value_type const& item) {
+ return item.get_name();
}
};
- template<typename T, typename... _Context>
- requires std::derived_from<T, Named<_Context...>>
- using NamedRegistry = ValueRegistry<T, _get_name<T, _Context...>>;
+ template<typename Value, typename... Context>
+ requires std::derived_from<Value, Named<Context...>>
+ using NamedRegistry = ValueRegistry<RegistryValueInfoNamed<Value, Context...>>;
- template<typename T, typename... _Context>
- requires std::derived_from<T, Named<_Context...>>
- using NamedInstanceRegistry = InstanceRegistry<T, _get_name<T, _Context...>>;
+ template<typename Value, typename... Context>
+ requires std::derived_from<Value, Named<Context...>>
+ using NamedInstanceRegistry = InstanceRegistry<RegistryValueInfoNamed<Value, Context...>>;
}