Porytiles
Loading...
Searching...
No Matches
infra_config.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <memory>
4#include <string>
5
10
11namespace porytiles {
12
13/*
14 * NOTE: DO NOT EDIT THIS FILE DIRECTLY. It is AUTO-GENERATED from config_schema.yaml.
15 * To add new config values or make other changes, edit config_schema.yaml and regenerate via:
16 *
17 * uv run scripts/generate_config.py
18 */
19
20class ConfigProvider; // forward declaration; full type is in infra/config/config_provider.hpp
21
26 public:
27 virtual ~InfraConfig() = default;
28
39 virtual void add_provider(std::unique_ptr<ConfigProvider> provider) = 0;
40
41 // Public method with cross-field validation only (Tier 3)
43 tileset_paths_primary_src(ConfigScopeType type, const std::string &scope) const
44 {
45 auto validated_val = tileset_paths_primary_src_validated(type, scope);
46 return validated_val;
47 }
48
49 // Public method with cross-field validation only (Tier 3)
51 tileset_paths_primary_bin(ConfigScopeType type, const std::string &scope) const
52 {
53 auto validated_val = tileset_paths_primary_bin_validated(type, scope);
54 return validated_val;
55 }
56
57 // Public method with cross-field validation only (Tier 3)
59 tileset_paths_secondary_src(ConfigScopeType type, const std::string &scope) const
60 {
61 auto validated_val = tileset_paths_secondary_src_validated(type, scope);
62 return validated_val;
63 }
64
65 // Public method with cross-field validation only (Tier 3)
67 tileset_paths_secondary_bin(ConfigScopeType type, const std::string &scope) const
68 {
69 auto validated_val = tileset_paths_secondary_bin_validated(type, scope);
70 return validated_val;
71 }
72
73 // Public method with cross-field validation only (Tier 3)
75 metatile_attr_size(ConfigScopeType type, const std::string &scope) const
76 {
77 auto validated_val = metatile_attr_size_validated(type, scope);
78 return validated_val;
79 }
80
81 // Public method with cross-field validation only (Tier 3)
83 tileset_animations_wire_anim_code(ConfigScopeType type, const std::string &scope) const
84 {
85 auto validated_val = tileset_animations_wire_anim_code_validated(type, scope);
86 return validated_val;
87 }
88
89
90 protected:
91
92 // Protected method with single-value validation only (Tier 2)
93 [[nodiscard]] virtual ChainableResult<ConfigValue<std::string>>
94 tileset_paths_primary_src_validated(ConfigScopeType type, const std::string &scope) const
95 {
96 auto raw_val = tileset_paths_primary_src_raw(type, scope);
97 return raw_val;
98 }
99
100 // Protected virtual method that fetches raw value from provider (Tier 1)
101 [[nodiscard]] virtual ChainableResult<ConfigValue<std::string>>
102 tileset_paths_primary_src_raw(ConfigScopeType type, const std::string &scope) const = 0;
103
104 // Protected method with single-value validation only (Tier 2)
105 [[nodiscard]] virtual ChainableResult<ConfigValue<std::string>>
106 tileset_paths_primary_bin_validated(ConfigScopeType type, const std::string &scope) const
107 {
108 auto raw_val = tileset_paths_primary_bin_raw(type, scope);
109 return raw_val;
110 }
111
112 // Protected virtual method that fetches raw value from provider (Tier 1)
113 [[nodiscard]] virtual ChainableResult<ConfigValue<std::string>>
114 tileset_paths_primary_bin_raw(ConfigScopeType type, const std::string &scope) const = 0;
115
116 // Protected method with single-value validation only (Tier 2)
117 [[nodiscard]] virtual ChainableResult<ConfigValue<std::string>>
118 tileset_paths_secondary_src_validated(ConfigScopeType type, const std::string &scope) const
119 {
120 auto raw_val = tileset_paths_secondary_src_raw(type, scope);
121 return raw_val;
122 }
123
124 // Protected virtual method that fetches raw value from provider (Tier 1)
125 [[nodiscard]] virtual ChainableResult<ConfigValue<std::string>>
126 tileset_paths_secondary_src_raw(ConfigScopeType type, const std::string &scope) const = 0;
127
128 // Protected method with single-value validation only (Tier 2)
129 [[nodiscard]] virtual ChainableResult<ConfigValue<std::string>>
130 tileset_paths_secondary_bin_validated(ConfigScopeType type, const std::string &scope) const
131 {
132 auto raw_val = tileset_paths_secondary_bin_raw(type, scope);
133 return raw_val;
134 }
135
136 // Protected virtual method that fetches raw value from provider (Tier 1)
137 [[nodiscard]] virtual ChainableResult<ConfigValue<std::string>>
138 tileset_paths_secondary_bin_raw(ConfigScopeType type, const std::string &scope) const = 0;
139
140 // Protected method with single-value validation only (Tier 2)
141 [[nodiscard]] virtual ChainableResult<ConfigValue<std::size_t>>
142 metatile_attr_size_validated(ConfigScopeType type, const std::string &scope) const
143 {
144 auto raw_val = metatile_attr_size_raw(type, scope);
145 // Apply validators in sequence
146 if (raw_val.has_value()) {
147 raw_val = size_t_val_two_or_four(raw_val.value());
148 }
149 return raw_val;
150 }
151
152 // Protected virtual method that fetches raw value from provider (Tier 1)
153 [[nodiscard]] virtual ChainableResult<ConfigValue<std::size_t>>
154 metatile_attr_size_raw(ConfigScopeType type, const std::string &scope) const = 0;
155
156 // Protected method with single-value validation only (Tier 2)
157 [[nodiscard]] virtual ChainableResult<ConfigValue<bool>>
159 {
160 auto raw_val = tileset_animations_wire_anim_code_raw(type, scope);
161 return raw_val;
162 }
163
164 // Protected virtual method that fetches raw value from provider (Tier 1)
165 [[nodiscard]] virtual ChainableResult<ConfigValue<bool>>
166 tileset_animations_wire_anim_code_raw(ConfigScopeType type, const std::string &scope) const = 0;
167
168};
169
170} // namespace porytiles
A result type that maintains a chainable sequence of errors for debugging and error reporting.
Interface that defines a complete infra layer configuration.
ChainableResult< ConfigValue< std::string > > tileset_paths_secondary_bin(ConfigScopeType type, const std::string &scope) const
virtual void add_provider(std::unique_ptr< ConfigProvider > provider)=0
Prepends a ConfigProvider to the provider chain at highest priority.
virtual ChainableResult< ConfigValue< bool > > tileset_animations_wire_anim_code_raw(ConfigScopeType type, const std::string &scope) const =0
virtual ChainableResult< ConfigValue< std::string > > tileset_paths_primary_bin_validated(ConfigScopeType type, const std::string &scope) const
virtual ChainableResult< ConfigValue< std::string > > tileset_paths_primary_src_raw(ConfigScopeType type, const std::string &scope) const =0
virtual ChainableResult< ConfigValue< std::string > > tileset_paths_primary_src_validated(ConfigScopeType type, const std::string &scope) const
ChainableResult< ConfigValue< std::size_t > > metatile_attr_size(ConfigScopeType type, const std::string &scope) const
virtual ChainableResult< ConfigValue< std::string > > tileset_paths_secondary_src_validated(ConfigScopeType type, const std::string &scope) const
virtual ~InfraConfig()=default
virtual ChainableResult< ConfigValue< std::string > > tileset_paths_secondary_src_raw(ConfigScopeType type, const std::string &scope) const =0
virtual ChainableResult< ConfigValue< bool > > tileset_animations_wire_anim_code_validated(ConfigScopeType type, const std::string &scope) const
ChainableResult< ConfigValue< std::string > > tileset_paths_primary_bin(ConfigScopeType type, const std::string &scope) const
virtual ChainableResult< ConfigValue< std::size_t > > metatile_attr_size_raw(ConfigScopeType type, const std::string &scope) const =0
virtual ChainableResult< ConfigValue< std::string > > tileset_paths_secondary_bin_validated(ConfigScopeType type, const std::string &scope) const
ChainableResult< ConfigValue< std::string > > tileset_paths_primary_src(ConfigScopeType type, const std::string &scope) const
virtual ChainableResult< ConfigValue< std::size_t > > metatile_attr_size_validated(ConfigScopeType type, const std::string &scope) const
ChainableResult< ConfigValue< bool > > tileset_animations_wire_anim_code(ConfigScopeType type, const std::string &scope) const
virtual ChainableResult< ConfigValue< std::string > > tileset_paths_primary_bin_raw(ConfigScopeType type, const std::string &scope) const =0
ChainableResult< ConfigValue< std::string > > tileset_paths_secondary_src(ConfigScopeType type, const std::string &scope) const
virtual ChainableResult< ConfigValue< std::string > > tileset_paths_secondary_bin_raw(ConfigScopeType type, const std::string &scope) const =0
ConfigScopeType
Specifies the scope type for configuration value lookups.
ChainableResult< ConfigValue< std::size_t > > size_t_val_two_or_four(const ConfigValue< std::size_t > &val)
Validates that a size_t config value is either 2 or 4.
Cross-cutting configuration validators shared across all architectural layers.