[commands] Remove deprecated classes and functions (#5409)

Removes:
- PerpetualCommand
- Command.perpetually()
- CommandGroupBase
- Command.IsGrouped() (C++ only)
- Command.SetGrouped() (C++ only)
- Command.withInterrupt()
- ProxyScheduleCommand
- Button
- InternalButton, JoystickButton, NetworkButton and POVButton now subclass Trigger
- Old style Trigger functions:
    - Trigger.whenActive
    - Trigger.whileActiveOnce
    - Trigger.whileActiveContinuous
    - Trigger.whenInactive
    - Trigger.toggleWhenActive
    - Trigger.cancelWhenActive
- CommandScheduler.clearButtons()
- CommandScheduler.addButtons() (Java only)
- Command supplier constructor of SelectCommand
This commit is contained in:
Ryan Blue
2023-07-10 12:56:18 -04:00
committed by GitHub
parent b250a03944
commit 7a099cb02a
49 changed files with 82 additions and 2031 deletions

View File

@@ -16,7 +16,6 @@
#include <utility>
#include <vector>
#include <wpi/deprecated.h>
#include <wpi/sendable/SendableBuilder.h>
#include "frc2/command/CommandBase.h"
@@ -95,17 +94,6 @@ class SelectCommand : public CommandHelper<CommandBase, SelectCommand<Key>> {
// Prevent template expansion from emulating copy ctor
SelectCommand(SelectCommand&) = delete;
/**
* Creates a new selectcommand.
*
* @param toRun a supplier providing the command to run
* @deprecated Replace with {@link ProxyCommand},
* composing multiple of them in a {@link ParallelRaceGroup} if needed.
*/
WPI_DEPRECATED("Replace with ProxyCommand")
explicit SelectCommand(std::function<Command*()> toRun)
: m_toRun{std::move(toRun)} {}
SelectCommand(SelectCommand&& other) = default;
void Initialize() override;
@@ -147,7 +135,6 @@ class SelectCommand : public CommandHelper<CommandBase, SelectCommand<Key>> {
private:
std::unordered_map<Key, std::unique_ptr<Command>> m_commands;
std::function<Key()> m_selector;
std::function<Command*()> m_toRun;
Command* m_selectedCommand;
bool m_runsWhenDisabled = true;
Command::InterruptionBehavior m_interruptBehavior{
@@ -156,16 +143,12 @@ class SelectCommand : public CommandHelper<CommandBase, SelectCommand<Key>> {
template <typename T>
void SelectCommand<T>::Initialize() {
if (m_selector) {
auto find = m_commands.find(m_selector());
if (find == m_commands.end()) {
m_selectedCommand = new PrintCommand(
"SelectCommand selector value does not correspond to any command!");
return;
}
m_selectedCommand = find->second.get();
auto find = m_commands.find(m_selector());
if (find == m_commands.end()) {
m_selectedCommand = new PrintCommand(
"SelectCommand selector value does not correspond to any command!");
} else {
m_selectedCommand = m_toRun();
m_selectedCommand = find->second.get();
}
m_selectedCommand->Initialize();
}