HDF5 C++ API  1.8.16
 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 files COPYING and Copyright.html. COPYING can be found at the root *
10  * of the source code distribution tree; Copyright.html can be found at the *
11  * root level of an installed copy of the electronic HDF5 document set and *
12  * is linked from the top-level documents page. It can also be found at *
13  * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
14  * access to either file, you may request a copy from help@hdfgroup.org. *
15  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
16 
17 #ifndef __H5File_H
18 #define __H5File_H
19 
20 #ifndef H5_NO_NAMESPACE
21 namespace H5 {
22 #endif
23 
29 class H5_DLLCPP H5File : public H5Location, public CommonFG {
30  public:
31  // Creates or opens an HDF5 file.
32  H5File( const char* name, unsigned int flags,
33  const FileCreatPropList& create_plist = FileCreatPropList::DEFAULT,
34  const FileAccPropList& access_plist = FileAccPropList::DEFAULT );
35  H5File( const H5std_string& name, unsigned int flags,
36  const FileCreatPropList& create_plist = FileCreatPropList::DEFAULT,
37  const FileAccPropList& access_plist = FileAccPropList::DEFAULT );
38 
39  // Open the file
40  void openFile(const H5std_string& name, unsigned int flags,
41  const FileAccPropList& access_plist = FileAccPropList::DEFAULT);
42  void openFile(const char* name, unsigned int flags,
43  const FileAccPropList& access_plist = FileAccPropList::DEFAULT);
44 
45  // Close this file.
46  virtual void close();
47 
48  // Gets the access property list of this file.
49  FileAccPropList getAccessPlist() const;
50 
51  // Gets the creation property list of this file.
52  FileCreatPropList getCreatePlist() const;
53 
54  // Retrieves the file size of an opened file.
55  hsize_t getFileSize() const;
56 
57  // Returns the amount of free space in the file.
58  hssize_t getFreeSpace() const;
59 
60  // Returns the number of opened object IDs (files, datasets, groups
61  // and datatypes) in the same file.
62  ssize_t getObjCount(unsigned types = H5F_OBJ_ALL) const;
63 
64  // Retrieves a list of opened object IDs (files, datasets, groups
65  // and datatypes) in the same file.
66  void getObjIDs(unsigned types, size_t max_objs, hid_t *oid_list) const;
67 
68  // Returns the pointer to the file handle of the low-level file driver.
69  void getVFDHandle(void **file_handle) const;
70  void getVFDHandle(const FileAccPropList& fapl, void **file_handle) const;
71  void getVFDHandle(FileAccPropList& fapl, void **file_handle) const; // kept for backward compatibility
72 
73  // Determines if a file, specified by its name, is in HDF5 format
74  static bool isHdf5(const char* name );
75  static bool isHdf5(const H5std_string& name );
76 
77  // Reopens this file.
78  void reOpen(); // added for better name
79 
80 #ifndef DOXYGEN_SHOULD_SKIP_THIS
81  void reopen(); // obsolete in favor of reOpen()
82 
83  // Gets the file id
84  virtual hid_t getLocId() const;
85 
86  // Creates an H5File using an existing file id. Not recommended
87  // in applications.
88  H5File(hid_t existing_id);
89 
90 #endif // DOXYGEN_SHOULD_SKIP_THIS
91 
93  virtual H5std_string fromClass () const { return("H5File"); }
94 
95  // Throw file exception.
96  virtual void throwException(const H5std_string& func_name, const H5std_string& msg) const;
97 
98  // Default constructor
99  H5File();
100 
101  // Copy constructor: makes a copy of the original H5File object.
102  H5File(const H5File& original);
103 
104  // Gets the HDF5 file id.
105  virtual hid_t getId() const;
106 
107  // H5File destructor.
108  virtual ~H5File();
109 
110  protected:
111 #ifndef DOXYGEN_SHOULD_SKIP_THIS
112  // Sets the HDF5 file id.
113  virtual void p_setId(const hid_t new_id);
114 #endif // DOXYGEN_SHOULD_SKIP_THIS
115 
116  private:
117  hid_t id; // HDF5 file id
118 
119  // This function is private and contains common code between the
120  // constructors taking a string or a char*
121  void p_get_file( const char* name, unsigned int flags, const FileCreatPropList& create_plist, const FileAccPropList& access_plist );
122 
123 };
124 #ifndef H5_NO_NAMESPACE
125 }
126 #endif
127 #endif // __H5File_H
virtual H5std_string fromClass() const
Returns this class name.
Definition: H5File.h:93
static const FileCreatPropList & DEFAULT
Default file creation property list.
Definition: H5FcreatProp.h:28
H5Location is an abstract base class, added in version 1.8.12.
Definition: H5Location.h:49
static const FileAccPropList & DEFAULT
Default file access property list.
Definition: H5FaccProp.h:31
Class FileCreatPropList represents the HDF5 file create property list.
Definition: H5FcreatProp.h:25
Class FileAccPropList represents the HDF5 file access property list.
Definition: H5FaccProp.h:28
Class H5File represents an HDF5 file.
Definition: H5File.h:29
CommonFG is an abstract base class of H5File and H5Group.
Definition: H5CommonFG.h:35


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