Cleaned up robot startup and cleanup/shutdown code (#77)

Cleaned up RobotBase, removed singleton list from SensorBase, and removed unused typedefs and NULL_TASK macro from HAL's Task.hpp. Making the robot class instance static fixed non-POD statics used by the instance during destruction from being destroyed first.
This commit is contained in:
Tyler Veness
2016-06-19 00:13:18 -07:00
committed by Peter Johnson
parent ecc210f99a
commit d66c61a36e
10 changed files with 16 additions and 184 deletions

View File

@@ -17,20 +17,6 @@
#include "Utility.h"
#include "networktables/NetworkTable.h"
RobotBase* RobotBase::m_instance = nullptr;
void RobotBase::setInstance(RobotBase* robot) {
wpi_assert(m_instance == nullptr);
m_instance = robot;
}
RobotBase& RobotBase::getInstance() { return *m_instance; }
void RobotBase::robotSetup(RobotBase* robot) {
std::printf("\n********** Robot program starting **********\n");
robot->StartCompetition();
}
/**
* Constructor for a generic robot program.
*
@@ -46,8 +32,6 @@ RobotBase::RobotBase() : m_ds(DriverStation::GetInstance()) {
RobotState::SetImplementation(DriverStation::GetInstance());
HLUsageReporting::SetImplementation(new HardwareHLReporting());
RobotBase::setInstance(this);
NetworkTable::SetNetworkIdentity("Robot");
NetworkTable::SetPersistentFilename("/home/lvuser/networktables.ini");
@@ -60,18 +44,6 @@ RobotBase::RobotBase() : m_ds(DriverStation::GetInstance()) {
}
}
/**
* Free the resources for a RobotBase class.
* This includes deleting all classes that might have been allocated as
* Singletons to they would never be deleted except here.
*/
RobotBase::~RobotBase() {
SensorBase::DeleteSingletons();
delete m_task;
m_task = nullptr;
m_instance = nullptr;
}
/**
* Determine if the Robot is currently enabled.
* @return True if the Robot is currently enabled by the field controls.
@@ -111,17 +83,3 @@ bool RobotBase::IsTest() const { return m_ds.IsTest(); }
* function was called?
*/
bool RobotBase::IsNewDataAvailable() const { return m_ds.IsNewControlData(); }
/**
* This class exists for the sole purpose of getting its destructor called when
* the module unloads.
* Before the module is done unloading, we need to delete the RobotBase derived
* singleton. This should delete the other remaining singletons that were
* registered. This should also stop all tasks that are using the Task class.
*/
class RobotDeleter {
public:
RobotDeleter() {}
~RobotDeleter() { delete &RobotBase::getInstance(); }
};
static RobotDeleter g_robotDeleter;