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 HDF5. The full HDF5 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 the * 10 * root level of an installed copy of the electronic HDF5 document set and * 11 * is linked from the top-level documents page. It can also be found at * 12 * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * 13 * access to either file, you may request a copy from help@hdfgroup.org. * 14 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 15 16 /* 17 * Programmer: Quincey Koziol <koziol@ncsa.uiuc.edu> 18 * Thursday, September 28, 2000 19 * 20 * Purpose: This file contains declarations which are visible only within 21 * the H5S package. Source files outside the H5S package should 22 * include H5Sprivate.h instead. 23 */ 24 #ifndef H5S_PACKAGE 25 #error "Do not include this file outside the H5S package!" 26 #endif 27 28 #ifndef _H5Spkg_H 29 #define _H5Spkg_H 30 31 #include "H5Sprivate.h" 32 33 /* Flags to indicate special dataspace features are active */ 34 #define H5S_VALID_MAX 0x01 35 #define H5S_VALID_PERM 0x02 36 37 38 /* Initial version of the dataspace information */ 39 #define H5O_SDSPACE_VERSION_1 1 40 41 /* This version adds support for "null" dataspaces, encodes the type of the 42 * dataspace in the message and eliminated the rest of the "reserved" 43 * bytes. 44 */ 45 #define H5O_SDSPACE_VERSION_2 2 46 47 /* The latest version of the format. Look through the 'encode' 48 * and 'size' callbacks for places to change when updating this. */ 49 #define H5O_SDSPACE_VERSION_LATEST H5O_SDSPACE_VERSION_2 50 51 52 /* 53 * Dataspace extent information 54 */ 55 /* Extent container */ 56 struct H5S_extent_t { 57 H5O_shared_t sh_loc; /* Shared message info (must be first) */ 58 59 H5S_class_t type; /* Type of extent */ 60 unsigned version; /* Version of object header message to encode this object with */ 61 hsize_t nelem; /* Number of elements in extent */ 62 63 unsigned rank; /* Number of dimensions */ 64 hsize_t *size; /* Current size of the dimensions */ 65 hsize_t *max; /* Maximum size of the dimensions */ 66 }; 67 68 /* 69 * Dataspace selection information 70 */ 71 /* Node in point selection list (typedef'd in H5Sprivate.h) */ 72 struct H5S_pnt_node_t { 73 hsize_t *pnt; /* Pointer to a selected point */ 74 struct H5S_pnt_node_t *next; /* pointer to next point in list */ 75 }; 76 77 /* Information about point selection list */ 78 typedef struct { 79 H5S_pnt_node_t *head; /* Pointer to head of point list */ 80 } H5S_pnt_list_t; 81 82 /* Information about new-style hyperslab spans */ 83 84 /* Information a particular hyperslab span */ 85 struct H5S_hyper_span_t { 86 hsize_t low, high; /* Low & high bounds of span */ 87 hsize_t nelem; /* Number of elements in span (only needed during I/O) */ 88 hsize_t pstride; /* Pseudo-stride from start of previous span (only used during I/O) */ 89 struct H5S_hyper_span_info_t *down; /* Pointer to list of spans in next dimension down */ 90 struct H5S_hyper_span_t *next; /* Pointer to next span in list */ 91 }; 92 93 /* Information about a list of hyperslab spans */ 94 struct H5S_hyper_span_info_t { 95 unsigned count; /* Ref. count of number of spans which share this span */ 96 struct H5S_hyper_span_info_t *scratch; /* Scratch pointer 97 * (used during copies, as mark 98 * during precomputes for I/O & 99 * to point to the last span in a 100 * list during single element adds) 101 */ 102 struct H5S_hyper_span_t *head; /* Pointer to list of spans in next dimension down */ 103 }; 104 105 /* Information about new-style hyperslab selection */ 106 typedef struct { 107 hbool_t diminfo_valid; /* Whether the dataset has valid diminfo */ 108 H5S_hyper_dim_t opt_diminfo[H5S_MAX_RANK]; /* per-dim selection info */ 109 H5S_hyper_dim_t app_diminfo[H5S_MAX_RANK]; /* per-dim selection info */ 110 /* 'opt_diminfo' points to a [potentially] optimized version of the user's 111 * hyperslab information. 'app_diminfo' points to the actual parameters 112 * that the application used for setting the hyperslab selection. These 113 * are only used for re-gurgitating the original values used to set the 114 * hyperslab to the application when it queries the hyperslab selection 115 * information. */ 116 H5S_hyper_span_info_t *span_lst; /* List of hyperslab span information */ 117 } H5S_hyper_sel_t; 118 119 /* Selection information methods */ 120 /* Method to copy a selection */ 121 typedef herr_t (*H5S_sel_copy_func_t)(H5S_t *dst, const H5S_t *src, hbool_t share_selection); 122 /* Method to retrieve a list of offset/length sequences for selection */ 123 typedef herr_t (*H5S_sel_get_seq_list_func_t)(const H5S_t *space, unsigned flags, 124 H5S_sel_iter_t *iter, size_t maxseq, size_t maxbytes, 125 size_t *nseq, size_t *nbytes, hsize_t *off, size_t *len); 126 /* Method to release current selection */ 127 typedef herr_t (*H5S_sel_release_func_t)(H5S_t *space); 128 /* Method to determine if current selection is valid for dataspace */ 129 typedef htri_t (*H5S_sel_is_valid_func_t)(const H5S_t *space); 130 /* Method to determine number of bytes required to store current selection */ 131 typedef hssize_t (*H5S_sel_serial_size_func_t)(const H5S_t *space); 132 /* Method to store current selection in "serialized" form (a byte sequence suitable for storing on disk) */ 133 typedef herr_t (*H5S_sel_serialize_func_t)(const H5S_t *space, uint8_t *buf); 134 /* Method to store create selection from "serialized" form (a byte sequence suitable for storing on disk) */ 135 typedef herr_t (*H5S_sel_deserialize_func_t)(H5S_t *space, const uint8_t *buf); 136 /* Method to determine smallest n-D bounding box containing the current selection */ 137 typedef herr_t (*H5S_sel_bounds_func_t)(const H5S_t *space, hsize_t *start, hsize_t *end); 138 /* Method to determine linear offset of initial element in selection within dataspace */ 139 typedef herr_t (*H5S_sel_offset_func_t)(const H5S_t *space, hsize_t *offset); 140 /* Method to determine if current selection is contiguous */ 141 typedef htri_t (*H5S_sel_is_contiguous_func_t)(const H5S_t *space); 142 /* Method to determine if current selection is a single block */ 143 typedef htri_t (*H5S_sel_is_single_func_t)(const H5S_t *space); 144 /* Method to determine if current selection is "regular" */ 145 typedef htri_t (*H5S_sel_is_regular_func_t)(const H5S_t *space); 146 /* Method to adjust a selection by an offset */ 147 typedef herr_t (*H5S_sel_adjust_u_func_t)(H5S_t *space, const hsize_t *offset); 148 /* Method to construct single element projection onto scalar dataspace */ 149 typedef herr_t (*H5S_sel_project_scalar)(const H5S_t *space, hsize_t *offset); 150 /* Method to construct selection projection onto/into simple dataspace */ 151 typedef herr_t (*H5S_sel_project_simple)(const H5S_t *space, H5S_t *new_space, hsize_t *offset); 152 /* Method to initialize iterator for current selection */ 153 typedef herr_t (*H5S_sel_iter_init_func_t)(H5S_sel_iter_t *sel_iter, const H5S_t *space); 154 155 /* Selection class information */ 156 typedef struct { 157 H5S_sel_type type; /* Type of selection (all, none, points or hyperslab) */ 158 159 /* Methods */ 160 H5S_sel_copy_func_t copy; /* Method to make a copy of a selection */ 161 H5S_sel_get_seq_list_func_t get_seq_list; /* Method to retrieve a list of offset/length sequences for selection */ 162 H5S_sel_release_func_t release; /* Method to release current selection */ 163 H5S_sel_is_valid_func_t is_valid; /* Method to determine if current selection is valid for dataspace */ 164 H5S_sel_serial_size_func_t serial_size; /* Method to determine number of bytes required to store current selection */ 165 H5S_sel_serialize_func_t serialize; /* Method to store current selection in "serialized" form (a byte sequence suitable for storing on disk) */ 166 H5S_sel_deserialize_func_t deserialize; /* Method to store create selection from "serialized" form (a byte sequence suitable for storing on disk) */ 167 H5S_sel_bounds_func_t bounds; /* Method to determine to smallest n-D bounding box containing the current selection */ 168 H5S_sel_offset_func_t offset; /* Method to determine linear offset of initial element in selection within dataspace */ 169 H5S_sel_is_contiguous_func_t is_contiguous; /* Method to determine if current selection is contiguous */ 170 H5S_sel_is_single_func_t is_single; /* Method to determine if current selection is a single block */ 171 H5S_sel_is_regular_func_t is_regular; /* Method to determine if current selection is "regular" */ 172 H5S_sel_adjust_u_func_t adjust_u; /* Method to adjust a selection by an offset */ 173 H5S_sel_project_scalar project_scalar; /* Method to construct scalar dataspace projection */ 174 H5S_sel_project_simple project_simple; /* Method to construct simple dataspace projection */ 175 H5S_sel_iter_init_func_t iter_init; /* Method to initialize iterator for current selection */ 176 } H5S_select_class_t; 177 178 /* Selection information object */ 179 typedef struct { 180 const H5S_select_class_t *type; /* Pointer to selection's class info */ 181 hbool_t offset_changed; /* Indicate that the offset for the selection has been changed */ 182 hssize_t offset[H5S_MAX_RANK]; /* Offset within the extent */ 183 hsize_t num_elem; /* Number of elements in selection */ 184 union { 185 H5S_pnt_list_t *pnt_lst; /* List of selected points (order is important) */ 186 H5S_hyper_sel_t *hslab; /* Info about hyperslab selections */ 187 } sel_info; 188 } H5S_select_t; 189 190 /* Main dataspace structure (typedef'd in H5Sprivate.h) */ 191 struct H5S_t { 192 H5S_extent_t extent; /* Dataspace extent (must stay first) */ 193 H5S_select_t select; /* Dataspace selection */ 194 }; 195 196 /* Selection iteration methods */ 197 /* Method to retrieve the current coordinates of iterator for current selection */ 198 typedef herr_t (*H5S_sel_iter_coords_func_t)(const H5S_sel_iter_t *iter, hsize_t *coords); 199 /* Method to retrieve the current block of iterator for current selection */ 200 typedef herr_t (*H5S_sel_iter_block_func_t)(const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end); 201 /* Method to determine number of elements left in iterator for current selection */ 202 typedef hsize_t (*H5S_sel_iter_nelmts_func_t)(const H5S_sel_iter_t *iter); 203 /* Method to determine if there are more blocks left in the current selection */ 204 typedef htri_t (*H5S_sel_iter_has_next_block_func_t)(const H5S_sel_iter_t *iter); 205 /* Method to move selection iterator to the next element in the selection */ 206 typedef herr_t (*H5S_sel_iter_next_func_t)(H5S_sel_iter_t *iter, size_t nelem); 207 /* Method to move selection iterator to the next block in the selection */ 208 typedef herr_t (*H5S_sel_iter_next_block_func_t)(H5S_sel_iter_t *iter); 209 /* Method to release iterator for current selection */ 210 typedef herr_t (*H5S_sel_iter_release_func_t)(H5S_sel_iter_t *iter); 211 212 /* Selection iteration class */ 213 typedef struct H5S_sel_iter_class_t { 214 H5S_sel_type type; /* Type of selection (all, none, points or hyperslab) */ 215 216 /* Methods on selections */ 217 H5S_sel_iter_coords_func_t iter_coords; /* Method to retrieve the current coordinates of iterator for current selection */ 218 H5S_sel_iter_block_func_t iter_block; /* Method to retrieve the current block of iterator for current selection */ 219 H5S_sel_iter_nelmts_func_t iter_nelmts; /* Method to determine number of elements left in iterator for current selection */ 220 H5S_sel_iter_has_next_block_func_t iter_has_next_block; /* Method to query if there is another block left in the selection */ 221 H5S_sel_iter_next_func_t iter_next; /* Method to move selection iterator to the next element in the selection */ 222 H5S_sel_iter_next_block_func_t iter_next_block; /* Method to move selection iterator to the next block in the selection */ 223 H5S_sel_iter_release_func_t iter_release; /* Method to release iterator for current selection */ 224 } H5S_sel_iter_class_t; 225 226 /* 227 * All selection class methods. 228 */ 229 H5_DLLVAR const H5S_select_class_t H5S_sel_all[1]; 230 231 /* 232 * Hyperslab selection class methods. 233 */ 234 H5_DLLVAR const H5S_select_class_t H5S_sel_hyper[1]; 235 236 /* 237 * None selection class methods. 238 */ 239 H5_DLLVAR const H5S_select_class_t H5S_sel_none[1]; 240 241 /* 242 * Pointer selection class methods. 243 */ 244 H5_DLLVAR const H5S_select_class_t H5S_sel_point[1]; 245 246 /* Extent functions */ 247 H5_DLL herr_t H5S_extent_release(H5S_extent_t *extent); 248 H5_DLL herr_t H5S_extent_copy(H5S_extent_t *dst, const H5S_extent_t *src, 249 hbool_t copy_max); 250 251 /* Operations on selections */ 252 253 /* Testing functions */ 254 #ifdef H5S_TESTING 255 H5_DLL htri_t H5S_select_shape_same_test(hid_t sid1, hid_t sid2); 256 H5_DLL htri_t H5S_get_rebuild_status_test(hid_t space_id); 257 #endif /* H5S_TESTING */ 258 259 #endif /*_H5Spkg_H*/ 260 261