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

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -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);

View File

@@ -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:

View File

@@ -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:

View File

@@ -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();
};

View File

@@ -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();
};

View File

@@ -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:

View File

@@ -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);

View File

@@ -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).
*

View File

@@ -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.

View File

@@ -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;

View File

@@ -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.

View File

@@ -81,6 +81,9 @@ class InstantCommand : public Command {
InstantCommand() = default;
virtual ~InstantCommand() = default;
InstantCommand(InstantCommand&&) = default;
InstantCommand& operator=(InstantCommand&&) = default;
protected:
std::function<void()> m_func = nullptr;
void _Initialize() override;

View File

@@ -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

View File

@@ -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.
*/

View File

@@ -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();

View File

@@ -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<Impl> m_impl;
};

View File

@@ -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();

View File

@@ -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.

View File

@@ -54,6 +54,9 @@ class TimedCommand : public Command {
virtual ~TimedCommand() = default;
TimedCommand(TimedCommand&&) = default;
TimedCommand& operator=(TimedCommand&&) = default;
protected:
/**
* Ends command when timed out.

View File

@@ -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

View File

@@ -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();
};

View File

@@ -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.

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