All Classes Namespaces Functions Typedefs Enumerations Pages
vectorserie.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_VECTORSERIE_H_
23 #define _HDF5SERIE_VECTORSERIE_H_
24 
25 #include <hdf5serie/interface.h>
26 #include <hdf5serie/file.h>
27 #include <vector>
28 
29 namespace H5 {
30 
31 
32 
62  template<class T>
63  class VectorSerie : public Dataset {
64  friend class Container<Object, GroupBase>;
65  private:
66  hid_t memDataTypeID;
67  ScopedHID memDataSpaceID;
68  hsize_t dims[2];
69  protected:
70  VectorSerie(int dummy, GroupBase *parent_, const std::string &name_);
71  VectorSerie(GroupBase *parent_, const std::string &name_, int cols,
72  int compression=File::getDefaultCompression(), int chunkSize=File::getDefaultChunkSize());
73  ~VectorSerie();
74  void close();
75  void open();
76 
77  public:
82  void setDescription(const std::string& desc);
83 
89  void append(const T data[], size_t size);
90 
95  template<class DataType>
96  void append(const DataType &data){
97  append(&data[0], data.size());
98  }
99 
101  inline int getRows();
102 
104  inline unsigned int getColumns();
105 
110  void getRow(const int row, size_t size, T data[]);
111 
116  template<class DataType>
117  void getRow(const int row, DataType &data) {
118  getRow(row, data.size(), &data[0]);
119  }
120 
123  std::vector<T> getRow(const int row) {
124  std::vector<T> data(dims[1]);
125  getRow(row, dims[1], &data[0]);
126  return data;
127  }
128 
133  void getColumn(const int column, size_t size, T data[]);
134 
139  template<class DataType>
140  void getColumn(const int column, DataType &data) {
141  getColumn(column, data.size(), &data[0]);
142  }
143 
146  std::vector<T> getColumn(const int row) {
147  size_t rows=getRows();
148  std::vector<T> data(rows);
149  getColumn(row, rows, &data[0]);
150  return data;
151  }
152 
157  std::string getDescription();
158 
159  void setColumnLabel(const std::vector<std::string> &columnLabel);
160 
166  std::vector<std::string> getColumnLabel();
167  };
168 
169 
170 
171  // inline definitions
172 
173  template<class T>
175  ScopedHID fileSpaceID(H5Dget_space(id), &H5Sclose);
176  H5Sget_simple_extent_dims(fileSpaceID, dims, NULL);
177  return dims[0];
178  }
179 
180  template<class T>
181  unsigned int VectorSerie<T>::getColumns() {
182  return dims[1];
183  }
184 
185 }
186 
187 #endif // _TIMESERIE_H_
void setDescription(const std::string &desc)
Sets a description for the dataset.
Definition: vectorserie.cc:108
std::vector< T > getColumn(const int row)
Definition: vectorserie.h:146
std::vector< T > getRow(const int row)
Definition: vectorserie.h:123
unsigned int getColumns()
Returns the number of columns(=number of data elements) in the dataset.
Definition: vectorserie.h:181
std::vector< std::string > getColumnLabel()
Returns the column labels.
Definition: vectorserie.cc:179
Definition: interface.h:36
Definition: interface.h:73
Definition: interface.h:238
void getRow(const int row, DataType &data)
Definition: vectorserie.h:117
Serie of vectors.
Definition: vectorserie.h:63
std::string getDescription()
Return the description for the dataset.
Definition: vectorserie.cc:165
void getColumn(const int column, size_t size, T data[])
Returns the data vector at column column.
Definition: vectorserie.cc:150
void getRow(const int row, size_t size, T data[])
Returns the data vector at row row The first row is 0. The last avaliable row ist getRows()-1...
Definition: vectorserie.cc:128
void append(const T data[], size_t size)
Append a data vector.
Definition: vectorserie.cc:114
int getRows()
Returns the number of rows in the dataset.
Definition: vectorserie.h:174
void append(const DataType &data)
Definition: vectorserie.h:96
void getColumn(const int column, DataType &data)
Definition: vectorserie.h:140

Impressum / Disclaimer / Datenschutz Generated by doxygen 1.8.5 Valid HTML