HDF5 C++ API  1.10.1
 All Classes Namespaces Functions Variables Typedefs Friends Pages
H5DataType.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 __H5DataType_H
16 #define __H5DataType_H
17 
18 namespace H5 {
19 
27 // Inheritance: DataType -> H5Object -> H5Location -> IdComponent
28 class H5_DLLCPP DataType : public H5Object {
29  public:
30  // Creates a datatype given its class and size
31  DataType(const H5T_class_t type_class, size_t size);
32 
33  // Copy constructor: makes a copy of the original object
34  DataType(const DataType& original);
35 
36  // Creates a copy of a predefined type
37  DataType(const PredType& pred_type);
38 
39  // Creates a datatype by way of dereference.
40  DataType(const H5Location& loc, const void* ref, H5R_type_t ref_type = H5R_OBJECT, const PropList& plist = PropList::DEFAULT);
41 // DataType(const Attribute& attr, const void* ref, H5R_type_t ref_type = H5R_OBJECT, const PropList& plist = PropList::DEFAULT);
42 
43  // Closes this datatype.
44  virtual void close();
45 
46  // Copies an existing datatype to this datatype object.
47  void copy(const DataType& like_type);
48 
49  // Copies the datatype of dset to this datatype object.
50  void copy(const DataSet& dset);
51 
52  // Returns the datatype class identifier.
53  H5T_class_t getClass() const;
54 
55  // Commits a transient datatype to a file; this datatype becomes
56  // a named datatype which can be accessed from the location.
57  void commit(const H5Location& loc, const char* name);
58  void commit(const H5Location& loc, const H5std_string& name);
59 
60  // These two overloaded functions are kept for backward compatibility
61  // only; they missed the const - removed from 1.8.18 and 1.10.1
62  //void commit(H5Location& loc, const char* name);
63  //void commit(H5Location& loc, const H5std_string& name);
64 
65  // Determines whether this datatype is a named datatype or
66  // a transient datatype.
67  bool committed() const;
68 
69  // Finds a conversion function that can handle the conversion
70  // this datatype to the given datatype, dest.
71  H5T_conv_t find(const DataType& dest, H5T_cdata_t **pcdata) const;
72 
73  // Converts data from between specified datatypes.
74  void convert(const DataType& dest, size_t nelmts, void *buf, void *background, const PropList& plist=PropList::DEFAULT) const;
75 
76  // Assignment operator
77  DataType& operator=(const DataType& rhs);
78 
79  // Determines whether two datatypes are the same.
80  bool operator==(const DataType& compared_type) const;
81 
82  // Locks a datatype.
83  void lock() const;
84 
85  // Returns the size of a datatype.
86  size_t getSize() const;
87 
88  // Returns the base datatype from which a datatype is derived.
89  // Note: not quite right for specific types yet???
90  DataType getSuper() const;
91 
92  // Registers a conversion function.
93  void registerFunc(H5T_pers_t pers, const char* name, const DataType& dest, H5T_conv_t func) const;
94  void registerFunc(H5T_pers_t pers, const H5std_string& name, const DataType& dest, H5T_conv_t func) const;
95 
96  // Removes a conversion function from all conversion paths.
97  void unregister(H5T_pers_t pers, const char* name, const DataType& dest, H5T_conv_t func) const;
98  void unregister(H5T_pers_t pers, const H5std_string& name, const DataType& dest, H5T_conv_t func) const;
99 
100  // Tags an opaque datatype.
101  void setTag(const char* tag) const;
102  void setTag(const H5std_string& tag) const;
103 
104  // Gets the tag associated with an opaque datatype.
105  H5std_string getTag() const;
106 
107  // Checks whether this datatype contains (or is) a certain type class.
108  bool detectClass(H5T_class_t cls) const;
109 
110  // Checks whether this datatype is a variable-length string.
111  bool isVariableStr() const;
112 
113  // Returns a copy of the creation property list of a datatype.
114  PropList getCreatePlist() const;
115 
117  virtual H5std_string fromClass () const { return("DataType"); }
118 
119 // From CommonFG then H5Location
120  // Constructors to open a generic named datatype at a given location.
121  DataType(const H5Location& loc, const char* name);
122  DataType(const H5Location& loc, const H5std_string& name);
123 
124 // End of From CommonFG then H5Location
125 
126  // Creates a copy of an existing DataType using its id
127  DataType(const hid_t type_id);
128 
129  // Default constructor
130  DataType();
131 
132  // Gets the datatype id.
133  virtual hid_t getId() const;
134 
135  // Destructor: properly terminates access to this datatype.
136  virtual ~DataType();
137 
138  protected:
139 #ifndef DOXYGEN_SHOULD_SKIP_THIS
140  hid_t id; // HDF5 datatype id
141 
142  // Sets the datatype id.
143  virtual void p_setId(const hid_t new_id);
144 
145  // Opens a datatype and returns the id.
146  hid_t p_opentype(const H5Location& loc, const char* dtype_name) const;
147 
148 #endif // DOXYGEN_SHOULD_SKIP_THIS
149 
150  private:
151  // Friend function to set DataType id. For library use only.
152  friend void f_DataType_setId(DataType* dtype, hid_t new_id);
153 
154  void p_commit(hid_t loc_id, const char* name);
155 
156 }; // end of DataType
157 } // namespace H5
158 
159 #endif // __H5DataType_H
Class PredType holds the definition of all the HDF5 predefined datatypes.
Definition: H5PredType.h:28
Class DataType provides generic operations on HDF5 datatypes.
Definition: H5DataType.h:28
Class H5Object is a bridge between H5Location and DataSet, DataType, and Group.
Definition: H5Object.h:59
virtual H5std_string fromClass() const
Returns this class name.
Definition: H5DataType.h:117
H5Location is an abstract base class, added in version 1.8.12.
Definition: H5Location.h:36
Class DataSet operates on HDF5 datasets.
Definition: H5DataSet.h:28
Class PropList inherits from IdComponent and provides wrappers for the HDF5 generic property list...
Definition: H5PropList.h:24
static const PropList & DEFAULT
Default property list.
Definition: H5PropList.h:27


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