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

A command composition that runs one of two commands, depending on the value of the given condition when this command is initialized. More...

#include <wpi/commands2/ConditionalCommand.hpp>

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

Public Member Functions

template<std::derived_from< Command > Command1, std::derived_from< Command > Command2>
 ConditionalCommand (Command1 &&onTrue, Command2 &&onFalse, std::function< bool()> condition)
 Creates a new ConditionalCommand.
 ConditionalCommand (std::unique_ptr< Command > &&onTrue, std::unique_ptr< Command > &&onFalse, std::function< bool()> condition)
 Creates a new ConditionalCommand.
 ConditionalCommand (ConditionalCommand &&other)=default
 ConditionalCommand (const ConditionalCommand &other)=delete
void Initialize () override
void Execute () override
void End (bool interrupted) override
bool IsFinished () override
bool RunsWhenDisabled () const override
InterruptionBehavior GetInterruptionBehavior () const override
void InitSendable (wpi::util::SendableBuilder &builder) override
Public Member Functions inherited from wpi::cmd::CommandHelper< Command, ConditionalCommand >
 CommandHelper ()=default
CommandPtr ToPtr () &&override

Detailed Description

A command composition that runs one of two commands, depending on the value of the given condition when this command is initialized.

The rules for command compositions apply: command instances that are passed to it are owned by the composition and cannot be added to any other composition or scheduled individually, and the composition requires all subsystems its components require.

This class is provided by the NewCommands VendorDep

See also
ScheduleCommand

Constructor & Destructor Documentation

◆ ConditionalCommand() [1/4]

template<std::derived_from< Command > Command1, std::derived_from< Command > Command2>
wpi::cmd::ConditionalCommand::ConditionalCommand ( Command1 && onTrue,
Command2 && onFalse,
std::function< bool()> condition )
inline

Creates a new ConditionalCommand.

Parameters
onTruethe command to run if the condition is true
onFalsethe command to run if the condition is false
conditionthe condition to determine which command to run

◆ ConditionalCommand() [2/4]

wpi::cmd::ConditionalCommand::ConditionalCommand ( std::unique_ptr< Command > && onTrue,
std::unique_ptr< Command > && onFalse,
std::function< bool()> condition )

Creates a new ConditionalCommand.

Parameters
onTruethe command to run if the condition is true
onFalsethe command to run if the condition is false
conditionthe condition to determine which command to run

◆ ConditionalCommand() [3/4]

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

◆ ConditionalCommand() [4/4]

wpi::cmd::ConditionalCommand::ConditionalCommand ( const ConditionalCommand & other)
delete

Member Function Documentation

◆ End()

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

◆ Execute()

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

◆ GetInterruptionBehavior()

InterruptionBehavior wpi::cmd::ConditionalCommand::GetInterruptionBehavior ( ) const
override

◆ Initialize()

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

◆ InitSendable()

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

◆ IsFinished()

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

◆ RunsWhenDisabled()

bool wpi::cmd::ConditionalCommand::RunsWhenDisabled ( ) const
override

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