/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2001-2025 German Aerospace Center (DLR) and others.3// This program and the accompanying materials are made available under the4// terms of the Eclipse Public License 2.0 which is available at5// https://www.eclipse.org/legal/epl-2.0/6// This Source Code may also be made available under the following Secondary7// Licenses when the conditions for such availability set forth in the Eclipse8// Public License 2.0 are satisfied: GNU General Public License, version 29// or later which is available at10// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html11// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later12/****************************************************************************/13/// @file Command.h14/// @author Christian Roessel15/// @author Daniel Krajzewicz16/// @date Thu, 20 Dec 200117///18// Base (microsim) event class19/****************************************************************************/20#pragma once21#include <config.h>22#include <utils/common/SUMOTime.h>23#include <utils/common/UtilExceptions.h>242526// ===========================================================================27// class definitions28// ===========================================================================29/**30* @class Command31* @brief Base (microsim) event class32*33* Classes derived from Command may be added to MSEventControl instances in34* order to be executed at a certain time step.35*36* As soon as the simulation reaches the desired time step, the command (event)37* is executed by calling "execute" with the current time step. The method must38* return either 0, if the event shall not be executed again or a positive value39* (in simulation seconds) that described when it shall be executed again. The method40* must not return a value below zero, the behaviour is undefined in this case.41*42* @warning The EventControl the Command is added to gets responsible for43* this command's deletion.44*45* @see Design Patterns, Gamma et al.46* @see WrappingCommand47* @see MSEventControl48*/49class Command {50public:51/// @brief Constructor52Command() { }535455/// @brief Destructor.56virtual ~Command() { }575859/** @brief Executes the command.60*61* The implementations should return 0 if the command shall not be repeated,62* or a value larger than 0 that describe the time after which the command63* shall be executed again. Values below 0 must not be returned.64*65* @param[in] currentTime The current simulation time66* @return The time after which the command shall be executed again, 0 if this command shall be descheduled.67* @exception ProcessError Derived actions may throw this exception68*/69virtual SUMOTime execute(SUMOTime currentTime) = 0;7071/** @brief Reschedule or deschedule the command when quick-loading state72*73* The implementations should return -1 if the command shall not be re-scheduled,74* or a value >= 0 that describe the new time at which the command75* shall be executed again.76*77* @param[in] currentTime The current simulation time78* @param[in] execTime The time at which the command would have been executed79* @param[in] newTime The simulation time at which the simulation is restarted80* @return The time at which the command shall be executed again81*/82virtual SUMOTime shiftTime(SUMOTime /*currentTime*/, SUMOTime /*execTime*/, SUMOTime /*newTime*/) {83return -1;84}8586int priority = 0;8788};899091