All Classes Namespaces Functions Typedefs Enumerations Pages
matrixserie.h
1 /* Copyright (C) 2009 Markus Friedrich
2  *
3  * This library is free software; you can redistribute it and/or
4  * modify it under the terms of the GNU Lesser General Public
5  * License as published by the Free Software Foundation; either
6  * version 2.1 of the License, or (at your option) any later version.
7  *
8  * This library is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  * Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public
14  * License along with this library; if not, write to the Free Software
15  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16  *
17  * Contact:
18  * friedrich.at.gc@googlemail.com
19  *
20  */
21 
22 #ifndef _HDF5SERIE_MATRIXSERIE_H_
23 #define _HDF5SERIE_MATRIXSERIE_H_
24 
25 #include <fmatvec/atom.h>
26 #include <vector>
27 #include <string>
28 #include <assert.h>
29 #include <hdf5serie/simpleattribute.h>
30 #include <hdf5serie/fileserie.h>
31 
32 namespace H5 {
33 
34 
35 
65  template<class T>
66  class MatrixSerie : public DataSet, virtual public fmatvec::Atom {
67  private:
68  DataType memDataType;
69  DataSpace memDataSpace;
70  hsize_t dims[3];
71  public:
76  MatrixSerie();
77 
79  MatrixSerie(const MatrixSerie<T>& dataset);
80 
85  MatrixSerie(const CommonFG& parent, const std::string& name);
86 
91  MatrixSerie(const CommonFG& parent, const std::string& name, const int rows, const int cols, int compression=FileSerie::getDefaultCompression(), int chunkSize=FileSerie::getDefaultChunkSize());
92 
99  void create(const CommonFG& parent, const std::string& name, const int rows, const int cols, int compression=FileSerie::getDefaultCompression(), int chunksize=FileSerie::getDefaultChunkSize());
100 
105  void open(const CommonFG& parent, const std::string& name);
106 
111  void setDescription(const std::string& desc);
112 
118  void append(const std::vector<std::vector<T> > &matrix);
119 
121  inline unsigned int getNumberOfMatrices();
122 
124  inline unsigned int getRows();
125 
127  inline unsigned int getColumns();
128 
133  std::vector<std::vector<T> > getMatrix(const int number);
134 
139  std::string getDescription();
140 
141  void extend(const hsize_t* size);
142  };
143 
144 
145 
146  // inline definitions
147 
148  template<class T>
150  return dims[0];
151  }
152 
153  template<class T>
154  unsigned int MatrixSerie<T>::getRows() {
155  // get current dims from dataspace (maybe another (single-)writer process has increased the number of rows)
156  DataSpace fileDataSpace=getSpace();
157  fileDataSpace.getSimpleExtentDims(dims);
158  // return current value
159  return dims[1];
160  }
161 
162  template<class T>
163  unsigned int MatrixSerie<T>::getColumns() {
164  return dims[2];
165  }
166 
167 }
168 
169 #endif
std::vector< std::vector< T > > getMatrix(const int number)
Returns the matrix at position number.
Definition: matrixserie.cc:132
unsigned int getColumns()
Returns the number of columns of the matrix.
Definition: matrixserie.h:163
void append(const std::vector< std::vector< T > > &matrix)
Append a matrix.
Definition: matrixserie.cc:113
std::string getDescription()
Return the description for the dataset.
Definition: matrixserie.cc:153
void create(const CommonFG &parent, const std::string &name, const int rows, const int cols, int compression=FileSerie::getDefaultCompression(), int chunksize=FileSerie::getDefaultChunkSize())
Creating a dataset.
Definition: matrixserie.cc:69
void setDescription(const std::string &desc)
Sets a description for the dataset.
Definition: matrixserie.cc:108
unsigned int getNumberOfMatrices()
Returns the number of matrices in the dataset.
Definition: matrixserie.h:149
MatrixSerie()
A stub constructor.
Definition: matrixserie.cc:36
void open(const CommonFG &parent, const std::string &name)
Open a dataset.
Definition: matrixserie.cc:89
unsigned int getRows()
Returns the number of rows of the matrix.
Definition: matrixserie.h:154
Serie of matrices.
Definition: matrixserie.h:66

Impressum / Disclaimer / Datenschutz Generated by doxygen 1.8.5 Valid HTML