ProteoWizard
Public Types | Public Member Functions | Private Member Functions | Private Attributes
pwiz::msdata::mz5::Connection_mz5 Class Reference

This class is used for reading and writing information to a mz5 file. More...

#include <Connection_mz5.hpp>

List of all members.

Public Types

enum  OpenPolicy { FailIfFileExists, RemoveAndCreate, ReadWrite, ReadOnly }
 mz5 file open policy. More...

Public Member Functions

 Connection_mz5 (const std::string filename, const OpenPolicy op=ReadOnly, const Configuration_mz5 config=Configuration_mz5())
 Default constructor.
 ~Connection_mz5 ()
 Closes all open datasets and flushes file to filesystem.
void createAndWrite1DDataSet (hsize_t size, void *data, const Configuration_mz5::MZ5DataSets v)
 Creates and write a one dimensional dataset.
void extendData (const std::vector< double > &d1, const Configuration_mz5::MZ5DataSets v)
 Extends data of to a dataset.
const std::map
< Configuration_mz5::MZ5DataSets,
size_t > & 
getFields ()
 Returns a list of all existing datasets in this file.
void * readDataSet (Configuration_mz5::MZ5DataSets v, size_t &dsend, void *ptr=0)
 Reads a dataset.
void clean (const Configuration_mz5::MZ5DataSets v, void *data, const size_t dsend)
 Clean up of open datasets and destruction of corresponding data elements.
void getData (std::vector< double > &data, const Configuration_mz5::MZ5DataSets v, const hsize_t start, const hsize_t end)
 Gets data from a numerical dataset and writes it to the vector.
const Configuration_mz5getConfiguration ()
 Getter.

Private Member Functions

H5::DSetCreatPropList getCParm (int rank, const Configuration_mz5::MZ5DataSets &v, const hsize_t &datadim)
 Creates a DSetCreatPropList for a dataset.
H5::DataSet getDataSet (int rank, hsize_t *dim, hsize_t *maxdim, const Configuration_mz5::MZ5DataSets v)
 Creates a dataset.
void readFile ()
 Initializes a file and read internal mz5 information.
void extendAndWrite1DDataSet (const H5::DataSet &dataset, const std::vector< double > &d1)
 Extends and appends data to an existing dataset with no buffer.
void addToBuffer (std::vector< double > &b, const std::vector< double > &d1, const size_t bs, const H5::DataSet &dataset)
 Internal method to add data to a buffer.
void flush (const Configuration_mz5::MZ5DataSets v)
 Flushes all data to the hard drive.
void close ()
 Closes the file and flushes all open buffers/datasets.

Private Attributes

std::map
< Configuration_mz5::MZ5DataSets,
size_t > 
fields_
 Existing field in file.
H5::H5File * file_
 MZ5 file reference.
Configuration_mz5 config_
 mz5 configuration object.
std::map
< Configuration_mz5::MZ5DataSets,
H5::DataSet > 
bufferMap_
 Mapping from a dataset enumeration value to the dataset.
std::map
< Configuration_mz5::MZ5DataSets,
std::vector< double > > 
buffers_
 Mapping from a dataset enumeration value to a buffer.
bool closed_
 Flag whether file is closed or not.

Detailed Description

This class is used for reading and writing information to a mz5 file.

On destruction it will automatically close all existing datasets and flush the file.

Definition at line 40 of file Connection_mz5.hpp.


Member Enumeration Documentation

mz5 file open policy.

Enumerator:
FailIfFileExists 

Fails if the file already exists.

RemoveAndCreate 

If file exists, it will be deleted and created empty.

ReadWrite 

Open file with read and write support.

ReadOnly 

Open file with read only support.

Definition at line 46 of file Connection_mz5.hpp.

{
/**
* Fails if the file already exists.
*/
/**
* If file exists, it will be deleted and created empty.
*/
/**
* Open file with read and write support.
*/
/**
* Open file with read only support.
*/
};

Constructor & Destructor Documentation

pwiz::msdata::mz5::Connection_mz5::Connection_mz5 ( const std::string  filename,
const OpenPolicy  op = ReadOnly,
const Configuration_mz5  config = Configuration_mz5() 
)

Default constructor.

When opening a file, which is a hdf5 file but no mz5 file, a runtime_error is thrown.

Parameters:
filenamefile name
opopen policy
configurationconfiguration used to determine chunk and buffer sizes
pwiz::msdata::mz5::Connection_mz5::~Connection_mz5 ( )

Closes all open datasets and flushes file to filesystem.


Member Function Documentation

void pwiz::msdata::mz5::Connection_mz5::createAndWrite1DDataSet ( hsize_t  size,
void *  data,
const Configuration_mz5::MZ5DataSets  v 
)

Creates and write a one dimensional dataset.

Parameters:
sizesize of the dataset
datavoid pointer to the dataset beginning
vdataset enumeration value
void pwiz::msdata::mz5::Connection_mz5::extendData ( const std::vector< double > &  d1,
const Configuration_mz5::MZ5DataSets  v 
)

