HDF5 C++ API  1.8.12
 All Classes Namespaces Files Functions Variables Typedefs Macros Pages
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 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( H5Location& loc, const char* name);
61  void commit( H5Location& loc, const H5std_string& name);
62 
63  // Determines whether this datatype is a named datatype or
64  // a transient datatype.
65  bool committed() const;
66 
67  // Finds a conversion function that can handle the conversion
68  // this datatype to the given datatype, dest.
69  H5T_conv_t find( const DataType& dest, H5T_cdata_t **pcdata ) const;
70 
71  // Converts data from between specified datatypes.
72  void convert( const DataType& dest, size_t nelmts, void *buf, void *background, const PropList& plist=PropList::DEFAULT) const;
73 
74  // Assignment operator
75  DataType& operator=( const DataType& rhs );
76 
77  // Determines whether two datatypes are the same.
78  bool operator==(const DataType& compared_type ) const;
79 
80  // Locks a datatype.
81  void lock() const;
82 
83  // Returns the size of a datatype.
84  size_t getSize() const;
85 
86  // Returns the base datatype from which a datatype is derived.
87  // Note: not quite right for specific types yet???
88  DataType getSuper() const;
89 
90  // Registers a conversion function.
91  void registerFunc(H5T_pers_t pers, const char* name, const DataType& dest, H5T_conv_t func ) const;
92  void registerFunc(H5T_pers_t pers, const H5std_string& name, const DataType& dest, H5T_conv_t func ) const;
93 
94  // Removes a conversion function from all conversion paths.
95  void unregister( H5T_pers_t pers, const char* name, const DataType& dest, H5T_conv_t func ) const;
96  void unregister( H5T_pers_t pers, const H5std_string& name, const DataType& dest, H5T_conv_t func ) const;
97 
98  // Tags an opaque datatype.
99  void setTag( const char* tag ) const;
100  void setTag( const H5std_string& tag ) const;
101 
102  // Gets the tag associated with an opaque datatype.
103  H5std_string getTag() const;
104 
105  // Checks whether this datatype contains (or is) a certain type class.
106  bool detectClass(H5T_class_t cls) const;
107 
108  // Checks whether this datatype is a variable-length string.
109  bool isVariableStr() const;
110 
112  virtual H5std_string fromClass () const { return("DataType"); }
113 
114  // Creates a copy of an existing DataType using its id
115  DataType( const hid_t type_id );
116 
117  // Default constructor
118  DataType();
119 
120  // Gets the datatype id.
121  virtual hid_t getId() const;
122 
123  // Destructor: properly terminates access to this datatype.
124  virtual ~DataType();
125 
126  protected:
127 #ifndef DOXYGEN_SHOULD_SKIP_THIS
128  hid_t id; // HDF5 datatype id
129 
130  // Sets the datatype id.
131  virtual void p_setId(const hid_t new_id);
132 #endif // DOXYGEN_SHOULD_SKIP_THIS
133 
134  private:
135  void p_commit(hid_t loc_id, const char* name);
136 };
137 #ifndef H5_NO_NAMESPACE
138 }
139 #endif
140 #endif // __H5DataType_H
Class Attribute operates on HDF5 attributes.
Definition: H5Attribute.h:32
Class PropList provides operations for generic property lists.
Definition: H5PropList.h:25
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
virtual H5std_string fromClass() const
Returns this class name.
Definition: H5DataType.h:112
Class H5Object is a bridge between H5Location and DataSet, DataType, and Group.
Definition: H5Object.h:47
hid_t id
Definition: H5DataType.h:128
#define H5std_string
Definition: H5Exception.h:29
Class DataType provides generic operations on HDF5 datatypes.
Definition: H5DataType.h:34
static const PropList DEFAULT
Constant for default property.
Definition: H5PropList.h:28