STIR  6.2.0
Public Types | Public Member Functions | Static Public Member Functions | List of all members
stir::InputFileFormatRegistry< DataT > Class Template Reference

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< FactoryFactorySPtr
 
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...
 

Detailed Description

template<class DataT>
class stir::InputFileFormatRegistry< DataT >

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.

See also
RegisterInputFileFormat on a convenient way to add InputFileFormat objects to the default registry.
terminology

'Factory' is terminology often used in C++ for an object that can make another object.

Member Function Documentation

◆ default_sptr()

template<class DataT >
static shared_ptr<self_type>& stir::InputFileFormatRegistry< DataT >::default_sptr ( )
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.

Warning
This function returns a reference to the default registry. This can be used to assign your own registry to make it the default for all other subsequent calls. This might lead to unexpected behaviour if your registry does not contain the expected factories.

◆ find_factory() [1/2]

template<class DataT >
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().

◆ find_factory() [2/2]

template<class DataT >
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().

◆ list_registered_names()

template<class DataT >
void stir::InputFileFormatRegistry< DataT >::list_registered_names ( std::ostream &  stream) const

List all possible registered names to the stream.

Names are separated with newlines.


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