RTC Toolkit 5.1.0
Loading...
Searching...
No Matches
dataRecorder.hpp
Go to the documentation of this file.
1
12#ifndef RTCTK_COMPONENTFRAMEWORK_DATARECORDER_HPP
13#define RTCTK_COMPONENTFRAMEWORK_DATARECORDER_HPP
14
15#include <array>
16#include <filesystem>
17#include <gsl/span>
18#include <string_view>
19#include <tuple>
20
22
28template <class... T>
30public:
32 std::string_view name;
33 std::string_view unit;
34
35 constexpr ColumnMetaData(const std::string_view& new_name, const std::string_view& new_unit)
37 }
38 };
39
43 using TupleType = std::tuple<T...>;
44
48 using DisabledFields = std::array<bool, sizeof...(T)>;
49 using ColumnDescription = const std::array<ColumnMetaData, sizeof...(T)>;
50
60
61 virtual ~DataRecorder() = default;
62
72
77 virtual void Write(const std::tuple<T...>& data) = 0;
78
83 virtual void Write(const gsl::span<const std::tuple<T...>> data) {
84 for (const auto& element : data) {
86 }
87 }
88
93 virtual void Open(const std::filesystem::path& file) = 0;
94
98 virtual void Close() = 0;
99
103 virtual std::string DefaultFileExtension() = 0;
104
105protected:
111};
112
113} // namespace rtctk::componentFramework
114
115#endif // RTCTK_COMPONENTFRAMEWORK_DATARECORDER_HPP
This is an abstract class that can be used to implement an OutputStage for a Recording Unit.
Definition dataRecorder.hpp:29
virtual void Close()=0
Close the currently open file.
DisabledFields m_disabled_fields
Array of fields that should not be recorded.
Definition dataRecorder.hpp:109
const ColumnDescription m_column_description
Definition dataRecorder.hpp:110
virtual std::string DefaultFileExtension()=0
Default filename extension for the recorder.
std::tuple< T... > TupleType
Type of the tuple returned by user-defined method AsTuple.
Definition dataRecorder.hpp:43
const std::array< ColumnMetaData, sizeof...(T)> ColumnDescription
Definition dataRecorder.hpp:49
std::array< bool, sizeof...(T)> DisabledFields
Type for disabled fields, an array of bools with length equal to size of the data tuple.
Definition dataRecorder.hpp:48
virtual void Write(const gsl::span< const std::tuple< T... > > data)
Write multiple rows of data.
Definition dataRecorder.hpp:83
virtual void Write(const std::tuple< T... > &data)=0
Write a single row of data.
void SetDisabledFields(const DisabledFields &disable)
Disable certain fields so that they are not recorded.
Definition dataRecorder.hpp:69
virtual void Open(const std::filesystem::path &file)=0
Open a file.
DataRecorder(const ColumnDescription &columns, const DisabledFields &disable={})
Create a new recorder.
Definition dataRecorder.hpp:57
Definition commandReplier.cpp:22
elt::mal::future< std::string > InjectReqRepEvent(StateMachineEngine &engine)
Definition malEventInjector.hpp:23
constexpr ColumnMetaData(const std::string_view &new_name, const std::string_view &new_unit)
Definition dataRecorder.hpp:35
std::string_view unit
Definition dataRecorder.hpp:33
std::string_view name
Definition dataRecorder.hpp:32