mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-30 02:31:44 +00:00
Use llvm::Twine across C++ Command structure.
This commit is contained in:
@@ -12,12 +12,13 @@
|
||||
|
||||
using namespace frc;
|
||||
|
||||
NetworkButton::NetworkButton(llvm::StringRef tableName, llvm::StringRef field)
|
||||
NetworkButton::NetworkButton(const llvm::Twine& tableName,
|
||||
const llvm::Twine& field)
|
||||
: NetworkButton(nt::NetworkTableInstance::GetDefault().GetTable(tableName),
|
||||
field) {}
|
||||
|
||||
NetworkButton::NetworkButton(std::shared_ptr<nt::NetworkTable> table,
|
||||
llvm::StringRef field)
|
||||
const llvm::Twine& field)
|
||||
: m_entry(table->GetEntry(field)) {}
|
||||
|
||||
bool NetworkButton::Get() {
|
||||
|
||||
@@ -16,7 +16,7 @@ using namespace frc;
|
||||
*
|
||||
* @param name The name for this command group
|
||||
*/
|
||||
CommandGroup::CommandGroup(const std::string& name) : Command(name) {}
|
||||
CommandGroup::CommandGroup(const llvm::Twine& name) : Command(name) {}
|
||||
|
||||
/**
|
||||
* Adds a new Command to the group. The Command will be started after all the
|
||||
|
||||
@@ -42,7 +42,7 @@ ConditionalCommand::ConditionalCommand(Command* onTrue, Command* onFalse) {
|
||||
* @param onTrue The Command to execute if Condition() returns true
|
||||
* @param onFalse The Command to execute if Condition() returns false
|
||||
*/
|
||||
ConditionalCommand::ConditionalCommand(const std::string& name, Command* onTrue,
|
||||
ConditionalCommand::ConditionalCommand(const llvm::Twine& name, Command* onTrue,
|
||||
Command* onFalse)
|
||||
: Command(name) {
|
||||
m_onTrue = onTrue;
|
||||
|
||||
@@ -14,6 +14,6 @@ using namespace frc;
|
||||
*
|
||||
* @param name The name for this command
|
||||
*/
|
||||
InstantCommand::InstantCommand(const std::string& name) : Command(name) {}
|
||||
InstantCommand::InstantCommand(const llvm::Twine& name) : Command(name) {}
|
||||
|
||||
bool InstantCommand::IsFinished() { return true; }
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
using namespace frc;
|
||||
|
||||
PIDCommand::PIDCommand(const std::string& name, double p, double i, double d,
|
||||
PIDCommand::PIDCommand(const llvm::Twine& 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);
|
||||
@@ -22,12 +22,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 std::string& name, double p, double i, double d)
|
||||
PIDCommand::PIDCommand(const llvm::Twine& name, double p, double i, double d)
|
||||
: Command(name) {
|
||||
m_controller = std::make_shared<PIDController>(p, i, d, this, this);
|
||||
}
|
||||
|
||||
PIDCommand::PIDCommand(const std::string& name, double p, double i, double d,
|
||||
PIDCommand::PIDCommand(const llvm::Twine& name, double p, double i, double d,
|
||||
double period)
|
||||
: Command(name) {
|
||||
m_controller = std::make_shared<PIDController>(p, i, d, this, this, period);
|
||||
|
||||
@@ -19,7 +19,7 @@ using namespace frc;
|
||||
* @param i the integral value
|
||||
* @param d the derivative value
|
||||
*/
|
||||
PIDSubsystem::PIDSubsystem(const std::string& name, double p, double i,
|
||||
PIDSubsystem::PIDSubsystem(const llvm::Twine& name, double p, double i,
|
||||
double d)
|
||||
: Subsystem(name) {
|
||||
m_controller = std::make_shared<PIDController>(p, i, d, this, this);
|
||||
@@ -35,7 +35,7 @@ PIDSubsystem::PIDSubsystem(const std::string& name, double p, double i,
|
||||
* @param d the derivative value
|
||||
* @param f the feedforward value
|
||||
*/
|
||||
PIDSubsystem::PIDSubsystem(const std::string& name, double p, double i,
|
||||
PIDSubsystem::PIDSubsystem(const llvm::Twine& name, double p, double i,
|
||||
double d, double f)
|
||||
: Subsystem(name) {
|
||||
m_controller = std::make_shared<PIDController>(p, i, d, f, this, this);
|
||||
@@ -55,7 +55,7 @@ PIDSubsystem::PIDSubsystem(const std::string& name, double p, double i,
|
||||
* @param f the feedfoward value
|
||||
* @param period the time (in seconds) between calculations
|
||||
*/
|
||||
PIDSubsystem::PIDSubsystem(const std::string& name, double p, double i,
|
||||
PIDSubsystem::PIDSubsystem(const llvm::Twine& name, double p, double i,
|
||||
double d, double f, double period)
|
||||
: Subsystem(name) {
|
||||
m_controller =
|
||||
|
||||
@@ -11,9 +11,9 @@
|
||||
|
||||
using namespace frc;
|
||||
|
||||
PrintCommand::PrintCommand(const std::string& message)
|
||||
: InstantCommand("Print \"" + message + "\"") {
|
||||
m_message = message;
|
||||
PrintCommand::PrintCommand(const llvm::Twine& message)
|
||||
: InstantCommand("Print \"" + message + llvm::Twine('"')) {
|
||||
m_message = message.str();
|
||||
}
|
||||
|
||||
void PrintCommand::Initialize() { llvm::outs() << m_message << "\n"; }
|
||||
void PrintCommand::Initialize() { llvm::outs() << m_message << '\n'; }
|
||||
|
||||
@@ -15,7 +15,7 @@ using namespace frc;
|
||||
* @param name the name of the command
|
||||
* @param timeout the time (in seconds) before this command "times out"
|
||||
*/
|
||||
TimedCommand::TimedCommand(const std::string& name, double timeout)
|
||||
TimedCommand::TimedCommand(const llvm::Twine& name, double timeout)
|
||||
: Command(name, timeout) {}
|
||||
|
||||
/**
|
||||
|
||||
@@ -23,5 +23,5 @@ WaitCommand::WaitCommand(double timeout)
|
||||
*
|
||||
* @param timeout the time (in seconds) before this command "times out"
|
||||
*/
|
||||
WaitCommand::WaitCommand(const std::string& name, double timeout)
|
||||
WaitCommand::WaitCommand(const llvm::Twine& name, double timeout)
|
||||
: TimedCommand(name, timeout) {}
|
||||
|
||||
@@ -14,7 +14,7 @@ using namespace frc;
|
||||
WaitForChildren::WaitForChildren(double timeout)
|
||||
: Command("WaitForChildren", timeout) {}
|
||||
|
||||
WaitForChildren::WaitForChildren(const std::string& name, double timeout)
|
||||
WaitForChildren::WaitForChildren(const llvm::Twine& name, double timeout)
|
||||
: Command(name, timeout) {}
|
||||
|
||||
bool WaitForChildren::IsFinished() {
|
||||
|
||||
@@ -23,7 +23,7 @@ WaitUntilCommand::WaitUntilCommand(double time)
|
||||
m_time = time;
|
||||
}
|
||||
|
||||
WaitUntilCommand::WaitUntilCommand(const std::string& name, double time)
|
||||
WaitUntilCommand::WaitUntilCommand(const llvm::Twine& name, double time)
|
||||
: Command(name, time) {
|
||||
m_time = time;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <llvm/StringRef.h>
|
||||
#include <llvm/Twine.h>
|
||||
|
||||
#include "Buttons/Button.h"
|
||||
#include "networktables/NetworkTable.h"
|
||||
@@ -19,8 +19,9 @@ namespace frc {
|
||||
|
||||
class NetworkButton : public Button {
|
||||
public:
|
||||
NetworkButton(llvm::StringRef tableName, llvm::StringRef field);
|
||||
NetworkButton(std::shared_ptr<nt::NetworkTable> table, llvm::StringRef field);
|
||||
NetworkButton(const llvm::Twine& tableName, const llvm::Twine& field);
|
||||
NetworkButton(std::shared_ptr<nt::NetworkTable> table,
|
||||
const llvm::Twine& field);
|
||||
virtual ~NetworkButton() = default;
|
||||
|
||||
virtual bool Get();
|
||||
|
||||
@@ -8,9 +8,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <list>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <llvm/Twine.h>
|
||||
|
||||
#include "Commands/Command.h"
|
||||
#include "Commands/CommandGroupEntry.h"
|
||||
|
||||
@@ -36,7 +37,7 @@ namespace frc {
|
||||
class CommandGroup : public Command {
|
||||
public:
|
||||
CommandGroup() = default;
|
||||
explicit CommandGroup(const std::string& name);
|
||||
explicit CommandGroup(const llvm::Twine& name);
|
||||
virtual ~CommandGroup() = default;
|
||||
|
||||
void AddSequential(Command* command);
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <llvm/Twine.h>
|
||||
|
||||
#include "Commands/Command.h"
|
||||
#include "Commands/InstantCommand.h"
|
||||
@@ -33,7 +33,7 @@ namespace frc {
|
||||
class ConditionalCommand : public Command {
|
||||
public:
|
||||
explicit ConditionalCommand(Command* onTrue, Command* onFalse = nullptr);
|
||||
ConditionalCommand(const std::string& name, Command* onTrue,
|
||||
ConditionalCommand(const llvm::Twine& name, Command* onTrue,
|
||||
Command* onFalse = nullptr);
|
||||
virtual ~ConditionalCommand() = default;
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <llvm/Twine.h>
|
||||
|
||||
#include "Commands/Command.h"
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace frc {
|
||||
*/
|
||||
class InstantCommand : public Command {
|
||||
public:
|
||||
explicit InstantCommand(const std::string& name);
|
||||
explicit InstantCommand(const llvm::Twine& name);
|
||||
InstantCommand() = default;
|
||||
virtual ~InstantCommand() = default;
|
||||
|
||||
|
||||
@@ -8,7 +8,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include <llvm/Twine.h>
|
||||
|
||||
#include "Commands/Command.h"
|
||||
#include "PIDController.h"
|
||||
@@ -19,10 +20,10 @@ namespace frc {
|
||||
|
||||
class PIDCommand : public Command, public PIDOutput, public PIDSource {
|
||||
public:
|
||||
PIDCommand(const std::string& name, double p, double i, double d);
|
||||
PIDCommand(const std::string& name, double p, double i, double d,
|
||||
PIDCommand(const llvm::Twine& name, double p, double i, double d);
|
||||
PIDCommand(const llvm::Twine& name, double p, double i, double d,
|
||||
double period);
|
||||
PIDCommand(const std::string& name, double p, double i, double d, double f,
|
||||
PIDCommand(const llvm::Twine& 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);
|
||||
|
||||
@@ -8,7 +8,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include <llvm/Twine.h>
|
||||
|
||||
#include "Commands/Subsystem.h"
|
||||
#include "PIDController.h"
|
||||
@@ -28,9 +29,9 @@ namespace frc {
|
||||
*/
|
||||
class PIDSubsystem : public Subsystem, public PIDOutput, public PIDSource {
|
||||
public:
|
||||
PIDSubsystem(const std::string& name, double p, double i, double d);
|
||||
PIDSubsystem(const std::string& name, double p, double i, double d, double f);
|
||||
PIDSubsystem(const std::string& name, double p, double i, double d, double f,
|
||||
PIDSubsystem(const llvm::Twine& name, double p, double i, double d);
|
||||
PIDSubsystem(const llvm::Twine& name, double p, double i, double d, double f);
|
||||
PIDSubsystem(const llvm::Twine& name, double p, double i, double d, double f,
|
||||
double period);
|
||||
PIDSubsystem(double p, double i, double d);
|
||||
PIDSubsystem(double p, double i, double d, double f);
|
||||
|
||||
@@ -9,13 +9,15 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <llvm/Twine.h>
|
||||
|
||||
#include "Commands/InstantCommand.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
class PrintCommand : public InstantCommand {
|
||||
public:
|
||||
explicit PrintCommand(const std::string& message);
|
||||
explicit PrintCommand(const llvm::Twine& message);
|
||||
virtual ~PrintCommand() = default;
|
||||
|
||||
protected:
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <llvm/Twine.h>
|
||||
|
||||
#include "Commands/Command.h"
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace frc {
|
||||
*/
|
||||
class TimedCommand : public Command {
|
||||
public:
|
||||
TimedCommand(const std::string& name, double timeout);
|
||||
TimedCommand(const llvm::Twine& name, double timeout);
|
||||
explicit TimedCommand(double timeout);
|
||||
virtual ~TimedCommand() = default;
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <llvm/Twine.h>
|
||||
|
||||
#include "Commands/TimedCommand.h"
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace frc {
|
||||
class WaitCommand : public TimedCommand {
|
||||
public:
|
||||
explicit WaitCommand(double timeout);
|
||||
WaitCommand(const std::string& name, double timeout);
|
||||
WaitCommand(const llvm::Twine& name, double timeout);
|
||||
virtual ~WaitCommand() = default;
|
||||
};
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <llvm/Twine.h>
|
||||
|
||||
#include "Commands/Command.h"
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace frc {
|
||||
class WaitForChildren : public Command {
|
||||
public:
|
||||
explicit WaitForChildren(double timeout);
|
||||
WaitForChildren(const std::string& name, double timeout);
|
||||
WaitForChildren(const llvm::Twine& name, double timeout);
|
||||
virtual ~WaitForChildren() = default;
|
||||
|
||||
protected:
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <llvm/Twine.h>
|
||||
|
||||
#include "Commands/Command.h"
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace frc {
|
||||
class WaitUntilCommand : public Command {
|
||||
public:
|
||||
explicit WaitUntilCommand(double time);
|
||||
WaitUntilCommand(const std::string& name, double time);
|
||||
WaitUntilCommand(const llvm::Twine& name, double time);
|
||||
virtual ~WaitUntilCommand() = default;
|
||||
|
||||
protected:
|
||||
|
||||
Reference in New Issue
Block a user