Use llvm::Twine across C++ Command structure.

This commit is contained in:
Peter Johnson
2017-12-01 20:50:35 -08:00
parent 001dedf3b2
commit ab137abab5
22 changed files with 52 additions and 45 deletions

View File

@@ -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() {

View File

@@ -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

View File

@@ -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;

View File

@@ -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; }

View File

@@ -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);

View File

@@ -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 =

View File

@@ -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'; }

View File

@@ -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) {}
/**

View File

@@ -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) {}

View File

@@ -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() {

View File

@@ -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;
}