WPILibC++ 2027.0.0-alpha-4
Loading...
Searching...
No Matches
wpi::cmd::DeferredCommand Class Reference

Defers Command construction to runtime. More...

#include <wpi/commands2/DeferredCommand.hpp>

Inheritance diagram for wpi::cmd::DeferredCommand:
wpi::cmd::CommandHelper< Command, DeferredCommand >

Public Member Functions

 DeferredCommand (wpi::util::unique_function< CommandPtr()> supplier, Requirements requirements)
 Creates a new DeferredCommand that directly runs the supplied command when initialized, and ends when it ends.
 DeferredCommand (DeferredCommand &&other)=default
void Initialize () override
void Execute () override
void End (bool interrupted) override
bool IsFinished () override
void InitSendable (wpi::util::SendableBuilder &builder) override
Public Member Functions inherited from wpi::cmd::CommandHelper< Command, DeferredCommand >
 CommandHelper ()=default
CommandPtr ToPtr () &&override

Detailed Description

Defers Command construction to runtime.

Runs the command returned by a supplier when this command is initialized, and ends when it ends. Useful for performing runtime tasks before creating a new command. If this command is interrupted, it will cancel the command.

Note that the supplier must create a new Command each call. For selecting one of a preallocated set of commands, use SelectCommand.

This class is provided by the NewCommands VendorDep

Constructor & Destructor Documentation

◆ DeferredCommand() [1/2]

wpi::cmd::DeferredCommand::DeferredCommand ( wpi::util::unique_function< CommandPtr()> supplier,
Requirements requirements )

Creates a new DeferredCommand that directly runs the supplied command when initialized, and ends when it ends.

Useful for lazily creating commands when the DeferredCommand is initialized, such as if the supplied command depends on runtime state. The supplier will be called each time this command is initialized. The supplier must create a new Command each call.

Parameters
supplierThe command supplier
requirementsThe command requirements.

◆ DeferredCommand() [2/2]

wpi::cmd::DeferredCommand::DeferredCommand ( DeferredCommand && other)
default

Member Function Documentation

◆ End()

void wpi::cmd::DeferredCommand::End ( bool interrupted)
override

◆ Execute()

void wpi::cmd::DeferredCommand::Execute ( )
override

◆ Initialize()

void wpi::cmd::DeferredCommand::Initialize ( )
override

◆ InitSendable()

void wpi::cmd::DeferredCommand::InitSendable ( wpi::util::SendableBuilder & builder)
override

◆ IsFinished()

bool wpi::cmd::DeferredCommand::IsFinished ( )
override

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