Program Listing for File command_mapper.hpp

Return to documentation for file (src/tap/control/command_mapper.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_MAPPER_HPP_
#define TAPROOT_COMMAND_MAPPER_HPP_

#include <vector>

#include "tap/communication/serial/remote.hpp"
#include "tap/util_macros.hpp"

namespace tap
{
class Drivers;
namespace control
{
class CommandMapping;

class CommandMapper
{
public:
    explicit CommandMapper(Drivers *drivers) : drivers(drivers) {}
    DISALLOW_COPY_AND_ASSIGN(CommandMapper)
    mockable ~CommandMapper() = default;

    mockable void handleKeyStateChange(
        uint16_t key,
        tap::communication::serial::Remote::SwitchState leftSwitch,
        tap::communication::serial::Remote::SwitchState rightSwitch,
        bool mouseL,
        bool mouseR);

    mockable void addMap(CommandMapping *mapping);

    mockable std::size_t getSize() const { return commandsToRun.size(); }

    mockable const CommandMapping *getAtIndex(std::size_t index) const;

private:
    std::vector<CommandMapping *> commandsToRun;

    Drivers *drivers;
};  // class CommandMapper

}  // namespace control
}  // namespace tap

#endif  // TAPROOT_COMMAND_MAPPER_HPP_