00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #ifdef USE_HDF5
00032 #ifndef _HDF5IO_H
00033 #define _HDF5IO_H
00034 #include <typeinfo>
00035
00036 hid_t require_attribute(hid_t file_id, string path,
00037 hid_t data_type, hid_t data_id);
00038
00039
00040 class HDF5WriterBase
00041 {
00042 public:
00043 static const hssize_t CHUNK_SIZE;
00044 HDF5WriterBase();
00045 virtual ~HDF5WriterBase();
00046 void setFilename(string filename);
00047 string getFilename() const;
00048 bool isOpen() const;
00049 void setMode(unsigned int mode);
00050 unsigned int getMode() const;
00051 void setChunkSize(unsigned int);
00052 unsigned int getChunkSize() const;
00053 void setCompressor(string compressor);
00054 string getCompressor() const;
00055 void setCompression(unsigned int level);
00056 unsigned int getCompression() const;
00057 void setStringAttr(string name, string value);
00058 void setDoubleAttr(string name, double value);
00059 void setLongAttr(string name, long value);
00060 string getStringAttr(string name) const;
00061 double getDoubleAttr(string name) const;
00062 long getLongAttr(string name) const;
00063
00064 void setStringVecAttr(string name, vector < string > value);
00065 void setDoubleVecAttr(string name, vector < double > value);
00066 void setLongVecAttr(string name, vector < long > value);
00067 vector < string > getStringVecAttr(string name) const;
00068 vector < double > getDoubleVecAttr(string name) const;
00069 vector < long > getLongVecAttr(string name) const;
00070
00071 virtual void flushAttributes();
00072 virtual void flush();
00073 virtual void close();
00074
00075 static const Cinfo* initCinfo();
00076
00077 protected:
00078 herr_t openFile();
00079 hid_t createDataset2D(hid_t parent, string name, unsigned int rows);
00080
00085 map <string, hid_t> nodemap_;
00087 hid_t filehandle_;
00088 string filename_;
00089 unsigned int openmode_;
00090
00091 map<string, string> sattr_;
00092 map<string, double> dattr_;
00093 map<string, long> lattr_;
00094 map<string, vector < string > > svecattr_;
00095 map<string, vector < double > > dvecattr_;
00096 map<string, vector < long > > lvecattr_;
00097
00098 unsigned int chunkSize_;
00099 string compressor_;
00100 unsigned int compression_;
00101 };
00102
00103 template <typename A> herr_t writeScalarAttr(hid_t file_id, string path, A value)
00104 {
00105 cerr << "This should be never be called."
00106 << " Specialized version exist for basic types." << endl;
00107 return -1;
00108 }
00109
00110
00112
00114
00115 template <typename A> herr_t writeVectorAttr(hid_t file_id, string path,
00116 vector < A > value)
00117 {
00118 cerr << "writeVectorAttr: This should be never be called."
00119 << " Specialized version exist for basic types." << endl;
00120 return -1;
00121 }
00122
00123 #endif // _HDF5IO_H
00124 #endif // USE_HDF5
00125
00126
00127
00128
00129