HDF5 C++ API  1.8.15
 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.
87  H5File(hid_t existing_id);
88 
89 #endif // DOXYGEN_SHOULD_SKIP_THIS
90 
92  virtual H5std_string fromClass () const { return("H5File"); }
93 
94  // Throw file exception.
95  virtual void throwException(const H5std_string& func_name, const H5std_string& msg) 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 };
123 #ifndef H5_NO_NAMESPACE
124 }
125 #endif
126 #endif // __H5File_H
virtual H5std_string fromClass() const
Returns this class name.
Definition: H5File.h:92
H5Location is an abstract base class, added in version 1.8.12.
Definition: H5Location.h:49
Class FileCreatPropList represents the HDF5 file create property list.
Definition: H5FcreatProp.h:25
static const FileCreatPropList DEFAULT
Constant for default property.
Definition: H5FcreatProp.h:28
Class FileAccPropList represents the HDF5 file access property list.
Definition: H5FaccProp.h:28
Class H5File represents an HDF5 file.
Definition: H5File.h:29
static const FileAccPropList DEFAULT
Constant for default property.
Definition: H5FaccProp.h:30
CommonFG is an abstract base class of H5File and H5Group.
Definition: H5CommonFG.h:35