SRS-control 0.1.4
Loading...
Searching...
No Matches
RawToDelimRawConveter.hpp
Go to the documentation of this file.
1#pragma once
2
6#include <cassert>
7#include <cstddef>
8#include <spdlog/spdlog.h>
10#include <string_view>
11#include <vector>
12
13namespace srs::workflow
14{
15 class TaskDiagram;
16}
17
18namespace srs::process
19{
21 : public ConverterTask<DataConvertOptions::raw_frame, std::string_view, std::string_view>
22 {
23 public:
24 explicit Raw2DelimRawConverter(size_t n_lines = 1)
25 : ConverterTask{ "RawDelimiter", raw, n_lines }
26 {
27 output_data_.resize(n_lines);
28 }
29
34 ~Raw2DelimRawConverter() { spdlog::debug("Taskflow: raw data delimiter is finished!"); }
35
37
38 [[nodiscard]] auto operator()(std::size_t line_num) const -> OutputType
39 {
40 assert(line_num < get_n_lines());
41 return std::string_view{ output_data_[line_num].data(), output_data_[line_num].size() };
42 }
43
44 auto run(const OutputTo<InputType> auto& prev_data_converter, std::size_t line_number) -> RunResult
45 {
46 assert(line_number < get_n_lines());
47 auto& output_data = output_data_[line_number];
48 output_data.clear();
49 convert(prev_data_converter(line_number), output_data);
50 return this->operator()(line_number);
51 }
52
53 private:
54 std::vector<std::vector<char>> output_data_;
55 static void convert(std::string_view input, std::vector<char>& output);
56 };
57} // namespace srs::process
std::expected< OutputType, std::string_view > RunResult
ConverterTask(std::string_view name, DataConvertOptions prev_convert, std::size_t n_lines=1)
auto run(const OutputTo< InputType > auto &prev_data_converter, std::size_t line_number) -> RunResult
Raw2DelimRawConverter & operator=(const Raw2DelimRawConverter &)=default
Raw2DelimRawConverter & operator=(Raw2DelimRawConverter &&)=delete
std::vector< std::vector< char > > output_data_
Raw2DelimRawConverter(const Raw2DelimRawConverter &)=default
Raw2DelimRawConverter(Raw2DelimRawConverter &&)=delete
auto operator()(std::size_t line_num) const -> OutputType
static void convert(std::string_view input, std::vector< char > &output)
uint32_t RawDelimSizeType