adtf_file_library
0.13.1
|
#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::Reader > | makeReader (const std::string &reader_id) const |
create an instance for the given reader_id More... | |
std::shared_ptr< adtf_file::Reader > | 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 . 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... | |
A container for reader factories.
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
[in] | factory | The factory to add. |
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.
filename
no callback is made and an exception is thrown. capable_reader_callback
function throws, the reader is marked as not capable! filename | The file to open. |
capable_reader_callback | The callback to return the create and opened capable reader. |
sample_factory | The sample factory to use for the open call. |
stream_type_factory | The streamtype factory to use for the open call. |
configuration | The reader configuration to set before opened. |
std::runtime_error | if no capable reader was found |
const std::unordered_map<std::string, std::shared_ptr<const ReaderFactory> >& adtf_file::ReaderFactories::getFactories | ( | ) | const |
Get the Factories.
std::shared_ptr<adtf_file::Reader> adtf_file::ReaderFactories::makeReader | ( | const std::string & | reader_id | ) | const |
create an instance for the given reader_id
reader_id | The reader identifier for the reader to create. |
reader_id
is not allowed to be empty! std::runtime_error | if factory to make reader for reader_id does not exists |
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
.
reader_id
is empty, it obtains the Readerfactory and Reader to deal with the given filename
. 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. reader_id | The identifier of the reader implementation. |
filename | The file to open. |
sample_factory | The sample factory to use for the open call. |
stream_type_factory | The streamtype factory to use for the open call. |
configuration | The reader configuration to set before opened. |
reader_id
exists or a capable reader was found. std::runtime_error | if reader_id does not exists |
std::runtime_error | if no capable reader was found |
void adtf_file::ReaderFactories::remove | ( | const std::string & | reader_id | ) |
Removes the given reader factory implementation.
[in] | reader_id | The identifier of the reader implementation |