[wpilibc] Move NullDeleter from frc/Base.h to wpi/NullDeleter.h (#3387)

frc/Base.h was also deleted because it's now empty.
This commit is contained in:
Tyler Veness
2021-05-26 07:24:53 -07:00
committed by GitHub
parent cb0051ae60
commit f4e2d26d58
16 changed files with 48 additions and 51 deletions

View File

@@ -10,7 +10,6 @@
#include <wpi/deprecated.h>
#include <wpi/mutex.h>
#include "frc/Base.h"
#include "frc/LinearFilter.h"
#include "frc/PIDInterface.h"
#include "frc/PIDOutput.h"

View File

@@ -10,7 +10,6 @@
#include <wpi/deprecated.h>
#include <wpi/mutex.h>
#include "frc/Base.h"
#include "frc/Controller.h"
#include "frc/Notifier.h"
#include "frc/PIDBase.h"

View File

@@ -4,8 +4,6 @@
#pragma once
#include "frc/Base.h"
namespace frc {
/**

View File

@@ -5,8 +5,8 @@
#include "frc/AnalogAccelerometer.h"
#include <hal/FRCUsageReporting.h>
#include <wpi/NullDeleter.h>
#include "frc/Base.h"
#include "frc/Errors.h"
#include "frc/smartdashboard/SendableBuilder.h"
#include "frc/smartdashboard/SendableRegistry.h"
@@ -19,7 +19,7 @@ AnalogAccelerometer::AnalogAccelerometer(int channel)
}
AnalogAccelerometer::AnalogAccelerometer(AnalogInput* channel)
: m_analogInput(channel, NullDeleter<AnalogInput>()) {
: m_analogInput(channel, wpi::NullDeleter<AnalogInput>()) {
if (!channel) {
throw FRC_MakeError(err::NullParameter, "{}", "channel");
}

View File

@@ -4,8 +4,9 @@
#include "frc/AnalogEncoder.h"
#include <wpi/NullDeleter.h>
#include "frc/AnalogInput.h"
#include "frc/Base.h"
#include "frc/Counter.h"
#include "frc/Errors.h"
#include "frc/smartdashboard/SendableBuilder.h"
@@ -16,14 +17,14 @@ AnalogEncoder::AnalogEncoder(int channel)
: AnalogEncoder(std::make_shared<AnalogInput>(channel)) {}
AnalogEncoder::AnalogEncoder(AnalogInput& analogInput)
: m_analogInput{&analogInput, NullDeleter<AnalogInput>{}},
: m_analogInput{&analogInput, wpi::NullDeleter<AnalogInput>{}},
m_analogTrigger{m_analogInput.get()},
m_counter{} {
Init();
}
AnalogEncoder::AnalogEncoder(AnalogInput* analogInput)
: m_analogInput{analogInput, NullDeleter<AnalogInput>{}},
: m_analogInput{analogInput, wpi::NullDeleter<AnalogInput>{}},
m_analogTrigger{m_analogInput.get()},
m_counter{} {
Init();

View File

@@ -10,10 +10,10 @@
#include <hal/AnalogGyro.h>
#include <hal/Errors.h>
#include <hal/FRCUsageReporting.h>
#include <wpi/NullDeleter.h>
#include <wpi/StackTrace.h>
#include "frc/AnalogInput.h"
#include "frc/Base.h"
#include "frc/Errors.h"
#include "frc/Timer.h"
#include "frc/smartdashboard/SendableBuilder.h"
@@ -27,8 +27,8 @@ AnalogGyro::AnalogGyro(int channel)
}
AnalogGyro::AnalogGyro(AnalogInput* channel)
: AnalogGyro(
std::shared_ptr<AnalogInput>(channel, NullDeleter<AnalogInput>())) {}
: AnalogGyro(std::shared_ptr<AnalogInput>(
channel, wpi::NullDeleter<AnalogInput>())) {}
AnalogGyro::AnalogGyro(std::shared_ptr<AnalogInput> channel)
: m_analog(channel) {

View File

@@ -6,7 +6,8 @@
#include <utility>
#include "frc/Base.h"
#include <wpi/NullDeleter.h>
#include "frc/RobotController.h"
#include "frc/smartdashboard/SendableBuilder.h"
#include "frc/smartdashboard/SendableRegistry.h"
@@ -23,7 +24,7 @@ AnalogPotentiometer::AnalogPotentiometer(int channel, double fullRange,
AnalogPotentiometer::AnalogPotentiometer(AnalogInput* input, double fullRange,
double offset)
: AnalogPotentiometer(
std::shared_ptr<AnalogInput>(input, NullDeleter<AnalogInput>()),
std::shared_ptr<AnalogInput>(input, wpi::NullDeleter<AnalogInput>()),
fullRange, offset) {}
AnalogPotentiometer::AnalogPotentiometer(std::shared_ptr<AnalogInput> input,

View File

@@ -7,9 +7,9 @@
#include <utility>
#include <hal/FRCUsageReporting.h>
#include <wpi/NullDeleter.h>
#include "frc/AnalogInput.h"
#include "frc/Base.h"
#include "frc/DutyCycle.h"
#include "frc/Errors.h"
#include "frc/smartdashboard/SendableRegistry.h"
@@ -108,7 +108,8 @@ bool AnalogTrigger::GetTriggerState() {
std::shared_ptr<AnalogTriggerOutput> AnalogTrigger::CreateOutput(
AnalogTriggerType type) const {
return std::shared_ptr<AnalogTriggerOutput>(
new AnalogTriggerOutput(*this, type), NullDeleter<AnalogTriggerOutput>());
new AnalogTriggerOutput(*this, type),
wpi::NullDeleter<AnalogTriggerOutput>());
}
void AnalogTrigger::InitSendable(SendableBuilder& builder) {

View File

@@ -8,9 +8,9 @@
#include <hal/Counter.h>
#include <hal/FRCUsageReporting.h>
#include <wpi/NullDeleter.h>
#include "frc/AnalogTrigger.h"
#include "frc/Base.h"
#include "frc/DigitalInput.h"
#include "frc/Errors.h"
#include "frc/smartdashboard/SendableBuilder.h"
@@ -54,9 +54,9 @@ Counter::Counter(EncodingType encodingType, DigitalSource* upSource,
DigitalSource* downSource, bool inverted)
: Counter(encodingType,
std::shared_ptr<DigitalSource>(upSource,
NullDeleter<DigitalSource>()),
wpi::NullDeleter<DigitalSource>()),
std::shared_ptr<DigitalSource>(downSource,
NullDeleter<DigitalSource>()),
wpi::NullDeleter<DigitalSource>()),
inverted) {}
Counter::Counter(EncodingType encodingType,
@@ -103,7 +103,7 @@ void Counter::SetUpSource(int channel) {
void Counter::SetUpSource(AnalogTrigger* analogTrigger,
AnalogTriggerType triggerType) {
SetUpSource(std::shared_ptr<AnalogTrigger>(analogTrigger,
NullDeleter<AnalogTrigger>()),
wpi::NullDeleter<AnalogTrigger>()),
triggerType);
}
@@ -113,8 +113,8 @@ void Counter::SetUpSource(std::shared_ptr<AnalogTrigger> analogTrigger,
}
void Counter::SetUpSource(DigitalSource* source) {
SetUpSource(
std::shared_ptr<DigitalSource>(source, NullDeleter<DigitalSource>()));
SetUpSource(std::shared_ptr<DigitalSource>(
source, wpi::NullDeleter<DigitalSource>()));
}
void Counter::SetUpSource(std::shared_ptr<DigitalSource> source) {
@@ -128,8 +128,8 @@ void Counter::SetUpSource(std::shared_ptr<DigitalSource> source) {
}
void Counter::SetUpSource(DigitalSource& source) {
SetUpSource(
std::shared_ptr<DigitalSource>(&source, NullDeleter<DigitalSource>()));
SetUpSource(std::shared_ptr<DigitalSource>(
&source, wpi::NullDeleter<DigitalSource>()));
}
void Counter::SetUpSourceEdge(bool risingEdge, bool fallingEdge) {
@@ -157,8 +157,8 @@ void Counter::SetDownSource(int channel) {
void Counter::SetDownSource(AnalogTrigger* analogTrigger,
AnalogTriggerType triggerType) {
SetDownSource(std::shared_ptr<AnalogTrigger>(analogTrigger,
NullDeleter<AnalogTrigger>()),
SetDownSource(std::shared_ptr<AnalogTrigger>(
analogTrigger, wpi::NullDeleter<AnalogTrigger>()),
triggerType);
}
@@ -168,13 +168,13 @@ void Counter::SetDownSource(std::shared_ptr<AnalogTrigger> analogTrigger,
}
void Counter::SetDownSource(DigitalSource* source) {
SetDownSource(
std::shared_ptr<DigitalSource>(source, NullDeleter<DigitalSource>()));
SetDownSource(std::shared_ptr<DigitalSource>(
source, wpi::NullDeleter<DigitalSource>()));
}
void Counter::SetDownSource(DigitalSource& source) {
SetDownSource(
std::shared_ptr<DigitalSource>(&source, NullDeleter<DigitalSource>()));
SetDownSource(std::shared_ptr<DigitalSource>(
&source, wpi::NullDeleter<DigitalSource>()));
}
void Counter::SetDownSource(std::shared_ptr<DigitalSource> source) {

View File

@@ -6,8 +6,8 @@
#include <hal/DutyCycle.h>
#include <hal/FRCUsageReporting.h>
#include <wpi/NullDeleter.h>
#include "frc/Base.h"
#include "frc/DigitalSource.h"
#include "frc/Errors.h"
#include "frc/smartdashboard/SendableBuilder.h"
@@ -15,7 +15,7 @@
using namespace frc;
DutyCycle::DutyCycle(DigitalSource* source)
: m_source{source, NullDeleter<DigitalSource>()} {
: m_source{source, wpi::NullDeleter<DigitalSource>()} {
if (!m_source) {
throw FRC_MakeError(err::NullParameter, "{}", "source");
}
@@ -23,7 +23,7 @@ DutyCycle::DutyCycle(DigitalSource* source)
}
DutyCycle::DutyCycle(DigitalSource& source)
: m_source{&source, NullDeleter<DigitalSource>()} {
: m_source{&source, wpi::NullDeleter<DigitalSource>()} {
InitDutyCycle();
}

View File

@@ -4,7 +4,8 @@
#include "frc/DutyCycleEncoder.h"
#include "frc/Base.h"
#include <wpi/NullDeleter.h>
#include "frc/Counter.h"
#include "frc/DigitalInput.h"
#include "frc/DigitalSource.h"
@@ -21,12 +22,12 @@ DutyCycleEncoder::DutyCycleEncoder(int channel)
}
DutyCycleEncoder::DutyCycleEncoder(DutyCycle& dutyCycle)
: m_dutyCycle{&dutyCycle, NullDeleter<DutyCycle>{}} {
: m_dutyCycle{&dutyCycle, wpi::NullDeleter<DutyCycle>{}} {
Init();
}
DutyCycleEncoder::DutyCycleEncoder(DutyCycle* dutyCycle)
: m_dutyCycle{dutyCycle, NullDeleter<DutyCycle>{}} {
: m_dutyCycle{dutyCycle, wpi::NullDeleter<DutyCycle>{}} {
Init();
}

View File

@@ -8,8 +8,8 @@
#include <hal/Encoder.h>
#include <hal/FRCUsageReporting.h>
#include <wpi/NullDeleter.h>
#include "frc/Base.h"
#include "frc/DigitalInput.h"
#include "frc/Errors.h"
#include "frc/smartdashboard/SendableBuilder.h"
@@ -29,8 +29,8 @@ Encoder::Encoder(int aChannel, int bChannel, bool reverseDirection,
Encoder::Encoder(DigitalSource* aSource, DigitalSource* bSource,
bool reverseDirection, EncodingType encodingType)
: m_aSource(aSource, NullDeleter<DigitalSource>()),
m_bSource(bSource, NullDeleter<DigitalSource>()) {
: m_aSource(aSource, wpi::NullDeleter<DigitalSource>()),
m_bSource(bSource, wpi::NullDeleter<DigitalSource>()) {
if (!m_aSource) {
throw FRC_MakeError(err::NullParameter, "{}", "aSource");
}
@@ -42,8 +42,8 @@ Encoder::Encoder(DigitalSource* aSource, DigitalSource* bSource,
Encoder::Encoder(DigitalSource& aSource, DigitalSource& bSource,
bool reverseDirection, EncodingType encodingType)
: m_aSource(&aSource, NullDeleter<DigitalSource>()),
m_bSource(&bSource, NullDeleter<DigitalSource>()) {
: m_aSource(&aSource, wpi::NullDeleter<DigitalSource>()),
m_bSource(&bSource, wpi::NullDeleter<DigitalSource>()) {
InitEncoder(reverseDirection, encodingType);
}

View File

@@ -7,8 +7,8 @@
#include <utility>
#include <hal/FRCUsageReporting.h>
#include <wpi/NullDeleter.h>
#include "frc/Base.h"
#include "frc/Counter.h"
#include "frc/DigitalInput.h"
#include "frc/DigitalOutput.h"
@@ -36,8 +36,8 @@ Ultrasonic::Ultrasonic(int pingChannel, int echoChannel)
}
Ultrasonic::Ultrasonic(DigitalOutput* pingChannel, DigitalInput* echoChannel)
: m_pingChannel(pingChannel, NullDeleter<DigitalOutput>()),
m_echoChannel(echoChannel, NullDeleter<DigitalInput>()),
: m_pingChannel(pingChannel, wpi::NullDeleter<DigitalOutput>()),
m_echoChannel(echoChannel, wpi::NullDeleter<DigitalInput>()),
m_counter(m_echoChannel) {
if (!pingChannel) {
throw FRC_MakeError(err::NullParameter, "{}", "pingChannel");
@@ -49,8 +49,8 @@ Ultrasonic::Ultrasonic(DigitalOutput* pingChannel, DigitalInput* echoChannel)
}
Ultrasonic::Ultrasonic(DigitalOutput& pingChannel, DigitalInput& echoChannel)
: m_pingChannel(&pingChannel, NullDeleter<DigitalOutput>()),
m_echoChannel(&echoChannel, NullDeleter<DigitalInput>()),
: m_pingChannel(&pingChannel, wpi::NullDeleter<DigitalOutput>()),
m_echoChannel(&echoChannel, wpi::NullDeleter<DigitalInput>()),
m_counter(m_echoChannel) {
Initialize();
}

View File

@@ -10,7 +10,6 @@
#include <hal/FRCUsageReporting.h>
#include "frc/Base.h"
#include "frc/motorcontrol/MotorController.h"
using namespace frc;

View File

@@ -13,7 +13,6 @@
#include <wpi/mutex.h>
#include <wpi/raw_ostream.h>
#include "frc/Base.h"
#include "frc/Errors.h"
namespace frc {

View File

@@ -4,8 +4,7 @@
#pragma once
/** WPILib FRC namespace */
namespace frc {
namespace wpi {
// A struct to use as a deleter when a std::shared_ptr must wrap a raw pointer
// that is being deleted by someone else.
@@ -14,4 +13,4 @@ struct NullDeleter {
void operator()(T*) const noexcept {};
};
} // namespace frc
} // namespace wpi