mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-22 01:11:42 +00:00
Add format script which invokes clang-format on the C++ source code (#41)
On Windows machines, clang-format.exe must be in the PATH environment variable.
This commit is contained in:
committed by
Peter Johnson
parent
68690643d2
commit
e14e45da76
@@ -6,23 +6,24 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "LiveWindow/LiveWindow.h"
|
||||
#include "networktables/NetworkTable.h"
|
||||
#include <algorithm>
|
||||
#include <sstream>
|
||||
#include "networktables/NetworkTable.h"
|
||||
|
||||
/**
|
||||
* Get an instance of the LiveWindow main class
|
||||
* Get an instance of the LiveWindow main class.
|
||||
*
|
||||
* This is a singleton to guarantee that there is only a single instance
|
||||
* regardless of
|
||||
* how many times GetInstance is called.
|
||||
* regardless of how many times GetInstance is called.
|
||||
*/
|
||||
LiveWindow *LiveWindow::GetInstance() {
|
||||
LiveWindow* LiveWindow::GetInstance() {
|
||||
static LiveWindow instance;
|
||||
return &instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* LiveWindow constructor.
|
||||
*
|
||||
* Allocate the necessary tables.
|
||||
*/
|
||||
LiveWindow::LiveWindow() : m_scheduler(Scheduler::GetInstance()) {
|
||||
@@ -31,7 +32,8 @@ LiveWindow::LiveWindow() : m_scheduler(Scheduler::GetInstance()) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the enabled status of LiveWindow
|
||||
* Change the enabled status of LiveWindow.
|
||||
*
|
||||
* If it changes to enabled, start livewindow running otherwise stop it
|
||||
*/
|
||||
void LiveWindow::SetEnabled(bool enabled) {
|
||||
@@ -58,16 +60,19 @@ void LiveWindow::SetEnabled(bool enabled) {
|
||||
|
||||
/**
|
||||
* @name AddSensor(subsystem, name, component)
|
||||
*
|
||||
* Add a Sensor associated with the subsystem and call it by the given name.
|
||||
*
|
||||
* @param subsystem The subsystem this component is part of.
|
||||
* @param name The name of this component.
|
||||
* @param name The name of this component.
|
||||
* @param component A LiveWindowSendable component that represents a sensor.
|
||||
*/
|
||||
//@{
|
||||
/**
|
||||
* @brief Use a STL smart pointer to share ownership of component.
|
||||
*/
|
||||
void LiveWindow::AddSensor(const std::string &subsystem, const std::string &name,
|
||||
void LiveWindow::AddSensor(const std::string& subsystem,
|
||||
const std::string& name,
|
||||
std::shared_ptr<LiveWindowSendable> component) {
|
||||
m_components[component].subsystem = subsystem;
|
||||
m_components[component].name = name;
|
||||
@@ -77,20 +82,20 @@ void LiveWindow::AddSensor(const std::string &subsystem, const std::string &name
|
||||
/**
|
||||
* @brief Pass a reference to LiveWindow and retain ownership of the component.
|
||||
*/
|
||||
void LiveWindow::AddSensor(const std::string &subsystem,
|
||||
const std::string &name,
|
||||
LiveWindowSendable &component) {
|
||||
void LiveWindow::AddSensor(const std::string& subsystem,
|
||||
const std::string& name,
|
||||
LiveWindowSendable& component) {
|
||||
AddSensor(subsystem, name, std::shared_ptr<LiveWindowSendable>(
|
||||
&component, [](LiveWindowSendable*){}));
|
||||
&component, [](LiveWindowSendable*) {}));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Use a raw pointer to the LiveWindow.
|
||||
* @deprecated Prefer smart pointers or references.
|
||||
*/
|
||||
void LiveWindow::AddSensor(const std::string &subsystem,
|
||||
const std::string &name,
|
||||
LiveWindowSendable *component) {
|
||||
void LiveWindow::AddSensor(const std::string& subsystem,
|
||||
const std::string& name,
|
||||
LiveWindowSendable* component) {
|
||||
AddSensor(subsystem, name, std::shared_ptr<LiveWindowSendable>(
|
||||
component, NullDeleter<LiveWindowSendable>()));
|
||||
}
|
||||
@@ -98,16 +103,19 @@ void LiveWindow::AddSensor(const std::string &subsystem,
|
||||
|
||||
/**
|
||||
* @name AddActuator(subsystem, name, component)
|
||||
*
|
||||
* Add an Actuator associated with the subsystem and call it by the given name.
|
||||
*
|
||||
* @param subsystem The subsystem this component is part of.
|
||||
* @param name The name of this component.
|
||||
* @param name The name of this component.
|
||||
* @param component A LiveWindowSendable component that represents a actuator.
|
||||
*/
|
||||
//@{
|
||||
/**
|
||||
* @brief Use a STL smart pointer to share ownership of component.
|
||||
*/
|
||||
void LiveWindow::AddActuator(const std::string &subsystem, const std::string &name,
|
||||
void LiveWindow::AddActuator(const std::string& subsystem,
|
||||
const std::string& name,
|
||||
std::shared_ptr<LiveWindowSendable> component) {
|
||||
m_components[component].subsystem = subsystem;
|
||||
m_components[component].name = name;
|
||||
@@ -117,19 +125,20 @@ void LiveWindow::AddActuator(const std::string &subsystem, const std::string &na
|
||||
/**
|
||||
* @brief Pass a reference to LiveWindow and retain ownership of the component.
|
||||
*/
|
||||
void LiveWindow::AddActuator(const std::string &subsystem,
|
||||
const std::string &name,
|
||||
LiveWindowSendable &component) {
|
||||
void LiveWindow::AddActuator(const std::string& subsystem,
|
||||
const std::string& name,
|
||||
LiveWindowSendable& component) {
|
||||
AddActuator(subsystem, name, std::shared_ptr<LiveWindowSendable>(
|
||||
&component, [](LiveWindowSendable*){}));
|
||||
&component, [](LiveWindowSendable*) {}));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Use a raw pointer to the LiveWindow.
|
||||
* @deprecated Prefer smart pointers or references.
|
||||
*/
|
||||
void LiveWindow::AddActuator(const std::string &subsystem, const std::string &name,
|
||||
LiveWindowSendable *component) {
|
||||
void LiveWindow::AddActuator(const std::string& subsystem,
|
||||
const std::string& name,
|
||||
LiveWindowSendable* component) {
|
||||
AddActuator(subsystem, name,
|
||||
std::shared_ptr<LiveWindowSendable>(
|
||||
component, NullDeleter<LiveWindowSendable>()));
|
||||
@@ -140,7 +149,7 @@ void LiveWindow::AddActuator(const std::string &subsystem, const std::string &na
|
||||
* Meant for internal use in other WPILib classes.
|
||||
*/
|
||||
void LiveWindow::AddSensor(std::string type, int channel,
|
||||
LiveWindowSendable *component) {
|
||||
LiveWindowSendable* component) {
|
||||
std::ostringstream oss;
|
||||
oss << type << "[" << channel << "]";
|
||||
AddSensor("Ungrouped", oss.str(), component);
|
||||
@@ -155,26 +164,29 @@ void LiveWindow::AddSensor(std::string type, int channel,
|
||||
* Meant for internal use in other WPILib classes.
|
||||
*/
|
||||
void LiveWindow::AddActuator(std::string type, int channel,
|
||||
LiveWindowSendable *component) {
|
||||
LiveWindowSendable* component) {
|
||||
std::ostringstream oss;
|
||||
oss << type << "[" << channel << "]";
|
||||
AddActuator("Ungrouped", oss.str(), std::shared_ptr<LiveWindowSendable>(
|
||||
component, [](LiveWindowSendable *) {}));
|
||||
AddActuator("Ungrouped", oss.str(),
|
||||
std::shared_ptr<LiveWindowSendable>(component,
|
||||
[](LiveWindowSendable*) {}));
|
||||
}
|
||||
|
||||
/**
|
||||
* Meant for internal use in other WPILib classes.
|
||||
*/
|
||||
void LiveWindow::AddActuator(std::string type, int module, int channel,
|
||||
LiveWindowSendable *component) {
|
||||
LiveWindowSendable* component) {
|
||||
std::ostringstream oss;
|
||||
oss << type << "[" << module << "," << channel << "]";
|
||||
AddActuator("Ungrouped", oss.str(), std::shared_ptr<LiveWindowSendable>(
|
||||
component, [](LiveWindowSendable *) {}));
|
||||
AddActuator("Ungrouped", oss.str(),
|
||||
std::shared_ptr<LiveWindowSendable>(component,
|
||||
[](LiveWindowSendable*) {}));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tell all the sensors to update (send) their values
|
||||
* Tell all the sensors to update (send) their values.
|
||||
*
|
||||
* Actuators are handled through callbacks on their value changing from the
|
||||
* SmartDashboard widgets.
|
||||
*/
|
||||
@@ -207,8 +219,8 @@ void LiveWindow::InitializeLiveWindowComponents() {
|
||||
LiveWindowComponent c = elem.second;
|
||||
std::string subsystem = c.subsystem;
|
||||
std::string name = c.name;
|
||||
m_liveWindowTable->GetSubTable(subsystem)
|
||||
->PutString("~TYPE~", "LW Subsystem");
|
||||
m_liveWindowTable->GetSubTable(subsystem)->PutString("~TYPE~",
|
||||
"LW Subsystem");
|
||||
std::shared_ptr<ITable> table(
|
||||
m_liveWindowTable->GetSubTable(subsystem)->GetSubTable(name));
|
||||
table->PutString("~TYPE~", component->GetSmartDashboardType());
|
||||
|
||||
Reference in New Issue
Block a user