My Project 1.10.10
Loading...
Searching...
No Matches
H5DataType.h
1// C++ informative line for the emacs editor: -*- C++ -*-
2/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
3 * Copyright by The HDF Group. *
4 * All rights reserved. *
5 * *
6 * This file is part of HDF5. The full HDF5 copyright notice, including *
7 * terms governing use, modification, and redistribution, is contained in *
8 * the COPYING file, which can be found at the root of the source code *
9 * distribution tree, or in https://www.hdfgroup.org/licenses. *
10 * If you do not have access to either file, you may request a copy from *
11 * help@hdfgroup.org. *
12 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
13
14#ifndef H5DataType_H
15#define H5DataType_H
16
17namespace H5 {
18
26// Inheritance: DataType -> H5Object -> H5Location -> IdComponent
27class H5_DLLCPP DataType : public H5Object {
28 public:
29 // Creates a datatype given its class and size
30 DataType(const H5T_class_t type_class, size_t size);
31
32 // Copy constructor - same as the original DataType.
33 DataType(const DataType &original);
34
35 // Creates a copy of a predefined type
36 DataType(const PredType &pred_type);
37
38 // Constructors to open a generic named datatype at a given location.
39 DataType(const H5Location &loc, const char *name);
40 DataType(const H5Location &loc, const H5std_string &name);
41
42 // Creates a datatype by way of dereference.
43 DataType(const H5Location &loc, const void *ref, H5R_type_t ref_type = H5R_OBJECT,
44 const PropList &plist = PropList::DEFAULT);
45 // DataType(const Attribute& attr, const void* ref, H5R_type_t ref_type = H5R_OBJECT, const
46 // PropList& plist = PropList::DEFAULT);
47
48 // Closes this datatype.
49 virtual void close();
50
51 // Copies an existing datatype to this datatype object.
52 void copy(const DataType &like_type);
53
54 // Copies the datatype of dset to this datatype object.
55 void copy(const DataSet &dset);
56
57 // Returns a DataType instance by decoding the binary object
58 // description of this datatype.
59 virtual DataType *decode() const;
60
61 // Creates a binary object description of this datatype.
62 void encode();
63
64 // Returns the datatype class identifier.
65 H5T_class_t getClass() const;
66
67 // Commits a transient datatype to a file; this datatype becomes
68 // a named datatype which can be accessed from the location.
69 void commit(const H5Location &loc, const char *name);
70 void commit(const H5Location &loc, const H5std_string &name);
71
72 // These two overloaded functions are kept for backward compatibility
73 // only; they missed the const - removed from 1.8.18 and 1.10.1
74 // void commit(H5Location& loc, const char* name);
75 // void commit(H5Location& loc, const H5std_string& name);
76
77 // Determines whether this datatype is a named datatype or
78 // a transient datatype.
79 bool committed() const;
80
81 // Finds a conversion function that can handle the conversion
82 // this datatype to the given datatype, dest.
83 H5T_conv_t find(const DataType &dest, H5T_cdata_t **pcdata) const;
84
85 // Converts data from between specified datatypes.
86 void convert(const DataType &dest, size_t nelmts, void *buf, void *background,
87 const PropList &plist = PropList::DEFAULT) const;
88
89 // Assignment operator
90 DataType &operator=(const DataType &rhs);
91
92 // Determines whether two datatypes are the same.
93 bool operator==(const DataType &compared_type) const;
94
95 // Determines whether two datatypes are not the same.
96 bool operator!=(const DataType &compared_type) const;
97
98 // Locks a datatype.
99 void lock() const;
100
101 // Returns the size of a datatype.
102 size_t getSize() const;
103
104 // Returns the base datatype from which a datatype is derived.
105 // Note: not quite right for specific types yet???
106 DataType getSuper() const;
107
108 // Registers a conversion function.
109 void registerFunc(H5T_pers_t pers, const char *name, const DataType &dest, H5T_conv_t func) const;
110 void registerFunc(H5T_pers_t pers, const H5std_string &name, const DataType &dest, H5T_conv_t func) const;
111
112 // Removes a conversion function from all conversion paths.
113 void unregister(H5T_pers_t pers, const char *name, const DataType &dest, H5T_conv_t func) const;
114 void unregister(H5T_pers_t pers, const H5std_string &name, const DataType &dest, H5T_conv_t func) const;
115
116 // Tags an opaque datatype.
117 void setTag(const char *tag) const;
118 void setTag(const H5std_string &tag) const;
119
120 // Gets the tag associated with an opaque datatype.
121 H5std_string getTag() const;
122
123 // Checks whether this datatype contains (or is) a certain type class.
124 bool detectClass(H5T_class_t cls) const;
125 static bool detectClass(const PredType &pred_type, H5T_class_t cls);
126
127 // Checks whether this datatype is a variable-length string.
128 bool isVariableStr() const;
129
130 // Returns a copy of the creation property list of a datatype.
131 PropList getCreatePlist() const;
132
134 virtual H5std_string
135 fromClass() const
136 {
137 return ("DataType");
138 }
139
140 // Creates a copy of an existing DataType using its id
141 DataType(const hid_t type_id);
142
143 // Default constructor
144 DataType();
145
146 // Determines whether this datatype has a binary object description.
147 bool hasBinaryDesc() const;
148
149 // Gets the datatype id.
150 virtual hid_t getId() const;
151
152 // Destructor: properly terminates access to this datatype.
153 virtual ~DataType();
154
155 protected:
156#ifndef DOXYGEN_SHOULD_SKIP_THIS
157 hid_t id; // HDF5 datatype id
158
159 // Returns an id of a type by decoding the binary object
160 // description of this datatype.
161 hid_t p_decode() const;
162
163 // Sets the datatype id.
164 virtual void p_setId(const hid_t new_id);
165
166 // Opens a datatype and returns the id.
167 hid_t p_opentype(const H5Location &loc, const char *dtype_name) const;
168
169#endif // DOXYGEN_SHOULD_SKIP_THIS
170
171 private:
172 // Buffer for binary object description of this datatype, allocated
173 // in DataType::encode and used in DataType::decode
174 unsigned char *encoded_buf;
175 size_t buf_size;
176
177 // Friend function to set DataType id. For library use only.
178 friend void f_DataType_setId(DataType *dtype, hid_t new_id);
179
180 void p_commit(hid_t loc_id, const char *name);
181
182}; // end of DataType
183} // namespace H5
184
185#endif // H5DataType_H
Class DataSet operates on HDF5 datasets.
Definition H5DataSet.h:27
Class DataType provides generic operations on HDF5 datatypes.
Definition H5DataType.h:27
virtual H5std_string fromClass() const
Returns this class name.
Definition H5DataType.h:135
friend void f_DataType_setId(DataType *dtype, hid_t new_id)
H5Location is an abstract base class, added in version 1.8.12.
Definition H5Location.h:30
Class H5Object is a bridge between H5Location and DataSet, DataType, and Group.
Definition H5Object.h:64
Class PredType holds the definition of all the HDF5 predefined datatypes.
Definition H5PredType.h:27
Class PropList inherits from IdComponent and provides wrappers for the HDF5 generic property list.
Definition H5PropList.h:24
Definition H5AbstractDs.cpp:33


The HDF Group Help Desk:
  Copyright by The HDF Group