00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef _HDF5SERIE_VECTORSERIE_H_
00023 #define _HDF5SERIE_VECTORSERIE_H_
00024
00025 #include <hdf5serie/interface.h>
00026 #include <hdf5serie/file.h>
00027 #include <vector>
00028
00029 namespace H5 {
00030
00031
00032
00063 template<class T>
00064 class VectorSerie : public Dataset {
00065 friend class Container<Object, GroupBase>;
00066 private:
00067 hid_t memDataTypeID;
00068 ScopedHID memDataSpaceID;
00069 hsize_t dims[2];
00070 protected:
00071 VectorSerie(int dummy, GroupBase *parent_, const std::string &name_);
00072 VectorSerie(GroupBase *parent_, const std::string &name_, int cols,
00073 int compression=File::getDefaultCompression(), int chunkSize=File::getDefaultChunkSize());
00074 ~VectorSerie();
00075 void close();
00076 void open();
00077
00078 public:
00083 void setDescription(const std::string& desc);
00084
00090 void append(const T data[], size_t size);
00091
00096 template<class DataType>
00097 void append(const DataType &data){
00098 append(&data[0], data.size());
00099 }
00100
00102 inline int getRows();
00103
00105 inline unsigned int getColumns();
00106
00111 void getRow(const int row, size_t size, T data[]);
00112
00117 template<class DataType>
00118 void getRow(const int row, DataType &data) {
00119 getRow(row, data.size(), &data[0]);
00120 }
00121
00124 std::vector<T> getRow(const int row) {
00125 std::vector<T> data(dims[1]);
00126 getRow(row, dims[1], &data[0]);
00127 return data;
00128 }
00129
00134 void getColumn(const int column, size_t size, T data[]);
00135
00140 template<class DataType>
00141 void getColumn(const int column, DataType &data) {
00142 getColumn(column, data.size(), &data[0]);
00143 }
00144
00147 std::vector<T> getColumn(const int row) {
00148 size_t rows=getRows();
00149 std::vector<T> data(rows);
00150 getColumn(row, rows, &data[0]);
00151 return data;
00152 }
00153
00158 std::string getDescription();
00159
00160 void setColumnLabel(const std::vector<std::string> &columnLabel);
00161
00167 std::vector<std::string> getColumnLabel();
00168 };
00169
00170
00171
00172
00173
00174 template<class T>
00175 int VectorSerie<T>::getRows() {
00176 ScopedHID fileSpaceID(H5Dget_space(id), &H5Sclose);
00177 H5Sget_simple_extent_dims(fileSpaceID, dims, NULL);
00178 return dims[0];
00179 }
00180
00181 template<class T>
00182 unsigned int VectorSerie<T>::getColumns() {
00183 return dims[1];
00184 }
00185
00186 }
00187
00188 #endif // _TIMESERIE_H_