H5Tdevelop.h 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  2. * Copyright by The HDF Group. *
  3. * All rights reserved. *
  4. * *
  5. * This file is part of HDF5. The full HDF5 copyright notice, including *
  6. * terms governing use, modification, and redistribution, is contained in *
  7. * the COPYING file, which can be found at the root of the source code *
  8. * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
  9. * If you do not have access to either file, you may request a copy from *
  10. * help@hdfgroup.org. *
  11. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  12. /*
  13. * This file contains public declarations for the H5T (datatype) developer
  14. * support routines.
  15. */
  16. #ifndef _H5Tdevelop_H
  17. #define _H5Tdevelop_H
  18. /* Include package's public header */
  19. #include "H5Tpublic.h"
  20. /*****************/
  21. /* Public Macros */
  22. /*****************/
  23. /*******************/
  24. /* Public Typedefs */
  25. /*******************/
  26. /**
  27. * Commands sent to conversion functions
  28. */
  29. typedef enum H5T_cmd_t {
  30. H5T_CONV_INIT = 0, /**< query and/or initialize private data */
  31. H5T_CONV_CONV = 1, /**< convert data from source to dest datatype */
  32. H5T_CONV_FREE = 2 /**< function is being removed from path */
  33. } H5T_cmd_t;
  34. /**
  35. * How is the `bkg' buffer used by the conversion function?
  36. */
  37. typedef enum H5T_bkg_t {
  38. H5T_BKG_NO = 0, /**< background buffer is not needed, send NULL */
  39. H5T_BKG_TEMP = 1, /**< bkg buffer used as temp storage only */
  40. H5T_BKG_YES = 2 /**< init bkg buf with data before conversion */
  41. } H5T_bkg_t;
  42. /**
  43. * Type conversion client data
  44. */
  45. //! <!-- [H5T_cdata_t_snip] -->
  46. typedef struct H5T_cdata_t {
  47. H5T_cmd_t command; /**< what should the conversion function do? */
  48. H5T_bkg_t need_bkg; /**< is the background buffer needed? */
  49. hbool_t recalc; /**< recalculate private data */
  50. void * priv; /**< private data */
  51. } H5T_cdata_t;
  52. //! <!-- [H5T_cdata_t_snip] -->
  53. /**
  54. * Conversion function persistence
  55. */
  56. typedef enum H5T_pers_t {
  57. H5T_PERS_DONTCARE = -1, /**< wild card */
  58. H5T_PERS_HARD = 0, /**< hard conversion function */
  59. H5T_PERS_SOFT = 1 /**< soft conversion function */
  60. } H5T_pers_t;
  61. /**
  62. * All datatype conversion functions are...
  63. */
  64. //! <!-- [H5T_conv_t_snip] -->
  65. typedef herr_t (*H5T_conv_t)(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride,
  66. size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist);
  67. //! <!-- [H5T_conv_t_snip] -->
  68. /********************/
  69. /* Public Variables */
  70. /********************/
  71. /*********************/
  72. /* Public Prototypes */
  73. /*********************/
  74. #ifdef __cplusplus
  75. extern "C" {
  76. #endif
  77. /**
  78. * \ingroup CONV
  79. *
  80. * \brief Registers a datatype conversion function
  81. *
  82. * \param[in] pers Conversion function type
  83. * \param[in] name Name displayed in diagnostic output
  84. * \type_id{src_id} of source datatype
  85. * \type_id{dst_id} of destination datatype
  86. * \param[in] func Function to convert between source and destination datatypes
  87. *
  88. * \return \herr_t
  89. *
  90. * \details H5Tregister() registers a hard or soft conversion function for a
  91. * datatype conversion path. The parameter \p pers indicates whether a
  92. * conversion function is hard (#H5T_PERS_HARD) or soft
  93. * (#H5T_PERS_SOFT). User-defined functions employing compiler casting
  94. * are designated as \Emph{hard}; other user-defined conversion
  95. * functions registered with the HDF5 library (with H5Tregister() )
  96. * are designated as \Emph{soft}. The HDF5 library also has its own
  97. * hard and soft conversion functions.
  98. *
  99. * A conversion path can have only one hard function. When type is
  100. * #H5T_PERS_HARD, \p func replaces any previous hard function.
  101. *
  102. * When type is #H5T_PERS_SOFT, H5Tregister() adds the function to the
  103. * end of the master soft list and replaces the soft function in all
  104. * applicable existing conversion paths. Soft functions are used when
  105. * determining which conversion function is appropriate for this path.
  106. *
  107. * The \p name is used only for debugging and should be a short
  108. * identifier for the function.
  109. *
  110. * The path is specified by the source and destination datatypes \p
  111. * src_id and \p dst_id. For soft conversion functions, only the class
  112. * of these types is important.
  113. *
  114. * The type of the conversion function pointer is declared as:
  115. * \snippet this H5T_conv_t_snip
  116. *
  117. * The \ref H5T_cdata_t \c struct is declared as:
  118. * \snippet this H5T_cdata_t_snip
  119. *
  120. * \since 1.6.3 The following change occurred in the \ref H5T_conv_t function:
  121. * the \c nelmts parameter type changed to size_t.
  122. *
  123. */
  124. H5_DLL herr_t H5Tregister(H5T_pers_t pers, const char *name, hid_t src_id, hid_t dst_id, H5T_conv_t func);
  125. /**
  126. * \ingroup CONV
  127. *
  128. * \brief Removes a conversion function
  129. *
  130. * \param[in] pers Conversion function type
  131. * \param[in] name Name displayed in diagnostic output
  132. * \type_id{src_id} of source datatype
  133. * \type_id{dst_id} of destination datatype
  134. * \param[in] func Function to convert between source and destination datatypes
  135. *
  136. * \return \herr_t
  137. *
  138. * \details H5Tunregister() removes a conversion function matching criteria
  139. * such as soft or hard conversion, source and destination types, and
  140. * the conversion function.
  141. *
  142. * If a user is trying to remove a conversion function he registered,
  143. * all parameters can be used. If he is trying to remove a library’s
  144. * default conversion function, there is no guarantee the \p name and
  145. * \p func parameters will match the user’s chosen values. Passing in
  146. * some values may cause this function to fail. A good practice is to
  147. * pass in NULL as their values.
  148. *
  149. * All parameters are optional. The missing parameters will be used to
  150. * generalize the search criteria.
  151. *
  152. * The conversion function pointer type declaration is described in
  153. * H5Tregister().
  154. *
  155. * \version 1.6.3 The following change occurred in the \ref H5T_conv_t function:
  156. * the \c nelmts parameter type changed to size_t.
  157. *
  158. */
  159. H5_DLL herr_t H5Tunregister(H5T_pers_t pers, const char *name, hid_t src_id, hid_t dst_id, H5T_conv_t func);
  160. /**
  161. * \ingroup CONV
  162. *
  163. * \brief Finds a conversion function
  164. *
  165. * \type_id{src_id} of source datatype
  166. * \type_id{dst_id} of destination datatype
  167. * \param[out] pcdata Pointer to type conversion data
  168. *
  169. * \return Returns a pointer to a suitable conversion function if successful.
  170. * Otherwise returns NULL.
  171. *
  172. * \details H5Tfind() finds a conversion function that can handle a conversion
  173. * from type \p src_id to type \p dst_id. The \p pcdata argument is a
  174. * pointer to a pointer to type conversion data which was created and
  175. * initialized by the soft type conversion function of this path when
  176. * the conversion function was installed on the path.
  177. *
  178. */
  179. H5_DLL H5T_conv_t H5Tfind(hid_t src_id, hid_t dst_id, H5T_cdata_t **pcdata);
  180. /**
  181. * \ingroup CONV
  182. *
  183. * \brief Check whether the library’s default conversion is hard conversion
  184. *
  185. * \type_id{src_id} of source datatype
  186. * \type_id{dst_id} of destination datatype
  187. *
  188. * \return \htri_t
  189. *
  190. * \details H5Tcompiler_conv() determines whether the library’s conversion
  191. * function from type \p src_id to type \p dst_id is a compiler (hard)
  192. * conversion or not. A compiler conversion uses compiler’s casting; a
  193. * library (soft) conversion uses the library’s own conversion
  194. * function.
  195. *
  196. * \since 1.8.0
  197. *
  198. */
  199. H5_DLL htri_t H5Tcompiler_conv(hid_t src_id, hid_t dst_id);
  200. #ifdef __cplusplus
  201. }
  202. #endif
  203. /* Symbols defined for compatibility with previous versions of the HDF5 API.
  204. *
  205. * Use of these symbols is deprecated.
  206. */
  207. #ifndef H5_NO_DEPRECATED_SYMBOLS
  208. #endif /* H5_NO_DEPRECATED_SYMBOLS */
  209. #endif /* _H5Tdevelop_H */