My Project  1.10.11
H5File.h
1 // C++ informative line for the emacs editor: -*- C++ -*-
2 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
3  * Copyright by The HDF Group. *
4  * All rights reserved. *
5  * *
6  * This file is part of HDF5. The full HDF5 copyright notice, including *
7  * terms governing use, modification, and redistribution, is contained in *
8  * the COPYING file, which can be found at the root of the source code *
9  * distribution tree, or in https://www.hdfgroup.org/licenses. *
10  * If you do not have access to either file, you may request a copy from *
11  * help@hdfgroup.org. *
12  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
13 
14 #ifndef H5File_H
15 #define H5File_H
16 
17 namespace H5 {
18 
23 // Inheritance: Group -> CommonFG/H5Object -> H5Location -> IdComponent
24 class H5_DLLCPP H5File : public Group {
25  public:
26  // Creates or opens an HDF5 file.
27  H5File(const char *name, unsigned int flags,
28  const FileCreatPropList &create_plist = FileCreatPropList::DEFAULT,
29  const FileAccPropList &access_plist = FileAccPropList::DEFAULT);
30  H5File(const H5std_string &name, unsigned int flags,
31  const FileCreatPropList &create_plist = FileCreatPropList::DEFAULT,
32  const FileAccPropList &access_plist = FileAccPropList::DEFAULT);
33 
34  // Open the file
35  void openFile(const H5std_string &name, unsigned int flags,
36  const FileAccPropList &access_plist = FileAccPropList::DEFAULT);
37  void openFile(const char *name, unsigned int flags,
38  const FileAccPropList &access_plist = FileAccPropList::DEFAULT);
39 
40  // Close this file.
41  virtual void close() H5_OVERRIDE;
42 
43  // Gets a copy of the access property list of this file.
44  FileAccPropList getAccessPlist() const;
45 
46  // Gets a copy of the creation property list of this file.
47  FileCreatPropList getCreatePlist() const;
48 
49  // Gets general information about this file.
50  void getFileInfo(H5F_info2_t &file_info) const;
51 
52  // Returns the amount of free space in the file.
53  hssize_t getFreeSpace() const;
54 
55  // Returns the number of opened object IDs (files, datasets, groups
56  // and datatypes) in the same file.
57  ssize_t getObjCount(unsigned types = H5F_OBJ_ALL) const;
58 
59  // Retrieves a list of opened object IDs (files, datasets, groups
60  // and datatypes) in the same file.
61  void getObjIDs(unsigned types, size_t max_objs, hid_t *oid_list) const;
62 
63  // Returns the pointer to the file handle of the low-level file driver.
64  void getVFDHandle(void **file_handle) const;
65  void getVFDHandle(const FileAccPropList &fapl, void **file_handle) const;
66  // void getVFDHandle(FileAccPropList& fapl, void **file_handle) const; // removed from 1.8.18 and 1.10.1
67 
68  // Returns the file size of the HDF5 file.
69  hsize_t getFileSize() const;
70 
71  // Determines if a file, specified by its name, is in HDF5 format
72  static bool isHdf5(const char *name);
73  static bool isHdf5(const H5std_string &name);
74 
75  // Reopens this file.
76  void reOpen(); // added for better name
77 
78 #ifndef DOXYGEN_SHOULD_SKIP_THIS
79  void reopen(); // obsolete in favor of reOpen()
80 
81  // Creates an H5File using an existing file id. Not recommended
82  // in applications.
83  H5File(hid_t existing_id);
84 
85 #endif // DOXYGEN_SHOULD_SKIP_THIS
86 
88  virtual H5std_string
89  fromClass() const H5_OVERRIDE
90  {
91  return ("H5File");
92  }
93 
94  // Throw file exception.
95  virtual void throwException(const H5std_string &func_name, const H5std_string &msg) const H5_OVERRIDE;
96 
97  // For CommonFG to get the file id.
98  virtual hid_t getLocId() const H5_OVERRIDE;
99 
100  // Default constructor
101  H5File();
102 
103  // Copy constructor: same as the original H5File.
104  H5File(const H5File &original);
105 
106  // Gets the HDF5 file id.
107  virtual hid_t getId() const H5_OVERRIDE;
108 
109  // H5File destructor.
110  virtual ~H5File();
111 
112  protected:
113 #ifndef DOXYGEN_SHOULD_SKIP_THIS
114  // Sets the HDF5 file id.
115  virtual void p_setId(const hid_t new_id) H5_OVERRIDE;
116 #endif // DOXYGEN_SHOULD_SKIP_THIS
117 
118  private:
119  hid_t id; // HDF5 file id
120 
121  // This function is private and contains common code between the
122  // constructors taking a string or a char*
123  void p_get_file(const char *name, unsigned int flags, const FileCreatPropList &create_plist,
124  const FileAccPropList &access_plist);
125 
126 }; // end of H5File
127 } // namespace H5
128 
129 #endif // H5File_H
H5::Exception
Exception provides wrappers of HDF5 error handling functions.
Definition: H5Exception.h:27
H5::H5File::getFileInfo
void getFileInfo(H5F_info2_t &file_info) const
Retrieves the general information of this file.
Definition: H5File.cpp:368
H5::H5File::getVFDHandle
void getVFDHandle(void **file_handle) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: H5File.cpp:518
H5::H5File::getAccessPlist
FileAccPropList getAccessPlist() const
Returns a copy of the access property list of this file.
Definition: H5File.cpp:341
H5::IdComponent::incRefCount
void incRefCount() const
Increment reference counter for the id of this object.
Definition: H5IdComponent.cpp:54
H5::H5File::throwException
virtual void throwException(const H5std_string &func_name, const H5std_string &msg) const H5_OVERRIDE
Throws file exception - initially implemented for CommonFG.
Definition: H5File.cpp:659
H5::H5File::reOpen
void reOpen()
Reopens this file.
Definition: H5File.cpp:294
H5::H5File::openFile
void openFile(const H5std_string &name, unsigned int flags, const FileAccPropList &access_plist=FileAccPropList::DEFAULT)
This is an overloaded member function, provided for convenience. It takes an H5std_string for name.
Definition: H5File.cpp:272
H5::H5File::isHdf5
static bool isHdf5(const char *name)
Determines whether a file in HDF5 format. (Static)
Definition: H5File.cpp:197
H5::H5File::close
virtual void close() H5_OVERRIDE
Closes this HDF5 file.
Definition: H5File.cpp:633
H5::FileIException
Definition: H5Exception.h:88
H5::FileAccPropList::DEFAULT
static const FileAccPropList & DEFAULT
Default file access property list.
Definition: H5FaccProp.h:27
H5::Group
Class Group represents an HDF5 group.
Definition: H5Group.h:23
H5::H5File::getFreeSpace
hssize_t getFreeSpace() const
Returns the amount of free space in the file.
Definition: H5File.cpp:384
H5::H5File::H5File
H5File()
Default constructor: creates a stub H5File object.
Definition: H5File.cpp:47
H5::FileCreatPropList
Class FileCreatPropList inherits from PropList and provides wrappers for the HDF5 file create propert...
Definition: H5FcreatProp.h:24
H5::H5File::getId
virtual hid_t getId() const H5_OVERRIDE
Get the id of this file.
Definition: H5File.cpp:560
H5::H5File::getCreatePlist
FileCreatPropList getCreatePlist() const
Returns a copy of the creation property list of this file.
Definition: H5File.cpp:318
H5::H5File::getFileSize
hsize_t getFileSize() const
Returns the file size of the HDF5 file.
Definition: H5File.cpp:537
H5::Exception::getDetailMsg
H5std_string getDetailMsg() const
Returns the detailed message set at the time the exception is thrown.
Definition: H5Exception.cpp:264
H5::FileCreatPropList::DEFAULT
static const FileCreatPropList & DEFAULT
Default file creation property list.
Definition: H5FcreatProp.h:27
H5::H5File
Class H5File represents an HDF5 file and inherits from class Group as file is a root group.
Definition: H5File.h:24
H5::H5File::getObjIDs
void getObjIDs(unsigned types, size_t max_objs, hid_t *oid_list) const
Retrieves a list of opened object IDs (files, datasets, groups and datatypes) in the same file.
Definition: H5File.cpp:450
H5::PropList::getId
virtual hid_t getId() const
Get the id of this property list.
Definition: H5PropList.cpp:292
H5::H5File::~H5File
virtual ~H5File()
Properly terminates access to this file.
Definition: H5File.cpp:676
H5::H5File::getObjCount
ssize_t getObjCount(unsigned types=H5F_OBJ_ALL) const
Returns the number of opened object IDs (files, datasets, groups and datatypes) in the same file.
Definition: H5File.cpp:415
H5
Definition: H5AbstractDs.cpp:33
H5::H5File::getLocId
virtual hid_t getLocId() const H5_OVERRIDE
H5::H5File::fromClass
virtual H5std_string fromClass() const H5_OVERRIDE
Returns this class name.
Definition: H5File.h:89
H5::FileAccPropList
Class FileAccPropList inherits from PropList and provides wrappers for the HDF5 file access property ...
Definition: H5FaccProp.h:24


The HDF Group Help Desk:
  Copyright by The HDF Group