11#include <initializer_list>
23#include "wpi/util/SmallVector.hpp"
126 std::span<const uint8_t> schema, int64_t timestamp = 0);
144 std::string_view schema, int64_t timestamp = 0) {
147 std::span<const uint8_t>{
148 reinterpret_cast<const uint8_t*
>(schema.data()), schema.size()},
160 template <wpi::util::ProtobufSerializable T>
162 int64_t timestamp = 0) {
163 if (timestamp == 0) {
167 [
this](
auto typeString) {
return HasSchema(typeString); },
168 [
this, timestamp](
auto typeString,
auto schema) {
169 AddSchema(typeString,
"proto:FileDescriptorProto", schema, timestamp);
181 template <
typename T,
typename... I>
184 if (timestamp == 0) {
188 [
this, timestamp](
auto typeString,
auto schema) {
189 this->
AddSchema(typeString,
"structschema", schema, timestamp);
209 std::string_view metadata = {}, int64_t timestamp = 0);
217 void Finish(
int entry, int64_t timestamp = 0);
226 void SetMetadata(
int entry, std::string_view metadata, int64_t timestamp = 0);
235 void AppendRaw(
int entry, std::span<const uint8_t> data, int64_t timestamp);
244 void AppendRaw2(
int entry, std::span<
const std::span<const uint8_t>> data,
290 void AppendString(
int entry, std::string_view value, int64_t timestamp);
389 : m_buf{new uint8_t[alloc]}, m_maxLen{alloc} {}
396 : m_buf{oth.m_buf}, m_len{oth.m_len}, m_maxLen{oth.m_maxLen} {
408 m_maxLen = oth.m_maxLen;
417 uint8_t* rv = m_buf + m_len;
428 std::span<uint8_t>
GetData() {
return {m_buf, m_len}; }
429 std::span<const uint8_t>
GetData()
const {
return {m_buf, m_len}; }
445 :
m_msglog{msglog}, m_extraHeader{extraHeader} {}
490 static constexpr size_t kMaxBufferCount = 1024 * 1024 /
kBlockSize;
491 static constexpr size_t kMaxFreeCount = 256 * 1024 /
kBlockSize;
494 int StartImpl(std::string_view
name, std::string_view type,
495 std::string_view metadata, int64_t timestamp);
496 uint8_t* StartRecord(uint32_t entry, uint64_t timestamp, uint32_t payloadSize,
498 uint8_t* Reserve(
size_t size);
499 void AppendImpl(std::span<const uint8_t> data);
500 void AppendStringImpl(std::string_view str);
501 void AppendStartRecord(
int id, std::string_view
name, std::string_view type,
502 std::string_view metadata, int64_t timestamp);
503 void DoReleaseBufs(std::vector<Buffer>* bufs);
510 bool m_active =
false;
511 bool m_paused =
false;
512 std::string m_extraHeader;
513 std::vector<Buffer> m_free;
514 std::vector<Buffer> m_outgoing;
521 std::vector<uint8_t> data;
526 std::string metadata;
529 wpi::util::DenseMap<int, EntryInfo2> m_entryIds;
540 std::string_view metadata = {}, int64_t timestamp = 0)
560 explicit operator bool()
const {
return m_log !=
nullptr; }
568 void SetMetadata(std::string_view metadata, int64_t timestamp = 0) {
589 std::string_view type, std::string_view metadata = {},
590 int64_t timestamp = 0)
596 std::scoped_lock lock{rhs.m_mutex};
601 std::scoped_lock lock{
m_mutex, rhs.m_mutex};
625 std::scoped_lock lock{
m_mutex};
645 int64_t timestamp = 0)
648 std::string_view type, int64_t timestamp = 0)
657 void Append(std::span<const uint8_t> data, int64_t timestamp = 0) {
671 void Update(std::span<const uint8_t> data, int64_t timestamp = 0);
679 static constexpr std::string_view
kDataType =
"boolean";
685 std::string_view metadata, int64_t timestamp = 0)
694 void Append(
bool value, int64_t timestamp = 0) {
708 void Update(
bool value, int64_t timestamp = 0) {
709 std::scoped_lock lock{
m_mutex};
728 std::string_view metadata, int64_t timestamp = 0)
737 void Append(int64_t value, int64_t timestamp = 0) {
751 void Update(int64_t value, int64_t timestamp = 0) {
752 std::scoped_lock lock{
m_mutex};
771 int64_t timestamp = 0)
780 void Append(
float value, int64_t timestamp = 0) {
794 void Update(
float value, int64_t timestamp = 0) {
795 std::scoped_lock lock{
m_mutex};
814 int64_t timestamp = 0)
823 void Append(
double value, int64_t timestamp = 0) {
837 void Update(
double value, int64_t timestamp = 0) {
838 std::scoped_lock lock{
m_mutex};
857 int64_t timestamp = 0)
860 std::string_view type, int64_t timestamp = 0)
869 void Append(std::string_view value, int64_t timestamp = 0) {
883 void Update(std::string_view value, int64_t timestamp = 0) {
884 std::scoped_lock lock{
m_mutex};
901 int64_t timestamp = 0)
904 std::string_view metadata, int64_t timestamp = 0)
914 void Append(std::span<const bool> arr, int64_t timestamp = 0) {
924 void Append(std::initializer_list<bool> arr, int64_t timestamp = 0) {
925 Append(std::span{arr.begin(), arr.end()}, timestamp);
934 void Append(std::span<const int> arr, int64_t timestamp = 0) {
944 void Append(std::initializer_list<int> arr, int64_t timestamp = 0) {
945 Append(std::span{arr.begin(), arr.end()}, timestamp);
954 void Append(std::span<const uint8_t> arr, int64_t timestamp = 0) {
968 void Update(std::span<const bool> arr, int64_t timestamp = 0);
980 void Update(std::initializer_list<bool> arr, int64_t timestamp = 0) {
981 Update(std::span{arr.begin(), arr.end()}, timestamp);
994 void Update(std::span<const int> arr, int64_t timestamp = 0);
1006 void Update(std::initializer_list<int> arr, int64_t timestamp = 0) {
1007 Update(std::span{arr.begin(), arr.end()}, timestamp);
1020 void Update(std::span<const uint8_t> arr, int64_t timestamp = 0);
1033 int64_t timestamp = 0)
1036 std::string_view metadata, int64_t timestamp = 0)
1045 void Append(std::span<const int64_t> arr, int64_t timestamp = 0) {
1055 void Append(std::initializer_list<int64_t> arr, int64_t timestamp = 0) {
1056 Append({arr.begin(), arr.end()}, timestamp);
1069 void Update(std::span<const int64_t> arr, int64_t timestamp = 0);
1081 void Update(std::initializer_list<int64_t> arr, int64_t timestamp = 0) {
1082 Update({arr.begin(), arr.end()}, timestamp);
1097 std::string_view metadata, int64_t timestamp = 0)
1106 void Append(std::span<const float> arr, int64_t timestamp = 0) {
1116 void Append(std::initializer_list<float> arr, int64_t timestamp = 0) {
1117 Append({arr.begin(), arr.end()}, timestamp);
1130 void Update(std::span<const float> arr, int64_t timestamp = 0);
1142 void Update(std::initializer_list<float> arr, int64_t timestamp = 0) {
1143 Update({arr.begin(), arr.end()}, timestamp);
1156 int64_t timestamp = 0)
1159 std::string_view metadata, int64_t timestamp = 0)
1168 void Append(std::span<const double> arr, int64_t timestamp = 0) {
1178 void Append(std::initializer_list<double> arr, int64_t timestamp = 0) {
1179 Append({arr.begin(), arr.end()}, timestamp);
1192 void Update(std::span<const double> arr, int64_t timestamp = 0);
1204 void Update(std::initializer_list<double> arr, int64_t timestamp = 0) {
1205 Update({arr.begin(), arr.end()}, timestamp);
1219 int64_t timestamp = 0)
1222 std::string_view metadata, int64_t timestamp = 0)
1231 void Append(std::span<const std::string> arr, int64_t timestamp = 0) {
1241 void Append(std::span<const std::string_view> arr, int64_t timestamp = 0) {
1251 void Append(std::initializer_list<std::string_view> arr,
1252 int64_t timestamp = 0) {
1253 Append(std::span<const std::string_view>{arr.begin(), arr.end()},
1267 void Update(std::span<const std::string> arr, int64_t timestamp = 0);
1279 void Update(std::span<const std::string_view> arr, int64_t timestamp = 0);
1291 void Update(std::initializer_list<std::string_view> arr,
1292 int64_t timestamp = 0) {
1293 Update(std::span<const std::string_view>{arr.begin(), arr.end()},
1301template <
typename T,
typename... I>
1309 int64_t timestamp = 0)
1312 I... info, int64_t timestamp = 0)
1313 : m_info{
std::move(info)...} {
1315 log.AddStructSchema<T, I...>(info..., timestamp);
1317 metadata, timestamp);
1322 std::scoped_lock lock{rhs.m_mutex};
1323 m_lastValue = std::move(rhs.m_lastValue);
1327 m_info = std::move(rhs.m_info);
1328 std::scoped_lock lock{m_mutex, rhs.m_mutex};
1329 m_lastValue = std::move(rhs.m_lastValue);
1339 void Append(
const T& data, int64_t timestamp = 0) {
1340 if constexpr (
sizeof...(I) == 0) {
1342 uint8_t buf[S::GetSize()];
1348 wpi::util::SmallVector<uint8_t, 128> buf;
1349 buf.resize_for_overwrite(std::apply(S::GetSize, m_info));
1350 std::apply([&](
const I&... info) { S::Pack(buf, data, info...); }, m_info);
1364 void Update(
const T& data, int64_t timestamp = 0) {
1365 if constexpr (
sizeof...(I) == 0) {
1367 uint8_t buf[S::GetSize()];
1369 std::scoped_lock lock{m_mutex};
1370 if (m_lastValue.empty() ||
1371 !std::equal(buf, buf + S::GetSize(), m_lastValue.begin(),
1372 m_lastValue.end())) {
1373 m_lastValue.assign(buf, buf + S::GetSize());
1379 wpi::util::SmallVector<uint8_t, 128> buf;
1380 buf.resize_for_overwrite(std::apply(S::GetSize, m_info));
1381 std::apply([&](
const I&... info) { S::Pack(buf, data, info...); }, m_info);
1382 std::scoped_lock lock{m_mutex};
1383 if (m_lastValue.empty() ||
1384 !std::equal(buf.begin(), buf.end(), m_lastValue.begin(),
1385 m_lastValue.end())) {
1386 m_lastValue.assign(buf.begin(), buf.end());
1410 std::scoped_lock lock{m_mutex};
1411 if (m_lastValue.empty()) {
1412 return std::nullopt;
1415 [&](
const I&... info) {
return S::Unpack(m_lastValue, info...); },
1421 std::vector<uint8_t> m_lastValue;
1422 [[no_unique_address]]
1423 std::tuple<I...> m_info;
1429template <
typename T,
typename... I>
1437 int64_t timestamp = 0)
1440 std::string_view metadata, I... info,
1441 int64_t timestamp = 0)
1442 : m_info{
std::move(info)...} {
1444 log.AddStructSchema<T, I...>(info..., timestamp);
1448 metadata, timestamp);
1453 m_buf{
std::move(rhs.m_buf)},
1454 m_info{
std::move(rhs.m_info)} {
1455 std::scoped_lock lock{rhs.m_mutex};
1456 m_lastValue = std::move(rhs.m_lastValue);
1460 m_buf = std::move(rhs.m_buf);
1461 m_info = std::move(rhs.m_info);
1462 std::scoped_lock lock{m_mutex, rhs.m_mutex};
1463 m_lastValue = std::move(rhs.m_lastValue);
1473 template <
typename U>
1474#if __cpp_lib_ranges >= 201911L
1475 requires std::ranges::range<U> &&
1476 std::convertible_to<std::ranges::range_value_t<U>, T>
1478 void Append(U&& data, int64_t timestamp = 0) {
1480 [&](
const I&... info) {
1482 std::forward<U>(data),
1495 void Append(std::span<const T> data, int64_t timestamp = 0) {
1497 [&](
const I&... info) {
1516 void Update(std::span<const T> data, int64_t timestamp = 0) {
1518 [&](
const I&... info) {
1522 std::scoped_lock lock{m_mutex};
1523 if (!m_lastValue.has_value()) {
1524 m_lastValue = std::vector(
bytes.begin(),
bytes.end());
1526 }
else if (!std::equal(
bytes.begin(),
bytes.end(),
1527 m_lastValue->begin(),
1528 m_lastValue->end())) {
1529 m_lastValue->assign(
bytes.begin(),
bytes.end());
1557 std::scoped_lock lock{m_mutex};
1558 if (!m_lastValue.has_value()) {
1559 return std::nullopt;
1561 auto& lastValue = m_lastValue.value();
1562 size_t size = std::apply(S::GetSize, m_info);
1564 rv.reserve(lastValue.size() / size);
1565 for (
auto in = lastValue.begin(), end = lastValue.end(); in < end;
1568 [&](
const I&... info) {
1569 rv.emplace_back(S::Unpack(
1570 std::span<const uint8_t>{std::to_address(in), size}, info...));
1580 std::optional<std::vector<uint8_t>> m_lastValue;
1581 [[no_unique_address]]
1582 std::tuple<I...> m_info;
1588template <wpi::util::ProtobufSerializable T>
1597 std::string_view metadata, int64_t timestamp = 0) {
1599 log.AddProtobufSchema<T>(m_msg, timestamp);
1600 m_entry =
log.Start(
name, m_msg.GetTypeString(), metadata, timestamp);
1609 void Append(
const T& data, int64_t timestamp = 0) {
1610 wpi::util::SmallVector<uint8_t, 128> buf;
1612 std::scoped_lock lock{m_mutex};
1613 m_msg.Pack(buf, data);
1628 void Update(
const T& data, int64_t timestamp = 0) {
1629 std::scoped_lock lock{m_mutex};
1630 wpi::util::SmallVector<uint8_t, 128> buf;
1631 m_msg.Pack(buf, data);
1632 if (!m_lastValue.has_value()) {
1633 m_lastValue = std::vector(buf.begin(), buf.end());
1635 }
else if (!std::equal(buf.begin(), buf.end(), m_lastValue->begin(),
1636 m_lastValue->end())) {
1637 m_lastValue->assign(buf.begin(), buf.end());
1661 std::scoped_lock lock{m_mutex};
1662 if (!m_lastValue.has_value()) {
1663 return std::nullopt;
1665 return m_msg.Unpack(m_lastValue);
1671 std::optional<std::vector<uint8_t>> m_lastValue;
This file defines the DenseMap class.
@ name
Definition base.h:690
void Append(std::span< const uint8_t > arr, int64_t timestamp=0)
Appends a record to the log.
Definition DataLog.hpp:954
static constexpr const char * kDataType
Definition DataLog.hpp:897
void Append(std::initializer_list< bool > arr, int64_t timestamp=0)
Appends a record to the log.
Definition DataLog.hpp:924
void Update(std::initializer_list< bool > arr, int64_t timestamp=0)
Updates the last value and appends a record to the log if it has changed.
Definition DataLog.hpp:980
void Update(std::span< const bool > arr, int64_t timestamp=0)
Updates the last value and appends a record to the log if it has changed.
BooleanArrayLogEntry(DataLog &log, std::string_view name, int64_t timestamp=0)
Definition DataLog.hpp:900
void Append(std::initializer_list< int > arr, int64_t timestamp=0)
Appends a record to the log.
Definition DataLog.hpp:944
void Append(std::span< const int > arr, int64_t timestamp=0)
Appends a record to the log.
Definition DataLog.hpp:934
void Append(std::span< const bool > arr, int64_t timestamp=0)
Appends a record to the log.
Definition DataLog.hpp:914
BooleanArrayLogEntry(DataLog &log, std::string_view name, std::string_view metadata, int64_t timestamp=0)
Definition DataLog.hpp:903
void Update(std::initializer_list< int > arr, int64_t timestamp=0)
Updates the last value and appends a record to the log if it has changed.
Definition DataLog.hpp:1006
void Update(std::span< const uint8_t > arr, int64_t timestamp=0)
Updates the last value and appends a record to the log if it has changed.
BooleanArrayLogEntry()=default
void Update(std::span< const int > arr, int64_t timestamp=0)
Updates the last value and appends a record to the log if it has changed.
BooleanLogEntry()=default
BooleanLogEntry(DataLog &log, std::string_view name, std::string_view metadata, int64_t timestamp=0)
Definition DataLog.hpp:684
void Append(bool value, int64_t timestamp=0)
Appends a record to the log.
Definition DataLog.hpp:694
BooleanLogEntry(DataLog &log, std::string_view name, int64_t timestamp=0)
Definition DataLog.hpp:682
void Update(bool value, int64_t timestamp=0)
Updates the last value and appends a record to the log if it has changed.
Definition DataLog.hpp:708
static constexpr std::string_view kDataType
Definition DataLog.hpp:679
std::span< uint8_t > GetData()
Definition DataLog.hpp:428
Buffer(size_t alloc=kBlockSize)
Definition DataLog.hpp:388
Buffer(Buffer &&oth)
Definition DataLog.hpp:395
Buffer & operator=(Buffer &&oth)
Definition DataLog.hpp:402
~Buffer()
Definition DataLog.hpp:390
std::span< const uint8_t > GetData() const
Definition DataLog.hpp:429
void Clear()
Definition DataLog.hpp:424
Buffer(const Buffer &)=delete
size_t GetRemaining() const
Definition DataLog.hpp:426
void Unreserve(size_t size)
Definition DataLog.hpp:422
Buffer & operator=(const Buffer &)=delete
uint8_t * Reserve(size_t size)
Definition DataLog.hpp:415
Log entry base class.
Definition DataLog.hpp:536
DataLogEntry(DataLogEntry &&rhs)
Definition DataLog.hpp:547
DataLogEntry(const DataLogEntry &)=delete
void Finish(int64_t timestamp=0)
Finishes the entry.
Definition DataLog.hpp:577
DataLog * m_log
Definition DataLog.hpp:580
DataLogEntry(DataLog &log, std::string_view name, std::string_view type, std::string_view metadata={}, int64_t timestamp=0)
Definition DataLog.hpp:539
DataLogEntry & operator=(const DataLogEntry &)=delete
int m_entry
Definition DataLog.hpp:581
DataLogEntry & operator=(DataLogEntry &&rhs)
Definition DataLog.hpp:550
void SetMetadata(std::string_view metadata, int64_t timestamp=0)
Updates the metadata for the entry.
Definition DataLog.hpp:568
A data log for high-speed writing of data values.
Definition DataLog.hpp:69
wpi::util::Logger & m_msglog
Definition DataLog.hpp:506
void AppendBooleanArray(int entry, std::span< const bool > arr, int64_t timestamp)
Appends a boolean array record to the log.
void AppendBooleanArray(int entry, std::span< const int > arr, int64_t timestamp)
Appends a boolean array record to the log.
void SetMetadata(int entry, std::string_view metadata, int64_t timestamp=0)
Updates the metadata for an entry.
DataLog(wpi::util::Logger &msglog, std::string_view extraHeader="")
Constructs the log.
Definition DataLog.hpp:444
void AppendStringArray(int entry, std::span< const std::string > arr, int64_t timestamp)
Appends a string array record to the log.
virtual void Stop()
Stops appending start/metadata/schema records to the log.
int Start(std::string_view name, std::string_view type, std::string_view metadata={}, int64_t timestamp=0)
Start an entry.
DataLog & operator=(const DataLog &)=delete
void AddProtobufSchema(wpi::util::ProtobufMessage< T > &msg, int64_t timestamp=0)
Registers a protobuf schema.
Definition DataLog.hpp:161
void AppendRaw(int entry, std::span< const uint8_t > data, int64_t timestamp)
Appends a raw record to the log.
void AppendIntegerArray(int entry, std::span< const int64_t > arr, int64_t timestamp)
Appends an integer array record to the log.
DataLog(const DataLog &)=delete
void AddStructSchema(const I &... info, int64_t timestamp=0)
Registers a struct schema.
Definition DataLog.hpp:183
void ReleaseBufs(std::vector< Buffer > *bufs)
Releases memory for a set of buffers back to the internal buffer pool.
void AppendStringArray(int entry, std::span< const struct WPI_String > arr, int64_t timestamp)
Appends a string array record to the log.
void AddSchema(std::string_view name, std::string_view type, std::string_view schema, int64_t timestamp=0)
Registers a data schema.
Definition DataLog.hpp:143
void AppendBooleanArray(int entry, std::span< const uint8_t > arr, int64_t timestamp)
Appends a boolean array record to the log.
void AppendDouble(int entry, double value, int64_t timestamp)
Appends a double record to the log.
void AppendFloat(int entry, float value, int64_t timestamp)
Appends a float record to the log.
DataLog & operator=(const DataLog &&)=delete
void AppendFloatArray(int entry, std::span< const float > arr, int64_t timestamp)
Appends a float array record to the log.
virtual void Resume()
Resumes appending of data records to the log.
void AppendString(int entry, std::string_view value, int64_t timestamp)
Appends a string record to the log.
void AddSchema(std::string_view name, std::string_view type, std::span< const uint8_t > schema, int64_t timestamp=0)
Registers a data schema.
static wpi::util::Logger s_defaultMessageLog
Definition DataLog.hpp:384
DataLog(DataLog &&)=delete
virtual ~DataLog()=default
static constexpr size_t kBlockSize
Definition DataLog.hpp:383
virtual void Pause()
Pauses appending of data records to the log.
void AppendStringArray(int entry, std::span< const std::string_view > arr, int64_t timestamp)
Appends a string array record to the log.
bool HasSchema(std::string_view name) const
Returns whether there is a data schema already registered with the given name.
virtual bool BufferFull()=0
Called when internal buffers reach the maximum count.
void StartFile()
Starts the log.
void AppendRaw2(int entry, std::span< const std::span< const uint8_t > > data, int64_t timestamp)
Appends a raw record to the log.
void Finish(int entry, int64_t timestamp=0)
Finish an entry.
void AppendDoubleArray(int entry, std::span< const double > arr, int64_t timestamp)
Appends a double array record to the log.
virtual void Flush()=0
Explicitly flushes the log data to disk.
void AppendInteger(int entry, int64_t value, int64_t timestamp)
Appends an integer record to the log.
void FlushBufs(std::vector< Buffer > *writeBufs)
Provides complete set of all buffers that need to be written.
virtual void BufferHalfFull()
Called when internal buffers are half the maximum count.
void AppendBoolean(int entry, bool value, int64_t timestamp)
Appends a boolean record to the log.
std::optional< T > m_lastValue
Definition DataLog.hpp:631
DataLogValueEntryImpl()=default
std::optional< T > GetLastValue() const
Gets the last value.
Definition DataLog.hpp:624
DataLogValueEntryImpl & operator=(DataLogValueEntryImpl &&rhs)
Definition DataLog.hpp:599
wpi::util::mutex m_mutex
Definition DataLog.hpp:630
DataLogValueEntryImpl(DataLog &log, std::string_view name, std::string_view type, std::string_view metadata={}, int64_t timestamp=0)
Definition DataLog.hpp:588
bool HasLastValue() const
Gets whether there is a last value.
Definition DataLog.hpp:614
DataLogValueEntryImpl(DataLogValueEntryImpl &&rhs)
Definition DataLog.hpp:594
DoubleArrayLogEntry(DataLog &log, std::string_view name, int64_t timestamp=0)
Definition DataLog.hpp:1155
void Append(std::span< const double > arr, int64_t timestamp=0)
Appends a record to the log.
Definition DataLog.hpp:1168
static constexpr const char * kDataType
Definition DataLog.hpp:1152
void Append(std::initializer_list< double > arr, int64_t timestamp=0)
Appends a record to the log.
Definition DataLog.hpp:1178
void Update(std::span< const double > arr, int64_t timestamp=0)
Updates the last value and appends a record to the log if it has changed.
DoubleArrayLogEntry()=default
void Update(std::initializer_list< double > arr, int64_t timestamp=0)
Updates the last value and appends a record to the log if it has changed.
Definition DataLog.hpp:1204
DoubleArrayLogEntry(DataLog &log, std::string_view name, std::string_view metadata, int64_t timestamp=0)
Definition DataLog.hpp:1158
static constexpr std::string_view kDataType
Definition DataLog.hpp:808
DoubleLogEntry(DataLog &log, std::string_view name, std::string_view metadata, int64_t timestamp=0)
Definition DataLog.hpp:813
void Append(double value, int64_t timestamp=0)
Appends a record to the log.
Definition DataLog.hpp:823
DoubleLogEntry(DataLog &log, std::string_view name, int64_t timestamp=0)
Definition DataLog.hpp:811
void Update(double value, int64_t timestamp=0)
Updates the last value and appends a record to the log if it has changed.
Definition DataLog.hpp:837
void Update(std::initializer_list< float > arr, int64_t timestamp=0)
Updates the last value and appends a record to the log if it has changed.
Definition DataLog.hpp:1142
void Update(std::span< const float > arr, int64_t timestamp=0)
Updates the last value and appends a record to the log if it has changed.
FloatArrayLogEntry(DataLog &log, std::string_view name, std::string_view metadata, int64_t timestamp=0)
Definition DataLog.hpp:1096
static constexpr const char * kDataType
Definition DataLog.hpp:1091
void Append(std::span< const float > arr, int64_t timestamp=0)
Appends a record to the log.
Definition DataLog.hpp:1106
void Append(std::initializer_list< float > arr, int64_t timestamp=0)
Appends a record to the log.
Definition DataLog.hpp:1116
FloatArrayLogEntry(DataLog &log, std::string_view name, int64_t timestamp=0)
Definition DataLog.hpp:1094
FloatArrayLogEntry()=default
FloatLogEntry(DataLog &log, std::string_view name, int64_t timestamp=0)
Definition DataLog.hpp:768
FloatLogEntry(DataLog &log, std::string_view name, std::string_view metadata, int64_t timestamp=0)
Definition DataLog.hpp:770
void Update(float value, int64_t timestamp=0)
Updates the last value and appends a record to the log if it has changed.
Definition DataLog.hpp:794
static constexpr std::string_view kDataType
Definition DataLog.hpp:765
void Append(float value, int64_t timestamp=0)
Appends a record to the log.
Definition DataLog.hpp:780
IntegerArrayLogEntry(DataLog &log, std::string_view name, std::string_view metadata, int64_t timestamp=0)
Definition DataLog.hpp:1035
void Update(std::initializer_list< int64_t > arr, int64_t timestamp=0)
Updates the last value and appends a record to the log if it has changed.
Definition DataLog.hpp:1081
void Append(std::span< const int64_t > arr, int64_t timestamp=0)
Appends a record to the log.
Definition DataLog.hpp:1045
IntegerArrayLogEntry(DataLog &log, std::string_view name, int64_t timestamp=0)
Definition DataLog.hpp:1032
void Append(std::initializer_list< int64_t > arr, int64_t timestamp=0)
Appends a record to the log.
Definition DataLog.hpp:1055
void Update(std::span< const int64_t > arr, int64_t timestamp=0)
Updates the last value and appends a record to the log if it has changed.
IntegerArrayLogEntry()=default
static constexpr const char * kDataType
Definition DataLog.hpp:1029
IntegerLogEntry()=default
static constexpr std::string_view kDataType
Definition DataLog.hpp:722
IntegerLogEntry(DataLog &log, std::string_view name, std::string_view metadata, int64_t timestamp=0)
Definition DataLog.hpp:727
void Update(int64_t value, int64_t timestamp=0)
Updates the last value and appends a record to the log if it has changed.
Definition DataLog.hpp:751
IntegerLogEntry(DataLog &log, std::string_view name, int64_t timestamp=0)
Definition DataLog.hpp:725
void Append(int64_t value, int64_t timestamp=0)
Appends a record to the log.
Definition DataLog.hpp:737
void Update(const T &data, int64_t timestamp=0)
Updates the last value and appends a record to the log if it has changed.
Definition DataLog.hpp:1628
std::optional< T > GetLastValue() const
Gets the last value.
Definition DataLog.hpp:1660
ProtobufLogEntry(DataLog &log, std::string_view name, int64_t timestamp=0)
Definition DataLog.hpp:1594
void Append(const T &data, int64_t timestamp=0)
Appends a record to the log.
Definition DataLog.hpp:1609
ProtobufLogEntry(DataLog &log, std::string_view name, std::string_view metadata, int64_t timestamp=0)
Definition DataLog.hpp:1596
bool HasLastValue() const
Gets whether there is a last value.
Definition DataLog.hpp:1650
ProtobufLogEntry()=default
RawLogEntry(DataLog &log, std::string_view name, std::string_view metadata, int64_t timestamp=0)
Definition DataLog.hpp:644
RawLogEntry(DataLog &log, std::string_view name, std::string_view metadata, std::string_view type, int64_t timestamp=0)
Definition DataLog.hpp:647
static constexpr std::string_view kDataType
Definition DataLog.hpp:639
void Append(std::span< const uint8_t > data, int64_t timestamp=0)
Appends a record to the log.
Definition DataLog.hpp:657
RawLogEntry(DataLog &log, std::string_view name, int64_t timestamp=0)
Definition DataLog.hpp:642
void Update(std::span< const uint8_t > data, int64_t timestamp=0)
Updates the last value and appends a record to the log if it has changed.
void Update(std::span< const std::string_view > arr, int64_t timestamp=0)
Updates the last value and appends a record to the log if it has changed.
void Update(std::span< const std::string > arr, int64_t timestamp=0)
Updates the last value and appends a record to the log if it has changed.
void Append(std::initializer_list< std::string_view > arr, int64_t timestamp=0)
Appends a record to the log.
Definition DataLog.hpp:1251
static constexpr const char * kDataType
Definition DataLog.hpp:1215
StringArrayLogEntry(DataLog &log, std::string_view name, std::string_view metadata, int64_t timestamp=0)
Definition DataLog.hpp:1221
void Append(std::span< const std::string > arr, int64_t timestamp=0)
Appends a record to the log.
Definition DataLog.hpp:1231
void Append(std::span< const std::string_view > arr, int64_t timestamp=0)
Appends a record to the log.
Definition DataLog.hpp:1241
StringArrayLogEntry()=default
void Update(std::initializer_list< std::string_view > arr, int64_t timestamp=0)
Updates the last value and appends a record to the log if it has changed.
Definition DataLog.hpp:1291
StringArrayLogEntry(DataLog &log, std::string_view name, int64_t timestamp=0)
Definition DataLog.hpp:1218
StringLogEntry(DataLog &log, std::string_view name, std::string_view metadata, int64_t timestamp=0)
Definition DataLog.hpp:856
void Append(std::string_view value, int64_t timestamp=0)
Appends a record to the log.
Definition DataLog.hpp:869
static constexpr const char * kDataType
Definition DataLog.hpp:851
StringLogEntry(DataLog &log, std::string_view name, std::string_view metadata, std::string_view type, int64_t timestamp=0)
Definition DataLog.hpp:859
void Update(std::string_view value, int64_t timestamp=0)
Updates the last value and appends a record to the log if it has changed.
Definition DataLog.hpp:883
StringLogEntry(DataLog &log, std::string_view name, int64_t timestamp=0)
Definition DataLog.hpp:854
bool HasLastValue() const
Gets whether there is a last value.
Definition DataLog.hpp:1546
StructArrayLogEntry(DataLog &log, std::string_view name, I... info, int64_t timestamp=0)
Definition DataLog.hpp:1436
void Append(U &&data, int64_t timestamp=0)
Appends a record to the log.
Definition DataLog.hpp:1478
StructArrayLogEntry()=default
void Update(std::span< const T > data, int64_t timestamp=0)
Updates the last value and appends a record to the log if it has changed.
Definition DataLog.hpp:1516
StructArrayLogEntry & operator=(StructArrayLogEntry &&rhs)
Definition DataLog.hpp:1458
void Append(std::span< const T > data, int64_t timestamp=0)
Appends a record to the log.
Definition DataLog.hpp:1495
StructArrayLogEntry(StructArrayLogEntry &&rhs)
Definition DataLog.hpp:1451
StructArrayLogEntry(DataLog &log, std::string_view name, std::string_view metadata, I... info, int64_t timestamp=0)
Definition DataLog.hpp:1439
std::optional< std::vector< T > > GetLastValue() const
Gets the last value.
Definition DataLog.hpp:1556
std::optional< T > GetLastValue() const
Gets the last value.
Definition DataLog.hpp:1409
StructLogEntry & operator=(StructLogEntry &&rhs)
Definition DataLog.hpp:1325
bool HasLastValue() const
Gets whether there is a last value.
Definition DataLog.hpp:1399
StructLogEntry(StructLogEntry &&rhs)
Definition DataLog.hpp:1320
void Update(const T &data, int64_t timestamp=0)
Updates the last value and appends a record to the log if it has changed.
Definition DataLog.hpp:1364
StructLogEntry(DataLog &log, std::string_view name, I... info, int64_t timestamp=0)
Definition DataLog.hpp:1308
void Append(const T &data, int64_t timestamp=0)
Appends a record to the log.
Definition DataLog.hpp:1339
StructLogEntry(DataLog &log, std::string_view name, std::string_view metadata, I... info, int64_t timestamp=0)
Definition DataLog.hpp:1311
Ease of use wrapper to make nanopb streams more opaque to the user.
Definition Protobuf.hpp:308
void ForEachProtobufDescriptor(function_ref< bool(std::string_view filename)> exists, function_ref< void(std::string_view filename, std::span< const uint8_t > descriptor)> fn)
Loops over all protobuf descriptors including nested/referenced descriptors.
Definition Protobuf.hpp:384
StringMap is a sorted associative container that contains key-value pairs with unique string keys.
Definition StringMap.hpp:26
Definition Struct.hpp:437
Specifies that a type is capable of raw struct serialization and deserialization.
Definition Struct.hpp:69
Definition StringMap.hpp:773
Definition DataLog.hpp:37
ControlRecordType
Definition DataLog.hpp:39
@ kControlFinish
Definition DataLog.hpp:41
@ kControlStart
Definition DataLog.hpp:40
@ kControlSetMetadata
Definition DataLog.hpp:42
Definition DataLogReader.hpp:17
Definition raw_os_ostream.hpp:19
void ForEachStructSchema(std::invocable< std::string_view, std::string_view > auto fn, const I &... info)
Definition Struct.hpp:424
constexpr auto MakeStructArrayTypeString(const I &... info)
Definition Struct.hpp:370
constexpr auto GetStructTypeString(const I &... info)
Get the type string for a raw struct serializable type.
Definition Struct.hpp:314
constexpr bool is_constexpr(Lambda)
Definition type_traits.hpp:81
::std::mutex mutex
Definition mutex.hpp:17
uint64_t Now()
Return a value representing the current time in microseconds.
Protobuf serialization template.
Definition Protobuf.hpp:36
Struct serialization template.
Definition Struct.hpp:39