H5Ldevelop.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  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 H5L (link) developer
  14. * support routines.
  15. */
  16. #ifndef _H5Ldevelop_H
  17. #define _H5Ldevelop_H
  18. /* Include package's public header */
  19. #include "H5Lpublic.h"
  20. /*****************/
  21. /* Public Macros */
  22. /*****************/
  23. /**
  24. * \brief Current version of the H5L_class_t struct
  25. */
  26. #define H5L_LINK_CLASS_T_VERS 1
  27. /*******************/
  28. /* Public Typedefs */
  29. /*******************/
  30. /* The H5L_class_t struct can be used to override the behavior of a
  31. * "user-defined" link class. Users should populate the struct with callback
  32. * functions defined below.
  33. */
  34. /* Callback prototypes for user-defined links */
  35. /**
  36. * \brief Link creation callback
  37. */
  38. typedef herr_t (*H5L_create_func_t)(const char *link_name, hid_t loc_group, const void *lnkdata,
  39. size_t lnkdata_size, hid_t lcpl_id);
  40. /**
  41. * \brief Callback for link move
  42. */
  43. typedef herr_t (*H5L_move_func_t)(const char *new_name, hid_t new_loc, const void *lnkdata,
  44. size_t lnkdata_size);
  45. /**
  46. * \brief Callback for link copy
  47. */
  48. typedef herr_t (*H5L_copy_func_t)(const char *new_name, hid_t new_loc, const void *lnkdata,
  49. size_t lnkdata_size);
  50. /**
  51. * \brief Callback during link traversal
  52. */
  53. typedef hid_t (*H5L_traverse_func_t)(const char *link_name, hid_t cur_group, const void *lnkdata,
  54. size_t lnkdata_size, hid_t lapl_id, hid_t dxpl_id);
  55. /**
  56. * \brief Callback for link deletion
  57. */
  58. typedef herr_t (*H5L_delete_func_t)(const char *link_name, hid_t file, const void *lnkdata,
  59. size_t lnkdata_size);
  60. /**
  61. * \brief Callback for querying the link.
  62. *
  63. * Returns the size of the buffer needed.
  64. */
  65. typedef ssize_t (*H5L_query_func_t)(const char *link_name, const void *lnkdata, size_t lnkdata_size,
  66. void *buf /*out*/, size_t buf_size);
  67. /**
  68. * \brief Link prototype
  69. *
  70. * The H5L_class_t struct can be used to override the behavior of a
  71. * "user-defined" link class. Users should populate the struct with callback
  72. * functions defined elsewhere.
  73. */
  74. //! <!-- [H5L_class_t_snip] -->
  75. typedef struct {
  76. int version; /**< Version number of this struct */
  77. H5L_type_t id; /**< Link type ID */
  78. const char * comment; /**< Comment for debugging */
  79. H5L_create_func_t create_func; /**< Callback during link creation */
  80. H5L_move_func_t move_func; /**< Callback after moving link */
  81. H5L_copy_func_t copy_func; /**< Callback after copying link */
  82. H5L_traverse_func_t trav_func; /**< Callback during link traversal */
  83. H5L_delete_func_t del_func; /**< Callback for link deletion */
  84. H5L_query_func_t query_func; /**< Callback for queries */
  85. } H5L_class_t;
  86. //! <!-- [H5L_class_t_snip] -->
  87. /********************/
  88. /* Public Variables */
  89. /********************/
  90. /*********************/
  91. /* Public Prototypes */
  92. /*********************/
  93. #ifdef __cplusplus
  94. extern "C" {
  95. #endif
  96. /**
  97. * \ingroup H5LA
  98. *
  99. * \brief Registers a user-defined link class or changes behavior of an
  100. * existing class
  101. *
  102. * \param[in] cls Pointer to a buffer containing the struct describing the
  103. * user-defined link class
  104. *
  105. * \return \herr_t
  106. *
  107. * \details H5Lregister() registers a class of user-defined links, or changes
  108. * the behavior of an existing class.
  109. *
  110. * \p cls is a pointer to a buffer containing a copy of the
  111. * H5L_class_t struct. This struct is defined in H5Lpublic.h as
  112. * follows:
  113. * \snippet this H5L_class_t_snip
  114. *
  115. * The class definition passed with \p cls must include at least the
  116. * following:
  117. * \li An H5L_class_t version (which should be #H5L_LINK_CLASS_T_VERS)
  118. * \li A link class identifier, \c class_id
  119. * \li A traversal function, \c trav_func
  120. *
  121. * Remaining \c struct members are optional and may be passed as NULL.
  122. *
  123. * The link class passed in \c class_id must be in the user-definable
  124. * range between #H5L_TYPE_UD_MIN and #H5L_TYPE_UD_MAX
  125. * (see the table below) and will override
  126. * any existing link class with that identifier.
  127. *
  128. * As distributed, valid values of \c class_id used in HDF5 include
  129. * the following (defined in H5Lpublic.h):
  130. * \link_types
  131. *
  132. * The hard and soft link class identifiers cannot be modified or
  133. * reassigned, but the external link class is implemented as an
  134. * example in the user-definable link class identifier range.
  135. * H5Lregister() is used to register additional link classes. It could
  136. * also be used to modify the behavior of the external link class,
  137. * though that is not recommended.
  138. *
  139. * The following table summarizes existing link types and values and
  140. * the reserved and user-definable link class identifier value ranges.
  141. * <table>
  142. * <tr>
  143. * <th>Link class identifier or Value range</th>
  144. * <th>Description</th>
  145. * <th>Link class or label</th>
  146. * </tr>
  147. * <tr>
  148. * <td>0 to 63</td>
  149. * <td>Reserved range</td>
  150. * <td></td>
  151. * </tr>
  152. * <tr>
  153. * <td>64 to 255</td>
  154. * <td>User-definable range</td>
  155. * <td></td>
  156. * </tr>
  157. * <tr>
  158. * <td>64</td>
  159. * <td>Minimum user-defined value</td>
  160. * <td>#H5L_TYPE_UD_MIN</td>
  161. * </tr>
  162. * <tr>
  163. * <td>64</td>
  164. * <td>External link</td>
  165. * <td>#H5L_TYPE_EXTERNAL</td>
  166. * </tr>
  167. * <tr>
  168. * <td>255</td>
  169. * <td>Maximum user-defined value</td>
  170. * <td>#H5L_TYPE_UD_MAX</td>
  171. * </tr>
  172. * <tr>
  173. * <td>255</td>
  174. * <td>Maximum value</td>
  175. * <td>#H5L_TYPE_MAX</td>
  176. * </tr>
  177. * <tr>
  178. * <td>-1</td>
  179. * <td>Error</td>
  180. * <td>#H5L_TYPE_ERROR</td>
  181. * </tr>
  182. * </table>
  183. *
  184. * Note that HDF5 internally registers user-defined link classes only
  185. * by the numeric value of the link class identifier. An application,
  186. * on the other hand, will generally use a name for a user-defined
  187. * class, if for no other purpose than as a variable name. Assume,
  188. * for example, that a complex link type is registered with the link
  189. * class identifier 73 and that the code includes the following
  190. * assignment:
  191. * \code
  192. * H5L_TYPE_COMPLEX_A = 73
  193. * \endcode
  194. * The application can refer to the link class with a term,
  195. * \c H5L_TYPE_COMPLEX_A, that conveys meaning to a human reviewing
  196. * the code, while HDF5 recognizes it by the more cryptic numeric
  197. * identifier, 73.
  198. *
  199. * \attention Important details and considerations include the following:
  200. * \li If you plan to distribute files or software with a
  201. * user-defined link class, please contact the Help Desk at
  202. * The HDF Group to help prevent collisions between \c class_id
  203. * values. See below.
  204. * \li As distributed with HDF5, the external link class is
  205. * implemented as an example of a user-defined link class with
  206. * #H5L_TYPE_EXTERNAL equal to #H5L_TYPE_UD_MIN. \c class_id in
  207. * the H5L_class_t \c struct must not equal #H5L_TYPE_UD_MIN
  208. * unless you intend to overwrite or modify the behavior of
  209. * external links.
  210. * \li H5Lregister() can be used only with link class identifiers
  211. * in the user-definable range (see table above).
  212. * \li The hard and soft links defined by the HDF5 library,
  213. * #H5L_TYPE_HARD and #H5L_TYPE_SOFT, reside in the reserved
  214. * range below #H5L_TYPE_UD_MIN and cannot be redefined or
  215. * modified.
  216. * \li H5Lis_registered() can be used to determine whether a desired
  217. * link class identifier is available. \Emph{Note that this
  218. * function will tell you only whether the link class identifier
  219. * has been registered with the installed copy of HDF5; it
  220. * cannot tell you whether the link class has been registered
  221. * with The HDF Group.}
  222. * \li #H5L_TYPE_MAX is the maximum allowed value for a link type
  223. * identifier.
  224. * \li #H5L_TYPE_UD_MIN equals #H5L_TYPE_EXTERNAL.
  225. * \li #H5L_TYPE_UD_MAX equals #H5L_TYPE_MAX.
  226. * \li #H5L_TYPE_ERROR indicates that an error has occurred.
  227. *
  228. * \note \Bold{Registration with The HDF Group:}\n
  229. * There are sometimes reasons to take a broader approach to registering
  230. * a user-defined link class than just invoking H5Lregister(). For
  231. * example:
  232. * \li A user-defined link class is intended for use across an
  233. * organization, among collaborators, or across a community of users.
  234. * \li An application or library overlying HDF5 invokes a user-defined
  235. * link class that must be shipped with the software.
  236. * \li Files are distributed that make use of a user-defined link class.
  237. * \li Or simply, a specific user-defined link class is thought to be
  238. * widely useful.
  239. *
  240. * In such cases, you are encouraged to register that link class with
  241. * The HDF Group's Helpdesk. The HDF Group maintains a registry of known
  242. * user-defined link classes and tracks the selected link class
  243. * identifiers. This registry is intended to reduce the risk of
  244. * collisions between \c class_id values and to help coordinate the use
  245. * of specialized link classes.
  246. *
  247. * \since 1.8.0
  248. *
  249. */
  250. H5_DLL herr_t H5Lregister(const H5L_class_t *cls);
  251. /**
  252. * \ingroup H5LA
  253. *
  254. * \brief Unregisters a class of user-defined links
  255. *
  256. * \param[in] id User-defined link class identifier
  257. *
  258. * \return \herr_t
  259. *
  260. * \details H5Lunregister() unregisters a class of user-defined links,
  261. * preventing them from being traversed, queried, moved, etc.
  262. *
  263. * \note A link class can be re-registered using H5Lregister().
  264. *
  265. * \since 1.8.0
  266. *
  267. */
  268. H5_DLL herr_t H5Lunregister(H5L_type_t id);
  269. #ifdef __cplusplus
  270. }
  271. #endif
  272. /* Symbols defined for compatibility with previous versions of the HDF5 API.
  273. *
  274. * Use of these symbols is deprecated.
  275. */
  276. #ifndef H5_NO_DEPRECATED_SYMBOLS
  277. /* Previous versions of the H5L_class_t struct */
  278. #define H5L_LINK_CLASS_T_VERS_0 0
  279. /** Callback during link traversal */
  280. typedef hid_t (*H5L_traverse_0_func_t)(const char *link_name, hid_t cur_group, const void *lnkdata,
  281. size_t lnkdata_size, hid_t lapl_id);
  282. /** User-defined link types */
  283. typedef struct {
  284. int version; /**< Version number of this struct */
  285. H5L_type_t id; /**< Link type ID */
  286. const char * comment; /**< Comment for debugging */
  287. H5L_create_func_t create_func; /**< Callback during link creation */
  288. H5L_move_func_t move_func; /**< Callback after moving link */
  289. H5L_copy_func_t copy_func; /**< Callback after copying link */
  290. H5L_traverse_0_func_t trav_func; /**< Callback during link traversal */
  291. H5L_delete_func_t del_func; /**< Callback for link deletion */
  292. H5L_query_func_t query_func; /**< Callback for queries */
  293. } H5L_class_0_t;
  294. #endif /* H5_NO_DEPRECATED_SYMBOLS */
  295. #endif /* _H5Ldevelop_H */