WPILibC++ 2024.3.2
frc2::SelectCommand< Key > Class Template Reference

A command composition that runs one of a selection of commands using a selector and a key to command mapping. More...

#include <frc2/command/SelectCommand.h>

Inheritance diagram for frc2::SelectCommand< Key >:
frc2::CommandHelper< Command, SelectCommand< Key > >

Public Member Functions

template<std::derived_from< Command >... Commands>
 SelectCommand (std::function< Key()> selector, std::pair< Key, Commands >... commands)
 Creates a new SelectCommand. More...
 
 SelectCommand (std::function< Key()> selector, std::vector< std::pair< Key, std::unique_ptr< Command > > > &&commands)
 
 SelectCommand (const SelectCommand &other)=delete
 
 SelectCommand (SelectCommand &)=delete
 
 SelectCommand (SelectCommand &&other)=default
 
void Initialize () override
 
void Execute () override
 
void End (bool interrupted) override
 
bool IsFinished () override
 
bool RunsWhenDisabled () const override
 
Command::InterruptionBehavior GetInterruptionBehavior () const override
 
void InitSendable (wpi::SendableBuilder &builder) override
 
- Public Member Functions inherited from frc2::CommandHelper< Command, SelectCommand< Key > >
 CommandHelper ()=default
 
CommandPtr ToPtr () &&override
 

Protected Member Functions

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

Detailed Description

template<typename Key>
class frc2::SelectCommand< Key >

A command composition that runs one of a selection of commands using a selector and a key to command mapping.

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

Constructor & Destructor Documentation

◆ SelectCommand() [1/5]

template<typename Key >
template<std::derived_from< Command >... Commands>
frc2::SelectCommand< Key >::SelectCommand ( std::function< Key()>  selector,
std::pair< Key, Commands >...  commands 
)
inlineexplicit

Creates a new SelectCommand.

Parameters
commandsthe map of commands to choose from
selectorthe selector to determine which command to run

◆ SelectCommand() [2/5]

template<typename Key >
frc2::SelectCommand< Key >::SelectCommand ( std::function< Key()>  selector,
std::vector< std::pair< Key, std::unique_ptr< Command > > > &&  commands 
)
inline

◆ SelectCommand() [3/5]

template<typename Key >
frc2::SelectCommand< Key >::SelectCommand ( const SelectCommand< Key > &  other)
delete

◆ SelectCommand() [4/5]

template<typename Key >
frc2::SelectCommand< Key >::SelectCommand ( SelectCommand< Key > &  )
delete

◆ SelectCommand() [5/5]

template<typename Key >
frc2::SelectCommand< Key >::SelectCommand ( SelectCommand< Key > &&  other)
default

Member Function Documentation

◆ End()

template<typename Key >
void frc2::SelectCommand< Key >::End ( bool  interrupted)
inlineoverride

◆ Execute()

template<typename Key >
void frc2::SelectCommand< Key >::Execute ( )
inlineoverride

◆ GetInterruptionBehavior()

template<typename Key >
Command::InterruptionBehavior frc2::SelectCommand< Key >::GetInterruptionBehavior ( ) const
inlineoverride

◆ Initialize()

template<typename T >
void frc2::SelectCommand< T >::Initialize
override

◆ InitSendable()

template<typename Key >
void frc2::SelectCommand< Key >::InitSendable ( wpi::SendableBuilder builder)
inlineoverride

◆ IsFinished()

template<typename Key >
bool frc2::SelectCommand< Key >::IsFinished ( )
inlineoverride

◆ RunsWhenDisabled()

template<typename Key >
bool frc2::SelectCommand< Key >::RunsWhenDisabled ( ) const
inlineoverride

◆ TransferOwnership()

template<typename Key >
std::unique_ptr< Command > frc2::SelectCommand< Key >::TransferOwnership ( ) &&
inlineoverrideprotected

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