WPILibC++ 2027.0.0-alpha-5
Loading...
Searching...
No Matches
ProxyCommand.hpp
Go to the documentation of this file.
1// Copyright (c) FIRST and other WPILib contributors.
2// Open Source Software; you can modify and/or share it under the terms of
3// the WPILib BSD license file in the root directory of this project.
4
5#pragma once
6
7#include <memory>
8
12
13namespace wpi::cmd {
14/**
15 * Schedules a given command when this command is initialized and ends when it
16 * ends, but does not directly run it. Use this for including a command in a
17 * composition without adding its requirements, <strong>but only if you know
18 * what you are doing. If you are unsure, see <a
19 * href="https://docs.wpilib.org/en/stable/docs/software/commandbased/command-compositions.html#scheduling-other-commands">the
20 * WPILib docs</a> for a complete explanation of proxy semantics.</strong> Do
21 * not proxy a command from a subsystem already required by the composition, or
22 * else the composition will cancel itself when the proxy is reached. If this
23 * command is interrupted, it will cancel the command.
24 *
25 * <p>This class is provided by the Commands v2 VendorDep
26 */
27class ProxyCommand : public CommandHelper<Command, ProxyCommand> {
28 public:
29 /**
30 * Creates a new ProxyCommand that schedules the given command when
31 * initialized, and ends when it is no longer scheduled.
32 *
33 * @param command the command to run by proxy
34 */
35 explicit ProxyCommand(Command* command);
36
37 /**
38 * Creates a new ProxyCommand that schedules the given command when
39 * initialized, and ends when it is no longer scheduled.
40 *
41 * <p>Note that this constructor passes ownership of the given command to the
42 * returned ProxyCommand.
43 *
44 * @param command the command to schedule
45 */
46 explicit ProxyCommand(std::unique_ptr<Command> command);
47
48 ProxyCommand(ProxyCommand&& other) = default;
49
50 void Initialize() override;
51
52 void End(bool interrupted) override;
53
54 bool IsFinished() override;
55
57
58 private:
60 Command* m_command = nullptr;
61};
62} // namespace wpi::cmd
This file provides a collection of function (or more generally, callable) type erasure utilities supp...
A state machine representing a complete action to be performed by the robot.
Definition Command.hpp:38
void InitSendable(wpi::util::SendableBuilder &builder) override
void Initialize() override
ProxyCommand(ProxyCommand &&other)=default
void End(bool interrupted) override
bool IsFinished() override
ProxyCommand(std::unique_ptr< Command > command)
Creates a new ProxyCommand that schedules the given command when initialized, and ends when it is no ...
ProxyCommand(Command *command)
Creates a new ProxyCommand that schedules the given command when initialized, and ends when it is no ...
Helper class for building Sendable dashboard representations.
Definition SendableBuilder.hpp:21
unique_function is a type-erasing functor similar to std::function.
Definition FunctionExtras.hpp:57
Definition CommandNiDsStadiaController.hpp:15