Extends data of to a dataset.

This method automatically uses an internal buffer to write the data and calls extendsAndWrite1DDataSet()

Parameters:
d1data
vdataset enumeration value
const std::map<Configuration_mz5::MZ5DataSets, size_t>& pwiz::msdata::mz5::Connection_mz5::getFields ( )

Returns a list of all existing datasets in this file.

void* pwiz::msdata::mz5::Connection_mz5::readDataSet ( Configuration_mz5::MZ5DataSets  v,
size_t &  dsend,
void *  ptr = 0 
)

Reads a dataset.

If no pointer is set, this method will allocate the needed mememory with calloc. To regain the memory call clean().

Parameters:
vdataset enumeration value
dsenddataset size
ptrstart pointer where the data should be written to.
Returns:
pointer to the data
void pwiz::msdata::mz5::Connection_mz5::clean ( const Configuration_mz5::MZ5DataSets  v,
void *  data,
const size_t  dsend 
)

Clean up of open datasets and destruction of corresponding data elements.

This method calls vlenReclaim, free and close.

Parameters:
vdataset enumeration value
datapointer to the beginning of the data
dsendlength of the data.
void pwiz::msdata::mz5::Connection_mz5::getData ( std::vector< double > &  data,
const Configuration_mz5::MZ5DataSets  v,
const hsize_t  start,
const hsize_t  end 
)

Gets data from a numerical dataset and writes it to the vector.

This method is used to get mz,intensity and time.

Parameters:
datadata vector
vdataset enumeration value
startstart index
endend index
const Configuration_mz5& pwiz::msdata::mz5::Connection_mz5::getConfiguration ( )

Getter.

Returns:
current configuration
H5::DSetCreatPropList pwiz::msdata::mz5::Connection_mz5::getCParm ( int  rank,
const Configuration_mz5::MZ5DataSets v,
const hsize_t &  datadim 
)
private

Creates a DSetCreatPropList for a dataset.

Parameters:
rankdimensionality of dataset
datasetdataset used to determine the name
datadimdata dimensions
Returns:
DSetCreatPropList
H5::DataSet pwiz::msdata::mz5::Connection_mz5::getDataSet ( int  rank,
hsize_t *  dim,
hsize_t *  maxdim,
const Configuration_mz5::MZ5DataSets  v 
)
private

Creates a dataset.

Parameters:
rankdimensionality of the dataset
dimsize of each dimension
maxdimmaximal size of each dimension
vdataset enumeration value
Returns:
dataset
void pwiz::msdata::mz5::Connection_mz5::readFile ( )
private

Initializes a file and read internal mz5 information.

Will throw a runtime_error when the file is not a mz5 file.

void pwiz::msdata::mz5::Connection_mz5::extendAndWrite1DDataSet ( const H5::DataSet &  dataset,
const std::vector< double > &  d1 
)
private

Extends and appends data to an existing dataset with no buffer.

Parameters:
datasetdataset
d1data
void pwiz::msdata::mz5::Connection_mz5::addToBuffer ( std::vector< double > &  b,
const std::vector< double > &  d1,
const size_t  bs,
const H5::DataSet &  dataset 
)
private

Internal method to add data to a buffer.

Parameters:
bbuffer
d1data
bsbuffer size
datasetdataset
void pwiz::msdata::mz5::Connection_mz5::flush ( const Configuration_mz5::MZ5DataSets  v)
private

Flushes all data to the hard drive.

Parameters:
vdataset enumeration value
void pwiz::msdata::mz5::Connection_mz5::close ( )
private

Closes the file and flushes all open buffers/datasets.


Member Data Documentation

std::map<Configuration_mz5::MZ5DataSets, size_t> pwiz::msdata::mz5::Connection_mz5::fields_
private

Existing field in file.

Definition at line 207 of file Connection_mz5.hpp.

H5::H5File* pwiz::msdata::mz5::Connection_mz5::file_
private

MZ5 file reference.

Definition at line 211 of file Connection_mz5.hpp.

Configuration_mz5 pwiz::msdata::mz5::Connection_mz5::config_
mutableprivate

mz5 configuration object.

Definition at line 215 of file Connection_mz5.hpp.

std::map<Configuration_mz5::MZ5DataSets, H5::DataSet> pwiz::msdata::mz5::Connection_mz5::bufferMap_
private

Mapping from a dataset enumeration value to the dataset.

Definition at line 219 of file Connection_mz5.hpp.

std::map<Configuration_mz5::MZ5DataSets, std::vector<double> > pwiz::msdata::mz5::Connection_mz5::buffers_
private

Mapping from a dataset enumeration value to a buffer.

Definition at line 223 of file Connection_mz5.hpp.

bool pwiz::msdata::mz5::Connection_mz5::closed_
private

Flag whether file is closed or not.

Definition at line 227 of file Connection_mz5.hpp.


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