import configparser

class ConfigReader:
    """
    @brief Configuration file reader class
    
    @details This class provides methods to read, parse and retrieve 
    configuration parameters from INI-style configuration files.
    It uses Python's configparser module internally.
    """
    def __init__(self, config_path):
        """
      @brief Constructor for ConfigReader class
      
      @param config_path Path to the configuration file
      @exception FileNotFoundError If configuration file is not found
      """
        self.config_path = config_path
        self.config = configparser.ConfigParser()
        self.config.read(self.config_path)

    def get_value(self, section, key, fallback=None):
        """
        @brief Get value from configuration file
        
        @param section Configuration section name
        @param key Configuration key name
        @param fallback Default value if key not found
        @return Configuration value as string or fallback value
        """
        try:
            return self.config.get(section, key)
        except (configparser.NoSectionError, configparser.NoOptionError):
            return fallback

    def get_linear_parameter(self):
        """
        @brief Get linear parameter from configuration
        
        @return Linear parameter as float value
        """
        return float(self.get_value('Parameters', 'linear_parameter'))
    
    def get_image_path(self):
        """
        @brief Get image path from configuration
        
        @return Image file path as string
        """
        return self.get_value('Parameters', 'image_path')

    def get_video_path(self):
        """
       @brief Get video path from configuration
       
       @return Video file path as string
       """
        return self.get_value('Parameters', 'video_path')
    
    def get_overlap(self):
        """
        @brief Get overlap parameter from configuration
        
        @return Overlap value as string
        """
        return self.get_value('Parameters', 'overlap')
    
    def get_blend_mode(self):
        """
       @brief Get blend mode from configuration
       
       @return Blend mode as string
       """
        return self.get_value('Parameters', 'blend_mode')

    def save_config(self):
        """
        @brief Save current configuration to file
        
        @details Writes the current configuration state back to the file.
        This can be used to persist changes made to configuration values.
        """
        with open(self.config_path, 'w') as configfile:
            self.config.write(configfile)