adtf_file_library  0.13.2
multiplexer.h
Go to the documentation of this file.
1 
17 #pragma once
18 
19 #include <string>
20 #include <functional>
21 #include <unordered_map>
22 
24 #include <adtf_file/reader.h>
25 
26 namespace adtfdat_processing
27 {
28 
33 {
34 public:
42  OffsetReaderWrapper(const std::shared_ptr<Reader> original_reader,
43  std::chrono::nanoseconds offset,
44  std::chrono::nanoseconds start_offset,
45  std::chrono::nanoseconds end_offset);
46 
47  std::string getReaderIdentifier() const override;
48  uint32_t getFileVersion() const override;
49  std::string getDescription() const override;
50 
51  void open(const std::string& filename,
52  std::shared_ptr<adtf_file::SampleFactory> sample_factory,
53  std::shared_ptr<adtf_file::StreamTypeFactory> stream_type_factory) override;
54 
55  void setConfiguration(const adtf_file::Configuration& configuration) override;
56  const adtf_file::Configuration& getConfiguration() const override;
57 
58  std::vector<adtf_file::Extension> getExtensions() const override;
59  std::vector<adtf_file::Stream> getStreams() const override;
60 
62  std::optional<uint64_t> getItemCount() const override;
63  std::optional<double> getProgress() const override;
64 
65 private:
66  std::shared_ptr<Reader> _original_reader;
67  std::chrono::nanoseconds _offset;
68  std::chrono::nanoseconds _start_offset;
69  std::chrono::nanoseconds _end_offset;
70 
71  adtf_file::FileItem _next_item;
72  std::unordered_map<uint16_t, std::shared_ptr<const adtf_file::StreamItem>> _last_stream_types;
73 };
74 
79 {
80 public:
88  Multiplexer(const std::string& destination_file_name,
90  adtf_file::ADTFDatFileWriter::TargetADTFVersion::adtf3ns,
91  bool skip_stream_types_and_triggers = false);
92 
100  void addStream(const std::shared_ptr<adtf_file::Reader> reader,
101  const std::string& stream_name,
102  const std::string& destination_stream_name,
103  const std::shared_ptr<adtf_file::SampleSerializer> serializer);
104 
114  void addExtension(const std::string& name,
115  const void* extension_data,
116  size_t extension_size,
117  uint32_t user_id = 0,
118  uint32_t type_id = 0,
119  uint32_t version_id = 0);
120 
127  void process(const std::function<bool(double)>& progress_handler);
128 
129 private:
130  std::optional<double> calculateProgress();
131 
132 private:
134  bool _skip_stream_types_and_triggers;
135  std::unordered_map<std::shared_ptr<adtf_file::Reader>, std::unordered_map<uint16_t, size_t>>
136  _stream_mapping;
137 };
138 }
Default ADTF DAT File Writer to write an ADTF DAT File (IFHD file with ADTF type and sample content).
Definition: adtf_file_writer.h:272
TargetADTFVersion
Target Verion of the ADTF file to write.
Definition: adtf_file_writer.h:309
class to create or read a file item. This file item is either a sample, streamtype or trigger.
Definition: reader.h:156
Definition: reader.h:173
Definition: multiplexer.h:79
void addStream(const std::shared_ptr< adtf_file::Reader > reader, const std::string &stream_name, const std::string &destination_stream_name, const std::shared_ptr< adtf_file::SampleSerializer > serializer)
void addExtension(const std::string &name, const void *extension_data, size_t extension_size, uint32_t user_id=0, uint32_t type_id=0, uint32_t version_id=0)
void process(const std::function< bool(double)> &progress_handler)
Multiplexer(const std::string &destination_file_name, adtf_file::ADTFDatFileWriter::TargetADTFVersion target_adtf_version=adtf_file::ADTFDatFileWriter::TargetADTFVersion::adtf3ns, bool skip_stream_types_and_triggers=false)
Definition: multiplexer.h:33
std::vector< adtf_file::Stream > getStreams() const override
Get the Streams.
const adtf_file::Configuration & getConfiguration() const override
std::string getDescription() const override
OffsetReaderWrapper(const std::shared_ptr< Reader > original_reader, std::chrono::nanoseconds offset, std::chrono::nanoseconds start_offset, std::chrono::nanoseconds end_offset)
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::vector< adtf_file::Extension > getExtensions() const override
Get the Extensions if any.
std::string getReaderIdentifier() const override
Get the Reader Identifier of the Reader.
adtf_file::FileItem getNextItem() override
void open(const std::string &filename, 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...
void setConfiguration(const adtf_file::Configuration &configuration) override
uint32_t getFileVersion() const override
std::optional< double > getProgress() const override
Get the Progress, a relative file position between 0.0 and 1.0.
std::unordered_map< std::string, PropertyValue > Configuration
Configuration class as set of key - property value pairs This configuration is used to adjust the rea...
Definition: configuration.h:143
namespace for ADTF DAT Processing library.
Definition: ddl_helpers.h:38
const uint32_t version_id
IFHD Version ID V1.0.
Definition: indexedfile_v100.h:31

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