adtf_file_library  0.13.2
multi_file_reader.h
Go to the documentation of this file.
1 
17 #pragma once
18 #include <adtf_file/reader.h>
19 #include <unordered_map>
20 
21 namespace adtfdat_processing
22 {
23 
30 {
31 public:
36 
37  std::string getReaderIdentifier() const override;
38  void open(const std::string& file_name,
39  std::shared_ptr<adtf_file::SampleFactory> sample_factory,
40  std::shared_ptr<adtf_file::StreamTypeFactory> stream_type_factory) override;
41 
42  std::vector<adtf_file::Stream> getStreams() const override;
44  std::optional<uint64_t> getItemCount() const override;
45  std::optional<double> getProgress() const override;
46 
47 protected:
53 
62  std::shared_ptr<adtf_file::Reader> addFile(const std::string& file_name,
63  std::shared_ptr<adtf_file::SampleFactory> sample_factory,
64  std::shared_ptr<adtf_file::StreamTypeFactory> stream_type_factory);
68  void build();
69 
70 private:
71 
72  std::unordered_map<std::string, uint16_t> _stream_ids;
73 
74  struct File
75  {
76  std::shared_ptr<Reader> reader;
77  std::unordered_map<uint16_t, uint16_t> stream_ids;
78 
79  adtf_file::FileItem getNext()
80  {
81  auto item = reader->getNextItem();
82  item.stream_id = stream_ids[item.stream_id];
83  return item;
84  }
85  };
86  std::vector<File> _files;
87  std::vector<adtf_file::Stream> _streams;
88 
89  struct QueueItem
90  {
91  File* file;
92  adtf_file::FileItem file_item;
93  };
94  std::multimap<std::chrono::nanoseconds, QueueItem> _queue;
95 };
96 
101 
102 }
Definition: reader.h:318
class to create or read a file item. This file item is either a sample, streamtype or trigger.
Definition: reader.h:156
uint16_t stream_id
stream id the file items belongs to
Definition: reader.h:159
Definition: reader.h:355
Default Reader factory implementation for readers using a standard default CTOR.
Definition: reader.h:339
Definition: reader.h:173
Abstract base class for a multi reader. To use this class you need to override MultiFileReader::getFa...
Definition: multi_file_reader.h:30
std::optional< double > getProgress() const override
Get the Progress, a relative file position between 0.0 and 1.0.
adtf_file::FileItem getNextItem() override
std::shared_ptr< adtf_file::Reader > addFile(const std::string &file_name, std::shared_ptr< adtf_file::SampleFactory > sample_factory, std::shared_ptr< adtf_file::StreamTypeFactory > stream_type_factory)
Adds a file to the multi file reader and opens the file if supported.
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::Stream > getStreams() const override
Get the Streams.
std::string getReaderIdentifier() const override
Get the Reader Identifier of the Reader.
void build()
Merges the streams.
virtual adtf_file::ReaderFactories getFactories() const
Get all supported reader factories of this multireader.
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 ...
namespace for ADTF DAT Processing library.
Definition: ddl_helpers.h:38

Copyright © CARIAD SE.
Generated on Mon Jun 10 2024 by doxygen 1.9.1
GIT Commit Hash: eb3af397a6b49ad6fcad9a60d8277d909b458b48