// Copyright (c) FIRST and other WPILib contributors. // Open Source Software; you can modify and/or share it under the terms of // the WPILib BSD license file in the root directory of this project. #pragma once #include #include #include #include "Value_internal.h" #include "networktables/NetworkTableValue.h" #include "ntcore_cpp_types.h" namespace nt { class ValueCircularBuffer { public: explicit ValueCircularBuffer(size_t size) : m_storage{size} {} template void emplace_back(Args&&... args) { m_storage.emplace_back(std::forward(args...)); } std::vector ReadValue(); template std::vector::Value>> Read(); private: wpi::circular_buffer m_storage; }; template std::vector::Value>> ValueCircularBuffer::Read() { std::vector::Value>> rv; rv.reserve(m_storage.size()); for (auto&& val : m_storage) { if (IsNumericConvertibleTo(val) || IsType(val)) { rv.emplace_back(GetTimestamped(val)); } } m_storage.reset(); return rv; } } // namespace nt