My Project  1.12.2
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://www.hdfgroup.org/licenses. *
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() H5_OVERRIDE;
43 
44  // Gets a copy of the access property list of this file.
45  FileAccPropList getAccessPlist() const;
46 
47  // Gets a copy of 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  // Returns the 'file number' of the HDF5 file.
73  unsigned long getFileNum() const;
74 
75  // Determines if a file, specified by its name, is in HDF5 format
76  static bool isHdf5(const char *name);
77  static bool isHdf5(const H5std_string &name);
78 
79  // Determines if a file, specified by its name, can be accessed as HDF5
80  static bool isAccessible(const char * name,
81  const FileAccPropList &access_plist = FileAccPropList::DEFAULT);
82  static bool isAccessible(const H5std_string & name,
83  const FileAccPropList &access_plist = FileAccPropList::DEFAULT);
84 
85  // Reopens this file.
86  void reOpen(); // added for better name
87 
88 #ifndef DOXYGEN_SHOULD_SKIP_THIS
89  void reopen(); // obsolete in favor of reOpen()
90 
91  // Creates an H5File using an existing file id. Not recommended
92  // in applications.
93  H5File(hid_t existing_id);
94 
95 #endif // DOXYGEN_SHOULD_SKIP_THIS
96 
98  virtual H5std_string
99  fromClass() const H5_OVERRIDE
100  {
101  return ("H5File");
102  }
103 
104  // Throw file exception.
105  virtual void throwException(const H5std_string &func_name, const H5std_string &msg) const H5_OVERRIDE;
106 
107  // For CommonFG to get the file id.
108  virtual hid_t getLocId() const H5_OVERRIDE;
109 
110  // Default constructor
111  H5File();
112 
113  // Copy constructor: same as the original H5File.
114  H5File(const H5File &original);
115 
116  // Gets the HDF5 file id.
117  virtual hid_t getId() const H5_OVERRIDE;
118 
119  // H5File destructor.
120  virtual ~H5File() H5_OVERRIDE;
121 
122  protected:
123 #ifndef DOXYGEN_SHOULD_SKIP_THIS
124  // Sets the HDF5 file id.
125  virtual void p_setId(const hid_t new_id) H5_OVERRIDE;
126 #endif // DOXYGEN_SHOULD_SKIP_THIS
127 
128  private:
129  hid_t id; // HDF5 file id
130 
131  // This function is private and contains common code between the
132  // constructors taking a string or a char*
133  void p_get_file(const char *name, unsigned int flags, const FileCreatPropList &create_plist,
134  const FileAccPropList &access_plist);
135 
136 }; // end of H5File
137 } // namespace H5
138 
139 #endif // H5File_H
Class FileAccPropList inherits from PropList and provides wrappers for the HDF5 file access property ...
Definition: H5FaccProp.h:25
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
static const FileCreatPropList & DEFAULT
Default file creation property list.
Definition: H5FcreatProp.h:28
Class Group represents an HDF5 group.
Definition: H5Group.h:24
Class H5File represents an HDF5 file and inherits from class Group as file is a root group.
Definition: H5File.h:25
virtual hid_t getLocId() const H5_OVERRIDE
virtual H5std_string fromClass() const H5_OVERRIDE
Returns this class name.
Definition: H5File.h:99
Definition: H5AbstractDs.cpp:34


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