ADTF File Library
Loading...
Searching...
No Matches
streams_to_substreams_reader.h
Go to the documentation of this file.
1
16
17#pragma once
18#include <adtf_file/reader.h>
19#include <variant>
20
21namespace adtfdat_processing
22{
23
27class StreamsToSubstreamsReader: public adtf_file::SeekableReader,
29{
30public:
31 StreamsToSubstreamsReader();
32
33 std::string getReaderIdentifier() const override;
34 void open(const std::string& file_name,
35 std::shared_ptr<adtf_file::SampleFactory> sample_factory,
36 std::shared_ptr<adtf_file::StreamTypeFactory> stream_type_factory) override;
37
38 uint32_t getFileVersion() const override;
39 std::string getDescription() const override;
40 std::vector<adtf_file::Stream> getStreams() const override;
41 std::vector<adtf_file::Extension> getExtensions() const override;
43 std::optional<uint64_t> getItemCount() const override;
44 std::optional<double> getProgress() const override;
45
46 uint64_t getItemIndexForTimeStamp(std::chrono::nanoseconds time_stamp) override;
47 uint64_t getItemIndexForStreamItemIndex(uint16_t stream_id, uint64_t stream_item_index) override;
48 std::shared_ptr<const adtf_file::StreamType> getStreamTypeBefore(uint64_t item_index, uint16_t stream_id) override;
49 void seekTo(uint64_t item_index) override;
50
51private:
52 std::shared_ptr<adtf_file::SampleFactory> _sample_factory;
53 std::shared_ptr<adtf_file::StreamTypeFactory> _stream_type_factory;
54 std::shared_ptr<Reader> _reader;
55 adtf_file::Stream _stream;
56
57 struct SourceStream
58 {
59 std::string name;
60 std::shared_ptr<const adtf_file::PropertyStreamType> type;
61
62 bool operator==(const SourceStream& other) const
63 {
64 return name == other.name && type == other.type;
65 }
66 };
67 using SourceStreams = std::unordered_map<uint16_t, SourceStream>;
68 using SubstreamIDs = std::unordered_map<uint16_t, std::variant<uint32_t, std::unordered_map<uint32_t, uint32_t>>>;
69
70 struct MappedStreams
71 {
72 std::shared_ptr<adtf_file::StreamType> type;
73 SubstreamIDs substream_ids;
74 };
75 MappedStreams buildMap(const SourceStreams& streams) const;
76
77 struct Substreams
78 {
79 Substreams() = default;
80 Substreams(SourceStreams source_streams,
81 MappedStreams stream_map):
82 source_streams(std::move(source_streams)),
83 stream_map(std::move(stream_map))
84 {
85 }
86 SourceStreams source_streams;
87 MappedStreams stream_map;
88 };
89 const Substreams& buildCache(uint64_t item_index);
90 std::unordered_map<uint64_t, Substreams> _seek_cache;
91
92 Substreams _current_substreams;
93};
94
99
100}
Definition reader.h:345
class to create or read a file item. This file item is either a sample, streamtype or trigger.
Definition reader.h:172
Default Reader factory implementation for readers using a standard default CTOR.
Definition reader.h:367
Interface for seekable Reader, where the file position can be adapted.
Definition reader.h:288
class to create and describe a stream within a adtf_file::Reader. Each stream has an identifier strea...
Definition reader.h:150
std::shared_ptr< const adtf_file::StreamType > getStreamTypeBefore(uint64_t item_index, uint16_t stream_id) override
void open(const std::string &file_name, std::shared_ptr< adtf_file::SampleFactory > sample_factory, std::shared_ptr< adtf_file::StreamTypeFactory > stream_type_factory) override
opens a file by the given filename. The given factories must be used to create samples and streamtype...
std::vector< adtf_file::Extension > getExtensions() const override
Get the Extensions if any.
uint64_t getItemIndexForTimeStamp(std::chrono::nanoseconds time_stamp) override
void seekTo(uint64_t item_index) override
adtf_file::FileItem getNextItem() override
std::optional< double > getProgress() const override
Get the Progress, a relative file position between 0.0 and 1.0.
uint64_t getItemIndexForStreamItemIndex(uint16_t stream_id, uint64_t stream_item_index) override
std::vector< adtf_file::Stream > getStreams() const override
Get the Streams.
std::string getReaderIdentifier() const override
Get the Reader Identifier of the Reader.
std::optional< uint64_t > getItemCount() const override
Get the Item Count. This gets the overall count of all items (samples, stream types and triggers) of ...
std::string getDescription() const override
namespace for ADTF DAT Processing library.
Definition ddl_helpers.h:38
adtf_file::ReaderFactoryImplementation< StreamsToSubstreamsReader > StreamsToSubstreamsReaderFactory
Default reader factory implementation for the StreamsToSubstreamsReader.
Definition streams_to_substreams_reader.h:98