22 #include <unordered_map>
53 virtual void read(
void* destination,
size_t count) = 0;
64 static_assert(std::is_trivially_copyable<T>::value,
"Only trivially copyable types and std::string are allowed. Alternatively, provide a specialization for adtf_file::InputStream& operator>>(T& value).");
65 read(&value,
sizeof(T));
88 virtual std::string
getId()
const = 0;
115 (*this)[deserializer->getId()] = deserializer;
127 auto deserializer = find(
id);
128 if (deserializer == end())
130 throw std::runtime_error(
"no type deserializer for '" +
id +
"' available");
133 deserializer->second->deserialize(stream, stream_type);
166 virtual std::string
getId()
const = 0;
171 virtual std::shared_ptr<SampleDeserializer>
build()
const = 0;
178 template <
typename FACTORY>
187 std::shared_ptr<SampleDeserializer>
build()
const override
189 return std::make_shared<FACTORY>();
197 private std::unordered_map<std::string, std::shared_ptr<SampleDeserializerFactory>>
207 (*this)[factory->getId()] = factory;
217 std::shared_ptr<SampleDeserializer>
build(
const std::string&
id)
const
221 return at(
id)->build();
225 throw std::runtime_error(
"no sample deserializer factory for '" +
id +
"' available");
257 std::optional<SampleDeserializerFactories> sample_deserializer_factories);
288 void open(
const std::string& filename,
294 void open(
const std::string& filename);
308 void seekTo(uint64_t item_index)
override;
333 void openDescription(
const std::string& description_file_name,
bool ignore_unsupported_streams);
334 std::shared_ptr<const StreamType> buildType(
const std::string&
id,
InputStream& stream);
335 std::pair<std::shared_ptr<const StreamType>, std::shared_ptr<SampleDeserializer>> getInitialTypeAndSampleDeserializer(uint16_t stream_id);
336 std::pair<std::shared_ptr<const StreamType>, std::shared_ptr<SampleDeserializer> > getInitialTypeAndSampleFactoryAdtf2(
InputStream& stream);
337 std::pair<std::shared_ptr<const StreamType>, std::shared_ptr<SampleDeserializer>> getInitialTypeAndSampleFactoryAdtf3(
InputStream& stream);
338 std::chrono::nanoseconds fromFileTimeStamp(timestamp_t time_stamp);
339 timestamp_t toFileTimeStamp(std::chrono::nanoseconds time_stamp);
342 std::unique_ptr<ifhd::v500::IndexedFileReader> _file;
343 std::vector<Extension> _extensions;
344 std::vector<Stream> _streams;
347 std::unordered_map<size_t, std::shared_ptr<SampleDeserializer>> _stream_sample_deserializers;
348 std::shared_ptr<SampleFactory> _sample_factory;
349 std::shared_ptr<StreamTypeFactory> _stream_type_factory;
368 std::optional<SampleDeserializerFactories> sample_deserializer_factories = {}) :
369 _type_factories(type_factories),
370 _sample_deserializer_factories(sample_deserializer_factories)
376 return std::make_unique<ADTFDatFileReader>(_type_factories,
377 _sample_deserializer_factories);
381 std::optional<StreamTypeDeserializers> _type_factories;
382 std::optional<SampleDeserializerFactories> _sample_deserializer_factories;
392 return description.substr(0, description.find_first_of(
"\n"));
402 size_t pos_found = description.find_first_of(
"\n");
403 if (pos_found != std::string::npos)
405 return description.substr(pos_found);
409 return std::string(
"");
Special Reader factory to make readers for "adtfdat" files.
Definition: adtf_file_reader.h:356
std::shared_ptr< Reader > makeReader() const override
Creates a reader.
Definition: adtf_file_reader.h:374
ADTFDatFileReaderFactory(std::optional< StreamTypeDeserializers > type_factories={}, std::optional< SampleDeserializerFactories > sample_deserializer_factories={})
CTOR.
Definition: adtf_file_reader.h:367
ADTF File Reader to deserialze and read the content of a ADTF DAT File.
Definition: adtf_file_reader.h:235
std::vector< Extension > getExtensions() const override
Get the Extensions if any.
void open(const std::string &filename)
a file and uses default sample and stream type factories.
FileItem getNextItem() override
uint64_t getItemIndexForStreamItemIndex(uint16_t stream_id, uint64_t stream_item_index) override
static constexpr int64_t read_cache_deactivated
Definition: adtf_file_reader.h:244
std::string getDescription() const override
std::chrono::nanoseconds getFirstTime() const
Get the timestamp of the very first file item.
a_util::datetime::DateTime getDateTime() const
Get the File Date Time of creating the adtfdat file from fileheader.
std::vector< Stream > getStreams() const override
Get the Streams.
std::shared_ptr< const StreamType > getStreamTypeBefore(uint64_t item_index, uint16_t stream_id) override
uint64_t getItemIndexForTimeStamp(std::chrono::nanoseconds time_stamp) override
std::string getReaderIdentifier() const override
Get the Reader Identifier of the Reader.
Definition: adtf_file_reader.h:267
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::chrono::nanoseconds getLastTime() const
Get the timestamp of the very last file item.
int64_t getNextItemIndex() const
uint32_t getFileVersion() const override
void seekTo(uint64_t item_index) override
std::optional< double > getProgress() const override
Get the Progress, a relative file position between 0.0 and 1.0.
void open(const std::string &filename, std::shared_ptr< SampleFactory > sample_factory, std::shared_ptr< StreamTypeFactory > stream_type_factory) override
CTOR for a new Reader.
static constexpr int64_t read_cache_default
Definition: adtf_file_reader.h:240
ADTFDatFileReader(std::optional< StreamTypeDeserializers > type_factories, std::optional< SampleDeserializerFactories > sample_deserializer_factories)
CTOR for a new Reader.
ADTFDatFileReader(ADTFDatFileReader &&)=default
Move CTOR.
class to create or read a file item. This file item is either a sample, streamtype or trigger.
Definition: reader.h:156
base interface class for all available objects of the ADTF File Library that can be added to the obje...
Definition: object.h:33
The default interface class for stream types.
Definition: stream_type.h:32
Interface class for samples that are read from a Reader.
Definition: sample.h:72
Reader Factory interface to create a reader.
Definition: reader.h:324
container class for SampleDeserializerFactory
Definition: adtf_file_reader.h:198
std::shared_ptr< SampleDeserializer > build(const std::string &id) const
creates the SampleDeserializer for the given id
Definition: adtf_file_reader.h:217
SampleDeserializerFactories & add(const std::shared_ptr< SampleDeserializerFactory > &factory)
Adds a deserializer factory implemention to the container.
Definition: adtf_file_reader.h:205
SampleDeserializerFactory interface class.
Definition: adtf_file_reader.h:160
virtual std::string getId() const =0
Get the identifier if the factory.
virtual std::shared_ptr< SampleDeserializer > build() const =0
create a SampleDeserializer instance
Sample deserializer interface to deserialize a sample.
Definition: adtf_file_reader.h:141
virtual void setStreamType(const StreamType &type)=0
StreamType infomation to initialize deserializer if needed.
virtual void deserialize(ReadSample &sample, InputStream &stream)=0
Deserialize a sample from stream.
Interface for seekable Reader, where the file position can be adapted.
Definition: reader.h:267
StreamType deserializer interface to deserialize a stream type.
Definition: adtf_file_reader.h:82
virtual void deserialize(InputStream &stream, PropertyStreamType &stream_type) const =0
Derserialize a stream_type from stream.
virtual std::string getId() const =0
Get the Id of the serializer i.e. "adtf/default".
container class for StreamTypeDeserializers
Definition: adtf_file_reader.h:101
StreamTypeDeserializers()=default
CTOR.
void Deserialize(const std::string &id, InputStream &stream, PropertyStreamType &stream_type) const
deserializes the given stream into a stream_type with the StreamTypeDeserializer with id
Definition: adtf_file_reader.h:125
StreamTypeDeserializers & add(const std::shared_ptr< StreamTypeDeserializer > &deserializer)
Adds a deserializer implemention to the container.
Definition: adtf_file_reader.h:113
Stream Type base class.
Definition: stream_item.h:43
default implementation template for a SampleDeserializerFactory creating
Definition: adtf_file_reader.h:180
std::string getId() const override
Get the identifier if the factory.
Definition: adtf_file_reader.h:182
std::shared_ptr< SampleDeserializer > build() const override
create a SampleDeserializer instance
Definition: adtf_file_reader.h:187
template class for a sample factory to create sample with implementation type SAMPLE_CLASS
Definition: reader.h:120
template class for a streamtype factory to create streamtypes with implementation type STREAM_TYPE_CL...
Definition: reader.h:93
namespace for ADTF File library
Definition: adtf2_adtf_core_media_sample_deserializer.h:25
std::string getLongDescription(const std::string &description)
helper fuction to retrieve long description out of description
Definition: adtf_file_reader.h:400
std::string getShortDescription(const std::string &description)
helper fuction to retrieve short description out of description
Definition: adtf_file_reader.h:390