WPILibC++ 2024.3.2-63-g0f8aa8a
frc2::ProxyCommand Class Reference

Schedules a given command when this command is initialized and ends when it ends, but does not directly run it. More...

#include <frc2/command/ProxyCommand.h>

Inheritance diagram for frc2::ProxyCommand:
frc2::CommandHelper< Command, ProxyCommand >

Public Member Functions

 ProxyCommand (wpi::unique_function< Command *()> supplier)
 Creates a new ProxyCommand that schedules the supplied command when initialized, and ends when it is no longer scheduled. More...
 
 ProxyCommand (wpi::unique_function< CommandPtr()> supplier)
 Creates a new ProxyCommand that schedules the supplied command when initialized, and ends when it is no longer scheduled. More...
 
 ProxyCommand (Command *command)
 Creates a new ProxyCommand that schedules the given command when initialized, and ends when it is no longer scheduled. More...
 
 ProxyCommand (std::unique_ptr< Command > command)
 Creates a new ProxyCommand that schedules the given command when initialized, and ends when it is no longer scheduled. More...
 
 ProxyCommand (ProxyCommand &&other)=default
 
void Initialize () override
 
void End (bool interrupted) override
 
bool IsFinished () override
 
void InitSendable (wpi::SendableBuilder &builder) override
 
- Public Member Functions inherited from frc2::CommandHelper< Command, ProxyCommand >
 CommandHelper ()=default
 
CommandPtr ToPtr () &&override
 

Additional Inherited Members

- Protected Member Functions inherited from frc2::CommandHelper< Command, ProxyCommand >
std::unique_ptr< CommandTransferOwnership () &&override
 

Detailed Description

Schedules a given command when this command is initialized and ends when it ends, but does not directly run it.

Use this for including a command in a composition without adding its requirements, but only if you know what you are doing. If you are unsure, see the WPILib docs for a complete explanation of proxy semantics. Do not proxy a command from a subsystem already required by the composition, or else the composition will cancel itself when the proxy is reached. If this command is interrupted, it will cancel the command.

This class is provided by the NewCommands VendorDep

Constructor & Destructor Documentation

◆ ProxyCommand() [1/5]

frc2::ProxyCommand::ProxyCommand ( wpi::unique_function< Command *()>  supplier)
explicit

Creates a new ProxyCommand that schedules the supplied command when initialized, and ends when it is no longer scheduled.

Use this for lazily creating proxied commands at runtime. Proxying should only be done to escape from composition requirement semantics, so if only initialization time command construction is needed, use DeferredCommand instead.

Parameters
supplierthe command supplier
See also
DeferredCommand

◆ ProxyCommand() [2/5]

frc2::ProxyCommand::ProxyCommand ( wpi::unique_function< CommandPtr()>  supplier)
explicit

Creates a new ProxyCommand that schedules the supplied command when initialized, and ends when it is no longer scheduled.

Use this for lazily creating proxied commands at runtime. Proxying should only be done to escape from composition requirement semantics, so if only initialization time command construction is needed, use DeferredCommand instead.

Parameters
supplierthe command supplier
See also
DeferredCommand

◆ ProxyCommand() [3/5]

frc2::ProxyCommand::ProxyCommand ( Command command)
explicit

Creates a new ProxyCommand that schedules the given command when initialized, and ends when it is no longer scheduled.

Parameters
commandthe command to run by proxy

◆ ProxyCommand() [4/5]

frc2::ProxyCommand::ProxyCommand ( std::unique_ptr< Command command)
explicit

Creates a new ProxyCommand that schedules the given command when initialized, and ends when it is no longer scheduled.

Note that this constructor passes ownership of the given command to the returned ProxyCommand.

Parameters
commandthe command to schedule

◆ ProxyCommand() [5/5]

frc2::ProxyCommand::ProxyCommand ( ProxyCommand &&  other)
default

Member Function Documentation

◆ End()

void frc2::ProxyCommand::End ( bool  interrupted)
override

◆ Initialize()

void frc2::ProxyCommand::Initialize ( )
override

◆ InitSendable()

void frc2::ProxyCommand::InitSendable ( wpi::SendableBuilder builder)
override

◆ IsFinished()

bool frc2::ProxyCommand::IsFinished ( )
override

The documentation for this class was generated from the following file: