mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-23 01:21:42 +00:00
[wpiutil] Struct: Change from GetTypeString() to GetTypeName() (#6872)
This makes it easier to define schemas when the type name is non-trivial (e.g., templated structs). This is breaking for a) custom struct implementations and b) anything calling `wpi::Struct<T>::GetTypeString(info...)` in C++ directly. In both cases, it's a simple translation: For A, rename `GetTypeString()` to `GetTypeName()` and remove the struct: at the beginning, and for B, use `wpi::GetStructTypeString<T>(info...)` instead.
This commit is contained in:
@@ -11,9 +11,7 @@
|
||||
|
||||
template <>
|
||||
struct WPILIB_DLLEXPORT wpi::Struct<frc::ArmFeedforward> {
|
||||
static constexpr std::string_view GetTypeString() {
|
||||
return "struct:ArmFeedforward";
|
||||
}
|
||||
static constexpr std::string_view GetTypeName() { return "ArmFeedforward"; }
|
||||
static constexpr size_t GetSize() { return 32; }
|
||||
static constexpr std::string_view GetSchema() {
|
||||
return "double ks;double kg;double kv;double ka";
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
|
||||
template <>
|
||||
struct WPILIB_DLLEXPORT wpi::Struct<frc::DifferentialDriveWheelVoltages> {
|
||||
static constexpr std::string_view GetTypeString() {
|
||||
return "struct:DifferentialDriveWheelVoltages";
|
||||
static constexpr std::string_view GetTypeName() {
|
||||
return "DifferentialDriveWheelVoltages";
|
||||
}
|
||||
static constexpr size_t GetSize() { return 16; }
|
||||
static constexpr std::string_view GetSchema() {
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
|
||||
template <>
|
||||
struct WPILIB_DLLEXPORT wpi::Struct<frc::ElevatorFeedforward> {
|
||||
static constexpr std::string_view GetTypeString() {
|
||||
return "struct:ElevatorFeedforward";
|
||||
static constexpr std::string_view GetTypeName() {
|
||||
return "ElevatorFeedforward";
|
||||
}
|
||||
static constexpr size_t GetSize() { return 32; }
|
||||
static constexpr std::string_view GetSchema() {
|
||||
|
||||
@@ -11,9 +11,7 @@
|
||||
|
||||
template <>
|
||||
struct WPILIB_DLLEXPORT wpi::Struct<frc::Ellipse2d> {
|
||||
static constexpr std::string_view GetTypeString() {
|
||||
return "struct:Ellipse2d";
|
||||
}
|
||||
static constexpr std::string_view GetTypeName() { return "Ellipse2d"; }
|
||||
static constexpr size_t GetSize() {
|
||||
return wpi::GetStructSize<frc::Pose2d>() + 16;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
template <>
|
||||
struct WPILIB_DLLEXPORT wpi::Struct<frc::Pose2d> {
|
||||
static constexpr std::string_view GetTypeString() { return "struct:Pose2d"; }
|
||||
static constexpr std::string_view GetTypeName() { return "Pose2d"; }
|
||||
static constexpr size_t GetSize() {
|
||||
return wpi::GetStructSize<frc::Translation2d>() +
|
||||
wpi::GetStructSize<frc::Rotation2d>();
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
template <>
|
||||
struct WPILIB_DLLEXPORT wpi::Struct<frc::Pose3d> {
|
||||
static constexpr std::string_view GetTypeString() { return "struct:Pose3d"; }
|
||||
static constexpr std::string_view GetTypeName() { return "Pose3d"; }
|
||||
static constexpr size_t GetSize() {
|
||||
return wpi::GetStructSize<frc::Translation3d>() +
|
||||
wpi::GetStructSize<frc::Rotation3d>();
|
||||
|
||||
@@ -11,9 +11,7 @@
|
||||
|
||||
template <>
|
||||
struct WPILIB_DLLEXPORT wpi::Struct<frc::Quaternion> {
|
||||
static constexpr std::string_view GetTypeString() {
|
||||
return "struct:Quaternion";
|
||||
}
|
||||
static constexpr std::string_view GetTypeName() { return "Quaternion"; }
|
||||
static constexpr size_t GetSize() { return 32; }
|
||||
static constexpr std::string_view GetSchema() {
|
||||
return "double w;double x;double y;double z";
|
||||
|
||||
@@ -11,9 +11,7 @@
|
||||
|
||||
template <>
|
||||
struct WPILIB_DLLEXPORT wpi::Struct<frc::Rectangle2d> {
|
||||
static constexpr std::string_view GetTypeString() {
|
||||
return "struct:Rectangle2d";
|
||||
}
|
||||
static constexpr std::string_view GetTypeName() { return "Rectangle2d"; }
|
||||
static constexpr size_t GetSize() {
|
||||
return wpi::GetStructSize<frc::Pose2d>() + 16;
|
||||
}
|
||||
|
||||
@@ -11,9 +11,7 @@
|
||||
|
||||
template <>
|
||||
struct WPILIB_DLLEXPORT wpi::Struct<frc::Rotation2d> {
|
||||
static constexpr std::string_view GetTypeString() {
|
||||
return "struct:Rotation2d";
|
||||
}
|
||||
static constexpr std::string_view GetTypeName() { return "Rotation2d"; }
|
||||
static constexpr size_t GetSize() { return 8; }
|
||||
static constexpr std::string_view GetSchema() { return "double value"; }
|
||||
|
||||
|
||||
@@ -11,9 +11,7 @@
|
||||
|
||||
template <>
|
||||
struct WPILIB_DLLEXPORT wpi::Struct<frc::Rotation3d> {
|
||||
static constexpr std::string_view GetTypeString() {
|
||||
return "struct:Rotation3d";
|
||||
}
|
||||
static constexpr std::string_view GetTypeName() { return "Rotation3d"; }
|
||||
static constexpr size_t GetSize() {
|
||||
return wpi::GetStructSize<frc::Quaternion>();
|
||||
}
|
||||
|
||||
@@ -11,9 +11,7 @@
|
||||
|
||||
template <>
|
||||
struct WPILIB_DLLEXPORT wpi::Struct<frc::Transform2d> {
|
||||
static constexpr std::string_view GetTypeString() {
|
||||
return "struct:Transform2d";
|
||||
}
|
||||
static constexpr std::string_view GetTypeName() { return "Transform2d"; }
|
||||
static constexpr size_t GetSize() {
|
||||
return wpi::GetStructSize<frc::Translation2d>() +
|
||||
wpi::GetStructSize<frc::Rotation2d>();
|
||||
|
||||
@@ -11,9 +11,7 @@
|
||||
|
||||
template <>
|
||||
struct WPILIB_DLLEXPORT wpi::Struct<frc::Transform3d> {
|
||||
static constexpr std::string_view GetTypeString() {
|
||||
return "struct:Transform3d";
|
||||
}
|
||||
static constexpr std::string_view GetTypeName() { return "Transform3d"; }
|
||||
static constexpr size_t GetSize() {
|
||||
return wpi::GetStructSize<frc::Translation3d>() +
|
||||
wpi::GetStructSize<frc::Rotation3d>();
|
||||
|
||||
@@ -11,9 +11,7 @@
|
||||
|
||||
template <>
|
||||
struct WPILIB_DLLEXPORT wpi::Struct<frc::Translation2d> {
|
||||
static constexpr std::string_view GetTypeString() {
|
||||
return "struct:Translation2d";
|
||||
}
|
||||
static constexpr std::string_view GetTypeName() { return "Translation2d"; }
|
||||
static constexpr size_t GetSize() { return 16; }
|
||||
static constexpr std::string_view GetSchema() { return "double x;double y"; }
|
||||
|
||||
|
||||
@@ -11,9 +11,7 @@
|
||||
|
||||
template <>
|
||||
struct WPILIB_DLLEXPORT wpi::Struct<frc::Translation3d> {
|
||||
static constexpr std::string_view GetTypeString() {
|
||||
return "struct:Translation3d";
|
||||
}
|
||||
static constexpr std::string_view GetTypeName() { return "Translation3d"; }
|
||||
static constexpr size_t GetSize() { return 24; }
|
||||
static constexpr std::string_view GetSchema() {
|
||||
return "double x;double y;double z";
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
template <>
|
||||
struct WPILIB_DLLEXPORT wpi::Struct<frc::Twist2d> {
|
||||
static constexpr std::string_view GetTypeString() { return "struct:Twist2d"; }
|
||||
static constexpr std::string_view GetTypeName() { return "Twist2d"; }
|
||||
static constexpr size_t GetSize() { return 24; }
|
||||
static constexpr std::string_view GetSchema() {
|
||||
return "double dx;double dy;double dtheta";
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
template <>
|
||||
struct WPILIB_DLLEXPORT wpi::Struct<frc::Twist3d> {
|
||||
static constexpr std::string_view GetTypeString() { return "struct:Twist3d"; }
|
||||
static constexpr std::string_view GetTypeName() { return "Twist3d"; }
|
||||
static constexpr size_t GetSize() { return 48; }
|
||||
static constexpr std::string_view GetSchema() {
|
||||
return "double dx;double dy;double dz;double rx;double ry;double rz";
|
||||
|
||||
@@ -11,9 +11,7 @@
|
||||
|
||||
template <>
|
||||
struct WPILIB_DLLEXPORT wpi::Struct<frc::ChassisSpeeds> {
|
||||
static constexpr std::string_view GetTypeString() {
|
||||
return "struct:ChassisSpeeds";
|
||||
}
|
||||
static constexpr std::string_view GetTypeName() { return "ChassisSpeeds"; }
|
||||
static constexpr size_t GetSize() { return 24; }
|
||||
static constexpr std::string_view GetSchema() {
|
||||
return "double vx;double vy;double omega";
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
|
||||
template <>
|
||||
struct WPILIB_DLLEXPORT wpi::Struct<frc::DifferentialDriveKinematics> {
|
||||
static constexpr std::string_view GetTypeString() {
|
||||
return "struct:DifferentialDriveKinematics";
|
||||
static constexpr std::string_view GetTypeName() {
|
||||
return "DifferentialDriveKinematics";
|
||||
}
|
||||
static constexpr size_t GetSize() { return 8; }
|
||||
static constexpr std::string_view GetSchema() { return "double track_width"; }
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
|
||||
template <>
|
||||
struct WPILIB_DLLEXPORT wpi::Struct<frc::DifferentialDriveWheelPositions> {
|
||||
static constexpr std::string_view GetTypeString() {
|
||||
return "struct:DifferentialDriveWheelPositions";
|
||||
static constexpr std::string_view GetTypeName() {
|
||||
return "DifferentialDriveWheelPositions";
|
||||
}
|
||||
static constexpr size_t GetSize() { return 16; }
|
||||
static constexpr std::string_view GetSchema() {
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
|
||||
template <>
|
||||
struct WPILIB_DLLEXPORT wpi::Struct<frc::DifferentialDriveWheelSpeeds> {
|
||||
static constexpr std::string_view GetTypeString() {
|
||||
return "struct:DifferentialDriveWheelSpeeds";
|
||||
static constexpr std::string_view GetTypeName() {
|
||||
return "DifferentialDriveWheelSpeeds";
|
||||
}
|
||||
static constexpr size_t GetSize() { return 16; }
|
||||
static constexpr std::string_view GetSchema() {
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
|
||||
template <>
|
||||
struct WPILIB_DLLEXPORT wpi::Struct<frc::MecanumDriveKinematics> {
|
||||
static constexpr std::string_view GetTypeString() {
|
||||
return "struct:MecanumDriveKinematics";
|
||||
static constexpr std::string_view GetTypeName() {
|
||||
return "MecanumDriveKinematics";
|
||||
}
|
||||
static constexpr size_t GetSize() {
|
||||
return 4 * wpi::GetStructSize<frc::Translation2d>();
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
|
||||
template <>
|
||||
struct WPILIB_DLLEXPORT wpi::Struct<frc::MecanumDriveWheelPositions> {
|
||||
static constexpr std::string_view GetTypeString() {
|
||||
return "struct:MecanumDriveWheelPositions";
|
||||
static constexpr std::string_view GetTypeName() {
|
||||
return "MecanumDriveWheelPositions";
|
||||
}
|
||||
static constexpr size_t GetSize() { return 32; }
|
||||
static constexpr std::string_view GetSchema() {
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
|
||||
template <>
|
||||
struct WPILIB_DLLEXPORT wpi::Struct<frc::MecanumDriveWheelSpeeds> {
|
||||
static constexpr std::string_view GetTypeString() {
|
||||
return "struct:MecanumDriveWheelSpeeds";
|
||||
static constexpr std::string_view GetTypeName() {
|
||||
return "MecanumDriveWheelSpeeds";
|
||||
}
|
||||
static constexpr size_t GetSize() { return 32; }
|
||||
static constexpr std::string_view GetSchema() {
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
|
||||
template <>
|
||||
struct WPILIB_DLLEXPORT wpi::Struct<frc::SwerveModulePosition> {
|
||||
static constexpr std::string_view GetTypeString() {
|
||||
return "struct:SwerveModulePosition";
|
||||
static constexpr std::string_view GetTypeName() {
|
||||
return "SwerveModulePosition";
|
||||
}
|
||||
static constexpr size_t GetSize() {
|
||||
return 8 + wpi::GetStructSize<frc::Rotation2d>();
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
|
||||
template <>
|
||||
struct WPILIB_DLLEXPORT wpi::Struct<frc::SwerveModuleState> {
|
||||
static constexpr std::string_view GetTypeString() {
|
||||
return "struct:SwerveModuleState";
|
||||
static constexpr std::string_view GetTypeName() {
|
||||
return "SwerveModuleState";
|
||||
}
|
||||
static constexpr size_t GetSize() {
|
||||
return 8 + wpi::GetStructSize<frc::Rotation2d>();
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
template <>
|
||||
struct WPILIB_DLLEXPORT wpi::Struct<frc::DCMotor> {
|
||||
static constexpr std::string_view GetTypeString() { return "struct:DCMotor"; }
|
||||
static constexpr std::string_view GetTypeName() { return "DCMotor"; }
|
||||
static constexpr size_t GetSize() { return 40; }
|
||||
static constexpr std::string_view GetSchema() {
|
||||
return "double nominal_voltage;double stall_torque;double "
|
||||
|
||||
Reference in New Issue
Block a user