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


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