package vassistent.bootstrap;

import vassistent.model.AppState;
import vassistent.service.*;

/**
 * Lightweight container that stores shared application state and services.
 */
public class ApplicationContext {

    private AppState appState;

    private DataPersistenceService persistenceService;
    private StatisticsService statisticsService;
    private EvaluationService evaluationService;
    private AnimationFileService unrealService;
    private MqttClientService mqttService;
    private BinaryEventService binaryEventService;
    private ProcessManagerService processManagerService;

    /**
     * Stores the shared in-memory application state instance.
     *
     * @param appState state container used by UI and services
     */
    public void setAppState(AppState appState) {
        this.appState = appState;
    }

    /**
     * Stores the persistence service responsible for database access.
     *
     * @param persistenceService configured persistence service
     */
    public void setPersistenceService(DataPersistenceService persistenceService) {
        this.persistenceService = persistenceService;
    }

    /**
     * Stores the statistics service used for ratio calculations.
     *
     * @param statisticsService configured statistics service
     */
    public void setStatisticsService(StatisticsService statisticsService) {
        this.statisticsService = statisticsService;
    }

    /**
     * Stores the evaluation service used to derive problem levels.
     *
     * @param evaluationService configured evaluation service
     */
    public void setEvaluationService(EvaluationService evaluationService) {
        this.evaluationService = evaluationService;
    }

    /**
     * Stores the animation integration service.
     *
     * @param unrealService configured animation file service
     */
    public void setAnimationFileService(AnimationFileService unrealService) {
        this.unrealService = unrealService;
    }

    /**
     * Stores the MQTT client service.
     *
     * @param mqttService configured MQTT service
     */
    public void setMqttService(MqttClientService mqttService) {
        this.mqttService = mqttService;
    }

    /**
     * Stores the binary event service handling incoming predictions.
     *
     * @param binaryEventService configured event service
     */
    public void setBinaryEventService(BinaryEventService binaryEventService) {
        this.binaryEventService = binaryEventService;
    }

    /**
     * Returns the shared observable application state.
     *
     * @return application state
     */
    public AppState getAppState() {
        return appState;
    }

    /**
     * Returns the persistence service instance.
     *
     * @return persistence service
     */
    public DataPersistenceService getPersistenceService() {
        return persistenceService;
    }

    /**
     * Returns the statistics service instance.
     *
     * @return statistics service
     */
    public StatisticsService getStatisticsService() {
        return statisticsService;
    }

    /**
     * Returns the evaluation service instance.
     *
     * @return evaluation service
     */
    public EvaluationService getEvaluationService() {
        return evaluationService;
    }

    /**
     * Returns the animation file service instance.
     *
     * @return animation file service
     */
    public AnimationFileService getAnimationFileService() {
        return unrealService;
    }

    /**
     * Returns the MQTT service instance.
     *
     * @return MQTT service
     */
    public MqttClientService getMqttService() {
        return mqttService;
    }

    /**
     * Returns the binary event service instance.
     *
     * @return binary event service
     */
    public BinaryEventService getBinaryEventService() {
        return binaryEventService;
    }

    /**
     * Returns the external process manager service.
     *
     * @return process manager service
     */
    public ProcessManagerService getProcessManagerService() {
        return processManagerService;
    }

    /**
     * Stores the process manager service used for external helper processes.
     *
     * @param processManagerService configured process manager service
     */
    public void setProcessManagerService(ProcessManagerService processManagerService) {
        this.processManagerService = processManagerService;
    }
}
