STIR  6.2.0
Public Types | Public Member Functions | List of all members
stir::GE::RDF_HDF5::InputStreamWithRecordsFromHDF5< RecordT > Class Template Reference

A helper class to read data from a hdf5 file. More...

#include "stir/IO/InputStreamWithRecordsFromHDF5.h"

Public Types

typedef std::vector< std::streampos >::size_type SavedPosition
 

Public Member Functions

 InputStreamWithRecordsFromHDF5 (const std::string &filename, const std::size_t size_of_record_signature, const std::size_t max_size_of_record)
 Constructor taking a stream. More...
 
virtual Succeeded get_next_record (RecordT &record)
 
virtual Succeeded set_up ()
 
Succeeded reset ()
 go back to starting position
 
SavedPosition save_get_position ()
 save current "get" position in an internal array More...
 
Succeeded set_get_position (const SavedPosition &)
 set current "get" position to previously saved value
 
std::vector< std::streampos > get_saved_get_positions () const
 Function that enables the user to store the saved get_positions. More...
 
void set_saved_get_positions (const std::vector< std::streampos > &)
 Function that sets the saved get_positions. More...
 

Detailed Description

template<class RecordT>
class stir::GE::RDF_HDF5::InputStreamWithRecordsFromHDF5< RecordT >

A helper class to read data from a hdf5 file.

This class is really a helper class for reading different records from a stream. It is useful when all types of records have some kind of signature to allow the function to find out what the size of the record is. In that case, all IO handling is completely generic and is implemented in this class.

Current implementation needs a max_size_of_record to allocate enough memory (on the stack) before reading. This is efficient in many cases, but impractical in others.

Requirements
RecordT needs to have the following member functions
std::size_t
size_of_record_at_ptr(const char * const buffer, const std::size_t size_available_in_buffer,
const OptionsT options) const;
Succeeded
init_from_data_ptr(const char * const buffer,
const std::size_t size_of_record,
const OptionsT options);
Todo:
Allow choosing between allocation with new or on the stack.

Constructor & Destructor Documentation

◆ InputStreamWithRecordsFromHDF5()

template<class RecordT >
stir::GE::RDF_HDF5::InputStreamWithRecordsFromHDF5< RecordT >::InputStreamWithRecordsFromHDF5 ( const std::string &  filename,
const std::size_t  size_of_record_signature,
const std::size_t  max_size_of_record 
)
explicit

Constructor taking a stream.

Data will be assumed to start at the start of the DataSet. If reset() is used, it will go back to this starting position.

Member Function Documentation

◆ save_get_position()

template<class RecordT >
InputStreamWithRecordsFromHDF5< RecordT >::SavedPosition stir::GE::RDF_HDF5::InputStreamWithRecordsFromHDF5< RecordT >::save_get_position ( )
inline

save current "get" position in an internal array

Returns
an "index" into the array that allows you to go back.
See also
set_get_position

◆ get_saved_get_positions()

template<class RecordT >
std::vector< std::streampos > stir::GE::RDF_HDF5::InputStreamWithRecordsFromHDF5< RecordT >::get_saved_get_positions ( ) const
inline

Function that enables the user to store the saved get_positions.

Together with set_saved_get_positions(), this allows reinstating the saved get_positions when reopening the same stream.

◆ set_saved_get_positions()

template<class RecordT >
void stir::GE::RDF_HDF5::InputStreamWithRecordsFromHDF5< RecordT >::set_saved_get_positions ( const std::vector< std::streampos > &  poss)
inline

Function that sets the saved get_positions.

Normally, the argument results from a call to get_saved_get_positions() on the same stream.

Warning
There is no check if the argument actually makes sense for the current stream.

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