Class ConfigManager

Class Documentation

class ConfigManager

Centralized configuration management system with file loading and validation.

The ConfigManager class provides a complete configuration management solution that handles loading, parsing, validation, and access to configuration settings. It supports multiple configuration sources, type-safe value access, and comprehensive error handling and reporting.

Design

  • Hierarchical configuration loading (defaults → files → command-line)

  • Type-safe value conversion with error handling

  • Comprehensive validation and error reporting

  • Configuration file generation and templating

  • Category-based organization for large configuration sets

  • Thread-safe read operations after initialization

Usage Pattern

  1. Create ConfigManager instance (typically global)

  2. Call load_config() to initialize from files

  3. Use type-safe getters (get_string, get_int, etc.) to access values

  4. Optionally apply command-line overrides

  5. Use throughout application lifetime for configuration access

Handling

Configuration errors are collected rather than thrown as exceptions, allowing the application to continue with default values while reporting issues to the user for correction.

Note

The class follows the singleton-like pattern through a global instance but can be instantiated multiple times if needed for testing

Public Functions

ConfigManager()

Constructor initializing configuration system.

Creates a ConfigManager instance and initializes the default configuration schema. The configuration is not loaded from files until load_config() is explicitly called.