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

A command that allows the user to pass in functions for each of the basic command methods through the constructor. More...

#include <wpi/commands2/FunctionalCommand.hpp>

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

Public Member Functions

 FunctionalCommand (std::function< void()> onInit, std::function< void()> onExecute, std::function< void(bool)> onEnd, std::function< bool()> isFinished, Requirements requirements={})
 Creates a new FunctionalCommand.
 FunctionalCommand (FunctionalCommand &&other)=default
 FunctionalCommand (const FunctionalCommand &other)=default
void Initialize () override
void Execute () override
void End (bool interrupted) override
bool IsFinished () override
Public Member Functions inherited from wpi::cmd::CommandHelper< Command, FunctionalCommand >
 CommandHelper ()=default
CommandPtr ToPtr () &&override

Detailed Description

A command that allows the user to pass in functions for each of the basic command methods through the constructor.

Useful for inline definitions of complex commands - note, however, that if a command is beyond a certain complexity it is usually better practice to write a proper class for it than to inline it.

This class is provided by the NewCommands VendorDep

Constructor & Destructor Documentation

◆ FunctionalCommand() [1/3]

wpi::cmd::FunctionalCommand::FunctionalCommand ( std::function< void()> onInit,
std::function< void()> onExecute,
std::function< void(bool)> onEnd,
std::function< bool()> isFinished,
Requirements requirements = {} )

Creates a new FunctionalCommand.

Parameters
onInitthe function to run on command initialization
onExecutethe function to run on command execution
onEndthe function to run on command end
isFinishedthe function that determines whether the command has finished
requirementsthe subsystems required by this command

◆ FunctionalCommand() [2/3]

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

◆ FunctionalCommand() [3/3]

wpi::cmd::FunctionalCommand::FunctionalCommand ( const FunctionalCommand & other)
default

Member Function Documentation

◆ End()

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

◆ Execute()

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

◆ Initialize()

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

◆ IsFinished()

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

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