Skip to content

Commit

Permalink
Change TelemetryLoggable to ADL
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterJohnson committed Feb 17, 2025
1 parent 37016fd commit e4caa0d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 31 deletions.
25 changes: 0 additions & 25 deletions wpiutil/src/main/native/include/wpi/telemetry/TelemetryLoggable.h

This file was deleted.

16 changes: 10 additions & 6 deletions wpiutil/src/main/native/include/wpi/telemetry/TelemetryTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include "wpi/mutex.h"
#include "wpi/protobuf/Protobuf.h"
#include "wpi/struct/Struct.h"
#include "wpi/telemetry/TelemetryLoggable.h"
#include "wpi/telemetry/TelemetryRegistry.h"

namespace wpi {
Expand All @@ -26,8 +25,15 @@ class TelemetryTable;

namespace impl {
template <typename T, typename... I>
concept IsTelemetryLoggableADL = requires(
const T& a, TelemetryTable& table, I... info) { Log(a, table, info...); };
concept IsTelemetryLoggableADL =
requires(TelemetryTable& table, const T& value, I... info) {
Log(table, value, info...);
};

template <typename T, typename... I>
inline void TelemetryLogADL(TelemetryTable& table, const T& value, I... info) {
Log(table, value, info...);
}
} // namespace impl

/**
Expand Down Expand Up @@ -106,10 +112,8 @@ class TelemetryTable final {
Log(name, static_cast<int64_t>(value));
} else if constexpr (std::is_floating_point_v<T>) {
Log(name, static_cast<double>(value));
} else if constexpr (std::derived_from<T, TelemetryLoggable>) {
value.Log(GetTable(name));
} else if constexpr (impl::IsTelemetryLoggableADL<T, I...>) {
Log(value, GetTable(name), info...);
impl::TelemetryLogADL(GetTable(name), value, info...);
} else if constexpr (wpi::StructSerializable<T, I...>) {
using S = wpi::Struct<T, I...>;
TelemetryRegistry::AddStructSchema<T>(info...);
Expand Down

0 comments on commit e4caa0d

Please sign in to comment.