libpniio
Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes
pni::io::fio_reader Class Reference

FIO data reader. More...

#include <fio_reader.hpp>

Inheritance diagram for pni::io::fio_reader:
Inheritance graph
[legend]
Collaboration diagram for pni::io::fio_reader:
Collaboration graph
[legend]

Public Member Functions

 fio_reader ()
 default constructor More...
 
 fio_reader (const fio_reader &r)=delete
 copy construction is deleted More...
 
 fio_reader (fio_reader &&r)
 move constructor More...
 
 fio_reader (const pni::core::string &n)
 standard constructor More...
 
 ~fio_reader ()
 destructor More...
 
fio_readeroperator= (const fio_reader &r)=delete
 copy assignment is deleted More...
 
fio_readeroperator= (fio_reader &&r)
 move assignemnt operator More...
 
size_t nparameters () const
 get number of parameters More...
 
std::vector< pni::core::string > parameter_names () const
 get parameter names More...
 
template<typename T >
parameter (const pni::core::string &name) const
 get parameter by name More...
 
template<typename CTYPE >
CTYPE column (const pni::core::string &n) const
 get single column More...
 
template<typename CTYPE >
void column (const pni::core::string &n, CTYPE &c) const
 read single column More...
 
- Public Member Functions inherited from pni::io::spreadsheet_reader
virtual ~spreadsheet_reader ()
 destructor More...
 
spreadsheet_readeroperator= (const spreadsheet_reader &)=delete
 copy assignment operator is deleted More...
 
spreadsheet_readeroperator= (spreadsheet_reader &&r)
 move assignment operator More...
 
size_t ncolumns () const
 get column number More...
 
size_t nrecords () const
 get record number More...
 
iterator begin ()
 get iterator to first column More...
 
const_iterator begin () const
 get const first iterator More...
 
iterator end ()
 get last iterator More...
 
const_iterator end () const
 get const last iterator More...
 
bool has_column (const pni::core::string &name) const
 checks if a particular column exists More...
 
size_t column_index (const pni::core::string &name) const
 get column index More...
 
- Public Member Functions inherited from pni::io::data_reader
virtual ~data_reader ()
 destructor More...
 
pni::core::string filename () const
 get filename More...
 
void filename (const pni::core::string &fname)
 set filename More...
 
virtual void close ()
 close the file More...
 
virtual void open ()
 open file More...
 

Private Member Functions

void _parse_file (std::ifstream &stream)
 initial file parseing More...
 
void _parse_parameters (std::ifstream &stream)
 parse parameter section More...
 
void _parse_data (std::ifstream &stream)
 parse the data section More...
 
template<typename T >
void _get_parameter_data (std::ifstream &stream, T &value) const
 read parameter data More...
 
void _get_parameter_data (std::ifstream &stream, pni::core::string &value) const
 read string parameter More...
 
template<typename CTYPE >
void _read_column (size_t index, CTYPE &array) const
 read column data More...
 

Static Private Member Functions

static pni::core::type_id_t _typestr2id (const pni::core::string &tstr)
 type id from type string More...
 
static column_info _read_column_info (const pni::core::string &line)
 get ColumnInfo from line More...
 
static std::vector
< pni::core::string > 
_read_data_line (const pni::core::string &line)
 read data line More...
 

Private Attributes

std::map< pni::core::string,
std::streampos > 
_param_map
 parameter stream positions More...
 
std::streampos _data_offset
 offset where real data starts More...
 

Additional Inherited Members

- Public Types inherited from pni::io::spreadsheet_reader
typedef std::vector
< column_info >::iterator 
iterator
 iterator type More...
 
typedef std::vector
< column_info >
::const_iterator 
const_iterator
 const iterator type More...
 
- Protected Member Functions inherited from pni::io::spreadsheet_reader
 spreadsheet_reader ()
 default constructor More...
 
 spreadsheet_reader (const spreadsheet_reader &)=delete
 copy constructor is deleted More...
 
 spreadsheet_reader (spreadsheet_reader &&o)
 move constructor More...
 
 spreadsheet_reader (const pni::core::string &n)
 standard constructor More...
 
virtual void _append_column (const column_info &i)
 append a column More...
 
virtual column_info _get_column (size_t i) const
 get column information More...
 
virtual column_info _get_column (const pni::core::string &n) const
 get column information More...
 
void _nrecords (size_t n)
 set number of records More...
 
- Protected Member Functions inherited from pni::io::data_reader
std::ifstream & _get_stream () const
 get stream More...
 
void _set_binary ()
 set binary mode More...
 
 data_reader ()
 default constructor More...
 
 data_reader (const pni::core::string &fname, bool binary=false)
 standard constructor More...
 
 data_reader (data_reader &&r)
 move constructor More...
 
 data_reader (const data_reader &r)=delete
 copy constructor is deleted More...
 
