MISR Toolkit  1.5.1
H5DataType.h
Go to the documentation of this file.
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  // Opens 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);
45  DataType(const Attribute& attr, const void* ref, H5R_type_t ref_type = H5R_OBJECT);
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  // Determines whether this datatype is a named datatype or
72  // a transient datatype.
73  bool committed() const;
74 
75  // Finds a conversion function that can handle the conversion
76  // this datatype to the given datatype, dest.
77  H5T_conv_t find(const DataType& dest, H5T_cdata_t **pcdata) const;
78 
79  // Converts data from between specified datatypes.
80  void convert(const DataType& dest, size_t nelmts, void *buf, void *background, const PropList& plist=PropList::DEFAULT) const;
81 
82  // Assignment operator
83  DataType& operator=(const DataType& rhs);
84 
85  // Determines whether two datatypes are the same.
86  bool operator==(const DataType& compared_type) const;
87 
88  // Locks a datatype.
89  void lock() const;
90 
91  // Returns the size of a datatype.
92  size_t getSize() const;
93 
94  // Returns the base datatype from which a datatype is derived.
95  // Note: not quite right for specific types yet???
96  DataType getSuper() const;
97 
98  // Registers a conversion function.
99  void registerFunc(H5T_pers_t pers, const char* name, const DataType& dest, H5T_conv_t func) const;
100  void registerFunc(H5T_pers_t pers, const H5std_string& name, const DataType& dest, H5T_conv_t func) const;
101 
102  // Removes a conversion function from all conversion paths.
103  void unregister(H5T_pers_t pers, const char* name, const DataType& dest, H5T_conv_t func) const;
104  void unregister(H5T_pers_t pers, const H5std_string& name, const DataType& dest, H5T_conv_t func) const;
105 
106  // Tags an opaque datatype.
107  void setTag(const char* tag) const;
108  void setTag(const H5std_string& tag) const;
109 
110  // Gets the tag associated with an opaque datatype.
111  H5std_string getTag() const;
112 
113  // Checks whether this datatype contains (or is) a certain type class.
114  bool detectClass(H5T_class_t cls) const;
115 
116  // Checks whether this datatype is a variable-length string.
117  bool isVariableStr() const;
118 
119  // Returns a copy of the creation property list of a datatype.
120  PropList getCreatePlist() const;
121 
123  virtual H5std_string fromClass () const { return("DataType"); }
124 
125  // Throw DataTypeIException.
126  virtual void throwException(const H5std_string& func_name, const H5std_string& msg) const;
127 
128  // Creates a copy of an existing DataType using its id
129  DataType(const hid_t type_id);
130 
131  // Default constructor
132  DataType();
133 
134  // Determines whether this datatype has a binary object description.
135  bool hasBinaryDesc() const;
136 
137  // Gets the datatype id.
138  virtual hid_t getId() const;
139 
140  // Destructor: properly terminates access to this datatype.
141  virtual ~DataType();
142 
143  protected:
144 #ifndef DOXYGEN_SHOULD_SKIP_THIS
145  hid_t id; // HDF5 datatype id
146 
147  // Returns an id of a type by decoding the binary object
148  // description of this datatype.
149  hid_t p_decode() const;
150 
151  // Sets the datatype id.
152  virtual void p_setId(const hid_t new_id);
153 
154  // Opens a datatype and returns the id.
155  hid_t p_opentype(const H5Location& loc, const char* dtype_name) const;
156 #endif // DOXYGEN_SHOULD_SKIP_THIS
157 
158  private:
159  // Buffer for binary object description of this datatype, allocated
160  // in DataType::encode and used in DataType::decode
161  unsigned char *encoded_buf;
162  size_t buf_size;
163 
164  // Friend function to set DataType id. For library use only.
165  friend void f_DataType_setId(DataType* dtype, hid_t new_id);
166 
167 #ifndef DOXYGEN_SHOULD_SKIP_THIS
168  void p_commit(hid_t loc_id, const char* name);
169 #endif // DOXYGEN_SHOULD_SKIP_THIS
170 
171 }; // end of DataType
172 } // namespace H5
173 
174 #endif // __H5DataType_H
#define H5_DLLCPP
Definition: H5api_adpt.h:262
Class PredType holds the definition of all the HDF5 predefined datatypes.
Definition: H5PredType.h:28
H5T_class_t
Definition: H5Tpublic.h:28
Class Attribute operates on HDF5 attributes.
Definition: H5Attribute.h:29
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:37
H5Location is an abstract base class, providing a collection of wrappers of the C functions that take...
Definition: H5Location.h:42
Class DataSet operates on HDF5 datasets.
Definition: H5DataSet.h:28
HDFFCLIBAPI _fcd name
herr_t(* H5T_conv_t)(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist)
Definition: H5Tpublic.h:207
HDFFCLIBAPI intf intf * ref
#define H5std_string
Definition: H5Exception.h:25
HDFFCLIBAPI intf * size
int hid_t
Definition: H5Ipublic.h:54
HDFFCLIBAPI intf * tag
H5T_pers_t
Definition: H5Tpublic.h:157
Class PropList provides operations for generic property lists.
Definition: H5PropList.h:26
H5R_type_t
Definition: H5Rpublic.h:28
static const PropList & DEFAULT
Default property list.
Definition: H5PropList.h:29
unsigned char * encoded_buf
Definition: H5DataType.h:161
size_t buf_size
Definition: H5DataType.h:162
HDFFCLIBAPI intf _fcd intf * dtype
virtual H5std_string fromClass() const
Returns this class name.
Definition: H5DataType.h:123
HDFFCLIBAPI intf * buf

MISR Toolkit - Copyright © 2005 - 2020 Jet Propulsion Laboratory
Generated on Fri Jun 19 2020 22:49:52