package com.livingworld.core.services;

import com.livingworld.config.SimulationConfig;

/**
 * Service interface for managing simulation configuration.
 *
 * Implementations of this interface provide access to the current
 * {@link SimulationConfig}, support reloading from external sources,
 * and validate that all values are within acceptable ranges.
 */
public interface ConfigService {

    /**
     * Returns the current simulation configuration.
     *
     * @return the active {@link SimulationConfig} instance
     */
    SimulationConfig getSimulationConfig();

    /**
     * Reloads configuration from its external source (e.g., config file, mod settings).
     * Implementations should handle I/O and deserialization internally.
     */
    void reload();

    /**
     * Validates the current configuration by delegating to {@link SimulationConfig#validate()}.
     *
     * @throws RuntimeException if validation fails (wraps {@link IllegalArgumentException})
     */
    default void validate() {
        try {
            getSimulationConfig().validate();
        } catch (IllegalArgumentException e) {
            throw new RuntimeException("Configuration validation failed", e);
        }
    }
}