PageRenderTime 25ms CodeModel.GetById 16ms RepoModel.GetById 1ms app.codeStats 0ms

/ExternalLibs/hdf4/hdf4.2.5-win32/include/mfan.h

#
C++ Header | 373 lines | 80 code | 38 blank | 255 comment | 0 complexity | 6bf6bca5569db6957f820f2edac1a9fd MD5 | raw file
  1. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  2. * Copyright by The HDF Group. *
  3. * Copyright by the Board of Trustees of the University of Illinois. *
  4. * All rights reserved. *
  5. * *
  6. * This file is part of HDF. The full HDF copyright notice, including *
  7. * terms governing use, modification, and redistribution, is contained in *
  8. * the files COPYING and Copyright.html. COPYING can be found at the root *
  9. * of the source code distribution tree; Copyright.html can be found at *
  10. * http://hdfgroup.org/products/hdf4/doc/Copyright.html. If you do not have *
  11. * access to either file, you may request a copy from help@hdfgroup.org. *
  12. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  13. /* $Id: mfan.h 4932 2007-09-07 17:17:23Z bmribler $ */
  14. /*------------------------------------------------------------------------------
  15. * File: mfan.h
  16. * Author: GeorgeV
  17. * Purpose: header file for the Multi-file Annotation Interface
  18. * Invokes:
  19. * Contents:
  20. * Structure definitions: ANnode, ANentry
  21. * Constant definitions: AN_DATA_LABEL, AN_DATA_DESC
  22. * (-moved to hdf.h) AN_FILE_LABEL, AN_FILE_DESC
  23. *
  24. *----------------------------------------------------------------------------*/
  25. #ifndef _MFAN_H /* avoid re-inclusion */
  26. #define _MFAN_H
  27. #include "hdf.h"
  28. #if 0
  29. /* enumerated types of the varous annotation types
  30. * NOTE: moved to hdf.h since they are used by end users. */
  31. typedef enum
  32. {
  33. AN_DATA_LABEL = 0, /* Data label */
  34. AN_DATA_DESC, /* Data description */
  35. AN_FILE_LABEL, /* File label */
  36. AN_FILE_DESC /* File description */
  37. } ann_type;
  38. #endif
  39. #ifdef MFAN_C
  40. /* WE ARE IN MAIN ANNOTATION SOURCE FILE "mfan.c" */
  41. /* PRIVATE variables and definitions */
  42. /* This sturcture is used to find which file the annotation belongs to
  43. * and use the subsequent file specific annotation 'key' to find the
  44. * annotation. The annotation atom group(ANIDGROUP) keeps track of
  45. * all anotations across the file. */
  46. typedef struct ANnode
  47. {
  48. int32 file_id; /* which file this annotation belongs to */
  49. int32 ann_key; /* type/ref: used to find annotation in corresponding
  50. TBBT in filerec_t->tree[]. */
  51. intn new_ann; /* flag */
  52. } ANnode;
  53. /*
  54. * This structure is an entry in the label/desc tree
  55. * for a label/desc in the file, it gives the ref of the label/desc,
  56. * and the tag/ref of the data item to which the label/desc relates
  57. * The filerec_t->an_tree[] TBBT members will contain these entries.
  58. **/
  59. typedef struct ANentry
  60. {
  61. int32 ann_id; /* annotation id */
  62. uint16 annref; /* ref of annotation */
  63. uint16 elmtag; /* tag of data */
  64. uint16 elmref; /* ref of data */
  65. } ANentry;
  66. /* This is the size of the hash tables used for annotation IDs */
  67. #define ANATOM_HASH_SIZE 64
  68. /* Used to create unique 32bit keys from annotation type and reference number
  69. * This key is used to add nodes to a corresponding TBBT in
  70. * filrerec_t->an_tree[].
  71. * ----------------------------
  72. * | type(16bits) | ref(16bits) |
  73. * -----------------------------*/
  74. #define AN_CREATE_KEY(t,r) ((((int32)t & 0xffff) << 16) | r)
  75. /* Obtain Reference number from key */
  76. #define AN_KEY2REF(k) ((uint16)((int32)k & 0xffff))
  77. /* Obtain Annotation type from key */
  78. #define AN_KEY2TYPE(k) ((int32)((int32)k >> 16))
  79. #else /* !MFAN_C */
  80. /* WE are NOT in main ANNOTATION source file
  81. * Nothing EXPORTED except Public fcns */
  82. /******************************************************************************
  83. NAME
  84. ANdestroy -- Un-Initialize Annotation Interface
  85. DESCRIPTION
  86. Unallocates global annotaton node list and file list.
  87. RETURNS
  88. SUCCEED or FAIL
  89. *******************************************************************************/
  90. extern intn ANdestroy(void);
  91. /******************************************************************************
  92. NAME
  93. ANstart - open file for annotation handling
  94. DESCRIPTION
  95. Start annotation handling on the file return a annotation ID to the file.
  96. RETURNS
  97. A file ID or FAIL.
  98. *******************************************************************************/
  99. extern int32 ANstart(int32 file_id /* IN: file to start annotation access on */);
  100. /******************************************************************************
  101. NAME
  102. ANfileinfo - Report high-level information about the ANxxx interface for a given file.
  103. DESCRIPTION
  104. Reports general information about the number of file and object(i.e. data)
  105. annotations in the file. This routine is generally used to find
  106. the range of acceptable indices for ANselect calls.
  107. RETURNS
  108. Returns SUCCEED if successful and FAIL othewise
  109. *******************************************************************************/
  110. extern intn ANfileinfo(int32 an_id, /* IN: annotation interface id */
  111. int32 *n_file_label, /* OUT: the # of file labels */
  112. int32 *n_file_desc, /* OUT: the # of file descriptions */
  113. int32 *n_obj_label, /* OUT: the # of object labels */
  114. int32 *n_obj_desc /* OUT: the # of object descriptions */);
  115. /******************************************************************************
  116. NAME
  117. ANend - End annotation access to file file
  118. DESCRIPTION
  119. End annotation access to file.
  120. RETURNS
  121. SUCCEED if successful and FAIL otherwise.
  122. *******************************************************************************/
  123. extern int32 ANend(int32 an_id /* IN: Annotation ID of file to close */);
  124. /******************************************************************************
  125. NAME
  126. ANcreate - create a new element annotation and return a handle(id)
  127. DESCRIPTION
  128. Creates a data annotation, returns an 'an_id' to work with the new
  129. annotation which can either be a label or description.
  130. Valid annotation types are AN_DATA_LABEL for data labels and
  131. AN_DATA_DESC for data descriptions.
  132. RETURNS
  133. An ID to an annotation which can either be a label or description.
  134. *******************************************************************************/
  135. extern int32 ANcreate(int32 an_id, /* IN: annotation interface ID */
  136. uint16 elem_tag, /* IN: tag of item to be assigned annotation */
  137. uint16 elem_ref, /* IN: reference number of itme to be assigned ann*/
  138. ann_type type /* IN: annotation type */);
  139. /******************************************************************************
  140. NAME
  141. ANcreatef - create a new file annotation and return a handle(id)
  142. DESCRIPTION
  143. Creates a file annotation, returns an 'an_id' to work with the new
  144. file annotation which can either be a label or description.
  145. Valid annotation types are AN_FILE_LABEL for file labels and
  146. AN_FILE_DESC for file descritpions.
  147. RETURNS
  148. An ID to an annotation which can either be a file label or description
  149. *******************************************************************************/
  150. extern int32 ANcreatef(int32 an_id, /* IN: annotation interface ID */
  151. ann_type type /* IN: annotation type */);
  152. /******************************************************************************
  153. NAME
  154. ANselect - get an annotation ID from index of 'type'
  155. DESCRIPTION
  156. Get an annotation Id from index of 'type'.
  157. The position index is ZERO based
  158. RETURNS
  159. An ID to an annotation type which can either be a label or description
  160. *******************************************************************************/
  161. extern int32 ANselect(int32 an_id, /* IN: annotation interface ID */
  162. int32 index, /* IN: index of annottion to get ID for */
  163. ann_type type /* IN: annotation type */);
  164. /******************************************************************************
  165. NAME
  166. ANnumann - find number of annotation of 'type' that match the given element tag/ref
  167. DESCRIPTION
  168. Find number of annotation of 'type' for the given element
  169. tag/ref pair.Should not be used for File labels and
  170. descriptions.
  171. RETURNS
  172. number of annotation found if successful and FAIL (-1) otherwise
  173. *******************************************************************************/
  174. extern intn ANnumann(int32 an_id, /* IN: annotation interface id */
  175. ann_type type, /* IN: annotation type */
  176. uint16 elem_tag, /* IN: tag of item of which this is annotation */
  177. uint16 elem_ref /* IN: ref of item of which this is annotation*/);
  178. /******************************************************************************
  179. NAME
  180. ANannlist - generate list of annotation ids of 'type' that match the given element tag/ref
  181. DESCRIPTION
  182. Find and generate list of annotation ids of 'type' for the given
  183. element tag/ref pair.Should not be used for File labels and
  184. descriptions.
  185. RETURNS
  186. number of annotations ids found if successful and FAIL (-1) otherwise
  187. *******************************************************************************/
  188. extern intn ANannlist(int32 an_id, /* IN: annotation interface id */
  189. ann_type type, /* IN: annotation type */
  190. uint16 elem_tag, /* IN: tag of item of which this is annotation */
  191. uint16 elem_ref, /* IN: ref of item of which this is annotation*/
  192. int32 ann_list[] /* OUT: array of ann_id's that match criteria.*/);
  193. /******************************************************************************
  194. NAME
  195. ANannlen - get length of annotation givne annotation id
  196. DESCRIPTION
  197. Uses the annotation id to find ann_key & file_id
  198. RETURNS
  199. length of annotation if successful and FAIL (-1) otherwise
  200. *******************************************************************************/
  201. extern int32 ANannlen(int32 ann_id /* IN: annotation id */);
  202. /******************************************************************************
  203. NAME
  204. ANwriteann - write annotation given ann_id
  205. DESCRIPTION
  206. Checks for pre-existence of given annotation, replacing old one if it
  207. exists. Writes out annotation.
  208. RETURNS
  209. SUCCEED (0) if successful and FAIL (-1) otherwise
  210. *******************************************************************************/
  211. extern int32 ANwriteann(int32 ann_id, /* IN: annotation id */
  212. const char *ann, /* IN: annotation to write */
  213. int32 annlen /* IN: length of annotation*/);
  214. /******************************************************************************
  215. NAME
  216. ANreadann - read annotation given ann_id
  217. DESCRIPTION
  218. Gets tag and ref of annotation. Finds DD for that annotation.
  219. Reads the annotation, taking care of NULL terminator, if necessary.
  220. RETURNS
  221. SUCCEED (0) if successful and FAIL (-1) otherwise
  222. *******************************************************************************/
  223. extern int32 ANreadann(int32 ann_id, /* IN: annotation id (handle) */
  224. char *ann, /* OUT: space to return annotation in */
  225. int32 maxlen /* IN: size of space to return annotation in */);
  226. /******************************************************************************
  227. NAME
  228. ANendaccess - end access to an annotation given it's id
  229. DESCRIPTION
  230. Terminates access to an annotation. For now does nothing
  231. RETURNS
  232. SUCCEED(0) or FAIL(-1)
  233. *******************************************************************************/
  234. extern intn ANendaccess(int32 ann_id /* IN: annotation id */);
  235. /******************************************************************************
  236. NAME
  237. ANget_tagref - get tag/ref pair for annotation based on type and index
  238. DESCRIPTION
  239. Get the tag/ref of the annotation based on the type and index of the
  240. annotation. The position index is zero based
  241. RETURNS
  242. A tag/ref pairt to an annotation type which can either be a
  243. label or description.
  244. *******************************************************************************/
  245. extern int32 ANget_tagref(int32 an_id, /* IN: annotation interface ID */
  246. int32 index, /* IN: index of annotation to get tag/ref for*/
  247. ann_type type, /* IN: annotation type */
  248. uint16 *ann_tag,/* OUT: Tag for annotation */
  249. uint16 *ann_ref /* OUT: ref for annotation */);
  250. /******************************************************************************
  251. NAME
  252. ANid2tagref -- get tag/ref given annotation id
  253. DESCRIPTION
  254. Uses the annotation id to find ann_node entry which contains ann_ref
  255. RETURNS
  256. SUCCEED(0) if successful and FAIL (-1) otherwise.
  257. *******************************************************************************/
  258. extern int32 ANid2tagref(int32 ann_id, /* IN: annotation id */
  259. uint16 *ann_tag, /* OUT: Tag for annotation */
  260. uint16 *ann_ref /* OUT: ref for annotation */);
  261. /******************************************************************************
  262. NAME
  263. ANtagref2id -- get annotation id given tag/ref
  264. DESCRIPTION
  265. Gets the annotation id of the annotation given the tag/ref of
  266. the annotation itself and the annotation interface id.
  267. RETURNS
  268. Annotation id of annotation if successful and FAIL(-1) otherwise.
  269. *******************************************************************************/
  270. extern int32 ANtagref2id(int32 an_id, /* IN Annotation interface id */
  271. uint16 ann_tag, /* IN: Tag for annotation */
  272. uint16 ann_ref /* IN: ref for annotation */);
  273. /******************************************************************************
  274. NAME
  275. ANatype2tag - annotation type to corresponding annotation TAG
  276. DESCRIPTION
  277. Translate annotation type to corresponding TAG.
  278. RETURNS
  279. Returns TAG corresponding to annotatin type.
  280. *******************************************************************************/
  281. extern uint16 ANatype2tag(ann_type atype /* IN: Annotation type */);
  282. /******************************************************************************
  283. NAME
  284. ANtag2atype - annotation TAG to corresponding annotation type
  285. DESCRIPTION
  286. Translate annotation TAG to corresponding atype
  287. RETURNS
  288. Returns type corresponding to annotatin TAG.
  289. *******************************************************************************/
  290. extern ann_type ANtag2atype(uint16 atag /* IN: annotation tag */);
  291. #endif /* !MFAN_C */
  292. #endif /* _MFAN_H */