HDF5 C++ API  1.8.16
 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 #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 copy of a predefined type
43  DataType(const PredType& pred_type);
44 
45  // Creates a datatype by way of dereference.
46  DataType(const H5Location& loc, const void* ref, H5R_type_t ref_type = H5R_OBJECT);
47  DataType(const Attribute& attr, const void* ref, H5R_type_t ref_type = H5R_OBJECT);
48 
49  // Closes this datatype.
50  virtual void close();
51 
52  // Copies an existing datatype to this datatype object.
53  void copy(const DataType& like_type);
54 
55  // Copies the datatype of dset to this datatype object.
56  void copy(const DataSet& dset);
57 
58  // Returns the datatype class identifier.
59  H5T_class_t getClass() const;
60 
61  // Commits a transient datatype to a file; this datatype becomes
62  // a named datatype which can be accessed from the location.
63  void commit(const H5Location& loc, const char* name);
64  void commit(const H5Location& loc, const H5std_string& name);
65  // These two overloaded functions are kept for backward compatibility
66  // only; they missed the const.
67  void commit(H5Location& loc, const char* name);
68  void commit(H5Location& loc, const H5std_string& name);
69 
70  // Determines whether this datatype is a named datatype or
71  // a transient datatype.
72  bool committed() const;
73 
74  // Finds a conversion function that can handle the conversion
75  // this datatype to the given datatype, dest.
76  H5T_conv_t find( const DataType& dest, H5T_cdata_t **pcdata ) const;
77 
78  // Converts data from between specified datatypes.
79  void convert( const DataType& dest, size_t nelmts, void *buf, void *background, const PropList& plist=PropList::DEFAULT) const;
80 
81  // Assignment operator
82  DataType& operator=( const DataType& rhs );
83 
84  // Determines whether two datatypes are the same.
85  bool operator==(const DataType& compared_type ) const;
86 
87  // Locks a datatype.
88  void lock() const;
89 
90  // Returns the size of a datatype.
91  size_t getSize() const;
92 
93  // Returns the base datatype from which a datatype is derived.
94  // Note: not quite right for specific types yet???
95  DataType getSuper() const;
96 
97  // Registers a conversion function.
98  void registerFunc(H5T_pers_t pers, const char* name, const DataType& dest, H5T_conv_t func ) const;
99  void registerFunc(H5T_pers_t pers, const H5std_string& name, const DataType& dest, H5T_conv_t func ) const;
100 
101  // Removes a conversion function from all conversion paths.
102  void unregister( H5T_pers_t pers, const char* name, const DataType& dest, H5T_conv_t func ) const;
103  void unregister( H5T_pers_t pers, const H5std_string& name, const DataType& dest, H5T_conv_t func ) const;
104 
105  // Tags an opaque datatype.
106  void setTag( const char* tag ) const;
107  void setTag( const H5std_string& tag ) const;
108 
109  // Gets the tag associated with an opaque datatype.
110  H5std_string getTag() const;
111 
112  // Checks whether this datatype contains (or is) a certain type class.
113  bool detectClass(H5T_class_t cls) const;
114 
115  // Checks whether this datatype is a variable-length string.
116  bool isVariableStr() const;
117 
119  virtual H5std_string fromClass () const { return("DataType"); }
120 
121  // Creates a copy of an existing DataType using its id
122  DataType( const hid_t type_id );
123 
124  // Default constructor
125  DataType();
126 
127  // Gets the datatype id.
128  virtual hid_t getId() const;
129 
130  // Destructor: properly terminates access to this datatype.
131  virtual ~DataType();
132 
133  protected:
134 #ifndef DOXYGEN_SHOULD_SKIP_THIS
135  hid_t id; // HDF5 datatype id
136 
137  // Sets the datatype id.
138  virtual void p_setId(const hid_t new_id);
139 #endif // DOXYGEN_SHOULD_SKIP_THIS
140 
141  private:
142  // Friend function to set DataType id. For library use only.
143  friend void f_DataType_setId(DataType* dtype, hid_t new_id);
144 
145  void p_commit(hid_t loc_id, const char* name);
146 };
147 #ifndef H5_NO_NAMESPACE
148 }
149 #endif
150 #endif // __H5DataType_H
Definition: H5AbstractDs.cpp:31
Class PredType holds the definition of all the HDF5 predefined datatypes.
Definition: H5PredType.h:31
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:119
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
Default property list.
Definition: H5PropList.h:28


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