ADTF File Library
Loading...
Searching...
No Matches
sample_timestamp_sanitizer_reader.h
Go to the documentation of this file.
1
16
17#pragma once
18#include <adtf_file/reader.h>
19
20#include <chrono>
21#include <cstdint>
22#include <deque>
23#include <memory>
24#include <optional>
25#include <string>
26#include <utility>
27#include <vector>
28
29namespace adtfdat_processing
30{
38{
39public:
44
45 std::string getReaderIdentifier() const override;
46 void open(const std::string& file_name,
47 std::shared_ptr<adtf_file::SampleFactory> sample_factory,
48 std::shared_ptr<adtf_file::StreamTypeFactory> stream_type_factory) override;
49
50 uint32_t getFileVersion() const override;
51 std::string getDescription() const override;
52 std::vector<adtf_file::Stream> getStreams() const override;
53 std::vector<adtf_file::Extension> getExtensions() const override;
55 std::optional<uint64_t> getItemCount() const override;
56 std::optional<double> getProgress() const override;
57
58 uint64_t getItemIndexForTimeStamp(std::chrono::nanoseconds time_stamp) override;
59 uint64_t getItemIndexForStreamItemIndex(uint16_t stream_id, uint64_t stream_item_index) override;
60 std::shared_ptr<const adtf_file::StreamType> getStreamTypeBefore(uint64_t item_index, uint16_t stream_id) override;
61 void seekTo(uint64_t item_index) override;
62
63private:
64 void setupReader(const std::string& file_name,
65 const std::shared_ptr<adtf_file::SampleFactory>& sample_factory,
66 const std::shared_ptr<adtf_file::StreamTypeFactory>& stream_type_factory);
67 void resetTimestampTracking();
68
69 void refillQueue();
70 void sanitizeBlock();
71 void sanitizeFinalBlock();
72
73 void setSampleTimestamp(adtf_file::FileItem& file_item,
74 const std::shared_ptr<const adtf_file::Sample>& sample,
75 std::chrono::nanoseconds timestamp);
76 void setFileItemTimestamp(adtf_file::FileItem& file_item, std::chrono::nanoseconds timestamp);
77
78 std::shared_ptr<adtf_file::SampleFactory> _sample_factory{};
79 std::shared_ptr<Reader> _reader{};
80 std::vector<adtf_file::Stream> _streams{};
81
82 std::optional<std::chrono::nanoseconds> _lower_timestamp_bound{};
83 std::deque<adtf_file::FileItem> _item_queue;
84};
85
90
91} // namespace adtfdat_processing
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
std::vector< adtf_file::Stream > getStreams() const override
Get the Streams.
std::string getReaderIdentifier() const override
Get the Reader Identifier of the Reader.
uint64_t getItemIndexForTimeStamp(std::chrono::nanoseconds time_stamp) override
std::shared_ptr< const adtf_file::StreamType > getStreamTypeBefore(uint64_t item_index, uint16_t stream_id) override
adtf_file::FileItem getNextItem() override
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 ...
void seekTo(uint64_t item_index) 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...
uint64_t getItemIndexForStreamItemIndex(uint16_t stream_id, uint64_t stream_item_index) override
std::vector< adtf_file::Extension > getExtensions() const override
Get the Extensions if any.
std::optional< double > getProgress() const override
Get the Progress, a relative file position between 0.0 and 1.0.
namespace for ADTF DAT Processing library.
Definition ddl_helpers.h:38
adtf_file::ReaderFactoryImplementation< SampleTimestampSanitizerReader > SampleTimestampSanitizerReaderFactory
Default reader factory implementation for the SampleTimestampSanitizerReader.
Definition sample_timestamp_sanitizer_reader.h:89