Add move constructors and assignment operators to wpilibc (#1314)

Fixes #898.
This commit is contained in:
Tyler Veness
2018-09-24 00:08:25 -07:00
committed by Peter Johnson
parent b1965f74a8
commit 1aa8446725
136 changed files with 764 additions and 89 deletions

View File

@@ -8,6 +8,7 @@
#include "frc/AnalogGyro.h"
#include <climits>
#include <utility>
#include <hal/AnalogGyro.h>
#include <hal/Errors.h>
@@ -64,6 +65,20 @@ AnalogGyro::AnalogGyro(std::shared_ptr<AnalogInput> channel, int center,
AnalogGyro::~AnalogGyro() { HAL_FreeAnalogGyro(m_gyroHandle); }
AnalogGyro::AnalogGyro(AnalogGyro&& rhs)
: GyroBase(std::move(rhs)), m_analog(std::move(rhs.m_analog)) {
std::swap(m_gyroHandle, rhs.m_gyroHandle);
}
AnalogGyro& AnalogGyro::operator=(AnalogGyro&& rhs) {
GyroBase::operator=(std::move(rhs));
m_analog = std::move(rhs.m_analog);
std::swap(m_gyroHandle, rhs.m_gyroHandle);
return *this;
}
double AnalogGyro::GetAngle() const {
if (StatusIsFatal()) return 0.0;
int32_t status = 0;

View File

@@ -7,6 +7,8 @@
#include "frc/AnalogInput.h"
#include <utility>
#include <hal/AnalogAccumulator.h>
#include <hal/AnalogInput.h>
#include <hal/HAL.h>
@@ -43,9 +45,27 @@ AnalogInput::AnalogInput(int channel) {
SetName("AnalogInput", channel);
}
AnalogInput::~AnalogInput() {
HAL_FreeAnalogInputPort(m_port);
m_port = HAL_kInvalidHandle;
AnalogInput::~AnalogInput() { HAL_FreeAnalogInputPort(m_port); }
AnalogInput::AnalogInput(AnalogInput&& rhs)
: ErrorBase(std::move(rhs)),
SendableBase(std::move(rhs)),
PIDSource(std::move(rhs)),
m_channel(std::move(rhs.m_channel)),
m_accumulatorOffset(std::move(rhs.m_accumulatorOffset)) {
std::swap(m_port, rhs.m_port);
}
AnalogInput& AnalogInput::operator=(AnalogInput&& rhs) {
ErrorBase::operator=(std::move(rhs));
SendableBase::operator=(std::move(rhs));
PIDSource::operator=(std::move(rhs));
m_channel = std::move(rhs.m_channel);
std::swap(m_port, rhs.m_port);
m_accumulatorOffset = std::move(rhs.m_accumulatorOffset);
return *this;
}
int AnalogInput::GetValue() const {

View File

@@ -8,6 +8,7 @@
#include "frc/AnalogOutput.h"
#include <limits>
#include <utility>
#include <hal/HAL.h>
#include <hal/Ports.h>
@@ -46,6 +47,23 @@ AnalogOutput::AnalogOutput(int channel) {
AnalogOutput::~AnalogOutput() { HAL_FreeAnalogOutputPort(m_port); }
AnalogOutput::AnalogOutput(AnalogOutput&& rhs)
: ErrorBase(std::move(rhs)),
SendableBase(std::move(rhs)),
m_channel(std::move(rhs.m_channel)) {
std::swap(m_port, rhs.m_port);
}
AnalogOutput& AnalogOutput::operator=(AnalogOutput&& rhs) {
ErrorBase::operator=(std::move(rhs));
SendableBase::operator=(std::move(rhs));
m_channel = std::move(rhs.m_channel);
std::swap(m_port, rhs.m_port);
return *this;
}
void AnalogOutput::SetVoltage(double voltage) {
int32_t status = 0;
HAL_SetAnalogOutput(m_port, voltage, &status);

View File

@@ -7,7 +7,7 @@
#include "frc/AnalogTrigger.h"
#include <memory>
#include <utility>
#include <hal/HAL.h>
@@ -43,11 +43,32 @@ AnalogTrigger::~AnalogTrigger() {
int32_t status = 0;
HAL_CleanAnalogTrigger(m_trigger, &status);
if (m_ownsAnalog && m_analogInput != nullptr) {
if (m_ownsAnalog) {
delete m_analogInput;
}
}
AnalogTrigger::AnalogTrigger(AnalogTrigger&& rhs)
: ErrorBase(std::move(rhs)),
SendableBase(std::move(rhs)),
m_index(std::move(rhs.m_index)) {
std::swap(m_trigger, rhs.m_trigger);
std::swap(m_analogInput, rhs.m_analogInput);
std::swap(m_ownsAnalog, rhs.m_ownsAnalog);
}
AnalogTrigger& AnalogTrigger::operator=(AnalogTrigger&& rhs) {
ErrorBase::operator=(std::move(rhs));
SendableBase::operator=(std::move(rhs));
m_index = std::move(rhs.m_index);
std::swap(m_trigger, rhs.m_trigger);
std::swap(m_analogInput, rhs.m_analogInput);
std::swap(m_ownsAnalog, rhs.m_ownsAnalog);
return *this;
}
void AnalogTrigger::SetLimitsVoltage(double lower, double upper) {
if (StatusIsFatal()) return;
int32_t status = 0;

View File

@@ -7,6 +7,8 @@
#include "frc/CAN.h"
#include <utility>
#include <hal/HAL.h>
using namespace frc;
@@ -46,6 +48,18 @@ CAN::~CAN() {
}
}
CAN::CAN(CAN&& rhs) : ErrorBase(std::move(rhs)) {
std::swap(m_handle, rhs.m_handle);
}
CAN& CAN::operator=(CAN&& rhs) {
ErrorBase::operator=(std::move(rhs));
std::swap(m_handle, rhs.m_handle);
return *this;
}
void CAN::WritePacket(const uint8_t* data, int length, int apiId) {
int32_t status = 0;
HAL_WriteCANPacket(m_handle, data, length, apiId, &status);

View File

@@ -7,6 +7,8 @@
#include "frc/Counter.h"
#include <utility>
#include <hal/HAL.h>
#include "frc/AnalogTrigger.h"
@@ -91,6 +93,29 @@ Counter::~Counter() {
m_counter = HAL_kInvalidHandle;
}
Counter::Counter(Counter&& rhs)
: ErrorBase(std::move(rhs)),
SendableBase(std::move(rhs)),
CounterBase(std::move(rhs)),
m_upSource(std::move(rhs.m_upSource)),
m_downSource(std::move(rhs.m_downSource)),
m_index(std::move(rhs.m_index)) {
std::swap(m_counter, rhs.m_counter);
}
Counter& Counter::operator=(Counter&& rhs) {
ErrorBase::operator=(std::move(rhs));
SendableBase::operator=(std::move(rhs));
CounterBase::operator=(std::move(rhs));
m_upSource = std::move(rhs.m_upSource);
m_downSource = std::move(rhs.m_downSource);
std::swap(m_counter, rhs.m_counter);
m_index = std::move(rhs.m_index);
return *this;
}
void Counter::SetUpSource(int channel) {
if (StatusIsFatal()) return;
SetUpSource(std::make_shared<DigitalInput>(channel));

View File

@@ -9,6 +9,7 @@
#include <algorithm>
#include <array>
#include <utility>
#include <hal/Constants.h>
#include <hal/DIO.h>
@@ -47,6 +48,20 @@ DigitalGlitchFilter::~DigitalGlitchFilter() {
}
}
DigitalGlitchFilter::DigitalGlitchFilter(DigitalGlitchFilter&& rhs)
: ErrorBase(std::move(rhs)), SendableBase(std::move(rhs)) {
std::swap(m_channelIndex, rhs.m_channelIndex);
}
DigitalGlitchFilter& DigitalGlitchFilter::operator=(DigitalGlitchFilter&& rhs) {
ErrorBase::operator=(std::move(rhs));
SendableBase::operator=(std::move(rhs));
std::swap(m_channelIndex, rhs.m_channelIndex);
return *this;
}
void DigitalGlitchFilter::Add(DigitalSource* input) {
DoAdd(input, m_channelIndex + 1);
}

View File

@@ -8,6 +8,7 @@
#include "frc/DigitalInput.h"
#include <limits>
#include <utility>
#include <hal/DIO.h>
#include <hal/HAL.h>
@@ -54,6 +55,20 @@ DigitalInput::~DigitalInput() {
HAL_FreeDIOPort(m_handle);
}
DigitalInput::DigitalInput(DigitalInput&& rhs)
: DigitalSource(std::move(rhs)), m_channel(std::move(rhs.m_channel)) {
std::swap(m_handle, rhs.m_handle);
}
DigitalInput& DigitalInput::operator=(DigitalInput&& rhs) {
DigitalSource::operator=(std::move(rhs));
m_channel = std::move(rhs.m_channel);
std::swap(m_handle, rhs.m_handle);
return *this;
}
bool DigitalInput::Get() const {
if (StatusIsFatal()) return false;
int32_t status = 0;

View File

@@ -8,6 +8,7 @@
#include "frc/DigitalOutput.h"
#include <limits>
#include <utility>
#include <hal/DIO.h>
#include <hal/HAL.h>
@@ -51,6 +52,25 @@ DigitalOutput::~DigitalOutput() {
HAL_FreeDIOPort(m_handle);
}
DigitalOutput::DigitalOutput(DigitalOutput&& rhs)
: ErrorBase(std::move(rhs)),
SendableBase(std::move(rhs)),
m_channel(std::move(rhs.m_channel)),
m_pwmGenerator(std::move(rhs.m_pwmGenerator)) {
std::swap(m_handle, rhs.m_handle);
}
DigitalOutput& DigitalOutput::operator=(DigitalOutput&& rhs) {
ErrorBase::operator=(std::move(rhs));
SendableBase::operator=(std::move(rhs));
m_channel = std::move(rhs.m_channel);
std::swap(m_handle, rhs.m_handle);
m_pwmGenerator = std::move(rhs.m_pwmGenerator);
return *this;
}
void DigitalOutput::Set(bool value) {
if (StatusIsFatal()) return;

View File

@@ -7,6 +7,8 @@
#include "frc/DoubleSolenoid.h"
#include <utility>
#include <hal/HAL.h>
#include <hal/Ports.h>
#include <hal/Solenoid.h>
@@ -81,6 +83,29 @@ DoubleSolenoid::~DoubleSolenoid() {
HAL_FreeSolenoidPort(m_reverseHandle);
}
DoubleSolenoid::DoubleSolenoid(DoubleSolenoid&& rhs)
: SolenoidBase(std::move(rhs)),
m_forwardChannel(std::move(rhs.m_forwardChannel)),
m_reverseChannel(std::move(rhs.m_reverseChannel)),
m_forwardMask(std::move(rhs.m_forwardMask)),
m_reverseMask(std::move(rhs.m_reverseMask)) {
std::swap(m_forwardHandle, rhs.m_forwardHandle);
std::swap(m_reverseHandle, rhs.m_reverseHandle);
}
DoubleSolenoid& DoubleSolenoid::operator=(DoubleSolenoid&& rhs) {
SolenoidBase::operator=(std::move(rhs));
m_forwardChannel = std::move(rhs.m_forwardChannel);
m_reverseChannel = std::move(rhs.m_reverseChannel);
m_forwardMask = std::move(rhs.m_forwardMask);
m_reverseMask = std::move(rhs.m_reverseMask);
std::swap(m_forwardHandle, rhs.m_forwardHandle);
std::swap(m_reverseHandle, rhs.m_reverseHandle);
return *this;
}
void DoubleSolenoid::Set(Value value) {
if (StatusIsFatal()) return;

View File

@@ -7,6 +7,8 @@
#include "frc/Encoder.h"
#include <utility>
#include <hal/HAL.h>
#include "frc/DigitalInput.h"
@@ -57,6 +59,31 @@ Encoder::~Encoder() {
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
}
Encoder::Encoder(Encoder&& rhs)
: ErrorBase(std::move(rhs)),
SendableBase(std::move(rhs)),
CounterBase(std::move(rhs)),
PIDSource(std::move(rhs)),
m_aSource(std::move(rhs.m_aSource)),
m_bSource(std::move(rhs.m_bSource)),
m_indexSource(std::move(rhs.m_indexSource)) {
std::swap(m_encoder, rhs.m_encoder);
}
Encoder& Encoder::operator=(Encoder&& rhs) {
ErrorBase::operator=(std::move(rhs));
SendableBase::operator=(std::move(rhs));
CounterBase::operator=(std::move(rhs));
PIDSource::operator=(std::move(rhs));
m_aSource = std::move(rhs.m_aSource);
m_bSource = std::move(rhs.m_bSource);
m_indexSource = std::move(rhs.m_indexSource);
std::swap(m_encoder, rhs.m_encoder);
return *this;
}
int Encoder::Get() const {
if (StatusIsFatal()) return 0;
int32_t status = 0;

View File

@@ -7,6 +7,8 @@
#include "frc/I2C.h"
#include <utility>
#include <hal/HAL.h>
#include <hal/I2C.h>
@@ -25,6 +27,21 @@ I2C::I2C(Port port, int deviceAddress)
I2C::~I2C() { HAL_CloseI2C(m_port); }
I2C::I2C(I2C&& rhs)
: ErrorBase(std::move(rhs)),
m_deviceAddress(std::move(rhs.m_deviceAddress)) {
std::swap(m_port, rhs.m_port);
}
I2C& I2C::operator=(I2C&& rhs) {
ErrorBase::operator=(std::move(rhs));
std::swap(m_port, rhs.m_port);
m_deviceAddress = std::move(rhs.m_deviceAddress);
return *this;
}
bool I2C::Transaction(uint8_t* dataToSend, int sendSize, uint8_t* dataReceived,
int receiveSize) {
int32_t status = 0;

View File

@@ -7,6 +7,8 @@
#include "frc/Notifier.h"
#include <utility>
#include <hal/HAL.h>
#include "frc/Timer.h"
@@ -63,6 +65,31 @@ Notifier::~Notifier() {
HAL_CleanNotifier(handle, &status);
}
Notifier::Notifier(Notifier&& rhs)
: ErrorBase(std::move(rhs)),
m_thread(std::move(rhs.m_thread)),
m_notifier(rhs.m_notifier.load()),
m_handler(std::move(rhs.m_handler)),
m_expirationTime(std::move(rhs.m_expirationTime)),
m_period(std::move(rhs.m_period)),
m_periodic(std::move(rhs.m_periodic)) {
rhs.m_notifier = HAL_kInvalidHandle;
}
Notifier& Notifier::operator=(Notifier&& rhs) {
ErrorBase::operator=(std::move(rhs));
m_thread = std::move(rhs.m_thread);
m_notifier = rhs.m_notifier.load();
rhs.m_notifier = HAL_kInvalidHandle;
m_handler = std::move(rhs.m_handler);
m_expirationTime = std::move(rhs.m_expirationTime);
m_period = std::move(rhs.m_period);
m_periodic = std::move(rhs.m_periodic);
return *this;
}
void Notifier::SetHandler(TimerEventHandler handler) {
std::lock_guard<wpi::mutex> lock(m_processMutex);
m_handler = handler;

View File

@@ -7,6 +7,8 @@
#include "frc/PWM.h"
#include <utility>
#include <hal/HAL.h>
#include <hal/PWM.h>
#include <hal/Ports.h>
@@ -57,6 +59,23 @@ PWM::~PWM() {
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
}
PWM::PWM(PWM&& rhs)
: ErrorBase(std::move(rhs)),
SendableBase(std::move(rhs)),
m_channel(std::move(rhs.m_channel)) {
std::swap(m_handle, rhs.m_handle);
}
PWM& PWM::operator=(PWM&& rhs) {
ErrorBase::operator=(std::move(rhs));
SendableBase::operator=(std::move(rhs));
m_channel = std::move(rhs.m_channel);
std::swap(m_handle, rhs.m_handle);
return *this;
}
void PWM::SetRaw(uint16_t value) {
if (StatusIsFatal()) return;

View File

@@ -7,6 +7,8 @@
#include "frc/Relay.h"
#include <utility>
#include <hal/HAL.h>
#include <hal/Ports.h>
#include <hal/Relay.h>
@@ -90,6 +92,31 @@ Relay::~Relay() {
if (m_reverseHandle != HAL_kInvalidHandle) HAL_FreeRelayPort(m_reverseHandle);
}
Relay::Relay(Relay&& rhs)
: MotorSafety(std::move(rhs)),
ErrorBase(std::move(rhs)),
SendableBase(std::move(rhs)),
m_channel(std::move(rhs.m_channel)),
m_direction(std::move(rhs.m_direction)),
m_safetyHelper(std::move(rhs.m_safetyHelper)) {
std::swap(m_forwardHandle, rhs.m_forwardHandle);
std::swap(m_reverseHandle, rhs.m_reverseHandle);
}
Relay& Relay::operator=(Relay&& rhs) {
MotorSafety::operator=(std::move(rhs));
ErrorBase::operator=(std::move(rhs));
SendableBase::operator=(std::move(rhs));
m_channel = std::move(rhs.m_channel);
m_direction = std::move(rhs.m_direction);
std::swap(m_forwardHandle, rhs.m_forwardHandle);
std::swap(m_reverseHandle, rhs.m_reverseHandle);
m_safetyHelper = std::move(rhs.m_safetyHelper);
return *this;
}
void Relay::Set(Relay::Value value) {
if (StatusIsFatal()) return;

View File

@@ -103,3 +103,7 @@ RobotBase::RobotBase() : m_ds(DriverStation::GetInstance()) {
LiveWindow::GetInstance()->SetEnabled(false);
}
RobotBase::RobotBase(RobotBase&&) : m_ds(DriverStation::GetInstance()) {}
RobotBase& RobotBase::operator=(RobotBase&&) { return *this; }

View File

@@ -8,6 +8,7 @@
#include "frc/SPI.h"
#include <cstring>
#include <utility>
#include <hal/HAL.h>
#include <hal/SPI.h>
@@ -138,6 +139,27 @@ SPI::SPI(Port port) : m_port(static_cast<HAL_SPIPort>(port)) {
SPI::~SPI() { HAL_CloseSPI(m_port); }
SPI::SPI(SPI&& rhs)
: ErrorBase(std::move(rhs)),
m_msbFirst(std::move(rhs.m_msbFirst)),
m_sampleOnTrailing(std::move(rhs.m_sampleOnTrailing)),
m_clockIdleHigh(std::move(rhs.m_clockIdleHigh)),
m_accum(std::move(rhs.m_accum)) {
std::swap(m_port, rhs.m_port);
}
SPI& SPI::operator=(SPI&& rhs) {
ErrorBase::operator=(std::move(rhs));
std::swap(m_port, rhs.m_port);
m_msbFirst = std::move(rhs.m_msbFirst);
m_sampleOnTrailing = std::move(rhs.m_sampleOnTrailing);
m_clockIdleHigh = std::move(rhs.m_clockIdleHigh);
m_accum = std::move(rhs.m_accum);
return *this;
}
void SPI::SetClockRate(double hz) { HAL_SetSPISpeed(m_port, hz); }
void SPI::SetMSBFirst() {

View File

@@ -7,6 +7,8 @@
#include "frc/SerialPort.h"
#include <utility>
#include <hal/HAL.h>
#include <hal/SerialPort.h>
@@ -95,6 +97,25 @@ SerialPort::~SerialPort() {
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
}
SerialPort::SerialPort(SerialPort&& rhs)
: ErrorBase(std::move(rhs)),
m_resourceManagerHandle(std::move(rhs.m_resourceManagerHandle)),
m_portHandle(std::move(rhs.m_portHandle)),
m_consoleModeEnabled(std::move(rhs.m_consoleModeEnabled)) {
std::swap(m_port, rhs.m_port);
}
SerialPort& SerialPort::operator=(SerialPort&& rhs) {
ErrorBase::operator=(std::move(rhs));
m_resourceManagerHandle = std::move(rhs.m_resourceManagerHandle);
m_portHandle = std::move(rhs.m_portHandle);
m_consoleModeEnabled = std::move(rhs.m_consoleModeEnabled);
std::swap(m_port, rhs.m_port);
return *this;
}
void SerialPort::SetFlowControl(SerialPort::FlowControl flowControl) {
int32_t status = 0;
HAL_SetSerialFlowControl(static_cast<HAL_SerialPort>(m_port), flowControl,

View File

@@ -7,6 +7,8 @@
#include "frc/Solenoid.h"
#include <utility>
#include <hal/HAL.h>
#include <hal/Ports.h>
#include <hal/Solenoid.h>
@@ -50,6 +52,20 @@ Solenoid::Solenoid(int moduleNumber, int channel)
Solenoid::~Solenoid() { HAL_FreeSolenoidPort(m_solenoidHandle); }
Solenoid::Solenoid(Solenoid&& rhs)
: SolenoidBase(std::move(rhs)), m_channel(std::move(rhs.m_channel)) {
std::swap(m_solenoidHandle, rhs.m_solenoidHandle);
}
Solenoid& Solenoid::operator=(Solenoid&& rhs) {
SolenoidBase::operator=(std::move(rhs));
std::swap(m_solenoidHandle, rhs.m_solenoidHandle);
m_channel = std::move(rhs.m_channel);
return *this;
}
void Solenoid::Set(bool on) {
if (StatusIsFatal()) return;
int32_t status = 0;

View File

@@ -9,6 +9,8 @@
#include <stdint.h>
#include <utility>
#include <hal/HAL.h>
#include "frc/Timer.h"
@@ -61,6 +63,22 @@ TimedRobot::~TimedRobot() {
HAL_CleanNotifier(m_notifier, &status);
}
TimedRobot::TimedRobot(TimedRobot&& rhs)
: IterativeRobotBase(std::move(rhs)),
m_expirationTime(std::move(rhs.m_expirationTime)) {
std::swap(m_notifier, rhs.m_notifier);
}
TimedRobot& TimedRobot::operator=(TimedRobot&& rhs) {
IterativeRobotBase::operator=(std::move(rhs));
ErrorBase::operator=(std::move(rhs));
std::swap(m_notifier, rhs.m_notifier);
m_expirationTime = std::move(rhs.m_expirationTime);
return *this;
}
void TimedRobot::UpdateAlarm() {
int32_t status = 0;
HAL_UpdateNotifierAlarm(

View File

@@ -119,7 +119,9 @@ void Ultrasonic::SetAutomaticMode(bool enabling) {
// m_task.SetPriority(kPriority);
} else {
// Wait for background task to stop running
m_thread.join();
if (m_thread.joinable()) {
m_thread.join();
}
// Clear all the counters (data now invalid) since automatic mode is
// disabled. No synchronization is needed because the background task is

View File

@@ -7,6 +7,8 @@
#include "frc/smartdashboard/SendableBase.h"
#include <utility>
#include "frc/livewindow/LiveWindow.h"
using namespace frc;
@@ -17,6 +19,20 @@ SendableBase::SendableBase(bool addLiveWindow) {
SendableBase::~SendableBase() { LiveWindow::GetInstance()->Remove(this); }
SendableBase::SendableBase(SendableBase&& rhs) {
m_name = std::move(rhs.m_name);
m_subsystem = std::move(rhs.m_subsystem);
}
SendableBase& SendableBase::operator=(SendableBase&& rhs) {
Sendable::operator=(std::move(rhs));
m_name = std::move(rhs.m_name);
m_subsystem = std::move(rhs.m_subsystem);
return *this;
}
std::string SendableBase::GetName() const {
std::lock_guard<wpi::mutex> lock(m_mutex);
return m_name;

View File

@@ -44,8 +44,8 @@ class ADXL345_I2C : public ErrorBase,
int deviceAddress = kAddress);
~ADXL345_I2C() override = default;
ADXL345_I2C(const ADXL345_I2C&) = delete;
ADXL345_I2C& operator=(const ADXL345_I2C&) = delete;
ADXL345_I2C(ADXL345_I2C&&) = default;
ADXL345_I2C& operator=(ADXL345_I2C&&) = default;
// Accelerometer interface
void SetRange(Range range) override;

View File

@@ -42,8 +42,8 @@ class ADXL345_SPI : public ErrorBase,
~ADXL345_SPI() override = default;
ADXL345_SPI(const ADXL345_SPI&) = delete;
ADXL345_SPI& operator=(const ADXL345_SPI&) = delete;
ADXL345_SPI(ADXL345_SPI&&) = default;
ADXL345_SPI& operator=(ADXL345_SPI&&) = default;
// Accelerometer interface
void SetRange(Range range) override;

View File

@@ -46,8 +46,8 @@ class ADXL362 : public ErrorBase, public SendableBase, public Accelerometer {
virtual ~ADXL362() = default;
ADXL362(const ADXL362&) = delete;
ADXL362& operator=(const ADXL362&) = delete;
ADXL362(ADXL362&&) = default;
ADXL362& operator=(ADXL362&&) = default;
// Accelerometer interface
void SetRange(Range range) override;

View File

@@ -42,6 +42,9 @@ class ADXRS450_Gyro : public GyroBase {
virtual ~ADXRS450_Gyro() = default;
ADXRS450_Gyro(ADXRS450_Gyro&&) = default;
ADXRS450_Gyro& operator=(ADXRS450_Gyro&&) = default;
/**
* Return the actual angle in degrees that the robot is currently facing.
*

View File

@@ -63,6 +63,9 @@ class AnalogAccelerometer : public ErrorBase,
~AnalogAccelerometer() override = default;
AnalogAccelerometer(AnalogAccelerometer&&) = default;
AnalogAccelerometer& operator=(AnalogAccelerometer&&) = default;
/**
* Return the acceleration in Gs.
*

View File

@@ -102,6 +102,9 @@ class AnalogGyro : public GyroBase {
virtual ~AnalogGyro();
AnalogGyro(AnalogGyro&& rhs);
AnalogGyro& operator=(AnalogGyro&& rhs);
/**
* Return the actual angle in degrees that the robot is currently facing.
*

View File

@@ -48,6 +48,9 @@ class AnalogInput : public ErrorBase, public SendableBase, public PIDSource {
~AnalogInput() override;
AnalogInput(AnalogInput&& rhs);
AnalogInput& operator=(AnalogInput&& rhs);
/**
* Get a sample straight from this channel.
*
@@ -281,8 +284,7 @@ class AnalogInput : public ErrorBase, public SendableBase, public PIDSource {
private:
int m_channel;
// TODO: Adjust HAL to avoid use of raw pointers.
HAL_AnalogInputHandle m_port;
HAL_AnalogInputHandle m_port = HAL_kInvalidHandle;
int64_t m_accumulatorOffset;
};

View File

@@ -30,6 +30,9 @@ class AnalogOutput : public ErrorBase, public SendableBase {
~AnalogOutput() override;
AnalogOutput(AnalogOutput&& rhs);
AnalogOutput& operator=(AnalogOutput&& rhs);
/**
* Set the value of the analog output.
*
@@ -53,7 +56,7 @@ class AnalogOutput : public ErrorBase, public SendableBase {
protected:
int m_channel;
HAL_AnalogOutputHandle m_port;
HAL_AnalogOutputHandle m_port = HAL_kInvalidHandle;
};
} // namespace frc

View File

@@ -94,6 +94,9 @@ class AnalogPotentiometer : public ErrorBase,
~AnalogPotentiometer() override = default;
AnalogPotentiometer(AnalogPotentiometer&&) = default;
AnalogPotentiometer& operator=(AnalogPotentiometer&&) = default;
/**
* Get the current reading of the potentiomer.
*

View File

@@ -43,6 +43,9 @@ class AnalogTrigger : public ErrorBase, public SendableBase {
~AnalogTrigger() override;
AnalogTrigger(AnalogTrigger&& rhs);
AnalogTrigger& operator=(AnalogTrigger&& rhs);
/**
* Set the upper and lower limits of the analog trigger.
*
@@ -133,7 +136,7 @@ class AnalogTrigger : public ErrorBase, public SendableBase {
private:
int m_index;
HAL_AnalogTriggerHandle m_trigger;
HAL_AnalogTriggerHandle m_trigger = HAL_kInvalidHandle;
AnalogInput* m_analogInput = nullptr;
bool m_ownsAnalog = false;
};

View File

@@ -52,6 +52,9 @@ class AnalogTriggerOutput : public DigitalSource {
public:
~AnalogTriggerOutput() override;
AnalogTriggerOutput(AnalogTriggerOutput&&) = default;
AnalogTriggerOutput& operator=(AnalogTriggerOutput&&) = default;
/**
* Get the state of the analog trigger output.
*

View File

@@ -17,8 +17,6 @@ static_assert(0,
static_assert(0, "Visual Studio 2015 or greater required.");
#endif
#define DEFAULT_MOVE_CONSTRUCTOR(ClassName) ClassName(ClassName&&) = default
/** WPILib FRC namespace */
namespace frc {
@@ -31,27 +29,6 @@ struct NullDeleter {
} // namespace frc
#include <atomic>
namespace frc {
// Use this for determining whether the default move constructor has been
// called on a containing object. This serves the purpose of allowing us to
// use the default move constructor of an object for moving all the data around
// while being able to use this to, for instance, chose not to de-allocate
// a PWM port in a destructor.
struct HasBeenMoved {
HasBeenMoved(HasBeenMoved&& other) {
other.moved = true;
moved = false;
}
HasBeenMoved() = default;
std::atomic<bool> moved{false};
operator bool() const { return moved; }
};
} // namespace frc
// For backwards compatibility
#ifdef NO_NAMESPACED_WPILIB
using namespace frc; // NOLINT

View File

@@ -29,6 +29,9 @@ class BuiltInAccelerometer : public ErrorBase,
*/
explicit BuiltInAccelerometer(Range range = kRange_8G);
BuiltInAccelerometer(BuiltInAccelerometer&&) = default;
BuiltInAccelerometer& operator=(BuiltInAccelerometer&&) = default;
// Accelerometer interface
/**
* Set the measuring range of the accelerometer.

View File

@@ -58,6 +58,9 @@ class CAN : public ErrorBase {
*/
~CAN() override;
CAN(CAN&& rhs);
CAN& operator=(CAN&& rhs);
/**
* Write a packet to the CAN device with a specific ID. This ID is 10 bits.
*
@@ -141,6 +144,6 @@ class CAN : public ErrorBase {
HAL_CAN_Dev_kMiscellaneous;
private:
HAL_CANHandle m_handle{HAL_kInvalidHandle};
HAL_CANHandle m_handle = HAL_kInvalidHandle;
};
} // namespace frc

View File

@@ -41,6 +41,9 @@ class Compressor : public ErrorBase, public SendableBase {
~Compressor() override = default;
Compressor(Compressor&&) = default;
Compressor& operator=(Compressor&&) = default;
/**
* Starts closed-loop control. Note that closed loop control is enabled by
* default.
@@ -166,7 +169,7 @@ class Compressor : public ErrorBase, public SendableBase {
void InitSendable(SendableBuilder& builder) override;
protected:
HAL_CompressorHandle m_compressorHandle;
HAL_CompressorHandle m_compressorHandle = HAL_kInvalidHandle;
private:
void SetCompressor(bool on);

View File

@@ -18,8 +18,12 @@ namespace frc {
*/
class Controller {
public:
Controller() = default;
virtual ~Controller() = default;
Controller(Controller&&) = default;
Controller& operator=(Controller&&) = default;
/**
* Allows the control loop to run
*/

View File

@@ -140,6 +140,9 @@ class Counter : public ErrorBase, public SendableBase, public CounterBase {
~Counter() override;
Counter(Counter&& rhs);
Counter& operator=(Counter&& rhs);
/**
* Set the upsource for the counter as a digital input channel.
*

View File

@@ -22,7 +22,12 @@ class CounterBase {
public:
enum EncodingType { k1X, k2X, k4X };
CounterBase() = default;
virtual ~CounterBase() = default;
CounterBase(CounterBase&&) = default;
CounterBase& operator=(CounterBase&&) = default;
virtual int Get() const = 0;
virtual void Reset() = 0;
virtual double GetPeriod() const = 0;

View File

@@ -23,6 +23,9 @@ class DMC60 : public PWMSpeedController {
* on-board, 10-19 are on the MXP port
*/
explicit DMC60(int channel);
DMC60(DMC60&&) = default;
DMC60& operator=(DMC60&&) = default;
};
} // namespace frc

View File

@@ -34,6 +34,9 @@ class DigitalGlitchFilter : public ErrorBase, public SendableBase {
DigitalGlitchFilter();
~DigitalGlitchFilter() override;
DigitalGlitchFilter(DigitalGlitchFilter&& rhs);
DigitalGlitchFilter& operator=(DigitalGlitchFilter&& rhs);
/**
* Assigns the DigitalSource to this glitch filter.
*

View File

@@ -35,6 +35,9 @@ class DigitalInput : public DigitalSource {
~DigitalInput() override;
DigitalInput(DigitalInput&& rhs);
DigitalInput& operator=(DigitalInput&& rhs);
/**
* Get the value from a digital input channel.
*
@@ -67,7 +70,7 @@ class DigitalInput : public DigitalSource {
private:
int m_channel;
HAL_DigitalHandle m_handle;
HAL_DigitalHandle m_handle = HAL_kInvalidHandle;
friend class DigitalGlitchFilter;
};

View File

@@ -35,6 +35,9 @@ class DigitalOutput : public ErrorBase, public SendableBase {
~DigitalOutput() override;
DigitalOutput(DigitalOutput&& rhs);
DigitalOutput& operator=(DigitalOutput&& rhs);
/**
* Set the value of a digital output.
*
@@ -121,8 +124,8 @@ class DigitalOutput : public ErrorBase, public SendableBase {
private:
int m_channel;
HAL_DigitalHandle m_handle;
HAL_DigitalPWMHandle m_pwmGenerator;
HAL_DigitalHandle m_handle = HAL_kInvalidHandle;
HAL_DigitalPWMHandle m_pwmGenerator = HAL_kInvalidHandle;
};
} // namespace frc

View File

@@ -24,6 +24,10 @@ namespace frc {
*/
class DigitalSource : public InterruptableSensorBase {
public:
DigitalSource() = default;
DigitalSource(DigitalSource&&) = default;
DigitalSource& operator=(DigitalSource&&) = default;
virtual HAL_Handle GetPortHandleForRouting() const = 0;
virtual AnalogTriggerType GetAnalogTriggerTypeForRouting() const = 0;
virtual bool IsAnalogTrigger() const = 0;

View File

@@ -45,6 +45,9 @@ class DoubleSolenoid : public SolenoidBase {
~DoubleSolenoid() override;
DoubleSolenoid(DoubleSolenoid&& rhs);
DoubleSolenoid& operator=(DoubleSolenoid&& rhs);
/**
* Set the value of a solenoid.
*

View File

@@ -37,6 +37,9 @@ class DriverStation : public ErrorBase {
~DriverStation() override;
DriverStation(const DriverStation&) = delete;
DriverStation& operator=(const DriverStation&) = delete;
/**
* Return a reference to the singleton DriverStation.
*

View File

@@ -133,6 +133,9 @@ class Encoder : public ErrorBase,
~Encoder() override;
Encoder(Encoder&& rhs);
Encoder& operator=(Encoder&& rhs);
// CounterBase interface
/**
* Gets the current count.

View File

@@ -77,8 +77,8 @@ class ErrorBase {
ErrorBase();
virtual ~ErrorBase() = default;
ErrorBase(const ErrorBase&) = delete;
ErrorBase& operator=(const ErrorBase&) = delete;
ErrorBase(ErrorBase&&) = default;
ErrorBase& operator=(ErrorBase&&) = default;
/**
* @brief Retrieve the current error.

View File

@@ -22,6 +22,9 @@ class WPI_DEPRECATED("Inherit directly from GenericHID instead.") GamepadBase
explicit GamepadBase(int port);
virtual ~GamepadBase() = default;
GamepadBase(GamepadBase&&) = default;
GamepadBase& operator=(GamepadBase&&) = default;
virtual bool GetBumper(JoystickHand hand = kRightHand) const = 0;
virtual bool GetStickButton(JoystickHand hand) const = 0;
};

View File

@@ -61,6 +61,9 @@ class GearTooth : public Counter {
explicit GearTooth(std::shared_ptr<DigitalSource> source,
bool directionSensitive = false);
GearTooth(GearTooth&&) = default;
GearTooth& operator=(GearTooth&&) = default;
/**
* Common code called by the constructors.
*/

View File

@@ -49,6 +49,9 @@ class GenericHID : public ErrorBase {
explicit GenericHID(int port);
virtual ~GenericHID() = default;
GenericHID(GenericHID&&) = default;
GenericHID& operator=(GenericHID&&) = default;
virtual double GetX(JoystickHand hand = kRightHand) const = 0;
virtual double GetY(JoystickHand hand = kRightHand) const = 0;

View File

@@ -23,6 +23,10 @@ class GyroBase : public Gyro,
public SendableBase,
public PIDSource {
public:
GyroBase() = default;
GyroBase(GyroBase&&) = default;
GyroBase& operator=(GyroBase&&) = default;
// PIDSource interface
/**
* Get the PIDOutput for the PIDSource base object. Can be set to return

View File

@@ -35,8 +35,8 @@ class I2C : public ErrorBase {
~I2C() override;
I2C(const I2C&) = delete;
I2C& operator=(const I2C&) = delete;
I2C(I2C&& rhs);
I2C& operator=(I2C&& rhs);
/**
* Generic transaction.

View File

@@ -26,6 +26,9 @@ class InterruptableSensorBase : public ErrorBase, public SendableBase {
InterruptableSensorBase() = default;
InterruptableSensorBase(InterruptableSensorBase&&) = default;
InterruptableSensorBase& operator=(InterruptableSensorBase&&) = default;
virtual HAL_Handle GetPortHandleForRouting() const = 0;
virtual AnalogTriggerType GetAnalogTriggerTypeForRouting() const = 0;

View File

@@ -25,6 +25,9 @@ class IterativeRobot : public IterativeRobotBase {
IterativeRobot();
virtual ~IterativeRobot() = default;
IterativeRobot(IterativeRobot&&) = default;
IterativeRobot& operator=(IterativeRobot&&) = default;
/**
* Provide an alternate "main loop" via StartCompetition().
*

View File

@@ -144,6 +144,9 @@ class IterativeRobotBase : public RobotBase {
virtual ~IterativeRobotBase() = default;
IterativeRobotBase(IterativeRobotBase&&) = default;
IterativeRobotBase& operator=(IterativeRobotBase&&) = default;
void LoopFunc();
double m_period;

View File

@@ -23,6 +23,9 @@ class Jaguar : public PWMSpeedController {
* on-board, 10-19 are on the MXP port
*/
explicit Jaguar(int channel);
Jaguar(Jaguar&&) = default;
Jaguar& operator=(Jaguar&&) = default;
};
} // namespace frc

View File

@@ -57,8 +57,8 @@ class Joystick : public GenericHID {
virtual ~Joystick() = default;
Joystick(const Joystick&) = delete;
Joystick& operator=(const Joystick&) = delete;
Joystick(Joystick&&) = default;
Joystick& operator=(Joystick&&) = default;
/**
* Set the channel associated with the X axis.

View File

@@ -22,6 +22,9 @@ class WPI_DEPRECATED("Inherit directly from GenericHID instead.") JoystickBase
explicit JoystickBase(int port);
virtual ~JoystickBase() = default;
JoystickBase(JoystickBase&&) = default;
JoystickBase& operator=(JoystickBase&&) = default;
virtual double GetZ(JoystickHand hand = kRightHand) const = 0;
virtual double GetTwist() const = 0;
virtual double GetThrottle() const = 0;

View File

@@ -15,6 +15,10 @@ namespace frc {
class MotorSafety {
public:
MotorSafety() = default;
MotorSafety(MotorSafety&&) = default;
MotorSafety& operator=(MotorSafety&&) = default;
virtual void SetExpiration(double timeout) = 0;
virtual double GetExpiration() const = 0;
virtual bool IsAlive() const = 0;

View File

@@ -33,6 +33,9 @@ class MotorSafetyHelper : public ErrorBase {
~MotorSafetyHelper();
MotorSafetyHelper(MotorSafetyHelper&&) = default;
MotorSafetyHelper& operator=(MotorSafetyHelper&&) = default;
/**
* Feed the motor safety object.
*

View File

@@ -39,6 +39,9 @@ class NidecBrushless : public ErrorBase,
~NidecBrushless() override = default;
NidecBrushless(NidecBrushless&&) = default;
NidecBrushless& operator=(NidecBrushless&&) = default;
// SpeedController interface
/**
* Set the PWM value.

View File

@@ -43,8 +43,8 @@ class Notifier : public ErrorBase {
*/
virtual ~Notifier();
Notifier(const Notifier&) = delete;
Notifier& operator=(const Notifier&) = delete;
Notifier(Notifier&& rhs);
Notifier& operator=(Notifier&& rhs);
/**
* Change the handler function.

View File

@@ -60,8 +60,8 @@ class PIDBase : public SendableBase, public PIDInterface, public PIDOutput {
~PIDBase() override = default;
PIDBase(const PIDBase&) = delete;
PIDBase& operator=(const PIDBase) = delete;
PIDBase(PIDBase&&) = default;
PIDBase& operator=(PIDBase&&) = default;
/**
* Return the current PID result.

View File

@@ -99,8 +99,8 @@ class PIDController : public PIDBase, public Controller {
~PIDController() override;
PIDController(const PIDController&) = delete;
PIDController& operator=(const PIDController) = delete;
PIDController(PIDController&&) = default;
PIDController& operator=(PIDController&&) = default;
/**
* Begin running the PIDController.

View File

@@ -10,6 +10,11 @@
namespace frc {
class PIDInterface {
public:
PIDInterface() = default;
PIDInterface(PIDInterface&&) = default;
PIDInterface& operator=(PIDInterface&&) = default;
virtual void SetPID(double p, double i, double d) = 0;
virtual double GetP() const = 0;
virtual double GetI() const = 0;

View File

@@ -72,6 +72,9 @@ class PWM : public ErrorBase, public SendableBase {
*/
~PWM() override;
PWM(PWM&& rhs);
PWM& operator=(PWM&& rhs);
/**
* Set the PWM value directly to the hardware.
*
@@ -223,7 +226,7 @@ class PWM : public ErrorBase, public SendableBase {
private:
int m_channel;
HAL_DigitalHandle m_handle;
HAL_DigitalHandle m_handle = HAL_kInvalidHandle;
};
} // namespace frc

View File

@@ -17,6 +17,9 @@ namespace frc {
*/
class PWMSpeedController : public SafePWM, public SpeedController {
public:
PWMSpeedController(PWMSpeedController&&) = default;
PWMSpeedController& operator=(PWMSpeedController&&) = default;
/**
* Set the PWM value.
*

View File

@@ -24,6 +24,9 @@ class PWMTalonSRX : public PWMSpeedController {
* on-board, 10-19 are on the MXP port
*/
explicit PWMTalonSRX(int channel);
PWMTalonSRX(PWMTalonSRX&&) = default;
PWMTalonSRX& operator=(PWMTalonSRX&&) = default;
};
} // namespace frc

View File

@@ -24,6 +24,9 @@ class PWMVictorSPX : public PWMSpeedController {
* are on-board, 10-19 are on the MXP port
*/
explicit PWMVictorSPX(int channel);
PWMVictorSPX(PWMVictorSPX&&) = default;
PWMVictorSPX& operator=(PWMVictorSPX&&) = default;
};
} // namespace frc

View File

@@ -7,6 +7,8 @@
#pragma once
#include <hal/PDP.h>
#include "frc/ErrorBase.h"
#include "frc/smartdashboard/SendableBase.h"
@@ -21,6 +23,9 @@ class PowerDistributionPanel : public ErrorBase, public SendableBase {
PowerDistributionPanel();
explicit PowerDistributionPanel(int module);
PowerDistributionPanel(PowerDistributionPanel&&) = default;
PowerDistributionPanel& operator=(PowerDistributionPanel&&) = default;
/**
* Query the input voltage of the PDP.
*
@@ -78,7 +83,7 @@ class PowerDistributionPanel : public ErrorBase, public SendableBase {
void InitSendable(SendableBuilder& builder) override;
private:
int m_handle;
HAL_PDPHandle m_handle = HAL_kInvalidHandle;
};
} // namespace frc

View File

@@ -195,6 +195,9 @@ class Preferences : public ErrorBase {
Preferences();
virtual ~Preferences() = default;
Preferences(Preferences&&) = default;
Preferences& operator=(Preferences&&) = default;
private:
std::shared_ptr<nt::NetworkTable> m_table;
NT_EntryListener m_listener;

View File

@@ -55,6 +55,9 @@ class Relay : public MotorSafety, public ErrorBase, public SendableBase {
*/
~Relay() override;
Relay(Relay&& rhs);
Relay& operator=(Relay&& rhs);
/**
* Set the relay state.
*

View File

@@ -33,8 +33,8 @@ class Resource : public ErrorBase {
public:
virtual ~Resource() = default;
Resource(const Resource&) = delete;
Resource& operator=(const Resource&) = delete;
Resource(Resource&&) = default;
Resource& operator=(Resource&&) = default;
/**
* Factory method to create a Resource allocation-tracker *if* needed.

View File

@@ -131,8 +131,10 @@ class RobotBase {
virtual ~RobotBase() = default;
RobotBase(const RobotBase&) = delete;
RobotBase& operator=(const RobotBase&) = delete;
// m_ds isn't moved in these because DriverStation is a singleton; every
// instance of RobotBase has a reference to the same object.
RobotBase(RobotBase&&);
RobotBase& operator=(RobotBase&&);
DriverStation& m_ds;

View File

@@ -129,8 +129,8 @@ class RobotDrive : public MotorSafety, public ErrorBase {
virtual ~RobotDrive() = default;
RobotDrive(const RobotDrive&) = delete;
RobotDrive& operator=(const RobotDrive&) = delete;
RobotDrive(RobotDrive&&) = default;
RobotDrive& operator=(RobotDrive&&) = default;
/**
* Drive the motors at "outputMagnitude" and "curve".

View File

@@ -23,6 +23,9 @@ class SD540 : public PWMSpeedController {
* on-board, 10-19 are on the MXP port
*/
explicit SD540(int channel);
SD540(SD540&&) = default;
SD540& operator=(SD540&&) = default;
};
} // namespace frc

View File

@@ -41,8 +41,8 @@ class SPI : public ErrorBase {
~SPI() override;
SPI(const SPI&) = delete;
SPI& operator=(const SPI&) = delete;
SPI(SPI&& rhs);
SPI& operator=(SPI&& rhs);
/**
* Configure the rate of the generated clock signal.

View File

@@ -37,6 +37,9 @@ class SafePWM : public PWM, public MotorSafety {
virtual ~SafePWM() = default;
SafePWM(SafePWM&&) = default;
SafePWM& operator=(SafePWM&&) = default;
/**
* Set the expiration time for the PWM object.
*

View File

@@ -98,6 +98,9 @@ class WPI_DEPRECATED(
SampleRobot();
virtual ~SampleRobot() = default;
SampleRobot(SampleRobot&&) = default;
SampleRobot& operator=(SampleRobot&&) = default;
private:
bool m_robotMainOverridden = true;
};

View File

@@ -89,8 +89,8 @@ class SerialPort : public ErrorBase {
~SerialPort();
SerialPort(const SerialPort&) = delete;
SerialPort& operator=(const SerialPort&) = delete;
SerialPort(SerialPort&& rhs);
SerialPort& operator=(SerialPort&& rhs);
/**
* Set the type of flow control to enable on this port.
@@ -217,7 +217,7 @@ class SerialPort : public ErrorBase {
int m_resourceManagerHandle = 0;
int m_portHandle = 0;
bool m_consoleModeEnabled = false;
int m_port;
Port m_port = kOnboard;
};
} // namespace frc

View File

@@ -26,6 +26,9 @@ class Servo : public SafePWM {
*/
explicit Servo(int channel);
Servo(Servo&&) = default;
Servo& operator=(Servo&&) = default;
/**
* Set the servo position.
*

View File

@@ -38,6 +38,9 @@ class Solenoid : public SolenoidBase {
~Solenoid() override;
Solenoid(Solenoid&& rhs);
Solenoid& operator=(Solenoid&& rhs);
/**
* Set the value of a solenoid.
*

View File

@@ -116,6 +116,9 @@ class SolenoidBase : public ErrorBase, public SendableBase {
*/
explicit SolenoidBase(int pcmID);
SolenoidBase(SolenoidBase&&) = default;
SolenoidBase& operator=(SolenoidBase&&) = default;
static constexpr int m_maxModules = 63;
static constexpr int m_maxPorts = 8;

View File

@@ -23,6 +23,9 @@ class Spark : public PWMSpeedController {
* on-board, 10-19 are on the MXP port
*/
explicit Spark(int channel);
Spark(Spark&&) = default;
Spark& operator=(Spark&&) = default;
};
} // namespace frc

View File

@@ -22,6 +22,9 @@ class SpeedControllerGroup : public SendableBase, public SpeedController {
SpeedControllers&... speedControllers);
~SpeedControllerGroup() override = default;
SpeedControllerGroup(SpeedControllerGroup&&) = default;
SpeedControllerGroup& operator=(SpeedControllerGroup&&) = default;
void Set(double speed) override;
double Get() const override;
void SetInverted(bool isInverted) override;

View File

@@ -44,8 +44,8 @@ class SynchronousPID : public PIDBase {
SynchronousPID(double Kp, double Ki, double Kd, double Kf, PIDSource& source,
PIDOutput& output);
SynchronousPID(const SynchronousPID&) = delete;
SynchronousPID& operator=(const SynchronousPID) = delete;
SynchronousPID(SynchronousPID&&) = default;
SynchronousPID& operator=(SynchronousPID&&) = default;
/**
* Read the input, calculate the output accordingly, and write to the output.

View File

@@ -23,6 +23,9 @@ class Talon : public PWMSpeedController {
* are on-board, 10-19 are on the MXP port
*/
explicit Talon(int channel);
Talon(Talon&&) = default;
Talon& operator=(Talon&&) = default;
};
} // namespace frc

View File

@@ -46,6 +46,9 @@ class TimedRobot : public IterativeRobotBase, public ErrorBase {
~TimedRobot() override;
TimedRobot(TimedRobot&& rhs);
TimedRobot& operator=(TimedRobot&& rhs);
private:
HAL_NotifierHandle m_notifier{0};

View File

@@ -66,8 +66,8 @@ class Timer {
virtual ~Timer() = default;
Timer(const Timer&) = delete;
Timer& operator=(const Timer&) = delete;
Timer(Timer&&) = default;
Timer& operator=(Timer&&) = default;
/**
* Get the current time from the timer. If the clock is running it is derived

View File

@@ -94,6 +94,9 @@ class Ultrasonic : public ErrorBase, public SendableBase, public PIDSource {
~Ultrasonic() override;
Ultrasonic(Ultrasonic&&) = default;
Ultrasonic& operator=(Ultrasonic&&) = default;
/**
* Single ping to ultrasonic sensor.
*

View File

@@ -26,6 +26,9 @@ class Victor : public PWMSpeedController {
* are on-board, 10-19 are on the MXP port
*/
explicit Victor(int channel);
Victor(Victor&&) = default;
Victor& operator=(Victor&&) = default;
};
} // namespace frc

View File

@@ -23,6 +23,9 @@ class VictorSP : public PWMSpeedController {
* on-board, 10-19 are on the MXP port
*/
explicit VictorSP(int channel);
VictorSP(VictorSP&&) = default;
VictorSP& operator=(VictorSP&&) = default;
};
} // namespace frc

View File

@@ -35,8 +35,8 @@ class Watchdog {
*/
explicit Watchdog(double timeout, std::function<void()> callback = [] {});
Watchdog(const Watchdog&) = delete;
Watchdog& operator=(const Watchdog&) = delete;
Watchdog(Watchdog&&) = default;
Watchdog& operator=(Watchdog&&) = default;
/**
* Get the time in seconds since the watchdog was last fed.

View File

@@ -34,8 +34,8 @@ class XboxController : public GenericHID {
virtual ~XboxController() = default;
XboxController(const XboxController&) = delete;
XboxController& operator=(const XboxController&) = delete;
XboxController(XboxController&&) = default;
XboxController& operator=(XboxController&&) = default;
/**
* Get the X axis value of the controller.

View File

@@ -25,6 +25,10 @@ namespace frc {
*/
class Button : public Trigger {
public:
Button() = default;
Button(Button&&) = default;
Button& operator=(Button&&) = default;
/**
* Specifies the command to run when a button is first pressed.
*

View File

@@ -16,6 +16,10 @@ class ButtonScheduler {
public:
ButtonScheduler(bool last, Trigger* button, Command* orders);
virtual ~ButtonScheduler() = default;
ButtonScheduler(ButtonScheduler&&) = default;
ButtonScheduler& operator=(ButtonScheduler&&) = default;
virtual void Execute() = 0;
void Start();

View File

@@ -18,6 +18,10 @@ class CancelButtonScheduler : public ButtonScheduler {
public:
CancelButtonScheduler(bool last, Trigger* button, Command* orders);
virtual ~CancelButtonScheduler() = default;
CancelButtonScheduler(CancelButtonScheduler&&) = default;
CancelButtonScheduler& operator=(CancelButtonScheduler&&) = default;
virtual void Execute();
private:

View File

@@ -18,6 +18,10 @@ class HeldButtonScheduler : public ButtonScheduler {
public:
HeldButtonScheduler(bool last, Trigger* button, Command* orders);
virtual ~HeldButtonScheduler() = default;
HeldButtonScheduler(HeldButtonScheduler&&) = default;
HeldButtonScheduler& operator=(HeldButtonScheduler&&) = default;
virtual void Execute();
};

Some files were not shown because too many files have changed in this diff Show More