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


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