HDF5 C++ API  1.8.14
 All Classes Namespaces Functions Variables Typedefs 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) const;
63  ssize_t getObjCount() const;
64 
65  // Retrieves a list of opened object IDs (files, datasets, groups
66  // and datatypes) in the same file.
67  void getObjIDs(unsigned types, size_t max_objs, hid_t *oid_list) const;
68 
69  // Returns the pointer to the file handle of the low-level file driver.
70  void getVFDHandle(void **file_handle) const;
71  void getVFDHandle(const FileAccPropList& fapl, void **file_handle) const;
72  void getVFDHandle(FileAccPropList& fapl, void **file_handle) const; // kept for backward compatibility
73 
74  // Determines if a file, specified by its name, is in HDF5 format
75  static bool isHdf5(const char* name );
76  static bool isHdf5(const H5std_string& name );
77 
78  // Reopens this file.
79  void reOpen(); // added for better name
80 
81 #ifndef DOXYGEN_SHOULD_SKIP_THIS
82  void reopen(); // obsolete in favor of reOpen()
83 
84  // Gets the file id
85  virtual hid_t getLocId() const;
86 
87 #endif // DOXYGEN_SHOULD_SKIP_THIS
88 
90  virtual H5std_string fromClass () const { return("H5File"); }
91 
92  // Throw file exception.
93  virtual void throwException(const H5std_string& func_name, const H5std_string& msg) const;
94 
95  // Default constructor
96  H5File();
97 
98  // Copy constructor: makes a copy of the original H5File object.
99  H5File(const H5File& original);
100 
101  // Gets the HDF5 file id.
102  virtual hid_t getId() const;
103 
104  // H5File destructor.
105  virtual ~H5File();
106 
107  protected:
108 #ifndef DOXYGEN_SHOULD_SKIP_THIS
109  // Sets the HDF5 file id.
110  virtual void p_setId(const hid_t new_id);
111 #endif // DOXYGEN_SHOULD_SKIP_THIS
112 
113  private:
114  hid_t id; // HDF5 file id
115 
116  // This function is private and contains common code between the
117  // constructors taking a string or a char*
118  void p_get_file( const char* name, unsigned int flags, const FileCreatPropList& create_plist, const FileAccPropList& access_plist );
119 
120 };
121 #ifndef H5_NO_NAMESPACE
122 }
123 #endif
124 #endif // __H5File_H
virtual H5std_string fromClass() const
Returns this class name.
Definition: H5File.h:90
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