From 1e40569a49ab0d557a2a43ee900f4f28d5c81cd3 Mon Sep 17 00:00:00 2001 From: Hop311 Date: Thu, 28 Sep 2023 23:33:46 +0100 Subject: Data types, defaults, callback cleanup --- src/openvic-simulation/types/IdentifierRegistry.hpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/openvic-simulation/types/IdentifierRegistry.hpp') diff --git a/src/openvic-simulation/types/IdentifierRegistry.hpp b/src/openvic-simulation/types/IdentifierRegistry.hpp index 482e917..7fe2656 100644 --- a/src/openvic-simulation/types/IdentifierRegistry.hpp +++ b/src/openvic-simulation/types/IdentifierRegistry.hpp @@ -155,6 +155,10 @@ namespace OpenVic { return nullptr; } + bool has_identifier(std::string_view identifier) const { + return get_item_by_identifier(identifier) != nullptr; + } + T* get_item_by_index(size_t index) { return index < items.size() ? &items[index] : nullptr; } @@ -163,6 +167,10 @@ namespace OpenVic { return index < items.size() ? &items[index] : nullptr; } + bool has_index(size_t index) const { + return get_item_by_index(index) != nullptr; + } + std::vector& get_items() { return items; } @@ -244,6 +252,8 @@ namespace OpenVic { bool plural##_are_locked() const { return plural.is_locked(); } \ type const* get_##singular##_by_identifier(std::string_view identifier) const { \ return plural.get_item_by_identifier(identifier); } \ + bool has_##singular##_identifier(std::string_view identifier) const { \ + return plural.has_identifier(identifier); } \ size_t get_##singular##_count() const { \ return plural.size(); } \ std::vector const& get_##plural() const { \ -- cgit v1.2.3-56-ga3b1