|
| 1 | +/** |
| 2 | + * @file config_store.h |
| 3 | + * @brief Unified configuration store |
| 4 | + * |
| 5 | + * Single source of truth for all configuration. |
| 6 | + * Memory-first design with lazy disk I/O. |
| 7 | + */ |
| 8 | + |
| 9 | +#ifndef CONFIG_STORE_H |
| 10 | +#define CONFIG_STORE_H |
| 11 | + |
| 12 | +#include <windows.h> |
| 13 | +#include "config_keys.h" |
| 14 | + |
| 15 | +/* ============================================================================ |
| 16 | + * Configuration access API |
| 17 | + * ============================================================================ */ |
| 18 | + |
| 19 | +/** |
| 20 | + * @brief Initialize configuration system |
| 21 | + * @param config_path Path to config file (UTF-8) |
| 22 | + * |
| 23 | + * Loads config from disk if exists, otherwise uses defaults. |
| 24 | + * Must be called before any other config functions. |
| 25 | + */ |
| 26 | +void Config_Init(const char* config_path); |
| 27 | + |
| 28 | +/** |
| 29 | + * @brief Shutdown configuration system |
| 30 | + * |
| 31 | + * Flushes any pending changes to disk and frees resources. |
| 32 | + */ |
| 33 | +void Config_Shutdown(void); |
| 34 | + |
| 35 | +/** |
| 36 | + * @brief Get string value |
| 37 | + * @param key Configuration key |
| 38 | + * @return String value (do not free, valid until next Set or Shutdown) |
| 39 | + */ |
| 40 | +const char* Config_GetString(ConfigKey key); |
| 41 | + |
| 42 | +/** |
| 43 | + * @brief Get integer value |
| 44 | + * @param key Configuration key |
| 45 | + * @return Integer value |
| 46 | + */ |
| 47 | +int Config_GetInt(ConfigKey key); |
| 48 | + |
| 49 | +/** |
| 50 | + * @brief Get boolean value |
| 51 | + * @param key Configuration key |
| 52 | + * @return Boolean value |
| 53 | + */ |
| 54 | +BOOL Config_GetBool(ConfigKey key); |
| 55 | + |
| 56 | +/** |
| 57 | + * @brief Get float value |
| 58 | + * @param key Configuration key |
| 59 | + * @return Float value |
| 60 | + */ |
| 61 | +float Config_GetFloat(ConfigKey key); |
| 62 | + |
| 63 | +/** |
| 64 | + * @brief Set string value |
| 65 | + * @param key Configuration key |
| 66 | + * @param value New value (will be copied) |
| 67 | + */ |
| 68 | +void Config_SetString(ConfigKey key, const char* value); |
| 69 | + |
| 70 | +/** |
| 71 | + * @brief Set integer value |
| 72 | + * @param key Configuration key |
| 73 | + * @param value New value |
| 74 | + */ |
| 75 | +void Config_SetInt(ConfigKey key, int value); |
| 76 | + |
| 77 | +/** |
| 78 | + * @brief Set boolean value |
| 79 | + * @param key Configuration key |
| 80 | + * @param value New value |
| 81 | + */ |
| 82 | +void Config_SetBool(ConfigKey key, BOOL value); |
| 83 | + |
| 84 | +/** |
| 85 | + * @brief Set float value |
| 86 | + * @param key Configuration key |
| 87 | + * @param value New value |
| 88 | + */ |
| 89 | +void Config_SetFloat(ConfigKey key, float value); |
| 90 | + |
| 91 | +/** |
| 92 | + * @brief Flush pending changes to disk |
| 93 | + * |
| 94 | + * Normally changes are batched. Call this to force immediate write. |
| 95 | + */ |
| 96 | +void Config_Flush(void); |
| 97 | + |
| 98 | +/** |
| 99 | + * @brief Reload configuration from disk |
| 100 | + * |
| 101 | + * Discards any unsaved changes and reloads from file. |
| 102 | + */ |
| 103 | +void Config_Reload(void); |
| 104 | + |
| 105 | +/** |
| 106 | + * @brief Mark config as dirty (needs save) |
| 107 | + * |
| 108 | + * Called automatically by Set functions. |
| 109 | + */ |
| 110 | +void Config_MarkDirty(void); |
| 111 | + |
| 112 | +/** |
| 113 | + * @brief Check if config has unsaved changes |
| 114 | + * @return TRUE if dirty |
| 115 | + */ |
| 116 | +BOOL Config_IsDirty(void); |
| 117 | + |
| 118 | +/** |
| 119 | + * @brief Get config file path |
| 120 | + * @return Path string (do not free) |
| 121 | + */ |
| 122 | +const char* Config_GetPath(void); |
| 123 | + |
| 124 | +/** |
| 125 | + * @brief Reset a key to its default value |
| 126 | + * @param key Configuration key |
| 127 | + */ |
| 128 | +void Config_ResetToDefault(ConfigKey key); |
| 129 | + |
| 130 | +/** |
| 131 | + * @brief Reset all configuration to defaults |
| 132 | + */ |
| 133 | +void Config_ResetAll(void); |
| 134 | + |
| 135 | +#endif /* CONFIG_STORE_H */ |
0 commit comments