NamedSendable::GetName() is now const qualified

Change-Id: Ie9e4daac4473e44f4248385f992da750501443e5
This commit is contained in:
Tyler Veness
2015-07-09 01:27:56 -07:00
parent eb7d55fd59
commit 451c4e81c3
7 changed files with 16 additions and 12 deletions

View File

@@ -175,7 +175,7 @@ class Command : public ErrorBase, public NamedSendable, public ITableListener {
static int m_commandCounter;
public:
virtual std::string GetName();
virtual std::string GetName() const;
virtual void InitTable(::std::shared_ptr<ITable> table);
virtual ::std::shared_ptr<ITable> GetTable() const;
virtual std::string GetSmartDashboardType() const;

View File

@@ -42,7 +42,7 @@ class Scheduler : public ErrorBase, public NamedSendable {
std::string GetSmartDashboardType() const;
void InitTable(::std::shared_ptr<ITable> subTable);
::std::shared_ptr<ITable> GetTable() const;
std::string GetName();
std::string GetName() const;
std::string GetType() const;
private:

View File

@@ -38,7 +38,7 @@ class Subsystem : public ErrorBase, public NamedSendable {
bool m_initializedDefaultCommand = false;
public:
virtual std::string GetName();
virtual std::string GetName() const;
virtual void InitTable(::std::shared_ptr<ITable> table);
virtual ::std::shared_ptr<ITable> GetTable() const;
virtual std::string GetSmartDashboardType() const;

View File

@@ -22,7 +22,7 @@ class NamedSendable : public Sendable {
* @return the name of the subtable of SmartDashboard that the Sendable object
* will use
*/
virtual std::string GetName() = 0;
virtual std::string GetName() const = 0;
};
#endif /* NAMEDSENDABLE_H_ */

View File

@@ -23,7 +23,7 @@ int Command::m_commandCounter = 0;
* Creates a new command.
* The name of this command will be default.
*/
Command::Command() : Command(nullptr, -1.0) {}
Command::Command() : Command("", -1.0) {}
/**
* Creates a new command with the given name and no timeout.
@@ -50,7 +50,14 @@ Command::Command(const std::string &name, double timeout) {
wpi_setWPIErrorWithContext(ParameterOutOfRange, "timeout < 0.0");
m_timeout = timeout;
m_name = name;
// If name contains an empty string
if (name.length() == 0) {
m_name = std::string("Command_") + std::string(typeid(*this).name());
}
else {
m_name = name;
}
}
Command::~Command() { // TODO deal with cleaning up all listeners
@@ -357,10 +364,7 @@ void Command::SetRunWhenDisabled(bool run) { m_runWhenDisabled = run; }
*/
bool Command::WillRunWhenDisabled() const { return m_runWhenDisabled; }
std::string Command::GetName() {
if (m_name.length() == 0) {
m_name = std::string("Command_") + std::string(typeid(*this).name());
}
std::string Command::GetName() const {
return m_name;
}

View File

@@ -252,7 +252,7 @@ void Scheduler::UpdateTable() {
}
}
std::string Scheduler::GetName() { return "Scheduler"; }
std::string Scheduler::GetName() const { return "Scheduler"; }
std::string Scheduler::GetType() const { return "Scheduler"; }

View File

@@ -122,7 +122,7 @@ void Subsystem::ConfirmCommand() {
}
}
std::string Subsystem::GetName() { return m_name; }
std::string Subsystem::GetName() const { return m_name; }
std::string Subsystem::GetSmartDashboardType() const { return "Subsystem"; }