diff --git a/wpilibc/src/main/native/cpp/AnalogGyro.cpp b/wpilibc/src/main/native/cpp/AnalogGyro.cpp index f7e1ee5013..5efe7b3d7f 100644 --- a/wpilibc/src/main/native/cpp/AnalogGyro.cpp +++ b/wpilibc/src/main/native/cpp/AnalogGyro.cpp @@ -8,6 +8,7 @@ #include "frc/AnalogGyro.h" #include +#include #include #include @@ -64,6 +65,20 @@ AnalogGyro::AnalogGyro(std::shared_ptr 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; diff --git a/wpilibc/src/main/native/cpp/AnalogInput.cpp b/wpilibc/src/main/native/cpp/AnalogInput.cpp index 135768378c..52a55d38fa 100644 --- a/wpilibc/src/main/native/cpp/AnalogInput.cpp +++ b/wpilibc/src/main/native/cpp/AnalogInput.cpp @@ -7,6 +7,8 @@ #include "frc/AnalogInput.h" +#include + #include #include #include @@ -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 { diff --git a/wpilibc/src/main/native/cpp/AnalogOutput.cpp b/wpilibc/src/main/native/cpp/AnalogOutput.cpp index 52bfbf9d40..b18af5b369 100644 --- a/wpilibc/src/main/native/cpp/AnalogOutput.cpp +++ b/wpilibc/src/main/native/cpp/AnalogOutput.cpp @@ -8,6 +8,7 @@ #include "frc/AnalogOutput.h" #include +#include #include #include @@ -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); diff --git a/wpilibc/src/main/native/cpp/AnalogTrigger.cpp b/wpilibc/src/main/native/cpp/AnalogTrigger.cpp index 1e9c2e1f05..aeb58dfbee 100644 --- a/wpilibc/src/main/native/cpp/AnalogTrigger.cpp +++ b/wpilibc/src/main/native/cpp/AnalogTrigger.cpp @@ -7,7 +7,7 @@ #include "frc/AnalogTrigger.h" -#include +#include #include @@ -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; diff --git a/wpilibc/src/main/native/cpp/CAN.cpp b/wpilibc/src/main/native/cpp/CAN.cpp index cf2b5c7825..8798b42504 100644 --- a/wpilibc/src/main/native/cpp/CAN.cpp +++ b/wpilibc/src/main/native/cpp/CAN.cpp @@ -7,6 +7,8 @@ #include "frc/CAN.h" +#include + #include 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); diff --git a/wpilibc/src/main/native/cpp/Counter.cpp b/wpilibc/src/main/native/cpp/Counter.cpp index 9779af680f..c97bbc5a05 100644 --- a/wpilibc/src/main/native/cpp/Counter.cpp +++ b/wpilibc/src/main/native/cpp/Counter.cpp @@ -7,6 +7,8 @@ #include "frc/Counter.h" +#include + #include #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(channel)); diff --git a/wpilibc/src/main/native/cpp/DigitalGlitchFilter.cpp b/wpilibc/src/main/native/cpp/DigitalGlitchFilter.cpp index 663fe91385..71211b3233 100644 --- a/wpilibc/src/main/native/cpp/DigitalGlitchFilter.cpp +++ b/wpilibc/src/main/native/cpp/DigitalGlitchFilter.cpp @@ -9,6 +9,7 @@ #include #include +#include #include #include @@ -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); } diff --git a/wpilibc/src/main/native/cpp/DigitalInput.cpp b/wpilibc/src/main/native/cpp/DigitalInput.cpp index 35f5b006df..273e9b6220 100644 --- a/wpilibc/src/main/native/cpp/DigitalInput.cpp +++ b/wpilibc/src/main/native/cpp/DigitalInput.cpp @@ -8,6 +8,7 @@ #include "frc/DigitalInput.h" #include +#include #include #include @@ -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; diff --git a/wpilibc/src/main/native/cpp/DigitalOutput.cpp b/wpilibc/src/main/native/cpp/DigitalOutput.cpp index 725d812f88..b05c6b101e 100644 --- a/wpilibc/src/main/native/cpp/DigitalOutput.cpp +++ b/wpilibc/src/main/native/cpp/DigitalOutput.cpp @@ -8,6 +8,7 @@ #include "frc/DigitalOutput.h" #include +#include #include #include @@ -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; diff --git a/wpilibc/src/main/native/cpp/DoubleSolenoid.cpp b/wpilibc/src/main/native/cpp/DoubleSolenoid.cpp index 03cce88ef4..86678aac59 100644 --- a/wpilibc/src/main/native/cpp/DoubleSolenoid.cpp +++ b/wpilibc/src/main/native/cpp/DoubleSolenoid.cpp @@ -7,6 +7,8 @@ #include "frc/DoubleSolenoid.h" +#include + #include #include #include @@ -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; diff --git a/wpilibc/src/main/native/cpp/Encoder.cpp b/wpilibc/src/main/native/cpp/Encoder.cpp index ffbedaab21..194ba8d7af 100644 --- a/wpilibc/src/main/native/cpp/Encoder.cpp +++ b/wpilibc/src/main/native/cpp/Encoder.cpp @@ -7,6 +7,8 @@ #include "frc/Encoder.h" +#include + #include #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; diff --git a/wpilibc/src/main/native/cpp/I2C.cpp b/wpilibc/src/main/native/cpp/I2C.cpp index 05b5907aef..4b18f73e71 100644 --- a/wpilibc/src/main/native/cpp/I2C.cpp +++ b/wpilibc/src/main/native/cpp/I2C.cpp @@ -7,6 +7,8 @@ #include "frc/I2C.h" +#include + #include #include @@ -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; diff --git a/wpilibc/src/main/native/cpp/Notifier.cpp b/wpilibc/src/main/native/cpp/Notifier.cpp index 9bcb0a7d53..69a9f4ed19 100644 --- a/wpilibc/src/main/native/cpp/Notifier.cpp +++ b/wpilibc/src/main/native/cpp/Notifier.cpp @@ -7,6 +7,8 @@ #include "frc/Notifier.h" +#include + #include #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 lock(m_processMutex); m_handler = handler; diff --git a/wpilibc/src/main/native/cpp/PWM.cpp b/wpilibc/src/main/native/cpp/PWM.cpp index f87dcfdf4d..6dfa41824a 100644 --- a/wpilibc/src/main/native/cpp/PWM.cpp +++ b/wpilibc/src/main/native/cpp/PWM.cpp @@ -7,6 +7,8 @@ #include "frc/PWM.h" +#include + #include #include #include @@ -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; diff --git a/wpilibc/src/main/native/cpp/Relay.cpp b/wpilibc/src/main/native/cpp/Relay.cpp index b2c3f5bd7c..240c187309 100644 --- a/wpilibc/src/main/native/cpp/Relay.cpp +++ b/wpilibc/src/main/native/cpp/Relay.cpp @@ -7,6 +7,8 @@ #include "frc/Relay.h" +#include + #include #include #include @@ -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; diff --git a/wpilibc/src/main/native/cpp/RobotBase.cpp b/wpilibc/src/main/native/cpp/RobotBase.cpp index ddcda7db98..6d1654e886 100644 --- a/wpilibc/src/main/native/cpp/RobotBase.cpp +++ b/wpilibc/src/main/native/cpp/RobotBase.cpp @@ -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; } diff --git a/wpilibc/src/main/native/cpp/SPI.cpp b/wpilibc/src/main/native/cpp/SPI.cpp index 807c14ac92..25547e5200 100644 --- a/wpilibc/src/main/native/cpp/SPI.cpp +++ b/wpilibc/src/main/native/cpp/SPI.cpp @@ -8,6 +8,7 @@ #include "frc/SPI.h" #include +#include #include #include @@ -138,6 +139,27 @@ SPI::SPI(Port port) : m_port(static_cast(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() { diff --git a/wpilibc/src/main/native/cpp/SerialPort.cpp b/wpilibc/src/main/native/cpp/SerialPort.cpp index 16caae9ec8..a399f4d7e8 100644 --- a/wpilibc/src/main/native/cpp/SerialPort.cpp +++ b/wpilibc/src/main/native/cpp/SerialPort.cpp @@ -7,6 +7,8 @@ #include "frc/SerialPort.h" +#include + #include #include @@ -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(m_port), flowControl, diff --git a/wpilibc/src/main/native/cpp/Solenoid.cpp b/wpilibc/src/main/native/cpp/Solenoid.cpp index a53e2c2fc8..3445f5dfa4 100644 --- a/wpilibc/src/main/native/cpp/Solenoid.cpp +++ b/wpilibc/src/main/native/cpp/Solenoid.cpp @@ -7,6 +7,8 @@ #include "frc/Solenoid.h" +#include + #include #include #include @@ -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; diff --git a/wpilibc/src/main/native/cpp/TimedRobot.cpp b/wpilibc/src/main/native/cpp/TimedRobot.cpp index 7e6f53c83e..24ab668bb1 100644 --- a/wpilibc/src/main/native/cpp/TimedRobot.cpp +++ b/wpilibc/src/main/native/cpp/TimedRobot.cpp @@ -9,6 +9,8 @@ #include +#include + #include #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( diff --git a/wpilibc/src/main/native/cpp/Ultrasonic.cpp b/wpilibc/src/main/native/cpp/Ultrasonic.cpp index 4758fbd8fd..ee4f5cc52d 100644 --- a/wpilibc/src/main/native/cpp/Ultrasonic.cpp +++ b/wpilibc/src/main/native/cpp/Ultrasonic.cpp @@ -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 diff --git a/wpilibc/src/main/native/cpp/smartdashboard/SendableBase.cpp b/wpilibc/src/main/native/cpp/smartdashboard/SendableBase.cpp index dc954ae7a1..28bd7fd489 100644 --- a/wpilibc/src/main/native/cpp/smartdashboard/SendableBase.cpp +++ b/wpilibc/src/main/native/cpp/smartdashboard/SendableBase.cpp @@ -7,6 +7,8 @@ #include "frc/smartdashboard/SendableBase.h" +#include + #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 lock(m_mutex); return m_name; diff --git a/wpilibc/src/main/native/include/frc/ADXL345_I2C.h b/wpilibc/src/main/native/include/frc/ADXL345_I2C.h index bfd39187ac..5d5fed41fd 100644 --- a/wpilibc/src/main/native/include/frc/ADXL345_I2C.h +++ b/wpilibc/src/main/native/include/frc/ADXL345_I2C.h @@ -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; diff --git a/wpilibc/src/main/native/include/frc/ADXL345_SPI.h b/wpilibc/src/main/native/include/frc/ADXL345_SPI.h index d3a3894035..ac5d6d9739 100644 --- a/wpilibc/src/main/native/include/frc/ADXL345_SPI.h +++ b/wpilibc/src/main/native/include/frc/ADXL345_SPI.h @@ -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; diff --git a/wpilibc/src/main/native/include/frc/ADXL362.h b/wpilibc/src/main/native/include/frc/ADXL362.h index 0c394b756f..896af15439 100644 --- a/wpilibc/src/main/native/include/frc/ADXL362.h +++ b/wpilibc/src/main/native/include/frc/ADXL362.h @@ -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; diff --git a/wpilibc/src/main/native/include/frc/ADXRS450_Gyro.h b/wpilibc/src/main/native/include/frc/ADXRS450_Gyro.h index a9636ed21b..e1b70e25f8 100644 --- a/wpilibc/src/main/native/include/frc/ADXRS450_Gyro.h +++ b/wpilibc/src/main/native/include/frc/ADXRS450_Gyro.h @@ -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. * diff --git a/wpilibc/src/main/native/include/frc/AnalogAccelerometer.h b/wpilibc/src/main/native/include/frc/AnalogAccelerometer.h index c8de331951..80dc98ec02 100644 --- a/wpilibc/src/main/native/include/frc/AnalogAccelerometer.h +++ b/wpilibc/src/main/native/include/frc/AnalogAccelerometer.h @@ -63,6 +63,9 @@ class AnalogAccelerometer : public ErrorBase, ~AnalogAccelerometer() override = default; + AnalogAccelerometer(AnalogAccelerometer&&) = default; + AnalogAccelerometer& operator=(AnalogAccelerometer&&) = default; + /** * Return the acceleration in Gs. * diff --git a/wpilibc/src/main/native/include/frc/AnalogGyro.h b/wpilibc/src/main/native/include/frc/AnalogGyro.h index 6cb075eef5..9e18d89c51 100644 --- a/wpilibc/src/main/native/include/frc/AnalogGyro.h +++ b/wpilibc/src/main/native/include/frc/AnalogGyro.h @@ -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. * diff --git a/wpilibc/src/main/native/include/frc/AnalogInput.h b/wpilibc/src/main/native/include/frc/AnalogInput.h index 40fd80516c..97ce2a8b75 100644 --- a/wpilibc/src/main/native/include/frc/AnalogInput.h +++ b/wpilibc/src/main/native/include/frc/AnalogInput.h @@ -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; }; diff --git a/wpilibc/src/main/native/include/frc/AnalogOutput.h b/wpilibc/src/main/native/include/frc/AnalogOutput.h index 673125ebcd..372d0ab3b2 100644 --- a/wpilibc/src/main/native/include/frc/AnalogOutput.h +++ b/wpilibc/src/main/native/include/frc/AnalogOutput.h @@ -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 diff --git a/wpilibc/src/main/native/include/frc/AnalogPotentiometer.h b/wpilibc/src/main/native/include/frc/AnalogPotentiometer.h index 94a6c2001a..a937c698c5 100644 --- a/wpilibc/src/main/native/include/frc/AnalogPotentiometer.h +++ b/wpilibc/src/main/native/include/frc/AnalogPotentiometer.h @@ -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. * diff --git a/wpilibc/src/main/native/include/frc/AnalogTrigger.h b/wpilibc/src/main/native/include/frc/AnalogTrigger.h index 03b99b241d..beb48fc296 100644 --- a/wpilibc/src/main/native/include/frc/AnalogTrigger.h +++ b/wpilibc/src/main/native/include/frc/AnalogTrigger.h @@ -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; }; diff --git a/wpilibc/src/main/native/include/frc/AnalogTriggerOutput.h b/wpilibc/src/main/native/include/frc/AnalogTriggerOutput.h index 6acd3dd1d9..eae7aef203 100644 --- a/wpilibc/src/main/native/include/frc/AnalogTriggerOutput.h +++ b/wpilibc/src/main/native/include/frc/AnalogTriggerOutput.h @@ -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. * diff --git a/wpilibc/src/main/native/include/frc/Base.h b/wpilibc/src/main/native/include/frc/Base.h index 2dc96b9827..1fdbe5dd29 100644 --- a/wpilibc/src/main/native/include/frc/Base.h +++ b/wpilibc/src/main/native/include/frc/Base.h @@ -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 - -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 moved{false}; - operator bool() const { return moved; } -}; - -} // namespace frc - // For backwards compatibility #ifdef NO_NAMESPACED_WPILIB using namespace frc; // NOLINT diff --git a/wpilibc/src/main/native/include/frc/BuiltInAccelerometer.h b/wpilibc/src/main/native/include/frc/BuiltInAccelerometer.h index 82fbc7164e..3c9fc4a543 100644 --- a/wpilibc/src/main/native/include/frc/BuiltInAccelerometer.h +++ b/wpilibc/src/main/native/include/frc/BuiltInAccelerometer.h @@ -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. diff --git a/wpilibc/src/main/native/include/frc/CAN.h b/wpilibc/src/main/native/include/frc/CAN.h index db7ed492dd..edb708e834 100644 --- a/wpilibc/src/main/native/include/frc/CAN.h +++ b/wpilibc/src/main/native/include/frc/CAN.h @@ -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 diff --git a/wpilibc/src/main/native/include/frc/Compressor.h b/wpilibc/src/main/native/include/frc/Compressor.h index d36f84066d..97f64d1e46 100644 --- a/wpilibc/src/main/native/include/frc/Compressor.h +++ b/wpilibc/src/main/native/include/frc/Compressor.h @@ -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); diff --git a/wpilibc/src/main/native/include/frc/Controller.h b/wpilibc/src/main/native/include/frc/Controller.h index 4c3753d0db..b3277230ad 100644 --- a/wpilibc/src/main/native/include/frc/Controller.h +++ b/wpilibc/src/main/native/include/frc/Controller.h @@ -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 */ diff --git a/wpilibc/src/main/native/include/frc/Counter.h b/wpilibc/src/main/native/include/frc/Counter.h index eb7a82f9aa..dff19a9a52 100644 --- a/wpilibc/src/main/native/include/frc/Counter.h +++ b/wpilibc/src/main/native/include/frc/Counter.h @@ -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. * diff --git a/wpilibc/src/main/native/include/frc/CounterBase.h b/wpilibc/src/main/native/include/frc/CounterBase.h index 688334136b..7fde3ac80c 100644 --- a/wpilibc/src/main/native/include/frc/CounterBase.h +++ b/wpilibc/src/main/native/include/frc/CounterBase.h @@ -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; diff --git a/wpilibc/src/main/native/include/frc/DMC60.h b/wpilibc/src/main/native/include/frc/DMC60.h index c1b30ba4d4..5a33b5a7c9 100644 --- a/wpilibc/src/main/native/include/frc/DMC60.h +++ b/wpilibc/src/main/native/include/frc/DMC60.h @@ -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 diff --git a/wpilibc/src/main/native/include/frc/DigitalGlitchFilter.h b/wpilibc/src/main/native/include/frc/DigitalGlitchFilter.h index 59d7a3326c..f33955e61b 100644 --- a/wpilibc/src/main/native/include/frc/DigitalGlitchFilter.h +++ b/wpilibc/src/main/native/include/frc/DigitalGlitchFilter.h @@ -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. * diff --git a/wpilibc/src/main/native/include/frc/DigitalInput.h b/wpilibc/src/main/native/include/frc/DigitalInput.h index 9355560244..af191aaf54 100644 --- a/wpilibc/src/main/native/include/frc/DigitalInput.h +++ b/wpilibc/src/main/native/include/frc/DigitalInput.h @@ -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; }; diff --git a/wpilibc/src/main/native/include/frc/DigitalOutput.h b/wpilibc/src/main/native/include/frc/DigitalOutput.h index 8f9ff744c6..49cb67dbcb 100644 --- a/wpilibc/src/main/native/include/frc/DigitalOutput.h +++ b/wpilibc/src/main/native/include/frc/DigitalOutput.h @@ -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 diff --git a/wpilibc/src/main/native/include/frc/DigitalSource.h b/wpilibc/src/main/native/include/frc/DigitalSource.h index af63b409ed..5d77daaa19 100644 --- a/wpilibc/src/main/native/include/frc/DigitalSource.h +++ b/wpilibc/src/main/native/include/frc/DigitalSource.h @@ -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; diff --git a/wpilibc/src/main/native/include/frc/DoubleSolenoid.h b/wpilibc/src/main/native/include/frc/DoubleSolenoid.h index ea8b901b0d..87c0c855bc 100644 --- a/wpilibc/src/main/native/include/frc/DoubleSolenoid.h +++ b/wpilibc/src/main/native/include/frc/DoubleSolenoid.h @@ -45,6 +45,9 @@ class DoubleSolenoid : public SolenoidBase { ~DoubleSolenoid() override; + DoubleSolenoid(DoubleSolenoid&& rhs); + DoubleSolenoid& operator=(DoubleSolenoid&& rhs); + /** * Set the value of a solenoid. * diff --git a/wpilibc/src/main/native/include/frc/DriverStation.h b/wpilibc/src/main/native/include/frc/DriverStation.h index bf0c05776a..d98754b563 100644 --- a/wpilibc/src/main/native/include/frc/DriverStation.h +++ b/wpilibc/src/main/native/include/frc/DriverStation.h @@ -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. * diff --git a/wpilibc/src/main/native/include/frc/Encoder.h b/wpilibc/src/main/native/include/frc/Encoder.h index 217ba48df9..02592473cc 100644 --- a/wpilibc/src/main/native/include/frc/Encoder.h +++ b/wpilibc/src/main/native/include/frc/Encoder.h @@ -133,6 +133,9 @@ class Encoder : public ErrorBase, ~Encoder() override; + Encoder(Encoder&& rhs); + Encoder& operator=(Encoder&& rhs); + // CounterBase interface /** * Gets the current count. diff --git a/wpilibc/src/main/native/include/frc/ErrorBase.h b/wpilibc/src/main/native/include/frc/ErrorBase.h index b8afb7c768..3be976570f 100644 --- a/wpilibc/src/main/native/include/frc/ErrorBase.h +++ b/wpilibc/src/main/native/include/frc/ErrorBase.h @@ -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. diff --git a/wpilibc/src/main/native/include/frc/GamepadBase.h b/wpilibc/src/main/native/include/frc/GamepadBase.h index ae6f8e4879..fd2a75e0f6 100644 --- a/wpilibc/src/main/native/include/frc/GamepadBase.h +++ b/wpilibc/src/main/native/include/frc/GamepadBase.h @@ -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; }; diff --git a/wpilibc/src/main/native/include/frc/GearTooth.h b/wpilibc/src/main/native/include/frc/GearTooth.h index 6b735deaed..230f6d1951 100644 --- a/wpilibc/src/main/native/include/frc/GearTooth.h +++ b/wpilibc/src/main/native/include/frc/GearTooth.h @@ -61,6 +61,9 @@ class GearTooth : public Counter { explicit GearTooth(std::shared_ptr source, bool directionSensitive = false); + GearTooth(GearTooth&&) = default; + GearTooth& operator=(GearTooth&&) = default; + /** * Common code called by the constructors. */ diff --git a/wpilibc/src/main/native/include/frc/GenericHID.h b/wpilibc/src/main/native/include/frc/GenericHID.h index ee66879428..74e5271fa1 100644 --- a/wpilibc/src/main/native/include/frc/GenericHID.h +++ b/wpilibc/src/main/native/include/frc/GenericHID.h @@ -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; diff --git a/wpilibc/src/main/native/include/frc/GyroBase.h b/wpilibc/src/main/native/include/frc/GyroBase.h index 881abcb497..d27c7d9262 100644 --- a/wpilibc/src/main/native/include/frc/GyroBase.h +++ b/wpilibc/src/main/native/include/frc/GyroBase.h @@ -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 diff --git a/wpilibc/src/main/native/include/frc/I2C.h b/wpilibc/src/main/native/include/frc/I2C.h index b0e0f94d9d..81d13dc2e2 100644 --- a/wpilibc/src/main/native/include/frc/I2C.h +++ b/wpilibc/src/main/native/include/frc/I2C.h @@ -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. diff --git a/wpilibc/src/main/native/include/frc/InterruptableSensorBase.h b/wpilibc/src/main/native/include/frc/InterruptableSensorBase.h index f2612b746a..7c9e3649f5 100644 --- a/wpilibc/src/main/native/include/frc/InterruptableSensorBase.h +++ b/wpilibc/src/main/native/include/frc/InterruptableSensorBase.h @@ -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; diff --git a/wpilibc/src/main/native/include/frc/IterativeRobot.h b/wpilibc/src/main/native/include/frc/IterativeRobot.h index 730215c036..c38aa31a0e 100644 --- a/wpilibc/src/main/native/include/frc/IterativeRobot.h +++ b/wpilibc/src/main/native/include/frc/IterativeRobot.h @@ -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(). * diff --git a/wpilibc/src/main/native/include/frc/IterativeRobotBase.h b/wpilibc/src/main/native/include/frc/IterativeRobotBase.h index 2eedf90ec4..2544155dd8 100644 --- a/wpilibc/src/main/native/include/frc/IterativeRobotBase.h +++ b/wpilibc/src/main/native/include/frc/IterativeRobotBase.h @@ -144,6 +144,9 @@ class IterativeRobotBase : public RobotBase { virtual ~IterativeRobotBase() = default; + IterativeRobotBase(IterativeRobotBase&&) = default; + IterativeRobotBase& operator=(IterativeRobotBase&&) = default; + void LoopFunc(); double m_period; diff --git a/wpilibc/src/main/native/include/frc/Jaguar.h b/wpilibc/src/main/native/include/frc/Jaguar.h index 4a8c60cbde..f22eb42a59 100644 --- a/wpilibc/src/main/native/include/frc/Jaguar.h +++ b/wpilibc/src/main/native/include/frc/Jaguar.h @@ -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 diff --git a/wpilibc/src/main/native/include/frc/Joystick.h b/wpilibc/src/main/native/include/frc/Joystick.h index 432dd6dbc8..4c17589507 100644 --- a/wpilibc/src/main/native/include/frc/Joystick.h +++ b/wpilibc/src/main/native/include/frc/Joystick.h @@ -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. diff --git a/wpilibc/src/main/native/include/frc/JoystickBase.h b/wpilibc/src/main/native/include/frc/JoystickBase.h index 83ff1953d9..b72caf16d5 100644 --- a/wpilibc/src/main/native/include/frc/JoystickBase.h +++ b/wpilibc/src/main/native/include/frc/JoystickBase.h @@ -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; diff --git a/wpilibc/src/main/native/include/frc/MotorSafety.h b/wpilibc/src/main/native/include/frc/MotorSafety.h index 7711df9941..abf4358f9b 100644 --- a/wpilibc/src/main/native/include/frc/MotorSafety.h +++ b/wpilibc/src/main/native/include/frc/MotorSafety.h @@ -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; diff --git a/wpilibc/src/main/native/include/frc/MotorSafetyHelper.h b/wpilibc/src/main/native/include/frc/MotorSafetyHelper.h index 8fbe91ba79..d004a66e8f 100644 --- a/wpilibc/src/main/native/include/frc/MotorSafetyHelper.h +++ b/wpilibc/src/main/native/include/frc/MotorSafetyHelper.h @@ -33,6 +33,9 @@ class MotorSafetyHelper : public ErrorBase { ~MotorSafetyHelper(); + MotorSafetyHelper(MotorSafetyHelper&&) = default; + MotorSafetyHelper& operator=(MotorSafetyHelper&&) = default; + /** * Feed the motor safety object. * diff --git a/wpilibc/src/main/native/include/frc/NidecBrushless.h b/wpilibc/src/main/native/include/frc/NidecBrushless.h index d3353746a3..d705e9cc6b 100644 --- a/wpilibc/src/main/native/include/frc/NidecBrushless.h +++ b/wpilibc/src/main/native/include/frc/NidecBrushless.h @@ -39,6 +39,9 @@ class NidecBrushless : public ErrorBase, ~NidecBrushless() override = default; + NidecBrushless(NidecBrushless&&) = default; + NidecBrushless& operator=(NidecBrushless&&) = default; + // SpeedController interface /** * Set the PWM value. diff --git a/wpilibc/src/main/native/include/frc/Notifier.h b/wpilibc/src/main/native/include/frc/Notifier.h index 898783817e..039f8c8093 100644 --- a/wpilibc/src/main/native/include/frc/Notifier.h +++ b/wpilibc/src/main/native/include/frc/Notifier.h @@ -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. diff --git a/wpilibc/src/main/native/include/frc/PIDBase.h b/wpilibc/src/main/native/include/frc/PIDBase.h index 966df1e918..f29b56e464 100644 --- a/wpilibc/src/main/native/include/frc/PIDBase.h +++ b/wpilibc/src/main/native/include/frc/PIDBase.h @@ -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. diff --git a/wpilibc/src/main/native/include/frc/PIDController.h b/wpilibc/src/main/native/include/frc/PIDController.h index 9833d72154..e9eea8b767 100644 --- a/wpilibc/src/main/native/include/frc/PIDController.h +++ b/wpilibc/src/main/native/include/frc/PIDController.h @@ -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. diff --git a/wpilibc/src/main/native/include/frc/PIDInterface.h b/wpilibc/src/main/native/include/frc/PIDInterface.h index 92a28c87a3..72d8beb77b 100644 --- a/wpilibc/src/main/native/include/frc/PIDInterface.h +++ b/wpilibc/src/main/native/include/frc/PIDInterface.h @@ -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; diff --git a/wpilibc/src/main/native/include/frc/PWM.h b/wpilibc/src/main/native/include/frc/PWM.h index dd5cecb315..44d55b30b5 100644 --- a/wpilibc/src/main/native/include/frc/PWM.h +++ b/wpilibc/src/main/native/include/frc/PWM.h @@ -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 diff --git a/wpilibc/src/main/native/include/frc/PWMSpeedController.h b/wpilibc/src/main/native/include/frc/PWMSpeedController.h index 02d8606e78..dbbb38c0f3 100644 --- a/wpilibc/src/main/native/include/frc/PWMSpeedController.h +++ b/wpilibc/src/main/native/include/frc/PWMSpeedController.h @@ -17,6 +17,9 @@ namespace frc { */ class PWMSpeedController : public SafePWM, public SpeedController { public: + PWMSpeedController(PWMSpeedController&&) = default; + PWMSpeedController& operator=(PWMSpeedController&&) = default; + /** * Set the PWM value. * diff --git a/wpilibc/src/main/native/include/frc/PWMTalonSRX.h b/wpilibc/src/main/native/include/frc/PWMTalonSRX.h index c26a4bc577..9260e1e85f 100644 --- a/wpilibc/src/main/native/include/frc/PWMTalonSRX.h +++ b/wpilibc/src/main/native/include/frc/PWMTalonSRX.h @@ -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 diff --git a/wpilibc/src/main/native/include/frc/PWMVictorSPX.h b/wpilibc/src/main/native/include/frc/PWMVictorSPX.h index d873dcff06..d7112c9b7c 100644 --- a/wpilibc/src/main/native/include/frc/PWMVictorSPX.h +++ b/wpilibc/src/main/native/include/frc/PWMVictorSPX.h @@ -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 diff --git a/wpilibc/src/main/native/include/frc/PowerDistributionPanel.h b/wpilibc/src/main/native/include/frc/PowerDistributionPanel.h index 5e5724e968..3be25513fb 100644 --- a/wpilibc/src/main/native/include/frc/PowerDistributionPanel.h +++ b/wpilibc/src/main/native/include/frc/PowerDistributionPanel.h @@ -7,6 +7,8 @@ #pragma once +#include + #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 diff --git a/wpilibc/src/main/native/include/frc/Preferences.h b/wpilibc/src/main/native/include/frc/Preferences.h index 0ed8b2be4c..57678a824f 100644 --- a/wpilibc/src/main/native/include/frc/Preferences.h +++ b/wpilibc/src/main/native/include/frc/Preferences.h @@ -195,6 +195,9 @@ class Preferences : public ErrorBase { Preferences(); virtual ~Preferences() = default; + Preferences(Preferences&&) = default; + Preferences& operator=(Preferences&&) = default; + private: std::shared_ptr m_table; NT_EntryListener m_listener; diff --git a/wpilibc/src/main/native/include/frc/Relay.h b/wpilibc/src/main/native/include/frc/Relay.h index 10f7903489..e25e48ae4f 100644 --- a/wpilibc/src/main/native/include/frc/Relay.h +++ b/wpilibc/src/main/native/include/frc/Relay.h @@ -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. * diff --git a/wpilibc/src/main/native/include/frc/Resource.h b/wpilibc/src/main/native/include/frc/Resource.h index 1bf5be0695..9df219632b 100644 --- a/wpilibc/src/main/native/include/frc/Resource.h +++ b/wpilibc/src/main/native/include/frc/Resource.h @@ -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. diff --git a/wpilibc/src/main/native/include/frc/RobotBase.h b/wpilibc/src/main/native/include/frc/RobotBase.h index 063ee8ace9..62e685846f 100644 --- a/wpilibc/src/main/native/include/frc/RobotBase.h +++ b/wpilibc/src/main/native/include/frc/RobotBase.h @@ -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; diff --git a/wpilibc/src/main/native/include/frc/RobotDrive.h b/wpilibc/src/main/native/include/frc/RobotDrive.h index 031af564aa..d4e7a26ff4 100644 --- a/wpilibc/src/main/native/include/frc/RobotDrive.h +++ b/wpilibc/src/main/native/include/frc/RobotDrive.h @@ -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". diff --git a/wpilibc/src/main/native/include/frc/SD540.h b/wpilibc/src/main/native/include/frc/SD540.h index 26b83088e8..91666b4a4c 100644 --- a/wpilibc/src/main/native/include/frc/SD540.h +++ b/wpilibc/src/main/native/include/frc/SD540.h @@ -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 diff --git a/wpilibc/src/main/native/include/frc/SPI.h b/wpilibc/src/main/native/include/frc/SPI.h index 1bc8fea1b1..f03a91a861 100644 --- a/wpilibc/src/main/native/include/frc/SPI.h +++ b/wpilibc/src/main/native/include/frc/SPI.h @@ -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. diff --git a/wpilibc/src/main/native/include/frc/SafePWM.h b/wpilibc/src/main/native/include/frc/SafePWM.h index 722e310f78..450e76f6d2 100644 --- a/wpilibc/src/main/native/include/frc/SafePWM.h +++ b/wpilibc/src/main/native/include/frc/SafePWM.h @@ -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. * diff --git a/wpilibc/src/main/native/include/frc/SampleRobot.h b/wpilibc/src/main/native/include/frc/SampleRobot.h index 7ea29a45e9..a0e97b1b75 100644 --- a/wpilibc/src/main/native/include/frc/SampleRobot.h +++ b/wpilibc/src/main/native/include/frc/SampleRobot.h @@ -98,6 +98,9 @@ class WPI_DEPRECATED( SampleRobot(); virtual ~SampleRobot() = default; + SampleRobot(SampleRobot&&) = default; + SampleRobot& operator=(SampleRobot&&) = default; + private: bool m_robotMainOverridden = true; }; diff --git a/wpilibc/src/main/native/include/frc/SerialPort.h b/wpilibc/src/main/native/include/frc/SerialPort.h index fdfdd865a4..99bc65f9d8 100644 --- a/wpilibc/src/main/native/include/frc/SerialPort.h +++ b/wpilibc/src/main/native/include/frc/SerialPort.h @@ -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 diff --git a/wpilibc/src/main/native/include/frc/Servo.h b/wpilibc/src/main/native/include/frc/Servo.h index a9c1345c79..967964b983 100644 --- a/wpilibc/src/main/native/include/frc/Servo.h +++ b/wpilibc/src/main/native/include/frc/Servo.h @@ -26,6 +26,9 @@ class Servo : public SafePWM { */ explicit Servo(int channel); + Servo(Servo&&) = default; + Servo& operator=(Servo&&) = default; + /** * Set the servo position. * diff --git a/wpilibc/src/main/native/include/frc/Solenoid.h b/wpilibc/src/main/native/include/frc/Solenoid.h index 0acf2c0fcc..8a90b2603d 100644 --- a/wpilibc/src/main/native/include/frc/Solenoid.h +++ b/wpilibc/src/main/native/include/frc/Solenoid.h @@ -38,6 +38,9 @@ class Solenoid : public SolenoidBase { ~Solenoid() override; + Solenoid(Solenoid&& rhs); + Solenoid& operator=(Solenoid&& rhs); + /** * Set the value of a solenoid. * diff --git a/wpilibc/src/main/native/include/frc/SolenoidBase.h b/wpilibc/src/main/native/include/frc/SolenoidBase.h index 5d0b157055..fe9f32e0ed 100644 --- a/wpilibc/src/main/native/include/frc/SolenoidBase.h +++ b/wpilibc/src/main/native/include/frc/SolenoidBase.h @@ -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; diff --git a/wpilibc/src/main/native/include/frc/Spark.h b/wpilibc/src/main/native/include/frc/Spark.h index 8507e3cf14..640696fcd3 100644 --- a/wpilibc/src/main/native/include/frc/Spark.h +++ b/wpilibc/src/main/native/include/frc/Spark.h @@ -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 diff --git a/wpilibc/src/main/native/include/frc/SpeedControllerGroup.h b/wpilibc/src/main/native/include/frc/SpeedControllerGroup.h index ed32a50ba8..3f0c699ac4 100644 --- a/wpilibc/src/main/native/include/frc/SpeedControllerGroup.h +++ b/wpilibc/src/main/native/include/frc/SpeedControllerGroup.h @@ -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; diff --git a/wpilibc/src/main/native/include/frc/SynchronousPID.h b/wpilibc/src/main/native/include/frc/SynchronousPID.h index fedf053a41..cecd08dd8c 100644 --- a/wpilibc/src/main/native/include/frc/SynchronousPID.h +++ b/wpilibc/src/main/native/include/frc/SynchronousPID.h @@ -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. diff --git a/wpilibc/src/main/native/include/frc/Talon.h b/wpilibc/src/main/native/include/frc/Talon.h index 41331a52d0..9a5400ff39 100644 --- a/wpilibc/src/main/native/include/frc/Talon.h +++ b/wpilibc/src/main/native/include/frc/Talon.h @@ -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 diff --git a/wpilibc/src/main/native/include/frc/TimedRobot.h b/wpilibc/src/main/native/include/frc/TimedRobot.h index 8458e25488..c0f087fc3c 100644 --- a/wpilibc/src/main/native/include/frc/TimedRobot.h +++ b/wpilibc/src/main/native/include/frc/TimedRobot.h @@ -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}; diff --git a/wpilibc/src/main/native/include/frc/Timer.h b/wpilibc/src/main/native/include/frc/Timer.h index c9e8ba4b4c..77bd9aa3ad 100644 --- a/wpilibc/src/main/native/include/frc/Timer.h +++ b/wpilibc/src/main/native/include/frc/Timer.h @@ -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 diff --git a/wpilibc/src/main/native/include/frc/Ultrasonic.h b/wpilibc/src/main/native/include/frc/Ultrasonic.h index a1b247206b..82ae6ca0ed 100644 --- a/wpilibc/src/main/native/include/frc/Ultrasonic.h +++ b/wpilibc/src/main/native/include/frc/Ultrasonic.h @@ -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. * diff --git a/wpilibc/src/main/native/include/frc/Victor.h b/wpilibc/src/main/native/include/frc/Victor.h index ef35e8c94c..5b6cba4445 100644 --- a/wpilibc/src/main/native/include/frc/Victor.h +++ b/wpilibc/src/main/native/include/frc/Victor.h @@ -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 diff --git a/wpilibc/src/main/native/include/frc/VictorSP.h b/wpilibc/src/main/native/include/frc/VictorSP.h index 96776d2d70..b23fba165f 100644 --- a/wpilibc/src/main/native/include/frc/VictorSP.h +++ b/wpilibc/src/main/native/include/frc/VictorSP.h @@ -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 diff --git a/wpilibc/src/main/native/include/frc/Watchdog.h b/wpilibc/src/main/native/include/frc/Watchdog.h index cc64d772e8..b130cc17fc 100644 --- a/wpilibc/src/main/native/include/frc/Watchdog.h +++ b/wpilibc/src/main/native/include/frc/Watchdog.h @@ -35,8 +35,8 @@ class Watchdog { */ explicit Watchdog(double timeout, std::function 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. diff --git a/wpilibc/src/main/native/include/frc/XboxController.h b/wpilibc/src/main/native/include/frc/XboxController.h index 17655d56a1..8aa2d5b35b 100644 --- a/wpilibc/src/main/native/include/frc/XboxController.h +++ b/wpilibc/src/main/native/include/frc/XboxController.h @@ -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. diff --git a/wpilibc/src/main/native/include/frc/buttons/Button.h b/wpilibc/src/main/native/include/frc/buttons/Button.h index a80d96e03e..71641e910f 100644 --- a/wpilibc/src/main/native/include/frc/buttons/Button.h +++ b/wpilibc/src/main/native/include/frc/buttons/Button.h @@ -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. * diff --git a/wpilibc/src/main/native/include/frc/buttons/ButtonScheduler.h b/wpilibc/src/main/native/include/frc/buttons/ButtonScheduler.h index 5f2ccb656f..ec2e35bc8e 100644 --- a/wpilibc/src/main/native/include/frc/buttons/ButtonScheduler.h +++ b/wpilibc/src/main/native/include/frc/buttons/ButtonScheduler.h @@ -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(); diff --git a/wpilibc/src/main/native/include/frc/buttons/CancelButtonScheduler.h b/wpilibc/src/main/native/include/frc/buttons/CancelButtonScheduler.h index d74799f845..8e4413a9c6 100644 --- a/wpilibc/src/main/native/include/frc/buttons/CancelButtonScheduler.h +++ b/wpilibc/src/main/native/include/frc/buttons/CancelButtonScheduler.h @@ -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: diff --git a/wpilibc/src/main/native/include/frc/buttons/HeldButtonScheduler.h b/wpilibc/src/main/native/include/frc/buttons/HeldButtonScheduler.h index 82f8628898..ad4a1607a7 100644 --- a/wpilibc/src/main/native/include/frc/buttons/HeldButtonScheduler.h +++ b/wpilibc/src/main/native/include/frc/buttons/HeldButtonScheduler.h @@ -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(); }; diff --git a/wpilibc/src/main/native/include/frc/buttons/InternalButton.h b/wpilibc/src/main/native/include/frc/buttons/InternalButton.h index 19c6924941..430a21e7b1 100644 --- a/wpilibc/src/main/native/include/frc/buttons/InternalButton.h +++ b/wpilibc/src/main/native/include/frc/buttons/InternalButton.h @@ -17,6 +17,9 @@ class InternalButton : public Button { explicit InternalButton(bool inverted); virtual ~InternalButton() = default; + InternalButton(InternalButton&&) = default; + InternalButton& operator=(InternalButton&&) = default; + void SetInverted(bool inverted); void SetPressed(bool pressed); diff --git a/wpilibc/src/main/native/include/frc/buttons/JoystickButton.h b/wpilibc/src/main/native/include/frc/buttons/JoystickButton.h index 1f36efdd49..1b4264ff43 100644 --- a/wpilibc/src/main/native/include/frc/buttons/JoystickButton.h +++ b/wpilibc/src/main/native/include/frc/buttons/JoystickButton.h @@ -17,6 +17,9 @@ class JoystickButton : public Button { JoystickButton(GenericHID* joystick, int buttonNumber); virtual ~JoystickButton() = default; + JoystickButton(JoystickButton&&) = default; + JoystickButton& operator=(JoystickButton&&) = default; + virtual bool Get(); private: diff --git a/wpilibc/src/main/native/include/frc/buttons/NetworkButton.h b/wpilibc/src/main/native/include/frc/buttons/NetworkButton.h index 9eab4ce39c..fef8065a55 100644 --- a/wpilibc/src/main/native/include/frc/buttons/NetworkButton.h +++ b/wpilibc/src/main/native/include/frc/buttons/NetworkButton.h @@ -24,6 +24,9 @@ class NetworkButton : public Button { const wpi::Twine& field); virtual ~NetworkButton() = default; + NetworkButton(NetworkButton&&) = default; + NetworkButton& operator=(NetworkButton&&) = default; + virtual bool Get(); private: diff --git a/wpilibc/src/main/native/include/frc/buttons/PressedButtonScheduler.h b/wpilibc/src/main/native/include/frc/buttons/PressedButtonScheduler.h index 43604f839a..0c1fb039e0 100644 --- a/wpilibc/src/main/native/include/frc/buttons/PressedButtonScheduler.h +++ b/wpilibc/src/main/native/include/frc/buttons/PressedButtonScheduler.h @@ -18,6 +18,10 @@ class PressedButtonScheduler : public ButtonScheduler { public: PressedButtonScheduler(bool last, Trigger* button, Command* orders); virtual ~PressedButtonScheduler() = default; + + PressedButtonScheduler(PressedButtonScheduler&&) = default; + PressedButtonScheduler& operator=(PressedButtonScheduler&&) = default; + virtual void Execute(); }; diff --git a/wpilibc/src/main/native/include/frc/buttons/ReleasedButtonScheduler.h b/wpilibc/src/main/native/include/frc/buttons/ReleasedButtonScheduler.h index b4d2c70bdc..899a483a3d 100644 --- a/wpilibc/src/main/native/include/frc/buttons/ReleasedButtonScheduler.h +++ b/wpilibc/src/main/native/include/frc/buttons/ReleasedButtonScheduler.h @@ -18,6 +18,10 @@ class ReleasedButtonScheduler : public ButtonScheduler { public: ReleasedButtonScheduler(bool last, Trigger* button, Command* orders); virtual ~ReleasedButtonScheduler() = default; + + ReleasedButtonScheduler(ReleasedButtonScheduler&&) = default; + ReleasedButtonScheduler& operator=(ReleasedButtonScheduler&&) = default; + virtual void Execute(); }; diff --git a/wpilibc/src/main/native/include/frc/buttons/ToggleButtonScheduler.h b/wpilibc/src/main/native/include/frc/buttons/ToggleButtonScheduler.h index 28831b8de4..4c7a2037bb 100644 --- a/wpilibc/src/main/native/include/frc/buttons/ToggleButtonScheduler.h +++ b/wpilibc/src/main/native/include/frc/buttons/ToggleButtonScheduler.h @@ -18,6 +18,10 @@ class ToggleButtonScheduler : public ButtonScheduler { public: ToggleButtonScheduler(bool last, Trigger* button, Command* orders); virtual ~ToggleButtonScheduler() = default; + + ToggleButtonScheduler(ToggleButtonScheduler&&) = default; + ToggleButtonScheduler& operator=(ToggleButtonScheduler&&) = default; + virtual void Execute(); private: diff --git a/wpilibc/src/main/native/include/frc/buttons/Trigger.h b/wpilibc/src/main/native/include/frc/buttons/Trigger.h index e5b0eb409c..8f8c4779b3 100644 --- a/wpilibc/src/main/native/include/frc/buttons/Trigger.h +++ b/wpilibc/src/main/native/include/frc/buttons/Trigger.h @@ -32,6 +32,10 @@ class Trigger : public SendableBase { public: Trigger() = default; ~Trigger() override = default; + + Trigger(Trigger&&) = default; + Trigger& operator=(Trigger&&) = default; + bool Grab(); virtual bool Get() = 0; void WhenActive(Command* command); diff --git a/wpilibc/src/main/native/include/frc/commands/Command.h b/wpilibc/src/main/native/include/frc/commands/Command.h index ba509384a2..7323c29beb 100644 --- a/wpilibc/src/main/native/include/frc/commands/Command.h +++ b/wpilibc/src/main/native/include/frc/commands/Command.h @@ -115,6 +115,9 @@ class Command : public ErrorBase, public SendableBase { ~Command() override = default; + Command(Command&&) = default; + Command& operator=(Command&&) = default; + /** * Returns the time since this command was initialized (in seconds). * diff --git a/wpilibc/src/main/native/include/frc/commands/CommandGroup.h b/wpilibc/src/main/native/include/frc/commands/CommandGroup.h index 3c08f34647..690ae6d05d 100644 --- a/wpilibc/src/main/native/include/frc/commands/CommandGroup.h +++ b/wpilibc/src/main/native/include/frc/commands/CommandGroup.h @@ -46,6 +46,9 @@ class CommandGroup : public Command { virtual ~CommandGroup() = default; + CommandGroup(CommandGroup&&) = default; + CommandGroup& operator=(CommandGroup&&) = default; + /** * Adds a new Command to the group. The Command will be started after all the * previously added Commands. diff --git a/wpilibc/src/main/native/include/frc/commands/CommandGroupEntry.h b/wpilibc/src/main/native/include/frc/commands/CommandGroupEntry.h index 14fcede9be..2147aeabe3 100644 --- a/wpilibc/src/main/native/include/frc/commands/CommandGroupEntry.h +++ b/wpilibc/src/main/native/include/frc/commands/CommandGroupEntry.h @@ -21,6 +21,10 @@ class CommandGroupEntry { CommandGroupEntry() = default; CommandGroupEntry(Command* command, Sequence state, double timeout = -1.0); + + CommandGroupEntry(CommandGroupEntry&&) = default; + CommandGroupEntry& operator=(CommandGroupEntry&&) = default; + bool IsTimedOut() const; double m_timeout = -1.0; diff --git a/wpilibc/src/main/native/include/frc/commands/ConditionalCommand.h b/wpilibc/src/main/native/include/frc/commands/ConditionalCommand.h index 722d38602b..142c5b0079 100644 --- a/wpilibc/src/main/native/include/frc/commands/ConditionalCommand.h +++ b/wpilibc/src/main/native/include/frc/commands/ConditionalCommand.h @@ -54,6 +54,9 @@ class ConditionalCommand : public Command { virtual ~ConditionalCommand() = default; + ConditionalCommand(ConditionalCommand&&) = default; + ConditionalCommand& operator=(ConditionalCommand&&) = default; + protected: /** * The Condition to test to determine which Command to run. diff --git a/wpilibc/src/main/native/include/frc/commands/InstantCommand.h b/wpilibc/src/main/native/include/frc/commands/InstantCommand.h index e412e092bb..987dc1875f 100644 --- a/wpilibc/src/main/native/include/frc/commands/InstantCommand.h +++ b/wpilibc/src/main/native/include/frc/commands/InstantCommand.h @@ -81,6 +81,9 @@ class InstantCommand : public Command { InstantCommand() = default; virtual ~InstantCommand() = default; + InstantCommand(InstantCommand&&) = default; + InstantCommand& operator=(InstantCommand&&) = default; + protected: std::function m_func = nullptr; void _Initialize() override; diff --git a/wpilibc/src/main/native/include/frc/commands/PIDCommand.h b/wpilibc/src/main/native/include/frc/commands/PIDCommand.h index b4709a80c6..02f17102e1 100644 --- a/wpilibc/src/main/native/include/frc/commands/PIDCommand.h +++ b/wpilibc/src/main/native/include/frc/commands/PIDCommand.h @@ -40,6 +40,9 @@ class PIDCommand : public Command, public PIDOutput, public PIDSource { Subsystem& subsystem); virtual ~PIDCommand() = default; + PIDCommand(PIDCommand&&) = default; + PIDCommand& operator=(PIDCommand&&) = default; + void SetSetpointRelative(double deltaSetpoint); // PIDOutput interface diff --git a/wpilibc/src/main/native/include/frc/commands/PIDSubsystem.h b/wpilibc/src/main/native/include/frc/commands/PIDSubsystem.h index 734c3877a5..19654920fa 100644 --- a/wpilibc/src/main/native/include/frc/commands/PIDSubsystem.h +++ b/wpilibc/src/main/native/include/frc/commands/PIDSubsystem.h @@ -105,6 +105,9 @@ class PIDSubsystem : public Subsystem, public PIDOutput, public PIDSource { ~PIDSubsystem() override = default; + PIDSubsystem(PIDSubsystem&&) = default; + PIDSubsystem& operator=(PIDSubsystem&&) = default; + /** * Enables the internal PIDController. */ diff --git a/wpilibc/src/main/native/include/frc/commands/PrintCommand.h b/wpilibc/src/main/native/include/frc/commands/PrintCommand.h index 9fead6b175..13156c9d4d 100644 --- a/wpilibc/src/main/native/include/frc/commands/PrintCommand.h +++ b/wpilibc/src/main/native/include/frc/commands/PrintCommand.h @@ -20,6 +20,9 @@ class PrintCommand : public InstantCommand { explicit PrintCommand(const wpi::Twine& message); virtual ~PrintCommand() = default; + PrintCommand(PrintCommand&&) = default; + PrintCommand& operator=(PrintCommand&&) = default; + protected: virtual void Initialize(); diff --git a/wpilibc/src/main/native/include/frc/commands/Scheduler.h b/wpilibc/src/main/native/include/frc/commands/Scheduler.h index 156b3d5fa1..c5c97baf51 100644 --- a/wpilibc/src/main/native/include/frc/commands/Scheduler.h +++ b/wpilibc/src/main/native/include/frc/commands/Scheduler.h @@ -87,6 +87,9 @@ class Scheduler : public ErrorBase, public SendableBase { Scheduler(); ~Scheduler() override; + Scheduler(Scheduler&&) = default; + Scheduler& operator=(Scheduler&&) = default; + struct Impl; std::unique_ptr m_impl; }; diff --git a/wpilibc/src/main/native/include/frc/commands/StartCommand.h b/wpilibc/src/main/native/include/frc/commands/StartCommand.h index 50d6b10609..4f0b6767d4 100644 --- a/wpilibc/src/main/native/include/frc/commands/StartCommand.h +++ b/wpilibc/src/main/native/include/frc/commands/StartCommand.h @@ -16,6 +16,9 @@ class StartCommand : public InstantCommand { explicit StartCommand(Command* commandToStart); virtual ~StartCommand() = default; + StartCommand(StartCommand&&) = default; + StartCommand& operator=(StartCommand&&) = default; + protected: virtual void Initialize(); diff --git a/wpilibc/src/main/native/include/frc/commands/Subsystem.h b/wpilibc/src/main/native/include/frc/commands/Subsystem.h index 4cde4bfeb9..bb6d166a0b 100644 --- a/wpilibc/src/main/native/include/frc/commands/Subsystem.h +++ b/wpilibc/src/main/native/include/frc/commands/Subsystem.h @@ -31,6 +31,9 @@ class Subsystem : public ErrorBase, public SendableBase { */ explicit Subsystem(const wpi::Twine& name); + Subsystem(Subsystem&&) = default; + Subsystem& operator=(Subsystem&&) = default; + /** * Sets the default command. If this is not called or is called with null, * then there will be no default command for the subsystem. diff --git a/wpilibc/src/main/native/include/frc/commands/TimedCommand.h b/wpilibc/src/main/native/include/frc/commands/TimedCommand.h index 8bddf9272d..d2be010364 100644 --- a/wpilibc/src/main/native/include/frc/commands/TimedCommand.h +++ b/wpilibc/src/main/native/include/frc/commands/TimedCommand.h @@ -54,6 +54,9 @@ class TimedCommand : public Command { virtual ~TimedCommand() = default; + TimedCommand(TimedCommand&&) = default; + TimedCommand& operator=(TimedCommand&&) = default; + protected: /** * Ends command when timed out. diff --git a/wpilibc/src/main/native/include/frc/commands/WaitCommand.h b/wpilibc/src/main/native/include/frc/commands/WaitCommand.h index 48d28ebc5c..481b1c6e08 100644 --- a/wpilibc/src/main/native/include/frc/commands/WaitCommand.h +++ b/wpilibc/src/main/native/include/frc/commands/WaitCommand.h @@ -31,6 +31,9 @@ class WaitCommand : public TimedCommand { WaitCommand(const wpi::Twine& name, double timeout); virtual ~WaitCommand() = default; + + WaitCommand(WaitCommand&&) = default; + WaitCommand& operator=(WaitCommand&&) = default; }; } // namespace frc diff --git a/wpilibc/src/main/native/include/frc/commands/WaitForChildren.h b/wpilibc/src/main/native/include/frc/commands/WaitForChildren.h index 720905eee1..6f2e285eed 100644 --- a/wpilibc/src/main/native/include/frc/commands/WaitForChildren.h +++ b/wpilibc/src/main/native/include/frc/commands/WaitForChildren.h @@ -19,6 +19,9 @@ class WaitForChildren : public Command { WaitForChildren(const wpi::Twine& name, double timeout); virtual ~WaitForChildren() = default; + WaitForChildren(WaitForChildren&&) = default; + WaitForChildren& operator=(WaitForChildren&&) = default; + protected: virtual bool IsFinished(); }; diff --git a/wpilibc/src/main/native/include/frc/commands/WaitUntilCommand.h b/wpilibc/src/main/native/include/frc/commands/WaitUntilCommand.h index 13cb125bcf..1231750599 100644 --- a/wpilibc/src/main/native/include/frc/commands/WaitUntilCommand.h +++ b/wpilibc/src/main/native/include/frc/commands/WaitUntilCommand.h @@ -29,6 +29,9 @@ class WaitUntilCommand : public Command { virtual ~WaitUntilCommand() = default; + WaitUntilCommand(WaitUntilCommand&&) = default; + WaitUntilCommand& operator=(WaitUntilCommand&&) = default; + protected: /** * Check if we've reached the actual finish time. diff --git a/wpilibc/src/main/native/include/frc/drive/DifferentialDrive.h b/wpilibc/src/main/native/include/frc/drive/DifferentialDrive.h index 5f9db3512f..c73242b53c 100644 --- a/wpilibc/src/main/native/include/frc/drive/DifferentialDrive.h +++ b/wpilibc/src/main/native/include/frc/drive/DifferentialDrive.h @@ -111,8 +111,8 @@ class DifferentialDrive : public RobotDriveBase { ~DifferentialDrive() override = default; - DifferentialDrive(const DifferentialDrive&) = delete; - DifferentialDrive& operator=(const DifferentialDrive&) = delete; + DifferentialDrive(DifferentialDrive&&) = default; + DifferentialDrive& operator=(DifferentialDrive&&) = default; /** * Arcade drive method for differential drive platform. diff --git a/wpilibc/src/main/native/include/frc/drive/KilloughDrive.h b/wpilibc/src/main/native/include/frc/drive/KilloughDrive.h index 5abfe20d4f..2fa356dfe7 100644 --- a/wpilibc/src/main/native/include/frc/drive/KilloughDrive.h +++ b/wpilibc/src/main/native/include/frc/drive/KilloughDrive.h @@ -86,8 +86,8 @@ class KilloughDrive : public RobotDriveBase { ~KilloughDrive() override = default; - KilloughDrive(const KilloughDrive&) = delete; - KilloughDrive& operator=(const KilloughDrive&) = delete; + KilloughDrive(KilloughDrive&&) = default; + KilloughDrive& operator=(KilloughDrive&&) = default; /** * Drive method for Killough platform. diff --git a/wpilibc/src/main/native/include/frc/drive/MecanumDrive.h b/wpilibc/src/main/native/include/frc/drive/MecanumDrive.h index bc771ce161..e0acaca6ab 100644 --- a/wpilibc/src/main/native/include/frc/drive/MecanumDrive.h +++ b/wpilibc/src/main/native/include/frc/drive/MecanumDrive.h @@ -75,8 +75,8 @@ class MecanumDrive : public RobotDriveBase { ~MecanumDrive() override = default; - MecanumDrive(const MecanumDrive&) = delete; - MecanumDrive& operator=(const MecanumDrive&) = delete; + MecanumDrive(MecanumDrive&&) = default; + MecanumDrive& operator=(MecanumDrive&&) = default; /** * Drive method for Mecanum platform. diff --git a/wpilibc/src/main/native/include/frc/drive/RobotDriveBase.h b/wpilibc/src/main/native/include/frc/drive/RobotDriveBase.h index 3662fb59ec..57565ae4e3 100644 --- a/wpilibc/src/main/native/include/frc/drive/RobotDriveBase.h +++ b/wpilibc/src/main/native/include/frc/drive/RobotDriveBase.h @@ -41,8 +41,8 @@ class RobotDriveBase : public MotorSafety, public SendableBase { RobotDriveBase(); ~RobotDriveBase() override = default; - RobotDriveBase(const RobotDriveBase&) = delete; - RobotDriveBase& operator=(const RobotDriveBase&) = delete; + RobotDriveBase(RobotDriveBase&&) = default; + RobotDriveBase& operator=(RobotDriveBase&&) = default; /** * Sets the deadband applied to the drive inputs (e.g., joystick values). diff --git a/wpilibc/src/main/native/include/frc/filters/Filter.h b/wpilibc/src/main/native/include/frc/filters/Filter.h index 6c5ef43e10..b0c0c1145a 100644 --- a/wpilibc/src/main/native/include/frc/filters/Filter.h +++ b/wpilibc/src/main/native/include/frc/filters/Filter.h @@ -22,6 +22,9 @@ class Filter : public PIDSource { explicit Filter(std::shared_ptr source); virtual ~Filter() = default; + Filter(Filter&&) = default; + Filter& operator=(Filter&&) = default; + // PIDSource interface void SetPIDSourceType(PIDSourceType pidSource) override; PIDSourceType GetPIDSourceType() const override; diff --git a/wpilibc/src/main/native/include/frc/filters/LinearDigitalFilter.h b/wpilibc/src/main/native/include/frc/filters/LinearDigitalFilter.h index 54ecb919e4..472d53b2f3 100644 --- a/wpilibc/src/main/native/include/frc/filters/LinearDigitalFilter.h +++ b/wpilibc/src/main/native/include/frc/filters/LinearDigitalFilter.h @@ -90,6 +90,9 @@ class LinearDigitalFilter : public Filter { wpi::ArrayRef ffGains, wpi::ArrayRef fbGains); + LinearDigitalFilter(LinearDigitalFilter&&) = default; + LinearDigitalFilter& operator=(LinearDigitalFilter&&) = default; + // Static methods to create commonly used filters /** * Creates a one-pole IIR low-pass filter of the form:
diff --git a/wpilibc/src/main/native/include/frc/interfaces/Accelerometer.h b/wpilibc/src/main/native/include/frc/interfaces/Accelerometer.h index c1f6c1f9e3..499ba5b9dd 100644 --- a/wpilibc/src/main/native/include/frc/interfaces/Accelerometer.h +++ b/wpilibc/src/main/native/include/frc/interfaces/Accelerometer.h @@ -14,8 +14,12 @@ namespace frc { */ class Accelerometer { public: + Accelerometer() = default; virtual ~Accelerometer() = default; + Accelerometer(Accelerometer&&) = default; + Accelerometer& operator=(Accelerometer&&) = default; + enum Range { kRange_2G = 0, kRange_4G = 1, kRange_8G = 2, kRange_16G = 3 }; /** diff --git a/wpilibc/src/main/native/include/frc/interfaces/Gyro.h b/wpilibc/src/main/native/include/frc/interfaces/Gyro.h index 507b61d0de..b5aa332f59 100644 --- a/wpilibc/src/main/native/include/frc/interfaces/Gyro.h +++ b/wpilibc/src/main/native/include/frc/interfaces/Gyro.h @@ -14,8 +14,12 @@ namespace frc { */ class Gyro { public: + Gyro() = default; virtual ~Gyro() = default; + Gyro(Gyro&&) = default; + Gyro& operator=(Gyro&&) = default; + /** * Calibrate the gyro by running for a number of samples and computing the * center value. Then use the center value as the Accumulator center value for diff --git a/wpilibc/src/main/native/include/frc/interfaces/Potentiometer.h b/wpilibc/src/main/native/include/frc/interfaces/Potentiometer.h index 0b2c7e360e..219e6ba7cd 100644 --- a/wpilibc/src/main/native/include/frc/interfaces/Potentiometer.h +++ b/wpilibc/src/main/native/include/frc/interfaces/Potentiometer.h @@ -16,8 +16,12 @@ namespace frc { */ class Potentiometer : public PIDSource { public: + Potentiometer() = default; virtual ~Potentiometer() = default; + Potentiometer(Potentiometer&&) = default; + Potentiometer& operator=(Potentiometer&&) = default; + /** * Common interface for getting the current value of a potentiometer. * diff --git a/wpilibc/src/main/native/include/frc/livewindow/LiveWindowSendable.h b/wpilibc/src/main/native/include/frc/livewindow/LiveWindowSendable.h index 1d62efbe46..9d89cc9a1c 100644 --- a/wpilibc/src/main/native/include/frc/livewindow/LiveWindowSendable.h +++ b/wpilibc/src/main/native/include/frc/livewindow/LiveWindowSendable.h @@ -22,6 +22,10 @@ namespace frc { class WPI_DEPRECATED("use Sendable directly instead") LiveWindowSendable : public Sendable { public: + LiveWindowSendable() = default; + LiveWindowSendable(LiveWindowSendable&&) = default; + LiveWindowSendable& operator=(LiveWindowSendable&&) = default; + /** * Update the table for this sendable object with the latest values. */ diff --git a/wpilibc/src/main/native/include/frc/smartdashboard/Sendable.h b/wpilibc/src/main/native/include/frc/smartdashboard/Sendable.h index d340752588..383c169ac6 100644 --- a/wpilibc/src/main/native/include/frc/smartdashboard/Sendable.h +++ b/wpilibc/src/main/native/include/frc/smartdashboard/Sendable.h @@ -17,8 +17,12 @@ class SendableBuilder; class Sendable { public: + Sendable() = default; virtual ~Sendable() = default; + Sendable(Sendable&&) = default; + Sendable& operator=(Sendable&&) = default; + /** * Gets the name of this Sendable object. * diff --git a/wpilibc/src/main/native/include/frc/smartdashboard/SendableBase.h b/wpilibc/src/main/native/include/frc/smartdashboard/SendableBase.h index dba38d3438..6d2fbbee96 100644 --- a/wpilibc/src/main/native/include/frc/smartdashboard/SendableBase.h +++ b/wpilibc/src/main/native/include/frc/smartdashboard/SendableBase.h @@ -27,6 +27,9 @@ class SendableBase : public Sendable { ~SendableBase() override; + SendableBase(SendableBase&& rhs); + SendableBase& operator=(SendableBase&& rhs); + using Sendable::SetName; std::string GetName() const final; diff --git a/wpilibc/src/main/native/include/frc/smartdashboard/SendableBuilderImpl.h b/wpilibc/src/main/native/include/frc/smartdashboard/SendableBuilderImpl.h index b246b6ae48..e10f08507b 100644 --- a/wpilibc/src/main/native/include/frc/smartdashboard/SendableBuilderImpl.h +++ b/wpilibc/src/main/native/include/frc/smartdashboard/SendableBuilderImpl.h @@ -27,12 +27,11 @@ namespace frc { class SendableBuilderImpl : public SendableBuilder { public: SendableBuilderImpl() = default; - SendableBuilderImpl(const SendableBuilderImpl&) = delete; - SendableBuilderImpl(SendableBuilderImpl&& other) = default; - SendableBuilderImpl& operator=(const SendableBuilderImpl&) = delete; - SendableBuilderImpl& operator=(SendableBuilderImpl&& other) = default; ~SendableBuilderImpl() override = default; + SendableBuilderImpl(SendableBuilderImpl&&) = default; + SendableBuilderImpl& operator=(SendableBuilderImpl&&) = default; + /** * Set the network table. Must be called prior to any Add* functions being * called. diff --git a/wpilibc/src/main/native/include/frc/smartdashboard/SendableChooserBase.h b/wpilibc/src/main/native/include/frc/smartdashboard/SendableChooserBase.h index 6ae2e6419a..ae7908ec43 100644 --- a/wpilibc/src/main/native/include/frc/smartdashboard/SendableChooserBase.h +++ b/wpilibc/src/main/native/include/frc/smartdashboard/SendableChooserBase.h @@ -29,6 +29,9 @@ class SendableChooserBase : public SendableBase { SendableChooserBase(); ~SendableChooserBase() override = default; + SendableChooserBase(SendableChooserBase&&) = default; + SendableChooserBase& operator=(SendableChooserBase&&) = default; + protected: static constexpr const char* kDefault = "default"; static constexpr const char* kOptions = "options";