mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-28 02:11:43 +00:00
Refactor HAL handle move construction/assignment (#1845)
A templated hal::Handle class is used to wrap handles to make them move-only. This eliminates a lot of boilerplate move constructor/assignment code in the main WPILib classes. HAL_SPIPort and HAL_I2CPort are also wrapped. The wrapper class does not implement destruction. This would require the wrapper class to be handle-specific (rather than generic) and would result in more code added than it removed, plus would add header dependencies on more HAL headers. In addition, some HAL handle release functions are more complex (e.g. have return values) and can't be easily mapped to a destructor.
This commit is contained in:
@@ -41,8 +41,8 @@ class SPI : public ErrorBase {
|
||||
|
||||
~SPI() override;
|
||||
|
||||
SPI(SPI&& rhs);
|
||||
SPI& operator=(SPI&& rhs);
|
||||
SPI(SPI&&) = default;
|
||||
SPI& operator=(SPI&&) = default;
|
||||
|
||||
/**
|
||||
* Configure the rate of the generated clock signal.
|
||||
@@ -345,7 +345,7 @@ class SPI : public ErrorBase {
|
||||
double GetAccumulatorIntegratedAverage() const;
|
||||
|
||||
protected:
|
||||
HAL_SPIPort m_port = HAL_SPI_kInvalid;
|
||||
hal::SPIPort m_port;
|
||||
bool m_msbFirst = false; // Default little-endian
|
||||
bool m_sampleOnTrailing = false; // Default data updated on falling edge
|
||||
bool m_clockIdleHigh = false; // Default clock active high
|
||||
|
||||
Reference in New Issue
Block a user