001/*
002 * VM-Operator
003 * Copyright (C) 2023 Michael N. Lipp
004 * 
005 * This program is free software: you can redistribute it and/or modify
006 * it under the terms of the GNU Affero General Public License as
007 * published by the Free Software Foundation, either version 3 of the
008 * License, or (at your option) any later version.
009 *
010 * This program is distributed in the hope that it will be useful,
011 * but WITHOUT ANY WARRANTY; without even the implied warranty of
012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
013 * GNU Affero General Public License for more details.
014 *
015 * You should have received a copy of the GNU Affero General Public License
016 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
017 */
018
019package org.jdrupes.vmoperator.runner.qemu.events;
020
021import org.jdrupes.vmoperator.runner.qemu.Configuration;
022import org.jdrupes.vmoperator.runner.qemu.events.RunnerStateChange.RunState;
023import org.jgrapes.core.Channel;
024import org.jgrapes.core.Event;
025
026/**
027 * An {@link Event} that notifies controllers about an updated 
028 * configuration. Controllers should adapt the resource that they
029 * manage to the new configuration. If the adaption cannot be
030 * made by the handler alone, it should call {@link Event#suspendHandling()}
031 * on the event and only {@link Event#resumeHandling() resume handling}
032 * when the adaption has completed.
033 */
034public class ConfigureQemu extends Event<Void> {
035
036    private final Configuration configuration;
037    private final RunState state;
038
039    /**
040     * Instantiates a new configuration event.
041     *
042     * @param channels the channels
043     */
044    public ConfigureQemu(Configuration configuration, RunState state,
045            Channel... channels) {
046        super(channels);
047        this.state = state;
048        this.configuration = configuration;
049    }
050
051    /**
052     * Returns the configuration.
053     *
054     * @return the configuration
055     */
056    public Configuration configuration() {
057        return configuration;
058    }
059
060    /**
061     * Returns the runner's state when the event was fired.
062     *
063     * @return the state
064     */
065    public RunState runState() {
066        return state;
067    }
068}