Hex  1.0
Hydrogen-electron collision solver
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
hdffile.h
Go to the documentation of this file.
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
2  * *
3  * / / / / __ \ \ / / *
4  * / /__ / / / _ \ \ \/ / *
5  * / ___ / | |/_/ / /\ \ *
6  * / / / / \_\ / / \ \ *
7  * *
8  * Jakub Benda (c) 2014 *
9  * Charles University in Prague *
10  * *
11 \* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
12 
13 #ifndef HEX_HDFFILE
14 #define HEX_HDFFILE
15 
16 #ifndef NO_HDF
17 
18 #include <string>
19 #include <H5Cpp.h>
20 
21 #include "complex.h"
22 
43 class HDFFile
44 {
45 public:
46 
53  typedef enum {
58  } FileAccess;
59 
61  HDFFile(std::string filename, FileAccess flag);
62 
64  ~HDFFile();
65 
67  size_t size (std::string dataset) const;
68 
70  template <typename T> bool read (std::string dataset, T * buffer, size_t length) const;
71 
73  template <typename T> bool write (std::string dataset, T const * data, size_t length);
74 
76  bool valid () const { return valid_; }
77 
78 private:
79 
81  H5::H5File * file_;
82 
84  bool valid_;
85 
87  bool read_(std::string dataset, void * buffer, hsize_t length, H5::AtomType dtype) const;
88 
90  bool write_(std::string dataset, void const * buffer, hsize_t length, H5::AtomType dtype);
91 };
92 
93 #endif
94 
95 #endif
bool write(std::string dataset, T const *data, size_t length)
Write data to a valid file.
bool read(std::string dataset, T *buffer, size_t length) const
load data from a valid file.
Definition: hdffile.h:54
Definition: hdffile.h:56
size_t size(std::string dataset) const
Get size of the dataset of valid file.
Definition: hdffile.cpp:60
HDFFile(std::string filename, FileAccess flag)
Constructor from filename and access mode.
Definition: hdffile.cpp:22
~HDFFile()
Destructor.
Definition: hdffile.cpp:50
FileAccess
Access mode.
Definition: hdffile.h:53
Definition: hdffile.h:57
HDF I/O management.
Definition: hdffile.h:43
bool valid() const
Check that the file is valid.
Definition: hdffile.h:76
Definition: hdffile.h:55