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