Program Listing for File command.hpp

Return to documentation for file (src/tap/control/command.hpp)

/*
 * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington <robomstr@uw.edu>
 *
 * This file is part of Taproot.
 *
 * Taproot is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Taproot is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Taproot.  If not, see <https://www.gnu.org/licenses/>.
 */

#ifndef TAPROOT_COMMAND_HPP_
#define TAPROOT_COMMAND_HPP_

#include "tap/util_macros.hpp"

#include "command_scheduler_types.hpp"

namespace tap
{
namespace control
{
class Subsystem;

class Command
{
public:
    Command();

    virtual ~Command();

    mockable inline subsystem_scheduler_bitmap_t getRequirementsBitwise() const
    {
        return commandRequirementsBitwise;
    }

    // This shouldn't be mockable
    inline int getGlobalIdentifier() const { return globalIdentifier; }

    mockable void addSubsystemRequirement(Subsystem* requirement);

    virtual const char* getName() const = 0;

    virtual bool isReady();

    virtual void initialize() = 0;

    virtual void execute() = 0;

    virtual void end(bool interrupted) = 0;

    virtual bool isFinished() const = 0;

private:
    const int globalIdentifier;

protected:
    command_scheduler_bitmap_t commandRequirementsBitwise = 0;
};  // class Command

}  // namespace control

}  // namespace tap

#endif  // TAPROOT_COMMAND_HPP_