adtf_file_library  0.13.1
Public Member Functions | List of all members
adtf_file::ReaderFactories Class Reference

#include <reader.h>

Public Member Functions

void add (const std::shared_ptr< const adtf_file::ReaderFactory > &factory)
 
void remove (const std::string &reader_id)
 
std::shared_ptr< adtf_file::ReadermakeReader (const std::string &reader_id) const
 create an instance for the given reader_id More...
 
std::shared_ptr< adtf_file::ReaderopenReader (const std::string &filename, const adtf_file::Configuration &configuration={}, std::shared_ptr< adtf_file::SampleFactory > sample_factory={}, std::shared_ptr< adtf_file::StreamTypeFactory > stream_type_factory={}, std::optional< std::string > reader_id={}) const
 Creates an instance for the given reader_id, sets the given configuration and opens the reader with given filename. More...
 
void getCapableReaders (const std::string &filename, const std::function< bool(const std::shared_ptr< Reader > &)> &capable_reader_callback, const adtf_file::Configuration &configuration={}, std::shared_ptr< adtf_file::SampleFactory > sample_factory={}, std::shared_ptr< adtf_file::StreamTypeFactory > stream_type_factory={}) const
 Get all capable readers can open the given file (filename). It will make and open all capable Reader and return it to the reader_callback if succeded. As long as the reader_callback return true further readers may be created and opened. More...
 
const std::unordered_map< std::string, std::shared_ptr< const ReaderFactory > > & getFactories () const
 Get the Factories. More...
 

Detailed Description

A container for reader factories.

Member Function Documentation

◆ add()

void adtf_file::ReaderFactories::add ( const std::shared_ptr< const adtf_file::ReaderFactory > &  factory)

Adds the given factory to the container and registeres it for the reader identifier

Parameters
[in]factoryThe factory to add.

◆ getCapableReaders()

void adtf_file::ReaderFactories::getCapableReaders ( const std::string &  filename,
const std::function< bool(const std::shared_ptr< Reader > &)> &  capable_reader_callback,
const adtf_file::Configuration configuration = {},
std::shared_ptr< adtf_file::SampleFactory sample_factory = {},
std::shared_ptr< adtf_file::StreamTypeFactory stream_type_factory = {} 
) const

Get all capable readers can open the given file (filename). It will make and open all capable Reader and return it to the reader_callback if succeded. As long as the reader_callback return true further readers may be created and opened.

Remarks
If no reader is able to open filename no callback is made and an exception is thrown.
If the capable_reader_callback function throws, the reader is marked as not capable!
Parameters
filenameThe file to open.
capable_reader_callbackThe callback to return the create and opened capable reader.
sample_factoryThe sample factory to use for the open call.
stream_type_factoryThe streamtype factory to use for the open call.
configurationThe reader configuration to set before opened.
Exceptions
std::runtime_errorif no capable reader was found

◆ getFactories()

const std::unordered_map<std::string, std::shared_ptr<const ReaderFactory> >& adtf_file::ReaderFactories::getFactories ( ) const

Get the Factories.

Returns
const std::unordered_map<std::string, std::shared_ptr<const ReaderFactory>>&

◆ makeReader()

std::shared_ptr<adtf_file::Reader> adtf_file::ReaderFactories::makeReader ( const std::string &  reader_id) const

create an instance for the given reader_id

Parameters
reader_idThe reader identifier for the reader to create.
Returns
std::shared_ptr<adtf_file::Reader>
Remarks
the reader_id is not allowed to be empty!
Exceptions
std::runtime_errorif factory to make reader for reader_id does not exists

◆ openReader()

std::shared_ptr<adtf_file::Reader> adtf_file::ReaderFactories::openReader ( const std::string &  filename,
const adtf_file::Configuration configuration = {},
std::shared_ptr< adtf_file::SampleFactory sample_factory = {},
std::shared_ptr< adtf_file::StreamTypeFactory stream_type_factory = {},
std::optional< std::string >  reader_id = {} 
) const

Creates an instance for the given reader_id, sets the given configuration and opens the reader with given filename.

Remarks
if reader_id is empty, it obtains the Readerfactory and Reader to deal with the given filename.
if reader_id is empty, readers derived by ExplicitReader will not be taken into concern, although they might be capable to open the file. To open an ExplicitReader the reader_id must be set to its reader identifier explicitly.
Parameters
reader_idThe identifier of the reader implementation.
filenameThe file to open.
sample_factoryThe sample factory to use for the open call.
stream_type_factoryThe streamtype factory to use for the open call.
configurationThe reader configuration to set before opened.
Returns
A new reader instance if reader_id exists or a capable reader was found.
Exceptions
std::runtime_errorif reader_id does not exists
std::runtime_errorif no capable reader was found

◆ remove()

void adtf_file::ReaderFactories::remove ( const std::string &  reader_id)

Removes the given reader factory implementation.

Parameters
[in]reader_idThe identifier of the reader implementation

The documentation for this class was generated from the following file:

Copyright © CARIAD SE.
Generated on Fri Apr 19 2024 by doxygen 1.9.1
GIT Commit Hash: 82d535f82776c20b12fc60740bdae991b62444a7