STIR  6.2.0
Public Member Functions | Protected Member Functions | List of all members
stir::DataProcessor< DataT > Class Template Referenceabstract

Base class that defines an interface for classes that do data processing. More...

#include "stir/DataProcessor.h"

Inheritance diagram for stir::DataProcessor< DataT >:
Inheritance graph
[legend]

Public Member Functions

Succeeded set_up (const DataT &data)
 Initialises any internal data (if necessary) using data as a template for sizes, sampling distances etc. More...
 
virtual void reset ()
 Makes sure we will ignore any previous call to set-up() More...
 
Succeeded apply (DataT &data)
 Calls set_up() (if not already done before) and process data in-place. More...
 
Succeeded apply (DataT &out_data, const DataT &in_data)
 Calls set_up() (if not already done before) and process in_data, putting the result in out_data. More...
 
parsing functions

parse() returns false if there is some error, true otherwise.

These call reset() first, and then ParsingObject::parse

bool parse (std::istream &f)
 
bool parse (const char *const filename)
 
- Public Member Functions inherited from stir::RegisteredObjectBase
virtual std::string get_registered_name () const =0
 Returns the name of the type of the object. More...
 
- Public Member Functions inherited from stir::ParsingObject
 ParsingObject (const ParsingObject &)
 
ParsingObjectoperator= (const ParsingObject &)
 
void ask_parameters ()
 
virtual std::string parameter_info ()
 
bool parse (std::istream &f)
 
bool parse (const char *const filename)
 
- Public Member Functions inherited from stir::TimedObject
void reset_timers ()
 reset all timers kept by this object
 
void stop_timers () const
 stop all timers kept by this object More...
 
void start_timers (bool do_reset=false) const
 start all timers kept by this object More...
 
double get_CPU_timer_value () const
 get current value of the CPU timer (since first use or last reset)
 
double get_wall_clock_timer_value () const
 get current value of the wall-clock timer (since first use or last reset)
 

Protected Member Functions

virtual Succeeded virtual_set_up (const DataT &)=0
 Will be called to build any internal parameters.
 
virtual void virtual_apply (DataT &data, const DataT &in_data) const =0
 Performs actual operation (virtual_set_up is called before this function)
 
virtual void virtual_apply (DataT &data) const =0
 Performs actual operation (in-place)
 
- Protected Member Functions inherited from stir::ParsingObject
virtual void set_defaults ()
 Set defaults before parsing.
 
virtual void initialise_keymap ()
 Initialise all keywords.
 
virtual bool post_processing ()
 This will be called at the end of the parsing. More...
 
virtual void set_key_values ()
 This will be called before parsing or parameter_info is called. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from stir::RegisteredObject< DataProcessor< DataT > >
static DataProcessor< DataT > * read_registered_object (std::istream *in, const std::string &registered_name)
 Construct a new object (of a type derived from Root, its actual type determined by the registered_name parameter) by parsing the istream. More...
 
static DataProcessor< DataT > * ask_type_and_parameters ()
 ask the user for the type, and then calls read_registered_object(0, type) More...
 
static void list_registered_names (std::ostream &stream)
 List all possible registered names to the stream. More...
 
- Protected Types inherited from stir::RegisteredObject< DataProcessor< DataT > >
typedef DataProcessor< DataT > *(* RootFactory) (std::istream *)
 The type of a root factory is a function, taking an istream* as argument, and returning a Root*.
 
typedef FactoryRegistry< std::string, RootFactory, interfile_lessRegistryType
 The type of the registry.
 
- Static Protected Member Functions inherited from stir::RegisteredObject< DataProcessor< DataT > >
static RegistryTyperegistry ()
 Static function returning the registry. More...
 
- Protected Attributes inherited from stir::ParsingObject
KeyParser parser
 

Detailed Description

template<typename DataT>
class stir::DataProcessor< DataT >

Base class that defines an interface for classes that do data processing.

Classes at the end of the DataProcessor hierarchy have to be able to parse parameter files etc. Moreover, it has to be possible to construct an DataProcessor object while parsing, where the actual type of derived class is determined at run-time. Luckily, this is exactly the situation that RegisteredObject and RegisteredParsingObject are supposed to handle. So, all this functionality is achieved by deriving DataProcessor from the appropriate RegisteredObject class, and deriving the 'leaves' from RegisteredParsingObject.

Member Function Documentation

◆ set_up()

template<typename DataT>
Succeeded stir::DataProcessor< DataT >::set_up ( const DataT &  data)
inline

Initialises any internal data (if necessary) using data as a template for sizes, sampling distances etc.

Warning
DataProcessor does NOT check if the input data for apply() actually corresponds to the template. So, most derived classes will not call set_up again if the input data does not correspond to the template, potentially resulting in erroneous output.

The reason that DataProcessor does not perform this check is that it does not know what the requirements are to call the 2 densities 'compatible'.

Referenced by stir::DataProcessor< TargetT >::apply().

◆ reset()

template<typename DataT >
void stir::DataProcessor< DataT >::reset ( )
inlinevirtual

Makes sure we will ignore any previous call to set-up()

If you change any internal variables of the data-processor, or are calling it on data if different size or so, you first have to call reset() such that the data-processor will call set_up() when necessary.

A derived class could overload reset() to re-initialise any internal variables, but this is not required.

Referenced by stir::DataProcessor< TargetT >::reset().

◆ apply() [1/2]

template<typename DataT>
Succeeded stir::DataProcessor< DataT >::apply ( DataT &  data)
inline

Calls set_up() (if not already done before) and process data in-place.

If set_up() returns Succeeded::false, a warning message is written, and the data is not changed.

◆ apply() [2/2]

template<typename DataT>
Succeeded stir::DataProcessor< DataT >::apply ( DataT &  out_data,
const DataT &  in_data 
)
inline

Calls set_up() (if not already done before) and process in_data, putting the result in out_data.

If set_up() returns Succeeded::false, a warning message is written, and the out_data is not changed.

Warning
Most derived classes will assume that out_data is already initialised appropriately (e.g. has correct dimensions, voxel sizes etc.).

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