mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-25 01:41:43 +00:00
Replaced all uses of DISALLOW_COPY_AND_ASSIGN macro
Change-Id: I8371beb286a20d4c7619aab226136569fdefafef
This commit is contained in:
@@ -10,8 +10,6 @@
|
||||
#if defined WIN32
|
||||
#include <semLib.h>
|
||||
|
||||
#define DISALLOW_COPY_AND_ASSIGN(ErrorBase)
|
||||
|
||||
#define wpi_setErrnoErrorWithContext(context)
|
||||
#define wpi_setErrnoError()
|
||||
#define wpi_setImaqErrorWithContext(code, context)
|
||||
|
||||
@@ -24,6 +24,9 @@ public:
|
||||
NTTask(const char* name, FUNCPTR function, INT32 priority = kDefaultPriority, UINT32 stackSize = 20000);
|
||||
virtual ~NTTask();
|
||||
|
||||
NTTask(const NTTask&) = delete;
|
||||
NTTask& operator=(const NTTask&) = delete;
|
||||
|
||||
#ifdef WIN32
|
||||
bool Start(void * arg0);
|
||||
#else
|
||||
@@ -66,7 +69,6 @@ private:
|
||||
UINT32 m_stackSize;
|
||||
INT32 m_priority;
|
||||
bool HandleError(STATUS results);
|
||||
DISALLOW_COPY_AND_ASSIGN(NTTask);
|
||||
};
|
||||
|
||||
#endif // WIN32
|
||||
|
||||
@@ -5,13 +5,6 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
#pragma once
|
||||
|
||||
// A macro for making a class move-only
|
||||
#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
|
||||
TypeName(const TypeName&) = delete; \
|
||||
TypeName& operator=(const TypeName&) = delete; \
|
||||
TypeName(TypeName&&) = default; \
|
||||
TypeName& operator=(TypeName&&) = default
|
||||
|
||||
// A struct to use as a deleter when a std::shared_ptr must wrap a raw pointer
|
||||
// that is being deleted by someone else.
|
||||
// This should only be called in deprecated functions; using it anywhere else
|
||||
|
||||
@@ -21,6 +21,10 @@ class Error {
|
||||
typedef int32_t Code;
|
||||
|
||||
Error() = default;
|
||||
|
||||
Error(const Error&) = delete;
|
||||
Error& operator=(const Error&) = delete;
|
||||
|
||||
void Clone(const Error& error);
|
||||
Code GetCode() const;
|
||||
std::string GetMessage() const;
|
||||
@@ -44,6 +48,4 @@ class Error {
|
||||
uint32_t m_lineNumber = 0;
|
||||
const ErrorBase* m_originatingObject = nullptr;
|
||||
double m_timestamp = 0.0;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(Error);
|
||||
};
|
||||
|
||||
@@ -54,6 +54,10 @@ class ErrorBase {
|
||||
public:
|
||||
ErrorBase() = default;
|
||||
virtual ~ErrorBase() = default;
|
||||
|
||||
ErrorBase(const ErrorBase&) = delete;
|
||||
ErrorBase& operator=(const ErrorBase&) = delete;
|
||||
|
||||
virtual Error& GetError();
|
||||
virtual const Error& GetError() const;
|
||||
virtual void SetErrnoError(const std::string& contextMessage,
|
||||
@@ -91,7 +95,4 @@ class ErrorBase {
|
||||
// TODO: Replace globalError with a global list of all errors.
|
||||
static priority_mutex _globalErrorMutex;
|
||||
static Error _globalError;
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(ErrorBase);
|
||||
};
|
||||
|
||||
@@ -17,6 +17,10 @@ class Notifier : public ErrorBase {
|
||||
public:
|
||||
Notifier(TimerEventHandler handler, void *param = nullptr);
|
||||
virtual ~Notifier();
|
||||
|
||||
Notifier(const Notifier&) = delete;
|
||||
Notifier& operator=(const Notifier&) = delete;
|
||||
|
||||
void StartSingle(double delay);
|
||||
void StartPeriodic(double period);
|
||||
void Stop();
|
||||
@@ -44,8 +48,6 @@ class Notifier : public ErrorBase {
|
||||
priority_mutex m_handlerMutex; // held by interrupt manager task while
|
||||
// handler call is in progress
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(Notifier);
|
||||
|
||||
#ifdef FRC_SIMULATOR
|
||||
static ::std::thread m_task;
|
||||
static ::std::atomic<bool> m_stopped;
|
||||
|
||||
@@ -34,6 +34,10 @@ class PIDController : public LiveWindowSendable,
|
||||
PIDController(float p, float i, float d, float f, PIDSource *source,
|
||||
PIDOutput *output, float period = 0.05);
|
||||
virtual ~PIDController() = default;
|
||||
|
||||
PIDController(const PIDController&) = delete;
|
||||
PIDController& operator=(const PIDController) = delete;
|
||||
|
||||
virtual float Get() const;
|
||||
virtual void SetContinuous(bool continuous = true);
|
||||
virtual void SetInputRange(float minimumInput, float maximumInput);
|
||||
@@ -111,6 +115,4 @@ class PIDController : public LiveWindowSendable,
|
||||
protected:
|
||||
::std::shared_ptr<ITable> m_table = nullptr;
|
||||
virtual void Calculate();
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(PIDController);
|
||||
};
|
||||
|
||||
@@ -25,6 +25,10 @@
|
||||
class Resource : public ErrorBase {
|
||||
public:
|
||||
virtual ~Resource() = default;
|
||||
|
||||
Resource(const Resource&) = delete;
|
||||
Resource& operator=(const Resource&) = delete;
|
||||
|
||||
static void CreateResourceObject(::std::unique_ptr<Resource>& r, uint32_t elements);
|
||||
explicit Resource(uint32_t size);
|
||||
uint32_t Allocate(const std::string &resourceDesc);
|
||||
@@ -36,6 +40,4 @@ class Resource : public ErrorBase {
|
||||
priority_recursive_mutex m_allocateLock;
|
||||
|
||||
static priority_recursive_mutex m_createLock;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(Resource);
|
||||
};
|
||||
|
||||
@@ -20,6 +20,10 @@ class SensorBase : public ErrorBase {
|
||||
public:
|
||||
SensorBase();
|
||||
virtual ~SensorBase() = default;
|
||||
|
||||
SensorBase(const SensorBase&) = delete;
|
||||
SensorBase& operator=(const SensorBase&) = delete;
|
||||
|
||||
static void DeleteSingletons();
|
||||
|
||||
static uint32_t GetDefaultSolenoidModule() { return 0; }
|
||||
@@ -51,7 +55,6 @@ class SensorBase : public ErrorBase {
|
||||
static void* m_pwm_ports[kPwmChannels];
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(SensorBase);
|
||||
static SensorBase* m_singletonList;
|
||||
SensorBase* m_nextSingleton;
|
||||
};
|
||||
|
||||
@@ -29,6 +29,10 @@ class Timer {
|
||||
public:
|
||||
Timer();
|
||||
virtual ~Timer() = default;
|
||||
|
||||
Timer(const Timer&) = delete;
|
||||
Timer& operator=(const Timer&) = delete;
|
||||
|
||||
double Get() const;
|
||||
void Reset();
|
||||
void Start();
|
||||
@@ -47,5 +51,4 @@ class Timer {
|
||||
double m_accumulatedTime = 0.0;
|
||||
bool m_running = false;
|
||||
mutable priority_mutex m_mutex;
|
||||
DISALLOW_COPY_AND_ASSIGN(Timer);
|
||||
};
|
||||
|
||||
@@ -54,6 +54,9 @@ class ADXL345_I2C : public Accelerometer,
|
||||
explicit ADXL345_I2C(Port port, Range range = kRange_2G);
|
||||
virtual ~ADXL345_I2C() = default;
|
||||
|
||||
ADXL345_I2C(const ADXL345_I2C&) = delete;
|
||||
ADXL345_I2C& operator=(const ADXL345_I2C&) = delete;
|
||||
|
||||
// Accelerometer interface
|
||||
virtual void SetRange(Range range) override;
|
||||
virtual double GetX() override;
|
||||
|
||||
@@ -58,6 +58,9 @@ class ADXL345_SPI : public Accelerometer,
|
||||
ADXL345_SPI(SPI::Port port, Range range = kRange_2G);
|
||||
virtual ~ADXL345_SPI() = default;
|
||||
|
||||
ADXL345_SPI(const ADXL345_SPI&) = delete;
|
||||
ADXL345_SPI& operator=(const ADXL345_SPI&) = delete;
|
||||
|
||||
// Accelerometer interface
|
||||
virtual void SetRange(Range range) override;
|
||||
virtual double GetX() override;
|
||||
|
||||
@@ -22,6 +22,9 @@ class I2C : SensorBase {
|
||||
I2C(Port port, uint8_t deviceAddress);
|
||||
virtual ~I2C();
|
||||
|
||||
I2C(const I2C&) = delete;
|
||||
I2C& operator=(const I2C&) = delete;
|
||||
|
||||
bool Transaction(uint8_t *dataToSend, uint8_t sendSize, uint8_t *dataReceived,
|
||||
uint8_t receiveSize);
|
||||
bool AddressOnly();
|
||||
|
||||
@@ -66,6 +66,9 @@ class Joystick : public GenericHID, public ErrorBase {
|
||||
Joystick(uint32_t port, uint32_t numAxisTypes, uint32_t numButtonTypes);
|
||||
virtual ~Joystick() = default;
|
||||
|
||||
Joystick(const Joystick&) = delete;
|
||||
Joystick& operator=(const Joystick&) = delete;
|
||||
|
||||
uint32_t GetAxisChannel(AxisType axis) const;
|
||||
void SetAxisChannel(AxisType axis, uint32_t channel);
|
||||
|
||||
@@ -103,8 +106,6 @@ class Joystick : public GenericHID, public ErrorBase {
|
||||
void SetOutputs(uint32_t value);
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(Joystick);
|
||||
|
||||
DriverStation &m_ds;
|
||||
uint32_t m_port;
|
||||
::std::vector<uint32_t> m_axes;
|
||||
|
||||
@@ -56,8 +56,11 @@ class RobotBase {
|
||||
static void robotSetup(RobotBase *robot);
|
||||
|
||||
protected:
|
||||
virtual ~RobotBase();
|
||||
RobotBase();
|
||||
virtual ~RobotBase();
|
||||
|
||||
RobotBase(const RobotBase&) = delete;
|
||||
RobotBase& operator=(const RobotBase&) = delete;
|
||||
|
||||
virtual void Prestart();
|
||||
|
||||
@@ -66,6 +69,4 @@ class RobotBase {
|
||||
|
||||
private:
|
||||
static RobotBase *m_instance;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(RobotBase);
|
||||
};
|
||||
|
||||
@@ -62,6 +62,9 @@ class RobotDrive : public MotorSafety, public ErrorBase {
|
||||
::std::shared_ptr<SpeedController> rearRightMotor);
|
||||
virtual ~RobotDrive() = default;
|
||||
|
||||
RobotDrive(const RobotDrive&) = delete;
|
||||
RobotDrive& operator=(const RobotDrive&) = delete;
|
||||
|
||||
void Drive(float outputMagnitude, float curve);
|
||||
void TankDrive(GenericHID *leftStick, GenericHID *rightStick,
|
||||
bool squaredInputs = true);
|
||||
@@ -127,5 +130,4 @@ class RobotDrive : public MotorSafety, public ErrorBase {
|
||||
if (m_rearRightMotor) motors++;
|
||||
return motors;
|
||||
}
|
||||
DISALLOW_COPY_AND_ASSIGN(RobotDrive);
|
||||
};
|
||||
|
||||
@@ -25,6 +25,9 @@ class SPI : public SensorBase {
|
||||
SPI(Port SPIport);
|
||||
virtual ~SPI();
|
||||
|
||||
SPI(const SPI&) = delete;
|
||||
SPI& operator=(const SPI&) = delete;
|
||||
|
||||
void SetClockRate(double hz);
|
||||
|
||||
void SetMSBFirst();
|
||||
@@ -52,6 +55,4 @@ class SPI : public SensorBase {
|
||||
|
||||
private:
|
||||
void Init();
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(SPI);
|
||||
};
|
||||
|
||||
@@ -48,6 +48,10 @@ class SerialPort : public ErrorBase {
|
||||
SerialPort(uint32_t baudRate, Port port = kOnboard, uint8_t dataBits = 8,
|
||||
Parity parity = kParity_None, StopBits stopBits = kStopBits_One);
|
||||
~SerialPort();
|
||||
|
||||
SerialPort(const SerialPort&) = delete;
|
||||
SerialPort& operator=(const SerialPort&) = delete;
|
||||
|
||||
void SetFlowControl(FlowControl flowControl);
|
||||
void EnableTermination(char terminator = '\n');
|
||||
void DisableTermination();
|
||||
@@ -66,6 +70,4 @@ class SerialPort : public ErrorBase {
|
||||
uint32_t m_portHandle = 0;
|
||||
bool m_consoleModeEnabled = false;
|
||||
uint8_t m_port;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(SerialPort);
|
||||
};
|
||||
|
||||
@@ -51,6 +51,9 @@ class AxisCamera : public ErrorBase {
|
||||
explicit AxisCamera(std::string const &cameraHost);
|
||||
virtual ~AxisCamera();
|
||||
|
||||
AxisCamera(const AxisCamera&) = delete;
|
||||
AxisCamera& operator=(const AxisCamera&) = delete;
|
||||
|
||||
bool IsFreshImage() const;
|
||||
|
||||
int GetImage(Image *image);
|
||||
@@ -116,6 +119,4 @@ class AxisCamera : public ErrorBase {
|
||||
bool WriteParameters();
|
||||
|
||||
int CreateCameraSocket(std::string const &requestString, bool setError);
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(AxisCamera);
|
||||
};
|
||||
|
||||
@@ -42,6 +42,9 @@ public:
|
||||
Joystick(uint32_t port, uint32_t numAxisTypes, uint32_t numButtonTypes);
|
||||
virtual ~Joystick() = default;
|
||||
|
||||
Joystick(const Joystick&) = delete;
|
||||
Joystick& operator=(const Joystick&) = delete;
|
||||
|
||||
uint32_t GetAxisChannel(AxisType axis);
|
||||
void SetAxisChannel(AxisType axis, uint32_t channel);
|
||||
|
||||
@@ -66,8 +69,6 @@ public:
|
||||
virtual float GetDirectionDegrees() const;
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(Joystick);
|
||||
|
||||
DriverStation *m_ds = nullptr;
|
||||
uint32_t m_port;
|
||||
std::unique_ptr<uint32_t[]> m_axes;
|
||||
|
||||
@@ -38,13 +38,14 @@ public:
|
||||
virtual void StartCompetition() = 0;
|
||||
|
||||
protected:
|
||||
virtual ~RobotBase() = default;
|
||||
RobotBase();
|
||||
virtual ~RobotBase() = default;
|
||||
|
||||
RobotBase(const RobotBase&) = delete;
|
||||
RobotBase& operator=(const RobotBase&) = delete;
|
||||
|
||||
DriverStation *m_ds;
|
||||
|
||||
private:
|
||||
static RobotBase *m_instance;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(RobotBase);
|
||||
};
|
||||
|
||||
@@ -43,6 +43,9 @@ public:
|
||||
SpeedController &frontRightMotor, SpeedController &rearRightMotor);
|
||||
virtual ~RobotDrive();
|
||||
|
||||
RobotDrive(const RobotDrive&) = delete;
|
||||
RobotDrive& operator=(const RobotDrive&) = delete;
|
||||
|
||||
void Drive(float outputMagnitude, float curve);
|
||||
void TankDrive(GenericHID *leftStick, GenericHID *rightStick, bool squaredInputs = true);
|
||||
void TankDrive(GenericHID &leftStick, GenericHID &rightStick, bool squaredInputs = true);
|
||||
@@ -106,5 +109,4 @@ private:
|
||||
motors++;
|
||||
return motors;
|
||||
}
|
||||
DISALLOW_COPY_AND_ASSIGN(RobotDrive);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user