mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[wpimath] Add ReportWarning to MathShared (#3441)
This commit is contained in:
@@ -77,6 +77,11 @@ class WPILibMathShared : public wpi::math::MathShared {
|
||||
args);
|
||||
}
|
||||
|
||||
void ReportWarningV(fmt::string_view format, fmt::format_args args) override {
|
||||
frc::ReportErrorV(warn::Warning, __FILE__, __LINE__, __FUNCTION__, format,
|
||||
args);
|
||||
}
|
||||
|
||||
void ReportUsage(wpi::math::MathUsageId id, int count) override {
|
||||
switch (id) {
|
||||
case wpi::math::MathUsageId::kKinematics_DifferentialDrive:
|
||||
|
||||
@@ -12,6 +12,8 @@ namespace {
|
||||
class DefaultMathShared : public MathShared {
|
||||
public:
|
||||
void ReportErrorV(fmt::string_view format, fmt::format_args args) override {}
|
||||
void ReportWarningV(fmt::string_view format, fmt::format_args args) override {
|
||||
}
|
||||
void ReportUsage(MathUsageId id, int count) override {}
|
||||
};
|
||||
} // namespace
|
||||
|
||||
@@ -25,12 +25,19 @@ class MathShared {
|
||||
public:
|
||||
virtual ~MathShared() = default;
|
||||
virtual void ReportErrorV(fmt::string_view format, fmt::format_args args) = 0;
|
||||
virtual void ReportWarningV(fmt::string_view format,
|
||||
fmt::format_args args) = 0;
|
||||
virtual void ReportUsage(MathUsageId id, int count) = 0;
|
||||
|
||||
template <typename S, typename... Args>
|
||||
inline void ReportError(const S& format, Args&&... args) {
|
||||
ReportErrorV(format, fmt::make_args_checked<Args...>(format, args...));
|
||||
}
|
||||
|
||||
template <typename S, typename... Args>
|
||||
inline void ReportWarning(const S& format, Args&&... args) {
|
||||
ReportWarningV(format, fmt::make_args_checked<Args...>(format, args...));
|
||||
}
|
||||
};
|
||||
|
||||
class MathSharedStore {
|
||||
@@ -48,6 +55,15 @@ class MathSharedStore {
|
||||
ReportErrorV(format, fmt::make_args_checked<Args...>(format, args...));
|
||||
}
|
||||
|
||||
static void ReportWarningV(fmt::string_view format, fmt::format_args args) {
|
||||
GetMathShared().ReportWarningV(format, args);
|
||||
}
|
||||
|
||||
template <typename S, typename... Args>
|
||||
static inline void ReportWarning(const S& format, Args&&... args) {
|
||||
ReportWarningV(format, fmt::make_args_checked<Args...>(format, args...));
|
||||
}
|
||||
|
||||
static void ReportUsage(MathUsageId id, int count) {
|
||||
GetMathShared().ReportUsage(id, count);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user