diff options
author | Hop311 <Hop3114@gmail.com> | 2024-01-14 12:27:56 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-14 12:27:56 +0100 |
commit | 2fcc7ccd409701f6bad343e57afe74bd05246b68 (patch) | |
tree | 8e2f7f4de34ec3d62e55f9918ce26900c16a5d0f /src/openvic-simulation/misc/Modifier.hpp | |
parent | 046e5619277c6f3dffbb29244b4b88029da31bee (diff) | |
parent | 70948572ef0fb5c6dae453c410fdaedfab36741b (diff) |
Merge pull request #129 from OpenVicProject/registry-template-fun
Reworked `UniqueKeyRegistry` template params
Diffstat (limited to 'src/openvic-simulation/misc/Modifier.hpp')
-rw-r--r-- | src/openvic-simulation/misc/Modifier.hpp | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/src/openvic-simulation/misc/Modifier.hpp b/src/openvic-simulation/misc/Modifier.hpp index 83efe9b..abb3891 100644 --- a/src/openvic-simulation/misc/Modifier.hpp +++ b/src/openvic-simulation/misc/Modifier.hpp @@ -3,13 +3,12 @@ #include "openvic-simulation/scripts/ConditionScript.hpp" #include "openvic-simulation/types/IdentifierRegistry.hpp" -#include "dataloader/NodeTools.hpp" - - namespace OpenVic { struct ModifierManager; struct ModifierEffect : HasIdentifier { + friend struct ModifierManager; + enum class format_t { PROPORTION_DECIMAL, /* An unscaled fraction/ratio, with 1 being "full"/"whole" */ PERCENTAGE_DECIMAL, /* A fraction/ratio scaled so that 100 is "full"/"whole" */ @@ -17,8 +16,6 @@ namespace OpenVic { INT /* A discrete quantity, e.g. building count limit */ }; - friend std::unique_ptr<ModifierEffect> std::make_unique<ModifierEffect>(std::string_view&&, bool&&, format_t&&); - private: /* If true, positive values will be green and negative values will be red. * If false, the colours will be switced. @@ -115,10 +112,10 @@ namespace OpenVic { struct ModifierManager { /* Some ModifierEffects are generated mid-load, such as max/min count modifiers for each building, so * we can't lock it until loading is over. This means we can't rely on locking for pointer stability, - * so instead we use an IdentifierInstanceRegistry (using std::unique_ptr's under the hood). + * so instead we store the effects in a deque which doesn't invalidate pointers on insert. */ private: - CaseInsensitiveIdentifierInstanceRegistry<ModifierEffect> IDENTIFIER_REGISTRY(modifier_effect); + CaseInsensitiveIdentifierRegistry<ModifierEffect, RegistryStorageInfoDeque> IDENTIFIER_REGISTRY(modifier_effect); case_insensitive_string_set_t complex_modifiers; IdentifierRegistry<Modifier> IDENTIFIER_REGISTRY(event_modifier); |