Permalink
Browse files

Namespace all wpilibc functions/classes into "frc" namespace. (#311)

Base.h provides a backwards compatibility shim (enabled unless
NAMESPACED_WPILIB is defined) that does a "using namespace frc".
However, as some header files do not include Base.h, this may
be a breaking change in some corner cases (with an easy fix).

Fixes #218.
  • Loading branch information...
1 parent 36ad45c commit 59267da72b529b0ff177928f1fb710a01012e13b @PeterJohnson PeterJohnson committed on GitHub Nov 2, 2016
Showing 318 changed files with 988 additions and 10 deletions.
@@ -11,6 +11,7 @@ model {
targetPlatform 'arm'
binaries.all {
tasks.withType(CppCompile) {
+ cppCompiler.args "-DNAMESPACED_WPILIB"
addNiLibraryLinks(linker, targetPlatform)
addNetworkTablesLibraryLinks(it, linker, targetPlatform)
}
@@ -14,6 +14,8 @@
#include "LiveWindow/LiveWindowSendable.h"
#include "interfaces/Accelerometer.h"
+namespace frc {
+
/**
* ADXL345 Accelerometer on I2C.
*
@@ -81,3 +83,5 @@ class ADXL345_I2C : public Accelerometer, public LiveWindowSendable {
private:
std::shared_ptr<ITable> m_table;
};
+
+} // namespace frc
@@ -15,6 +15,8 @@
#include "SensorBase.h"
#include "interfaces/Accelerometer.h"
+namespace frc {
+
class DigitalInput;
class DigitalOutput;
@@ -83,3 +85,5 @@ class ADXL345_SPI : public Accelerometer, public LiveWindowSendable {
private:
std::shared_ptr<ITable> m_table;
};
+
+} // namespace frc
@@ -15,6 +15,8 @@
#include "SensorBase.h"
#include "interfaces/Accelerometer.h"
+namespace frc {
+
class DigitalInput;
class DigitalOutput;
@@ -62,3 +64,5 @@ class ADXL362 : public Accelerometer, public LiveWindowSendable {
std::shared_ptr<ITable> m_table;
};
+
+} // namespace frc
@@ -14,6 +14,8 @@
#include "Notifier.h"
#include "SPI.h"
+namespace frc {
+
/**
* Use a rate gyro to return the robots heading relative to a starting position.
* The Gyro class tracks the robots heading based on the starting position. As
@@ -41,3 +43,5 @@ class ADXRS450_Gyro : public GyroBase {
uint16_t ReadRegister(int reg);
};
+
+} // namespace frc
@@ -15,6 +15,8 @@
#include "PIDSource.h"
#include "SensorBase.h"
+namespace frc {
+
/**
* Handle operation of an analog accelerometer.
* The accelerometer reads acceleration directly through the sensor. Many
@@ -51,3 +53,5 @@ class AnalogAccelerometer : public SensorBase,
std::shared_ptr<ITable> m_table;
};
+
+} // namespace frc
@@ -12,6 +12,8 @@
#include "GyroBase.h"
#include "HAL/Types.h"
+namespace frc {
+
class AnalogInput;
/**
@@ -58,3 +60,5 @@ class AnalogGyro : public GyroBase {
private:
HAL_GyroHandle m_gyroHandle = HAL_kInvalidHandle;
};
+
+} // namespace frc
@@ -15,6 +15,8 @@
#include "PIDSource.h"
#include "SensorBase.h"
+namespace frc {
+
/**
* Analog input class.
*
@@ -87,3 +89,5 @@ class AnalogInput : public SensorBase,
std::shared_ptr<ITable> m_table;
};
+
+} // namespace frc
@@ -16,6 +16,8 @@
#include "LiveWindow/LiveWindowSendable.h"
#include "SensorBase.h"
+namespace frc {
+
/**
* MXP analog output class.
*/
@@ -40,3 +42,5 @@ class AnalogOutput : public SensorBase, public LiveWindowSendable {
std::shared_ptr<ITable> m_table;
};
+
+} // namespace frc
@@ -14,6 +14,8 @@
#include "LiveWindow/LiveWindowSendable.h"
#include "interfaces/Potentiometer.h"
+namespace frc {
+
/**
* Class for reading analog potentiometers. Analog potentiometers read
* in an analog voltage that corresponds to a position. The position is
@@ -90,3 +92,5 @@ class AnalogPotentiometer : public Potentiometer, public LiveWindowSendable {
double m_fullRange, m_offset;
std::shared_ptr<ITable> m_table;
};
+
+} // namespace frc
@@ -13,6 +13,8 @@
#include "HAL/Types.h"
#include "SensorBase.h"
+namespace frc {
+
class AnalogInput;
class AnalogTrigger : public SensorBase {
@@ -39,3 +41,5 @@ class AnalogTrigger : public SensorBase {
AnalogInput* m_analogInput = nullptr;
bool m_ownsAnalog = false;
};
+
+} // namespace frc
@@ -10,6 +10,8 @@
#include "DigitalSource.h"
#include "HAL/AnalogTrigger.h"
+namespace frc {
+
class AnalogTrigger;
/**
@@ -67,3 +69,5 @@ class AnalogTriggerOutput : public DigitalSource {
const AnalogTrigger& m_trigger;
AnalogTriggerType m_outputType;
};
+
+} // namespace frc
@@ -7,9 +7,13 @@
#pragma once
+namespace frc {
+
enum class AnalogTriggerType {
kInWindow = 0,
kState = 1,
kRisingPulse = 2,
kFallingPulse = 3
};
+
+} // namespace frc
@@ -14,6 +14,8 @@
#include "SensorBase.h"
#include "interfaces/Accelerometer.h"
+namespace frc {
+
/**
* Built-in accelerometer.
*
@@ -42,3 +44,5 @@ class BuiltInAccelerometer : public Accelerometer,
private:
std::shared_ptr<ITable> m_table;
};
+
+} // namespace frc
@@ -9,6 +9,8 @@
#include "SpeedController.h"
+namespace frc {
+
/**
* Interface for "smart" CAN-based speed controllers.
*/
@@ -98,3 +100,5 @@ class CANSpeedController : public SpeedController {
// virtual void SetControlMode(ControlMode mode) = 0;
// virtual ControlMode GetControlMode() const = 0;
};
+
+} // namespace frc
@@ -19,6 +19,8 @@
#include "USBCamera.h"
#include "nivision.h"
+namespace frc {
+
class CameraServer : public ErrorBase {
private:
static constexpr uint16_t kPort = 1180;
@@ -80,3 +82,5 @@ class CameraServer : public ErrorBase {
void SetSize(int size);
};
+
+} // namespace frc
@@ -15,6 +15,8 @@
#include "SensorBase.h"
#include "tables/ITableListener.h"
+namespace frc {
+
/**
* PCM compressor
*/
@@ -63,3 +65,5 @@ class Compressor : public SensorBase,
std::shared_ptr<ITable> m_table;
};
+
+} // namespace frc
@@ -7,6 +7,8 @@
#pragma once
+namespace frc {
+
class ControllerPower {
public:
static float GetInputVoltage();
@@ -24,3 +26,5 @@ class ControllerPower {
static bool GetEnabled6V();
static int GetFaultCount6V();
};
+
+} // namespace frc
@@ -17,6 +17,8 @@
#include "LiveWindow/LiveWindowSendable.h"
#include "SensorBase.h"
+namespace frc {
+
class DigitalGlitchFilter;
/**
@@ -113,3 +115,5 @@ class Counter : public SensorBase,
std::shared_ptr<ITable> m_table;
friend class DigitalGlitchFilter;
};
+
+} // namespace frc
@@ -9,6 +9,8 @@
#include <stdint.h>
+namespace frc {
+
/**
* Interface for counting the number of ticks on a digital input channel.
* Encoders, Gear tooth sensors, and counters should all subclass this so it can
@@ -29,3 +31,5 @@ class CounterBase {
virtual bool GetStopped() const = 0;
virtual bool GetDirection() const = 0;
};
+
+} // namespace frc
@@ -12,6 +12,8 @@
#include "DigitalSource.h"
#include "HAL/cpp/priority_mutex.h"
+namespace frc {
+
class Encoder;
class Counter;
@@ -50,3 +52,5 @@ class DigitalGlitchFilter : public SensorBase {
static priority_mutex m_mutex;
static ::std::array<bool, 3> m_filterAllocated;
};
+
+} // namespace frc
@@ -15,6 +15,8 @@
#include "DigitalSource.h"
#include "LiveWindow/LiveWindowSendable.h"
+namespace frc {
+
class DigitalGlitchFilter;
/**
@@ -51,3 +53,5 @@ class DigitalInput : public DigitalSource, public LiveWindowSendable {
std::shared_ptr<ITable> m_table;
friend class DigitalGlitchFilter;
};
+
+} // namespace frc
@@ -15,6 +15,8 @@
#include "LiveWindow/LiveWindowSendable.h"
#include "tables/ITableListener.h"
+namespace frc {
+
/**
* Class to write to digital outputs.
* Write values to the digital output channels. Other devices implemented
@@ -58,3 +60,5 @@ class DigitalOutput : public DigitalSource,
std::shared_ptr<ITable> m_table;
};
+
+} // namespace frc
@@ -10,6 +10,8 @@
#include "HAL/Types.h"
#include "InterruptableSensorBase.h"
+namespace frc {
+
/**
* DigitalSource Interface.
* The DigitalSource represents all the possible inputs for a counter or a
@@ -28,3 +30,5 @@ class DigitalSource : public InterruptableSensorBase {
virtual bool IsAnalogTrigger() const = 0;
virtual int GetChannel() const = 0;
};
+
+} // namespace frc
@@ -15,6 +15,8 @@
#include "SolenoidBase.h"
#include "tables/ITableListener.h"
+namespace frc {
+
/**
* DoubleSolenoid class for running 2 channels of high voltage Digital Output
* (PCM).
@@ -55,3 +57,5 @@ class DoubleSolenoid : public SolenoidBase,
std::shared_ptr<ITable> m_table;
};
+
+} // namespace frc
@@ -19,6 +19,8 @@
#include "RobotState.h"
#include "SensorBase.h"
+namespace frc {
+
/**
* Provide access to the network communication data to / from the Driver
* Station.
@@ -137,3 +139,5 @@ class DriverStation : public SensorBase, public RobotStateInterface {
double m_nextMessageTime = 0;
};
+
+} // namespace frc
@@ -17,6 +17,8 @@
#include "PIDSource.h"
#include "SensorBase.h"
+namespace frc {
+
class DigitalSource;
class DigitalGlitchFilter;
@@ -105,3 +107,5 @@ class Encoder : public SensorBase,
std::shared_ptr<ITable> m_table;
friend class DigitalGlitchFilter;
};
+
+} // namespace frc
Oops, something went wrong.

0 comments on commit 59267da

Please sign in to comment.