mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-30 02:31:44 +00:00
[wpilibc] Use std::string_view instead of Twine (#3380)
Use fmtlib where needed for string formatting into std::string_view.
This commit is contained in:
@@ -9,13 +9,12 @@
|
||||
|
||||
using namespace frc;
|
||||
|
||||
NetworkButton::NetworkButton(const wpi::Twine& tableName,
|
||||
const wpi::Twine& field)
|
||||
NetworkButton::NetworkButton(std::string_view tableName, std::string_view field)
|
||||
: NetworkButton(nt::NetworkTableInstance::GetDefault().GetTable(tableName),
|
||||
field) {}
|
||||
|
||||
NetworkButton::NetworkButton(std::shared_ptr<nt::NetworkTable> table,
|
||||
const wpi::Twine& field)
|
||||
std::string_view field)
|
||||
: m_entry(table->GetEntry(field)) {}
|
||||
|
||||
bool NetworkButton::Get() {
|
||||
|
||||
@@ -21,7 +21,7 @@ int Command::m_commandCounter = 0;
|
||||
|
||||
Command::Command() : Command("", -1.0) {}
|
||||
|
||||
Command::Command(const wpi::Twine& name) : Command(name, -1.0) {}
|
||||
Command::Command(std::string_view name) : Command(name, -1.0) {}
|
||||
|
||||
Command::Command(double timeout) : Command("", timeout) {}
|
||||
|
||||
@@ -29,7 +29,7 @@ Command::Command(Subsystem& subsystem) : Command("", -1.0) {
|
||||
Requires(&subsystem);
|
||||
}
|
||||
|
||||
Command::Command(const wpi::Twine& name, double timeout) {
|
||||
Command::Command(std::string_view name, double timeout) {
|
||||
// We use -1.0 to indicate no timeout.
|
||||
if (timeout < 0.0 && timeout != -1.0) {
|
||||
throw FRC_MakeError(err::ParameterOutOfRange, "timeout {} < 0.0", timeout);
|
||||
@@ -38,16 +38,15 @@ Command::Command(const wpi::Twine& name, double timeout) {
|
||||
m_timeout = timeout;
|
||||
|
||||
// If name contains an empty string
|
||||
if (name.isTriviallyEmpty() ||
|
||||
(name.isSingleStringRef() && name.getSingleStringRef().empty())) {
|
||||
if (name.empty()) {
|
||||
SendableRegistry::GetInstance().Add(
|
||||
this, "Command_" + wpi::Twine(typeid(*this).name()));
|
||||
this, fmt::format("Command_{}", typeid(*this).name()));
|
||||
} else {
|
||||
SendableRegistry::GetInstance().Add(this, name);
|
||||
}
|
||||
}
|
||||
|
||||
Command::Command(const wpi::Twine& name, Subsystem& subsystem)
|
||||
Command::Command(std::string_view name, Subsystem& subsystem)
|
||||
: Command(name, -1.0) {
|
||||
Requires(&subsystem);
|
||||
}
|
||||
@@ -56,7 +55,7 @@ Command::Command(double timeout, Subsystem& subsystem) : Command("", timeout) {
|
||||
Requires(&subsystem);
|
||||
}
|
||||
|
||||
Command::Command(const wpi::Twine& name, double timeout, Subsystem& subsystem)
|
||||
Command::Command(std::string_view name, double timeout, Subsystem& subsystem)
|
||||
: Command(name, timeout) {
|
||||
Requires(&subsystem);
|
||||
}
|
||||
@@ -183,7 +182,7 @@ bool Command::IsTimedOut() const {
|
||||
return m_timeout != -1 && TimeSinceInitialized() >= m_timeout;
|
||||
}
|
||||
|
||||
bool Command::AssertUnlocked(const std::string& message) {
|
||||
bool Command::AssertUnlocked(std::string_view message) {
|
||||
if (m_locked) {
|
||||
throw FRC_MakeError(
|
||||
err::CommandIllegalUse,
|
||||
@@ -277,7 +276,7 @@ std::string Command::GetName() const {
|
||||
return SendableRegistry::GetInstance().GetName(this);
|
||||
}
|
||||
|
||||
void Command::SetName(const wpi::Twine& name) {
|
||||
void Command::SetName(std::string_view name) {
|
||||
SendableRegistry::GetInstance().SetName(this, name);
|
||||
}
|
||||
|
||||
@@ -285,7 +284,7 @@ std::string Command::GetSubsystem() const {
|
||||
return SendableRegistry::GetInstance().GetSubsystem(this);
|
||||
}
|
||||
|
||||
void Command::SetSubsystem(const wpi::Twine& name) {
|
||||
void Command::SetSubsystem(std::string_view name) {
|
||||
SendableRegistry::GetInstance().SetSubsystem(this, name);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
using namespace frc;
|
||||
|
||||
CommandGroup::CommandGroup(const wpi::Twine& name) : Command(name) {}
|
||||
CommandGroup::CommandGroup(std::string_view name) : Command(name) {}
|
||||
|
||||
void CommandGroup::AddSequential(Command* command) {
|
||||
if (!command) {
|
||||
|
||||
@@ -28,7 +28,7 @@ ConditionalCommand::ConditionalCommand(Command* onTrue, Command* onFalse) {
|
||||
RequireAll(*this, onTrue, onFalse);
|
||||
}
|
||||
|
||||
ConditionalCommand::ConditionalCommand(const wpi::Twine& name, Command* onTrue,
|
||||
ConditionalCommand::ConditionalCommand(std::string_view name, Command* onTrue,
|
||||
Command* onFalse)
|
||||
: Command(name) {
|
||||
m_onTrue = onTrue;
|
||||
|
||||
@@ -8,11 +8,11 @@
|
||||
|
||||
using namespace frc;
|
||||
|
||||
InstantCommand::InstantCommand(const wpi::Twine& name) : Command(name) {}
|
||||
InstantCommand::InstantCommand(std::string_view name) : Command(name) {}
|
||||
|
||||
InstantCommand::InstantCommand(Subsystem& subsystem) : Command(subsystem) {}
|
||||
|
||||
InstantCommand::InstantCommand(const wpi::Twine& name, Subsystem& subsystem)
|
||||
InstantCommand::InstantCommand(std::string_view name, Subsystem& subsystem)
|
||||
: Command(name, subsystem) {}
|
||||
|
||||
InstantCommand::InstantCommand(std::function<void()> func)
|
||||
@@ -23,13 +23,13 @@ InstantCommand::InstantCommand(Subsystem& subsystem, std::function<void()> func)
|
||||
m_func = func;
|
||||
}
|
||||
|
||||
InstantCommand::InstantCommand(const wpi::Twine& name,
|
||||
InstantCommand::InstantCommand(std::string_view name,
|
||||
std::function<void()> func)
|
||||
: InstantCommand(name) {
|
||||
m_func = func;
|
||||
}
|
||||
|
||||
InstantCommand::InstantCommand(const wpi::Twine& name, Subsystem& subsystem,
|
||||
InstantCommand::InstantCommand(std::string_view name, Subsystem& subsystem,
|
||||
std::function<void()> func)
|
||||
: InstantCommand(name, subsystem) {
|
||||
m_func = func;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
using namespace frc;
|
||||
|
||||
PIDCommand::PIDCommand(const wpi::Twine& name, double p, double i, double d,
|
||||
PIDCommand::PIDCommand(std::string_view name, double p, double i, double d,
|
||||
double f, double period)
|
||||
: Command(name) {
|
||||
m_controller = std::make_shared<PIDController>(p, i, d, this, this, period);
|
||||
@@ -19,12 +19,12 @@ PIDCommand::PIDCommand(double p, double i, double d, double f, double period) {
|
||||
std::make_shared<PIDController>(p, i, d, f, this, this, period);
|
||||
}
|
||||
|
||||
PIDCommand::PIDCommand(const wpi::Twine& name, double p, double i, double d)
|
||||
PIDCommand::PIDCommand(std::string_view name, double p, double i, double d)
|
||||
: Command(name) {
|
||||
m_controller = std::make_shared<PIDController>(p, i, d, this, this);
|
||||
}
|
||||
|
||||
PIDCommand::PIDCommand(const wpi::Twine& name, double p, double i, double d,
|
||||
PIDCommand::PIDCommand(std::string_view name, double p, double i, double d,
|
||||
double period)
|
||||
: Command(name) {
|
||||
m_controller = std::make_shared<PIDController>(p, i, d, this, this, period);
|
||||
@@ -38,7 +38,7 @@ PIDCommand::PIDCommand(double p, double i, double d, double period) {
|
||||
m_controller = std::make_shared<PIDController>(p, i, d, this, this, period);
|
||||
}
|
||||
|
||||
PIDCommand::PIDCommand(const wpi::Twine& name, double p, double i, double d,
|
||||
PIDCommand::PIDCommand(std::string_view name, double p, double i, double d,
|
||||
double f, double period, Subsystem& subsystem)
|
||||
: Command(name, subsystem) {
|
||||
m_controller = std::make_shared<PIDController>(p, i, d, this, this, period);
|
||||
@@ -51,13 +51,13 @@ PIDCommand::PIDCommand(double p, double i, double d, double f, double period,
|
||||
std::make_shared<PIDController>(p, i, d, f, this, this, period);
|
||||
}
|
||||
|
||||
PIDCommand::PIDCommand(const wpi::Twine& name, double p, double i, double d,
|
||||
PIDCommand::PIDCommand(std::string_view name, double p, double i, double d,
|
||||
Subsystem& subsystem)
|
||||
: Command(name, subsystem) {
|
||||
m_controller = std::make_shared<PIDController>(p, i, d, this, this);
|
||||
}
|
||||
|
||||
PIDCommand::PIDCommand(const wpi::Twine& name, double p, double i, double d,
|
||||
PIDCommand::PIDCommand(std::string_view name, double p, double i, double d,
|
||||
double period, Subsystem& subsystem)
|
||||
: Command(name, subsystem) {
|
||||
m_controller = std::make_shared<PIDController>(p, i, d, this, this, period);
|
||||
|
||||
@@ -8,20 +8,20 @@
|
||||
|
||||
using namespace frc;
|
||||
|
||||
PIDSubsystem::PIDSubsystem(const wpi::Twine& name, double p, double i, double d)
|
||||
PIDSubsystem::PIDSubsystem(std::string_view name, double p, double i, double d)
|
||||
: Subsystem(name) {
|
||||
m_controller = std::make_shared<PIDController>(p, i, d, this, this);
|
||||
AddChild("PIDController", m_controller);
|
||||
}
|
||||
|
||||
PIDSubsystem::PIDSubsystem(const wpi::Twine& name, double p, double i, double d,
|
||||
PIDSubsystem::PIDSubsystem(std::string_view name, double p, double i, double d,
|
||||
double f)
|
||||
: Subsystem(name) {
|
||||
m_controller = std::make_shared<PIDController>(p, i, d, f, this, this);
|
||||
AddChild("PIDController", m_controller);
|
||||
}
|
||||
|
||||
PIDSubsystem::PIDSubsystem(const wpi::Twine& name, double p, double i, double d,
|
||||
PIDSubsystem::PIDSubsystem(std::string_view name, double p, double i, double d,
|
||||
double f, double period)
|
||||
: Subsystem(name) {
|
||||
m_controller =
|
||||
|
||||
@@ -4,13 +4,14 @@
|
||||
|
||||
#include "frc/commands/PrintCommand.h"
|
||||
|
||||
#include <fmt/format.h>
|
||||
#include <wpi/raw_ostream.h>
|
||||
|
||||
using namespace frc;
|
||||
|
||||
PrintCommand::PrintCommand(const wpi::Twine& message)
|
||||
: InstantCommand("Print \"" + message + wpi::Twine('"')) {
|
||||
m_message = message.str();
|
||||
PrintCommand::PrintCommand(std::string_view message)
|
||||
: InstantCommand(fmt::format("Print \"{}\"", message)) {
|
||||
m_message = message;
|
||||
}
|
||||
|
||||
void PrintCommand::Initialize() {
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
using namespace frc;
|
||||
|
||||
Subsystem::Subsystem(const wpi::Twine& name) {
|
||||
Subsystem::Subsystem(std::string_view name) {
|
||||
SendableRegistry::GetInstance().AddLW(this, name, name);
|
||||
Scheduler::GetInstance()->RegisterSubsystem(this);
|
||||
}
|
||||
@@ -40,12 +40,12 @@ Command* Subsystem::GetDefaultCommand() {
|
||||
return m_defaultCommand;
|
||||
}
|
||||
|
||||
wpi::StringRef Subsystem::GetDefaultCommandName() {
|
||||
std::string Subsystem::GetDefaultCommandName() {
|
||||
Command* defaultCommand = GetDefaultCommand();
|
||||
if (defaultCommand) {
|
||||
return SendableRegistry::GetInstance().GetName(defaultCommand);
|
||||
} else {
|
||||
return wpi::StringRef();
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,12 +58,12 @@ Command* Subsystem::GetCurrentCommand() const {
|
||||
return m_currentCommand;
|
||||
}
|
||||
|
||||
wpi::StringRef Subsystem::GetCurrentCommandName() const {
|
||||
std::string Subsystem::GetCurrentCommandName() const {
|
||||
Command* currentCommand = GetCurrentCommand();
|
||||
if (currentCommand) {
|
||||
return SendableRegistry::GetInstance().GetName(currentCommand);
|
||||
} else {
|
||||
return wpi::StringRef();
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ std::string Subsystem::GetName() const {
|
||||
return SendableRegistry::GetInstance().GetName(this);
|
||||
}
|
||||
|
||||
void Subsystem::SetName(const wpi::Twine& name) {
|
||||
void Subsystem::SetName(std::string_view name) {
|
||||
SendableRegistry::GetInstance().SetName(this, name);
|
||||
}
|
||||
|
||||
@@ -83,20 +83,20 @@ std::string Subsystem::GetSubsystem() const {
|
||||
return SendableRegistry::GetInstance().GetSubsystem(this);
|
||||
}
|
||||
|
||||
void Subsystem::SetSubsystem(const wpi::Twine& name) {
|
||||
void Subsystem::SetSubsystem(std::string_view name) {
|
||||
SendableRegistry::GetInstance().SetSubsystem(this, name);
|
||||
}
|
||||
|
||||
void Subsystem::AddChild(const wpi::Twine& name,
|
||||
void Subsystem::AddChild(std::string_view name,
|
||||
std::shared_ptr<Sendable> child) {
|
||||
AddChild(name, *child);
|
||||
}
|
||||
|
||||
void Subsystem::AddChild(const wpi::Twine& name, Sendable* child) {
|
||||
void Subsystem::AddChild(std::string_view name, Sendable* child) {
|
||||
AddChild(name, *child);
|
||||
}
|
||||
|
||||
void Subsystem::AddChild(const wpi::Twine& name, Sendable& child) {
|
||||
void Subsystem::AddChild(std::string_view name, Sendable& child) {
|
||||
auto& registry = SendableRegistry::GetInstance();
|
||||
registry.AddLW(&child, registry.GetSubsystem(this), name);
|
||||
}
|
||||
|
||||
@@ -6,12 +6,12 @@
|
||||
|
||||
using namespace frc;
|
||||
|
||||
TimedCommand::TimedCommand(const wpi::Twine& name, double timeout)
|
||||
TimedCommand::TimedCommand(std::string_view name, double timeout)
|
||||
: Command(name, timeout) {}
|
||||
|
||||
TimedCommand::TimedCommand(double timeout) : Command(timeout) {}
|
||||
|
||||
TimedCommand::TimedCommand(const wpi::Twine& name, double timeout,
|
||||
TimedCommand::TimedCommand(std::string_view name, double timeout,
|
||||
Subsystem& subsystem)
|
||||
: Command(name, timeout, subsystem) {}
|
||||
|
||||
|
||||
@@ -4,10 +4,12 @@
|
||||
|
||||
#include "frc/commands/WaitCommand.h"
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
||||
using namespace frc;
|
||||
|
||||
WaitCommand::WaitCommand(double timeout)
|
||||
: TimedCommand("Wait(" + std::to_string(timeout) + ")", timeout) {}
|
||||
: TimedCommand(fmt::format("Wait({})", timeout), timeout) {}
|
||||
|
||||
WaitCommand::WaitCommand(const wpi::Twine& name, double timeout)
|
||||
WaitCommand::WaitCommand(std::string_view name, double timeout)
|
||||
: TimedCommand(name, timeout) {}
|
||||
|
||||
@@ -11,7 +11,7 @@ using namespace frc;
|
||||
WaitForChildren::WaitForChildren(double timeout)
|
||||
: Command("WaitForChildren", timeout) {}
|
||||
|
||||
WaitForChildren::WaitForChildren(const wpi::Twine& name, double timeout)
|
||||
WaitForChildren::WaitForChildren(std::string_view name, double timeout)
|
||||
: Command(name, timeout) {}
|
||||
|
||||
bool WaitForChildren::IsFinished() {
|
||||
|
||||
@@ -13,7 +13,7 @@ WaitUntilCommand::WaitUntilCommand(double time)
|
||||
m_time = time;
|
||||
}
|
||||
|
||||
WaitUntilCommand::WaitUntilCommand(const wpi::Twine& name, double time)
|
||||
WaitUntilCommand::WaitUntilCommand(std::string_view name, double time)
|
||||
: Command(name, time) {
|
||||
m_time = time;
|
||||
}
|
||||
|
||||
@@ -5,10 +5,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <string_view>
|
||||
|
||||
#include <networktables/NetworkTable.h>
|
||||
#include <networktables/NetworkTableEntry.h>
|
||||
#include <wpi/Twine.h>
|
||||
|
||||
#include "frc/buttons/Button.h"
|
||||
|
||||
@@ -16,9 +16,9 @@ namespace frc {
|
||||
|
||||
class NetworkButton : public Button {
|
||||
public:
|
||||
NetworkButton(const wpi::Twine& tableName, const wpi::Twine& field);
|
||||
NetworkButton(std::string_view tableName, std::string_view field);
|
||||
NetworkButton(std::shared_ptr<nt::NetworkTable> table,
|
||||
const wpi::Twine& field);
|
||||
std::string_view field);
|
||||
~NetworkButton() override = default;
|
||||
|
||||
NetworkButton(NetworkButton&&) = default;
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include <wpi/SmallPtrSet.h>
|
||||
#include <wpi/Twine.h>
|
||||
|
||||
#include "frc/commands/Subsystem.h"
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
@@ -59,7 +59,7 @@ class Command : public Sendable, public SendableHelper<Command> {
|
||||
*
|
||||
* @param name the name for this command
|
||||
*/
|
||||
explicit Command(const wpi::Twine& name);
|
||||
explicit Command(std::string_view name);
|
||||
|
||||
/**
|
||||
* Creates a new command with the given timeout and a default name.
|
||||
@@ -83,7 +83,7 @@ class Command : public Sendable, public SendableHelper<Command> {
|
||||
* @param timeout the time (in seconds) before this command "times out"
|
||||
* @see IsTimedOut()
|
||||
*/
|
||||
Command(const wpi::Twine& name, double timeout);
|
||||
Command(std::string_view name, double timeout);
|
||||
|
||||
/**
|
||||
* Creates a new command with the given name and timeout.
|
||||
@@ -91,7 +91,7 @@ class Command : public Sendable, public SendableHelper<Command> {
|
||||
* @param name the name of the command
|
||||
* @param subsystem the subsystem that the command requires
|
||||
*/
|
||||
Command(const wpi::Twine& name, Subsystem& subsystem);
|
||||
Command(std::string_view name, Subsystem& subsystem);
|
||||
|
||||
/**
|
||||
* Creates a new command with the given name and timeout.
|
||||
@@ -108,7 +108,7 @@ class Command : public Sendable, public SendableHelper<Command> {
|
||||
* @param timeout the time (in seconds) before this command "times out"
|
||||
* @param subsystem the subsystem that the command requires @see IsTimedOut()
|
||||
*/
|
||||
Command(const wpi::Twine& name, double timeout, Subsystem& subsystem);
|
||||
Command(std::string_view name, double timeout, Subsystem& subsystem);
|
||||
|
||||
~Command() override = default;
|
||||
|
||||
@@ -293,7 +293,7 @@ class Command : public Sendable, public SendableHelper<Command> {
|
||||
* message)
|
||||
* @return True if assert passed, false if assert failed.
|
||||
*/
|
||||
bool AssertUnlocked(const std::string& message);
|
||||
bool AssertUnlocked(std::string_view message);
|
||||
|
||||
/**
|
||||
* Sets the parent of this command. No actual change is made to the group.
|
||||
@@ -395,7 +395,7 @@ class Command : public Sendable, public SendableHelper<Command> {
|
||||
*
|
||||
* @param name name
|
||||
*/
|
||||
void SetName(const wpi::Twine& name);
|
||||
void SetName(std::string_view name);
|
||||
|
||||
/**
|
||||
* Gets the subsystem name of this Command.
|
||||
@@ -409,7 +409,7 @@ class Command : public Sendable, public SendableHelper<Command> {
|
||||
*
|
||||
* @param subsystem subsystem name
|
||||
*/
|
||||
void SetSubsystem(const wpi::Twine& subsystem);
|
||||
void SetSubsystem(std::string_view subsystem);
|
||||
|
||||
private:
|
||||
/**
|
||||
|
||||
@@ -4,10 +4,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
#include <wpi/Twine.h>
|
||||
|
||||
#include "frc/commands/Command.h"
|
||||
#include "frc/commands/CommandGroupEntry.h"
|
||||
|
||||
@@ -39,7 +38,7 @@ class CommandGroup : public Command {
|
||||
*
|
||||
* @param name The name for this command group
|
||||
*/
|
||||
explicit CommandGroup(const wpi::Twine& name);
|
||||
explicit CommandGroup(std::string_view name);
|
||||
|
||||
~CommandGroup() override = default;
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wpi/Twine.h>
|
||||
#include <string_view>
|
||||
|
||||
#include "frc/commands/Command.h"
|
||||
|
||||
@@ -46,7 +46,7 @@ class ConditionalCommand : public Command {
|
||||
* @param onTrue The Command to execute if Condition() returns true
|
||||
* @param onFalse The Command to execute if Condition() returns false
|
||||
*/
|
||||
ConditionalCommand(const wpi::Twine& name, Command* onTrue,
|
||||
ConditionalCommand(std::string_view name, Command* onTrue,
|
||||
Command* onFalse = nullptr);
|
||||
|
||||
~ConditionalCommand() override = default;
|
||||
|
||||
@@ -5,8 +5,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <functional>
|
||||
|
||||
#include <wpi/Twine.h>
|
||||
#include <string_view>
|
||||
|
||||
#include "frc/commands/Command.h"
|
||||
#include "frc/commands/Subsystem.h"
|
||||
@@ -25,7 +24,7 @@ class InstantCommand : public Command {
|
||||
*
|
||||
* @param name The name for this command
|
||||
*/
|
||||
explicit InstantCommand(const wpi::Twine& name);
|
||||
explicit InstantCommand(std::string_view name);
|
||||
|
||||
/**
|
||||
* Creates a new InstantCommand with the given requirement.
|
||||
@@ -40,7 +39,7 @@ class InstantCommand : public Command {
|
||||
* @param name The name for this command
|
||||
* @param subsystem The subsystem that the command requires
|
||||
*/
|
||||
InstantCommand(const wpi::Twine& name, Subsystem& subsystem);
|
||||
InstantCommand(std::string_view name, Subsystem& subsystem);
|
||||
|
||||
/**
|
||||
* Create a command that calls the given function when run.
|
||||
@@ -63,7 +62,7 @@ class InstantCommand : public Command {
|
||||
* @param name The name of the command.
|
||||
* @param func The function to run when Initialize() is run.
|
||||
*/
|
||||
InstantCommand(const wpi::Twine& name, std::function<void()> func);
|
||||
InstantCommand(std::string_view name, std::function<void()> func);
|
||||
|
||||
/**
|
||||
* Create a command that calls the given function when run.
|
||||
@@ -72,7 +71,7 @@ class InstantCommand : public Command {
|
||||
* @param subsystem The subsystems that this command runs on.
|
||||
* @param func The function to run when Initialize() is run.
|
||||
*/
|
||||
InstantCommand(const wpi::Twine& name, Subsystem& subsystem,
|
||||
InstantCommand(std::string_view name, Subsystem& subsystem,
|
||||
std::function<void()> func);
|
||||
|
||||
InstantCommand() = default;
|
||||
|
||||
@@ -5,8 +5,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <wpi/Twine.h>
|
||||
#include <string_view>
|
||||
|
||||
#include "frc/PIDController.h"
|
||||
#include "frc/PIDOutput.h"
|
||||
@@ -17,19 +16,19 @@ namespace frc {
|
||||
|
||||
class PIDCommand : public Command, public PIDOutput, public PIDSource {
|
||||
public:
|
||||
PIDCommand(const wpi::Twine& name, double p, double i, double d);
|
||||
PIDCommand(const wpi::Twine& name, double p, double i, double d,
|
||||
PIDCommand(std::string_view name, double p, double i, double d);
|
||||
PIDCommand(std::string_view name, double p, double i, double d,
|
||||
double period);
|
||||
PIDCommand(const wpi::Twine& name, double p, double i, double d, double f,
|
||||
PIDCommand(std::string_view name, double p, double i, double d, double f,
|
||||
double period);
|
||||
PIDCommand(double p, double i, double d);
|
||||
PIDCommand(double p, double i, double d, double period);
|
||||
PIDCommand(double p, double i, double d, double f, double period);
|
||||
PIDCommand(const wpi::Twine& name, double p, double i, double d,
|
||||
PIDCommand(std::string_view name, double p, double i, double d,
|
||||
Subsystem& subsystem);
|
||||
PIDCommand(const wpi::Twine& name, double p, double i, double d,
|
||||
double period, Subsystem& subsystem);
|
||||
PIDCommand(const wpi::Twine& name, double p, double i, double d, double f,
|
||||
PIDCommand(std::string_view name, double p, double i, double d, double period,
|
||||
Subsystem& subsystem);
|
||||
PIDCommand(std::string_view name, double p, double i, double d, double f,
|
||||
double period, Subsystem& subsystem);
|
||||
PIDCommand(double p, double i, double d, Subsystem& subsystem);
|
||||
PIDCommand(double p, double i, double d, double period, Subsystem& subsystem);
|
||||
|
||||
@@ -5,8 +5,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <wpi/Twine.h>
|
||||
#include <string_view>
|
||||
|
||||
#include "frc/PIDController.h"
|
||||
#include "frc/PIDOutput.h"
|
||||
@@ -34,7 +33,7 @@ class PIDSubsystem : public Subsystem, public PIDOutput, public PIDSource {
|
||||
* @param i the integral value
|
||||
* @param d the derivative value
|
||||
*/
|
||||
PIDSubsystem(const wpi::Twine& name, double p, double i, double d);
|
||||
PIDSubsystem(std::string_view name, double p, double i, double d);
|
||||
|
||||
/**
|
||||
* Instantiates a PIDSubsystem that will use the given P, I, D, and F values.
|
||||
@@ -45,7 +44,7 @@ class PIDSubsystem : public Subsystem, public PIDOutput, public PIDSource {
|
||||
* @param d the derivative value
|
||||
* @param f the feedforward value
|
||||
*/
|
||||
PIDSubsystem(const wpi::Twine& name, double p, double i, double d, double f);
|
||||
PIDSubsystem(std::string_view name, double p, double i, double d, double f);
|
||||
|
||||
/**
|
||||
* Instantiates a PIDSubsystem that will use the given P, I, D, and F values.
|
||||
@@ -60,7 +59,7 @@ class PIDSubsystem : public Subsystem, public PIDOutput, public PIDSource {
|
||||
* @param f the feedfoward value
|
||||
* @param period the time (in seconds) between calculations
|
||||
*/
|
||||
PIDSubsystem(const wpi::Twine& name, double p, double i, double d, double f,
|
||||
PIDSubsystem(std::string_view name, double p, double i, double d, double f,
|
||||
double period);
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,8 +5,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <wpi/Twine.h>
|
||||
#include <string_view>
|
||||
|
||||
#include "frc/commands/InstantCommand.h"
|
||||
|
||||
@@ -14,7 +13,7 @@ namespace frc {
|
||||
|
||||
class PrintCommand : public InstantCommand {
|
||||
public:
|
||||
explicit PrintCommand(const wpi::Twine& message);
|
||||
explicit PrintCommand(std::string_view message);
|
||||
~PrintCommand() override = default;
|
||||
|
||||
PrintCommand(PrintCommand&&) = default;
|
||||
|
||||
@@ -6,9 +6,7 @@
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include <wpi/StringRef.h>
|
||||
#include <wpi/Twine.h>
|
||||
#include <string_view>
|
||||
|
||||
#include "frc/smartdashboard/Sendable.h"
|
||||
#include "frc/smartdashboard/SendableHelper.h"
|
||||
@@ -26,7 +24,7 @@ class Subsystem : public Sendable, public SendableHelper<Subsystem> {
|
||||
*
|
||||
* @param name the name of the subsystem
|
||||
*/
|
||||
explicit Subsystem(const wpi::Twine& name);
|
||||
explicit Subsystem(std::string_view name);
|
||||
|
||||
Subsystem(Subsystem&&) = default;
|
||||
Subsystem& operator=(Subsystem&&) = default;
|
||||
@@ -54,7 +52,7 @@ class Subsystem : public Sendable, public SendableHelper<Subsystem> {
|
||||
*
|
||||
* @return the default command name
|
||||
*/
|
||||
wpi::StringRef GetDefaultCommandName();
|
||||
std::string GetDefaultCommandName();
|
||||
|
||||
/**
|
||||
* Sets the current command.
|
||||
@@ -75,7 +73,7 @@ class Subsystem : public Sendable, public SendableHelper<Subsystem> {
|
||||
*
|
||||
* @return the current command name
|
||||
*/
|
||||
wpi::StringRef GetCurrentCommandName() const;
|
||||
std::string GetCurrentCommandName() const;
|
||||
|
||||
/**
|
||||
* When the run method of the scheduler is called this method will be called.
|
||||
@@ -106,7 +104,7 @@ class Subsystem : public Sendable, public SendableHelper<Subsystem> {
|
||||
*
|
||||
* @param name name
|
||||
*/
|
||||
void SetName(const wpi::Twine& name);
|
||||
void SetName(std::string_view name);
|
||||
|
||||
/**
|
||||
* Gets the subsystem name of this Subsystem.
|
||||
@@ -120,7 +118,7 @@ class Subsystem : public Sendable, public SendableHelper<Subsystem> {
|
||||
*
|
||||
* @param subsystem subsystem name
|
||||
*/
|
||||
void SetSubsystem(const wpi::Twine& subsystem);
|
||||
void SetSubsystem(std::string_view subsystem);
|
||||
|
||||
/**
|
||||
* Associate a Sendable with this Subsystem.
|
||||
@@ -129,7 +127,7 @@ class Subsystem : public Sendable, public SendableHelper<Subsystem> {
|
||||
* @param name name to give child
|
||||
* @param child sendable
|
||||
*/
|
||||
void AddChild(const wpi::Twine& name, std::shared_ptr<Sendable> child);
|
||||
void AddChild(std::string_view name, std::shared_ptr<Sendable> child);
|
||||
|
||||
/**
|
||||
* Associate a Sendable with this Subsystem.
|
||||
@@ -138,7 +136,7 @@ class Subsystem : public Sendable, public SendableHelper<Subsystem> {
|
||||
* @param name name to give child
|
||||
* @param child sendable
|
||||
*/
|
||||
void AddChild(const wpi::Twine& name, Sendable* child);
|
||||
void AddChild(std::string_view name, Sendable* child);
|
||||
|
||||
/**
|
||||
* Associate a Sendable with this Subsystem.
|
||||
@@ -147,7 +145,7 @@ class Subsystem : public Sendable, public SendableHelper<Subsystem> {
|
||||
* @param name name to give child
|
||||
* @param child sendable
|
||||
*/
|
||||
void AddChild(const wpi::Twine& name, Sendable& child);
|
||||
void AddChild(std::string_view name, Sendable& child);
|
||||
|
||||
/**
|
||||
* Associate a {@link Sendable} with this Subsystem.
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wpi/Twine.h>
|
||||
#include <string_view>
|
||||
|
||||
#include "frc/commands/Command.h"
|
||||
|
||||
@@ -23,7 +23,7 @@ class TimedCommand : public Command {
|
||||
* @param name the name of the command
|
||||
* @param timeout the time (in seconds) before this command "times out"
|
||||
*/
|
||||
TimedCommand(const wpi::Twine& name, double timeout);
|
||||
TimedCommand(std::string_view name, double timeout);
|
||||
|
||||
/**
|
||||
* Creates a new WaitCommand with the given timeout.
|
||||
@@ -39,7 +39,7 @@ class TimedCommand : public Command {
|
||||
* @param timeout the time (in seconds) before this command "times out"
|
||||
* @param subsystem the subsystem that the command requires
|
||||
*/
|
||||
TimedCommand(const wpi::Twine& name, double timeout, Subsystem& subsystem);
|
||||
TimedCommand(std::string_view name, double timeout, Subsystem& subsystem);
|
||||
|
||||
/**
|
||||
* Creates a new WaitCommand with the given timeout.
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wpi/Twine.h>
|
||||
#include <string_view>
|
||||
|
||||
#include "frc/commands/TimedCommand.h"
|
||||
|
||||
@@ -25,7 +25,7 @@ class WaitCommand : public TimedCommand {
|
||||
*
|
||||
* @param timeout the time (in seconds) before this command "times out"
|
||||
*/
|
||||
WaitCommand(const wpi::Twine& name, double timeout);
|
||||
WaitCommand(std::string_view name, double timeout);
|
||||
|
||||
~WaitCommand() override = default;
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wpi/Twine.h>
|
||||
#include <string_view>
|
||||
|
||||
#include "frc/commands/Command.h"
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace frc {
|
||||
class WaitForChildren : public Command {
|
||||
public:
|
||||
explicit WaitForChildren(double timeout);
|
||||
WaitForChildren(const wpi::Twine& name, double timeout);
|
||||
WaitForChildren(std::string_view name, double timeout);
|
||||
~WaitForChildren() override = default;
|
||||
|
||||
WaitForChildren(WaitForChildren&&) = default;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wpi/Twine.h>
|
||||
#include <string_view>
|
||||
|
||||
#include "frc/commands/Command.h"
|
||||
|
||||
@@ -22,7 +22,7 @@ class WaitUntilCommand : public Command {
|
||||
*/
|
||||
explicit WaitUntilCommand(double time);
|
||||
|
||||
WaitUntilCommand(const wpi::Twine& name, double time);
|
||||
WaitUntilCommand(std::string_view name, double time);
|
||||
|
||||
~WaitUntilCommand() override = default;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user