HDF5 C++ API  1.8.20
 All Classes Namespaces Functions Variables Typedefs Friends Pages
H5File.h
1 // C++ informative line for the emacs editor: -*- C++ -*-
2 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
3  * Copyright by The HDF Group. *
4  * Copyright by the Board of Trustees of the University of Illinois. *
5  * All rights reserved. *
6  * *
7  * This file is part of HDF5. The full HDF5 copyright notice, including *
8  * terms governing use, modification, and redistribution, is contained in *
9  * the COPYING file, which can be found at the root of the source code *
10  * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
11  * If you do not have access to either file, you may request a copy from *
12  * help@hdfgroup.org. *
13  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
14 
15 #ifndef __H5File_H
16 #define __H5File_H
17 
18 namespace H5 {
19 
29 // Inheritance: Group -> CommonFG/H5Object -> H5Location -> IdComponent
30 class H5_DLLCPP H5File : public Group {
31  public:
32  // Creates or opens an HDF5 file.
33  H5File(const char* name, unsigned int flags,
34  const FileCreatPropList& create_plist = FileCreatPropList::DEFAULT,
35  const FileAccPropList& access_plist = FileAccPropList::DEFAULT);
36  H5File(const H5std_string& name, unsigned int flags,
37  const FileCreatPropList& create_plist = FileCreatPropList::DEFAULT,
38  const FileAccPropList& access_plist = FileAccPropList::DEFAULT);
39 
40  // Open the file
41  void openFile(const H5std_string& name, unsigned int flags,
42  const FileAccPropList& access_plist = FileAccPropList::DEFAULT);
43  void openFile(const char* name, unsigned int flags,
44  const FileAccPropList& access_plist = FileAccPropList::DEFAULT);
45 
46  // Close this file.
47  virtual void close();
48 
49  // Gets the access property list of this file.
50  FileAccPropList getAccessPlist() const;
51 
52  // Gets the creation property list of this file.
53  FileCreatPropList getCreatePlist() const;
54 
55  // Gets general information about this file.
56  void getFileInfo(H5F_info_t& file_info) const;
57 
58  // Retrieves the file size of an opened file.
59  hsize_t getFileSize() const;
60 
61  // Returns the amount of free space in the file.
62  hssize_t getFreeSpace() const;
63 
64  // Returns the number of opened object IDs (files, datasets, groups
65  // and datatypes) in the same file.
66  ssize_t getObjCount(unsigned types = H5F_OBJ_ALL) const;
67 
68  // Retrieves a list of opened object IDs (files, datasets, groups
69  // and datatypes) in the same file.
70  void getObjIDs(unsigned types, size_t max_objs, hid_t *oid_list) const;
71 
72  // Returns the pointer to the file handle of the low-level file driver.
73  void getVFDHandle(void **file_handle) const;
74  void getVFDHandle(const FileAccPropList& fapl, void **file_handle) const;
75  //void getVFDHandle(FileAccPropList& fapl, void **file_handle) const; // removed from 1.8.18 and 1.10.1
76 
77  // Determines if a file, specified by its name, is in HDF5 format
78  static bool isHdf5(const char* name);
79  static bool isHdf5(const H5std_string& name);
80 
81  // Reopens this file.
82  void reOpen(); // added for better name
83 
84 #ifndef DOXYGEN_SHOULD_SKIP_THIS
85  void reopen(); // obsolete in favor of reOpen()
86 
87  // Gets the file id
88  virtual hid_t getLocId() const;
89 
90  // Creates an H5File using an existing file id. Not recommended
91  // in applications.
92  H5File(hid_t existing_id);
93 
94 #endif // DOXYGEN_SHOULD_SKIP_THIS
95 
97  virtual H5std_string fromClass () const { return("H5File"); }
98 
99  // Throw file exception.
100  virtual void throwException(const H5std_string& func_name, const H5std_string& msg) const;
101 
102  // Default constructor
103  H5File();
104 
105  // Copy constructor: makes a copy of the original H5File object.
106  H5File(const H5File& original);
107 
108  // Gets the HDF5 file id.
109  virtual hid_t getId() const;
110 
111  // H5File destructor.
112  virtual ~H5File();
113 
114  protected:
115 #ifndef DOXYGEN_SHOULD_SKIP_THIS
116  // Sets the HDF5 file id.
117  virtual void p_setId(const hid_t new_id);
118 #endif // DOXYGEN_SHOULD_SKIP_THIS
119 
120  private:
121  hid_t id; // HDF5 file id
122 
123  // This function is private and contains common code between the
124  // constructors taking a string or a char*
125  void p_get_file(const char* name, unsigned int flags, const FileCreatPropList& create_plist, const FileAccPropList& access_plist);
126 
127 }; // end of H5File
128 } // namespace H5
129 
130 #endif // __H5File_H
Class Group represents an HDF5 group.
Definition: H5Group.h:24
virtual H5std_string fromClass() const
Returns this class name.
Definition: H5File.h:97
static const FileCreatPropList & DEFAULT
Default file creation property list.
Definition: H5FcreatProp.h:28
static const FileAccPropList & DEFAULT
Default file access property list.
Definition: H5FaccProp.h:28
Class FileCreatPropList inherits from PropList and provides wrappers for the HDF5 file create propert...
Definition: H5FcreatProp.h:25
Class FileAccPropList inherits from PropList and provides wrappers for the HDF5 file access property ...
Definition: H5FaccProp.h:25
Class H5File represents an HDF5 file.
Definition: H5File.h:30


The HDF Group Help Desk:
  Copyright by The HDF Group
and the Board of Trustees of the University of Illinois