STIR  6.2.0
Public Member Functions | List of all members
stir::ParseAndCreateFrom< OutputT, InputT, ParserT > Class Template Reference

template for adding keywords to a parser and creating an object More...

#include "stir/ParseAndCreateFrom.h"

Inheritance diagram for stir::ParseAndCreateFrom< OutputT, InputT, ParserT >:
Inheritance graph
[legend]

Public Member Functions

void set_defaults ()
 set default values for any parameters
 
void add_to_keymap (ParserT &)
 add any relevant parameters to a parser
 
void check_values () const
 should call error() if something is wrong
 
OutputT * create (const InputT &) const
 create a new object More...
 

Detailed Description

template<class OutputT, class InputT, class ParserT = KeyParser>
class stir::ParseAndCreateFrom< OutputT, InputT, ParserT >

template for adding keywords to a parser and creating an object

The idea is that a reconstructor needs to be able to create an image based on some parameters and the current input data. However, this needs to be flexible for different types, as for instance, many different reconstructors produce a DiscretisedDensity object but from different input data, or vice versa.

We do this using specialisations of this class. That way, PoissonLogLikelihoodWithLinearModelForMeanAndProjData etc can be templated without having to know what the actual OutputT is.

This of course only works if a specialisation is created for the OutputT and InputT of interest.

A specialisation needs to define all four member functions as the reconstruction code will otherwise break.

The default implementations don't do anything (aside from create()).

Check ParseAndCreateFrom<DiscretisedDensity<3, elemT>, ExamDataT> for an example which might make sense.

Member Function Documentation

◆ create()

template<class OutputT, class InputT, class ParserT = KeyParser>
OutputT* stir::ParseAndCreateFrom< OutputT, InputT, ParserT >::create ( const InputT &  ) const
inline

create a new object

This can take any parsed parameters into account.

The default just calls new.

Todo:
Currently we're assuming this returns a bare pointer (to a new object). This is due to limitations in the reconstruction classes. It will need to change to a std::unique pointer.

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