HDF5 C++ API  1.8.18
 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 namespace H5 {
21 
27 class H5_DLLCPP H5File : public H5Location, public CommonFG {
28  public:
29  // Creates or opens an HDF5 file.
30  H5File( const char* name, unsigned int flags,
31  const FileCreatPropList& create_plist = FileCreatPropList::DEFAULT,
32  const FileAccPropList& access_plist = FileAccPropList::DEFAULT );
33  H5File( const H5std_string& name, unsigned int flags,
34  const FileCreatPropList& create_plist = FileCreatPropList::DEFAULT,
35  const FileAccPropList& access_plist = FileAccPropList::DEFAULT );
36 
37  // Open the file
38  void openFile(const H5std_string& name, unsigned int flags,
39  const FileAccPropList& access_plist = FileAccPropList::DEFAULT);
40  void openFile(const char* name, unsigned int flags,
41  const FileAccPropList& access_plist = FileAccPropList::DEFAULT);
42 
43  // Close this file.
44  virtual void close();
45 
46  // Gets the access property list of this file.
47  FileAccPropList getAccessPlist() const;
48 
49  // Gets the creation property list of this file.
50  FileCreatPropList getCreatePlist() const;
51 
52  // Retrieves the file size of an opened file.
53  hsize_t getFileSize() const;
54 
55  // Returns the amount of free space in the file.
56  hssize_t getFreeSpace() const;
57 
58  // Returns the number of opened object IDs (files, datasets, groups
59  // and datatypes) in the same file.
60  ssize_t getObjCount(unsigned types = H5F_OBJ_ALL) const;
61 
62  // Retrieves a list of opened object IDs (files, datasets, groups
63  // and datatypes) in the same file.
64  void getObjIDs(unsigned types, size_t max_objs, hid_t *oid_list) const;
65 
66  // Returns the pointer to the file handle of the low-level file driver.
67  void getVFDHandle(void **file_handle) const;
68  void getVFDHandle(const FileAccPropList& fapl, void **file_handle) const;
69  //void getVFDHandle(FileAccPropList& fapl, void **file_handle) const; // removed from 1.8.18 and 1.10.1
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  // Gets the file id
82  virtual hid_t getLocId() const;
83 
84  // Creates an H5File using an existing file id. Not recommended
85  // in applications.
86  H5File(hid_t existing_id);
87 
88 #endif // DOXYGEN_SHOULD_SKIP_THIS
89 
91  virtual H5std_string fromClass () const { return("H5File"); }
92 
93  // Throw file exception.
94  virtual void throwException(const H5std_string& func_name, const H5std_string& msg) const;
95 
96  // Default constructor
97  H5File();
98 
99  // Copy constructor: makes a copy of the original H5File object.
100  H5File(const H5File& original);
101 
102  // Gets the HDF5 file id.
103  virtual hid_t getId() const;
104 
105  // H5File destructor.
106  virtual ~H5File();
107 
108  protected:
109 #ifndef DOXYGEN_SHOULD_SKIP_THIS
110  // Sets the HDF5 file id.
111  virtual void p_setId(const hid_t new_id);
112 #endif // DOXYGEN_SHOULD_SKIP_THIS
113 
114  private:
115  hid_t id; // HDF5 file id
116 
117  // This function is private and contains common code between the
118  // constructors taking a string or a char*
119  void p_get_file( const char* name, unsigned int flags, const FileCreatPropList& create_plist, const FileAccPropList& access_plist );
120 
121 };
122 }
123 #endif // __H5File_H
virtual H5std_string fromClass() const
Returns this class name.
Definition: H5File.h:91
static const FileCreatPropList & DEFAULT
Default file creation property list.
Definition: H5FcreatProp.h:26
H5Location is an abstract base class, added in version 1.8.12.
Definition: H5Location.h:47
static const FileAccPropList & DEFAULT
Default file access property list.
Definition: H5FaccProp.h:29
Class FileCreatPropList represents the HDF5 file create property list.
Definition: H5FcreatProp.h:23
Class FileAccPropList represents the HDF5 file access property list.
Definition: H5FaccProp.h:26
Class H5File represents an HDF5 file.
Definition: H5File.h:27
CommonFG is an abstract base class of H5File and H5Group.
Definition: H5CommonFG.h:33


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