My Project  1.10.6
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 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  // 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: same as the original H5File.
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 
H5::Exception
Exception provides wrappers of HDF5 error handling functions.
Definition: H5Exception.h:32
H5::H5File::getFileInfo
void getFileInfo(H5F_info2_t &file_info) const
Retrieves the general information of this file.
Definition: H5File.cpp:360
H5::H5File::close
virtual void close()
Closes this HDF5 file.
Definition: H5File.cpp:622
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:511
H5::H5File::getAccessPlist
FileAccPropList getAccessPlist() const
Returns a copy of the access property list of this file.
Definition: H5File.cpp:333
H5::IdComponent::incRefCount
void incRefCount() const
Increment reference counter for the id of this object.
Definition: H5IdComponent.cpp:53
H5::H5File::reOpen
void reOpen()
Reopens this file.
Definition: H5File.cpp:286
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:265
H5::H5File::isHdf5
static bool isHdf5(const char *name)
Determines whether a file in HDF5 format. (Static)
Definition: H5File.cpp:193
H5::FileIException
Definition: H5Exception.h:95
H5::FileAccPropList::DEFAULT
static const FileAccPropList & DEFAULT
Default file access property list.
Definition: H5FaccProp.h:28
H5::H5File::getId
virtual hid_t getId() const
Get the id of this file.
Definition: H5File.cpp:553
H5::Group
Class Group represents an HDF5 group.
Definition: H5Group.h:24
H5::H5File::getFreeSpace
hssize_t getFreeSpace() const
Returns the amount of free space in the file.
Definition: H5File.cpp:376
H5::H5File::H5File
H5File()
Default constructor: creates a stub H5File object.
Definition: H5File.cpp:52
H5::FileCreatPropList
Class FileCreatPropList inherits from PropList and provides wrappers for the HDF5 file create propert...
Definition: H5FcreatProp.h:25
H5::H5File::getCreatePlist
FileCreatPropList getCreatePlist() const
Returns a copy of the creation property list of this file.
Definition: H5File.cpp:309
H5::H5File::getFileSize
hsize_t getFileSize() const
Returns the file size of the HDF5 file.
Definition: H5File.cpp:530
H5::Exception::getDetailMsg
H5std_string getDetailMsg() const
Returns the detailed message set at the time the exception is thrown.
Definition: H5Exception.cpp:256
H5::FileCreatPropList::DEFAULT
static const FileCreatPropList & DEFAULT
Default file creation property list.
Definition: H5FcreatProp.h:28
H5::H5File::throwException
virtual void throwException(const H5std_string &func_name, const H5std_string &msg) const
Throws file exception - initially implemented for CommonFG.
Definition: H5File.cpp:649
H5::H5File
Class H5File represents an HDF5 file and inherits from class Group as file is a root group.
Definition: H5File.h:25
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:443
H5::PropList::getId
virtual hid_t getId() const
Get the id of this property list.
Definition: H5PropList.cpp:292
H5::H5File::getLocId
virtual hid_t getLocId() const
H5::H5File::fromClass
virtual H5std_string fromClass() const
Returns this class name.
Definition: H5File.h:89
H5::H5File::~H5File
virtual ~H5File()
Properly terminates access to this file.
Definition: H5File.cpp:666
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:408
H5
Definition: H5AbstractDs.cpp:34
H5::FileAccPropList
Class FileAccPropList inherits from PropList and provides wrappers for the HDF5 file access property ...
Definition: H5FaccProp.h:25


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