STIR
6.2.0
|
A class for registering (and finding) all input file formats. More...
#include "stir/IO/InputFileFormatRegistry.h"
Public Types | |
typedef DataT | data_type |
typedef InputFileFormat< DataT > | Factory |
typedef shared_ptr< Factory > | FactorySPtr |
typedef InputFileFormatRegistry< DataT > | self_type |
Public Member Functions | |
InputFileFormatRegistry () | |
Default constructor without defaults (see find_factory()) | |
void | add_to_registry (FactorySPtr const &factory, const unsigned ranking) |
Add a file-format to the registry with given ranking Ranking 0 is the 'highest', so will be found first. | |
void | remove_from_registry (const Factory &factory) |
Remove a pair from the registry. | |
Factory const & | find_factory (const FileSignature &signature, std::istream &input) const |
Find a factory that can handle a particular stream. More... | |
Factory const & | find_factory (const FileSignature &signature, const std::string &filename) const |
Find a factory that can handle a particular filename. More... | |
Factory const & | find_factory (const std::string &filename) const |
Find a factory that can handle a particular filename. | |
Factory const & | find_factory (std::istream &input) const |
Find a factory that can handle a particular stream. | |
void | list_registered_names (std::ostream &stream) const |
List all possible registered names to the stream. More... | |
Static Public Member Functions | |
static shared_ptr< self_type > & | default_sptr () |
A function to return the default registry. More... | |
A class for registering (and finding) all input file formats.
Preliminary
This class stores 'factories' that take a file as argument to produce a new object.
'Factory' is terminology often used in C++ for an object that can make another object.
|
static |
A function to return the default registry.
This default registry will be created when this function called the first time.It will then be empty.
Factory const& stir::InputFileFormatRegistry< DataT >::find_factory | ( | const FileSignature & | signature, |
std::istream & | input | ||
) | const |
Find a factory that can handle a particular stream.
The signature
and input
arguments are supposed to correspond to the same file.
The function will loop through all factories in the registry, in order of decreasing ranking
, and return the first factory found that can handle the data.
If no matching factory is found, we call error().
Referenced by stir::read_from_file().
Factory const& stir::InputFileFormatRegistry< DataT >::find_factory | ( | const FileSignature & | signature, |
const std::string & | filename | ||
) | const |
Find a factory that can handle a particular filename.
The signature
and input
arguments are supposed to correspond to the same file.
The function will loop through all factories in the registry, in order of decreasing ranking
, and return the first factory found that can handle the data.
If no matching factory is found, we call error().
void stir::InputFileFormatRegistry< DataT >::list_registered_names | ( | std::ostream & | stream | ) | const |
List all possible registered names to the stream.
Names are separated with newlines.