data_readeroperator= (const data_reader &r)=delete
 copy assigment is deleted More...
 
data_readeroperator= (data_reader &&r)
 move assignment More...
 

Detailed Description

FIO files are written by ONLINE a data acquisition and experiment control software used at DESY. FIO files are basically ACII files where data is stored in columns. Thus such files correspond to the family of spreadsheet style files.

Constructor & Destructor Documentation

pni::io::fio_reader::fio_reader ( )
pni::io::fio_reader::fio_reader ( const fio_reader r)
delete
pni::io::fio_reader::fio_reader ( fio_reader &&  r)
pni::io::fio_reader::fio_reader ( const pni::core::string &  n)
pni::io::fio_reader::~fio_reader ( )

Member Function Documentation

template<typename T >
void pni::io::fio_reader::_get_parameter_data ( std::ifstream &  stream,
T &  value 
) const
private

This template is used internally to extract parameter data from the input stream and store the result in a variable of type T.

Parameters
streaminput stream
valuewhere to store data
void pni::io::fio_reader::_get_parameter_data ( std::ifstream &  stream,
pni::core::string &  value 
) const
private

Overloaded version of the _get_parameter_data template method to handle string data.

Parameters
streaminput stream
valuestring value where to store parameter data
void pni::io::fio_reader::_parse_data ( std::ifstream &  stream)
private

Private function which execudes parser code for the data section of the FIO file. It collects all the information about columns present in the file.

Parameters
streaminput stream from which to read data
void pni::io::fio_reader::_parse_file ( std::ifstream &  stream)
private

This private method runs through the entire file once and calles the appropriate parses.

Parameters
streaminput stream from which to read data
void pni::io::fio_reader::_parse_parameters ( std::ifstream &  stream)
private

Method parses the parameter section of a file. It sets up the _param_map member variable.

Parameters
streaminput stream from which to read data
template<typename CTYPE >
void pni::io::fio_reader::_read_column ( size_t  index,
CTYPE &  array 
) const
private

Private template method to read column data and store it to an array object. If EOF is reached before all data was read an exception will be thrown.

Exceptions
file_errorif EOF is reached before end of data
Parameters
indexindex of the column in the file
arrayinstance of the Array template where to store the data
column_info pni::io::fio_reader::_read_column_info ( const pni::core::string &  line)
staticprivate

Method retrievs column information from a line.

Parameters
linestring object holding the lines content
Returns
instance of ColumnInfo
std::vector< pni::core::string > pni::io::fio_reader::_read_data_line ( const pni::core::string &  line)
staticprivate

Reads a data line and splits the line into its cells. The method returns a vector of Strings where each elements corresponds to a particular cell.

Parameters
lineinput line
Returns
vector with cell content as strings
pni::core::type_id_t pni::io::fio_reader::_typestr2id ( const pni::core::string &  tstr)
staticprivate

Method converts a FIO type string to a TypeID as provided by libpniio.

Parameters
tstrtype string
Returns
TypeID
template<typename CTYPE >
CTYPE pni::io::fio_reader::column ( const pni::core::string &  n) const

Returns a single column and stores the data into an array object. If the column name does not exist an exception is thrown.

Exceptions
key_errorif column does not exist
file_errorif EOF is reached before end of data
Parameters
nname of the column
Returns
instance of ATYPE holding the data.
template<typename CTYPE >
void pni::io::fio_reader::column ( const pni::core::string &  n,
CTYPE &  c 
) const

Read a single column and stores the result in an appropriate container. The method assumes that the container is of appropriate size and shape.

Exceptions
key_errorif the requested column does not exist
file_errorin any other case of error
Template Parameters
CTYPEcontainer type
Parameters
nname of the column
cinstance of CTYPE that will in the end contain the data
size_t pni::io::fio_reader::nparameters ( ) const

Return the number of parameters stored in the file.

Returns
number of parameters
fio_reader& pni::io::fio_reader::operator= ( const fio_reader r)
delete
fio_reader & pni::io::fio_reader::operator= ( fio_reader &&  r)
template<typename T >
T pni::io::fio_reader::parameter ( const pni::core::string &  name) const

Return the value of a parameter stored in the FIO file by name.

Exceptions
key_errrorif parameter name does not exist
Parameters
nameparameter name
Returns
parameter value as type T
std::vector< pni::core::string > pni::io::fio_reader::parameter_names ( ) const

Returns a vector of Strings holding the parameter names stored in the file.

Returns
parameter names

Field Documentation

std::streampos pni::io::fio_reader::_data_offset
private
std::map<pni::core::string,std::streampos> pni::io::fio_reader::_param_map
private

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