mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
Add move constructors and assignment operators to wpilibc (#1314)
Fixes #898.
This commit is contained in:
committed by
Peter Johnson
parent
b1965f74a8
commit
1aa8446725
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user