HDF5 C++ API  1.10.1
 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 
24 // Inheritance: Group -> CommonFG/H5Object -> H5Location -> IdComponent
25 class H5_DLLCPP H5File : public Group {
26  public:
27  // Creates or opens an HDF5 file.
28  H5File(const char* name, unsigned int flags,
29  const FileCreatPropList& create_plist = FileCreatPropList::DEFAULT,
30  const FileAccPropList& access_plist = FileAccPropList::DEFAULT);
31  H5File(const H5std_string& name, unsigned int flags,
32  const FileCreatPropList& create_plist = FileCreatPropList::DEFAULT,
33  const FileAccPropList& access_plist = FileAccPropList::DEFAULT);
34 
35  // Open the file
36  void openFile(const H5std_string& name, unsigned int flags,
37  const FileAccPropList& access_plist = FileAccPropList::DEFAULT);
38  void openFile(const char* name, unsigned int flags,
39  const FileAccPropList& access_plist = FileAccPropList::DEFAULT);
40 
41  // Close this file.
42  virtual void close();
43 
44  // Gets the access property list of this file.
45  FileAccPropList getAccessPlist() const;
46 
47  // Gets the creation property list of this file.
48  FileCreatPropList getCreatePlist() const;
49 
50  // Gets general information about this file.
51  void getFileInfo(H5F_info2_t& file_info) const;
52 
53  // Returns the amount of free space in the file.
54  hssize_t getFreeSpace() const;
55 
56  // Returns the number of opened object IDs (files, datasets, groups
57  // and datatypes) in the same file.
58  ssize_t getObjCount(unsigned types = H5F_OBJ_ALL) const;
59 
60  // Retrieves a list of opened object IDs (files, datasets, groups
61  // and datatypes) in the same file.
62  void getObjIDs(unsigned types, size_t max_objs, hid_t *oid_list) const;
63 
64  // Returns the pointer to the file handle of the low-level file driver.
65  void getVFDHandle(void **file_handle) const;
66  void getVFDHandle(const FileAccPropList& fapl, void **file_handle) const;
67  //void getVFDHandle(FileAccPropList& fapl, void **file_handle) const; // removed from 1.8.18 and 1.10.1
68 
69  // Returns the file size of the HDF5 file.
70  hsize_t getFileSize() const;
71 
72  // Determines if a file, specified by its name, is in HDF5 format
73  static bool isHdf5(const char* name);
74  static bool isHdf5(const H5std_string& name);
75 
76  // Reopens this file.
77  void reOpen(); // added for better name
78 
79 #ifndef DOXYGEN_SHOULD_SKIP_THIS
80  void reopen(); // obsolete in favor of reOpen()
81 
82  // Creates an H5File using an existing file id. Not recommended
83  // in applications.
84  H5File(hid_t existing_id);
85 
86 #endif // DOXYGEN_SHOULD_SKIP_THIS
87 
89  virtual H5std_string fromClass () const { return("H5File"); }
90 
91  // Throw file exception.
92  virtual void throwException(const H5std_string& func_name, const H5std_string& msg) const;
93 
94  // For CommonFG to get the file id.
95  virtual hid_t getLocId() const;
96 
97  // Default constructor
98  H5File();
99 
100  // Copy constructor: makes a copy of the original H5File object.
101  H5File(const H5File& original);
102 
103  // Gets the HDF5 file id.
104  virtual hid_t getId() const;
105 
106  // H5File destructor.
107  virtual ~H5File();
108 
109  protected:
110 #ifndef DOXYGEN_SHOULD_SKIP_THIS
111  // Sets the HDF5 file id.
112  virtual void p_setId(const hid_t new_id);
113 #endif // DOXYGEN_SHOULD_SKIP_THIS
114 
115  private:
116  hid_t id; // HDF5 file id
117 
118  // This function is private and contains common code between the
119  // constructors taking a string or a char*
120  void p_get_file(const char* name, unsigned int flags, const FileCreatPropList& create_plist, const FileAccPropList& access_plist);
121 
122 }; // end of H5File
123 } // namespace H5
124 
125 #endif // __H5File_H
126 
Class Group represents an HDF5 group.
Definition: H5Group.h:28
virtual H5std_string fromClass() const
Returns this class name.
Definition: H5File.h:89
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 and inherits from class Group as file is a root group...
Definition: H5File.h:25


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