HDF5 C++ API  1.8.13
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 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 // Class DataType inherits from H5Object and has several subclasses for
18 // specific HDF5 data types.
19 
20 #ifndef __H5DataType_H
21 #define __H5DataType_H
22 
23 #ifndef H5_NO_NAMESPACE
24 namespace H5 {
25 #endif
26 
34 class H5_DLLCPP DataType : public H5Object {
35  public:
36  // Creates a datatype given its class and size
37  DataType( const H5T_class_t type_class, size_t size );
38 
39  // Copy constructor: makes a copy of the original object
40  DataType( const DataType& original );
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  DataType(const Attribute& attr, const void* ref, H5R_type_t ref_type = H5R_OBJECT);
45 
46  // Closes this datatype.
47  virtual void close();
48 
49  // Copies an existing datatype to this datatype object.
50  void copy(const DataType& like_type);
51 
52  // Copies the datatype of dset to this datatype object.
53  void copy(const DataSet& dset);
54 
55  // Returns the datatype class identifier.
56  H5T_class_t getClass() const;
57 
58  // Commits a transient datatype to a file; this datatype becomes
59  // a named datatype which can be accessed from the location.
60  void commit(const H5Location& loc, const char* name);
61  void commit(const H5Location& loc, const H5std_string& name);
62  // These two overloaded functions are kept for backward compatibility
63  // only; they missed the const.
64  void commit(H5Location& loc, const char* name);
65  void commit(H5Location& loc, const H5std_string& name);
66 
67  // Determines whether this datatype is a named datatype or
68  // a transient datatype.
69  bool committed() const;
70 
71  // Finds a conversion function that can handle the conversion
72  // this datatype to the given datatype, dest.
73  H5T_conv_t find( const DataType& dest, H5T_cdata_t **pcdata ) const;
74 
75  // Converts data from between specified datatypes.
76  void convert( const DataType& dest, size_t nelmts, void *buf, void *background, const PropList& plist=PropList::DEFAULT) const;
77 
78  // Assignment operator
79  DataType& operator=( const DataType& rhs );
80 
81  // Determines whether two datatypes are the same.
82  bool operator==(const DataType& compared_type ) const;
83 
84  // Locks a datatype.
85  void lock() const;
86 
87  // Returns the size of a datatype.
88  size_t getSize() const;
89 
90  // Returns the base datatype from which a datatype is derived.
91  // Note: not quite right for specific types yet???
92  DataType getSuper() const;
93 
94  // Registers a conversion function.
95  void registerFunc(H5T_pers_t pers, const char* name, const DataType& dest, H5T_conv_t func ) const;
96  void registerFunc(H5T_pers_t pers, const H5std_string& name, const DataType& dest, H5T_conv_t func ) const;
97 
98  // Removes a conversion function from all conversion paths.
99  void unregister( H5T_pers_t pers, const char* name, const DataType& dest, H5T_conv_t func ) const;
100  void unregister( H5T_pers_t pers, const H5std_string& name, const DataType& dest, H5T_conv_t func ) const;
101 
102  // Tags an opaque datatype.
103  void setTag( const char* tag ) const;
104  void setTag( const H5std_string& tag ) const;
105 
106  // Gets the tag associated with an opaque datatype.
107  H5std_string getTag() const;
108 
109  // Checks whether this datatype contains (or is) a certain type class.
110  bool detectClass(H5T_class_t cls) const;
111 
112  // Checks whether this datatype is a variable-length string.
113  bool isVariableStr() const;
114 
116  virtual H5std_string fromClass () const { return("DataType"); }
117 
118  // Creates a copy of an existing DataType using its id
119  DataType( const hid_t type_id );
120 
121  // Default constructor
122  DataType();
123 
124  // Gets the datatype id.
125  virtual hid_t getId() const;
126 
127  // Destructor: properly terminates access to this datatype.
128  virtual ~DataType();
129 
130  protected:
131 #ifndef DOXYGEN_SHOULD_SKIP_THIS
132  hid_t id; // HDF5 datatype id
133 
134  // Sets the datatype id.
135  virtual void p_setId(const hid_t new_id);
136 #endif // DOXYGEN_SHOULD_SKIP_THIS
137 
138  private:
139  void p_commit(hid_t loc_id, const char* name);
140 };
141 #ifndef H5_NO_NAMESPACE
142 }
143 #endif
144 #endif // __H5DataType_H
Definition: H5AbstractDs.cpp:29
Class Attribute operates on HDF5 attributes.
Definition: H5Attribute.h:32
Class DataType provides generic operations on HDF5 datatypes.
Definition: H5DataType.h:34
Class H5Object is a bridge between H5Location and DataSet, DataType, and Group.
Definition: H5Object.h:47
virtual H5std_string fromClass() const
Returns this class name.
Definition: H5DataType.h:116
H5Location is an abstract base class, added in version 1.8.12.
Definition: H5Location.h:49
Class DataSet operates on HDF5 datasets.
Definition: H5DataSet.h:31
Class PropList provides operations for generic property lists.
Definition: H5PropList.h:25
static const PropList DEFAULT
Constant for default property.
Definition: H5PropList.h:28