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 COPYING file, which can be found at the root of the source code       *
9  * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases.  *
10  * If you do not have access to either file, you may request a copy from     *
11  * help@hdfgroup.org.                                                        *
12  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
13 
14 /*
15  * Programmer:	Quincey Koziol <koziol@ncsa.uiuc.edu>
16  *		Friday, November 16, 2001
17  *
18  * Purpose:	This file contains declarations which are visible only within
19  *		the H5P package.  Source files outside the H5P package should
20  *		include H5Pprivate.h instead.
21  */
22 #if !(defined H5P_FRIEND || defined H5P_MODULE)
23 #error "Do not include this file outside the H5P package!"
24 #endif
25 
26 #ifndef _H5Ppkg_H
27 #define _H5Ppkg_H
28 
29 /* Get package's private header */
30 #include "H5Pprivate.h"
31 
32 /* Other private headers needed by this file */
33 #include "H5SLprivate.h"	/* Skip lists				*/
34 
35 /**************************/
36 /* Package Private Macros */
37 /**************************/
38 
39 
40 /****************************/
41 /* Package Private Typedefs */
42 /****************************/
43 
44 /* Define enum for type of object that property is within */
45 typedef enum {
46     H5P_PROP_WITHIN_UNKNOWN=0,  /* Property container is unknown */
47     H5P_PROP_WITHIN_LIST,       /* Property is within a list */
48     H5P_PROP_WITHIN_CLASS       /* Property is within a class */
49 } H5P_prop_within_t;
50 
51 /* Define enum for modifications to class */
52 typedef enum {
53     H5P_MOD_ERR=(-1),   /* Indicate an error */
54     H5P_MOD_INC_CLS,    /* Increment the dependant class count*/
55     H5P_MOD_DEC_CLS,    /* Decrement the dependant class count*/
56     H5P_MOD_INC_LST,    /* Increment the dependant list count*/
57     H5P_MOD_DEC_LST,    /* Decrement the dependant list count*/
58     H5P_MOD_INC_REF,    /* Increment the ID reference count*/
59     H5P_MOD_DEC_REF,    /* Decrement the ID reference count*/
60     H5P_MOD_MAX         /* Upper limit on class modifications */
61 } H5P_class_mod_t;
62 
63 /* Define structure to hold property information */
64 typedef struct H5P_genprop_t {
65     /* Values for this property */
66     char *name;         /* Name of property */
67     size_t size;        /* Size of property value */
68     void *value;        /* Pointer to property value */
69     H5P_prop_within_t type;     /* Type of object the property is within */
70     hbool_t shared_name;   /* Whether the name is shared or not */
71 
72     /* Callback function pointers & info */
73     H5P_prp_create_func_t create;   /* Function to call when a property is created */
74     H5P_prp_set_func_t set; /* Function to call when a property value is set */
75     H5P_prp_get_func_t get; /* Function to call when a property value is retrieved */
76     H5P_prp_encode_func_t encode; /* Function to call when a property is encoded */
77     H5P_prp_decode_func_t decode; /* Function to call when a property is decoded */
78     H5P_prp_delete_func_t del; /* Function to call when a property is deleted */
79     H5P_prp_copy_func_t copy;  /* Function to call when a property is copied */
80     H5P_prp_compare_func_t cmp; /* Function to call when a property is compared */
81     H5P_prp_close_func_t close; /* Function to call when a property is closed */
82 } H5P_genprop_t;
83 
84 /* Define structure to hold class information */
85 struct H5P_genclass_t {
86     struct H5P_genclass_t *parent;     /* Pointer to parent class */
87     char      *name;       /* Name of property list class */
88     H5P_plist_type_t type; /* Type of property */
89     size_t     nprops;     /* Number of properties in class */
90     unsigned   plists;     /* Number of property lists that have been created since the last modification to the class */
91     unsigned   classes;    /* Number of classes that have been derived since the last modification to the class */
92     unsigned   ref_count;  /* Number of oustanding ID's open on this class object */
93     hbool_t    deleted;    /* Whether this class has been deleted and is waiting for dependent classes & proplists to close */
94     unsigned   revision;   /* Revision number of a particular class (global) */
95     H5SL_t    *props;      /* Skip list containing properties */
96 
97     /* Callback function pointers & info */
98     H5P_cls_create_func_t create_func;  /* Function to call when a property list is created */
99     void *create_data;     /* Pointer to user data to pass along to create callback */
100     H5P_cls_copy_func_t copy_func;      /* Function to call when a property list is copied */
101     void *copy_data;       /* Pointer to user data to pass along to copy callback */
102     H5P_cls_close_func_t close_func;    /* Function to call when a property list is closed */
103     void *close_data;      /* Pointer to user data to pass along to close callback */
104 };
105 
106 /* Define structure to hold property list information */
107 struct H5P_genplist_t {
108     H5P_genclass_t *pclass; /* Pointer to class info */
109     hid_t   plist_id;   /* Copy of the property list ID (for use in close callback) */
110     size_t  nprops;     /* Number of properties in class */
111     hbool_t class_init; /* Whether the class initialization callback finished successfully */
112     H5SL_t *del;        /* Skip list containing names of deleted properties */
113     H5SL_t *props;      /* Skip list containing properties */
114 };
115 
116 /* Property list/class iterator callback function pointer */
117 typedef int (*H5P_iterate_int_t)(H5P_genprop_t *prop, void *udata);
118 
119 /* Forward declarations (for prototypes & struct definitions) */
120 struct H5Z_filter_info_t;
121 
122 /*****************************/
123 /* Package Private Variables */
124 /*****************************/
125 
126 
127 /******************************/
128 /* Package Private Prototypes */
129 /******************************/
130 
131 /* Private functions, not part of the publicly documented API */
132 H5_DLL H5P_genclass_t *H5P_create_class(H5P_genclass_t *par_class,
133     const char *name, H5P_plist_type_t type,
134     H5P_cls_create_func_t cls_create, void *create_data,
135     H5P_cls_copy_func_t cls_copy, void *copy_data,
136     H5P_cls_close_func_t cls_close, void *close_data);
137 H5_DLL H5P_genclass_t *H5P_copy_pclass(H5P_genclass_t *pclass);
138 H5_DLL herr_t H5P_register_real(H5P_genclass_t *pclass, const char *name, size_t size,
139     const void *def_value, H5P_prp_create_func_t prp_create,
140     H5P_prp_set_func_t prp_set, H5P_prp_get_func_t prp_get,
141     H5P_prp_encode_func_t prp_encode, H5P_prp_decode_func_t prp_decode,
142     H5P_prp_delete_func_t prp_delete,
143     H5P_prp_copy_func_t prp_copy, H5P_prp_compare_func_t prp_cmp,
144     H5P_prp_close_func_t prp_close);
145 H5_DLL herr_t H5P_register(H5P_genclass_t **pclass, const char *name, size_t size,
146     const void *def_value, H5P_prp_create_func_t prp_create,
147     H5P_prp_set_func_t prp_set, H5P_prp_get_func_t prp_get,
148     H5P_prp_encode_func_t prp_encode, H5P_prp_decode_func_t prp_decode,
149     H5P_prp_delete_func_t prp_delete,
150     H5P_prp_copy_func_t prp_copy, H5P_prp_compare_func_t prp_cmp,
151     H5P_prp_close_func_t prp_close);
152 H5_DLL herr_t H5P_add_prop(H5SL_t *props, H5P_genprop_t *prop);
153 H5_DLL herr_t H5P_access_class(H5P_genclass_t *pclass, H5P_class_mod_t mod);
154 H5_DLL htri_t H5P_exist_pclass(H5P_genclass_t *pclass, const char *name);
155 H5_DLL herr_t H5P_get_size_plist(const H5P_genplist_t *plist, const char *name,
156     size_t *size);
157 H5_DLL herr_t H5P_get_size_pclass(H5P_genclass_t *pclass, const char *name,
158     size_t *size);
159 H5_DLL herr_t H5P_get_nprops_plist(const H5P_genplist_t *plist, size_t *nprops);
160 H5_DLL int H5P_cmp_class(const H5P_genclass_t *pclass1, const H5P_genclass_t *pclass2);
161 H5_DLL herr_t H5P_cmp_plist(const H5P_genplist_t *plist1, const H5P_genplist_t *plist2,
162     int *cmp_ret);
163 H5_DLL int H5P_iterate_plist(const H5P_genplist_t *plist, hbool_t iter_all_prop,
164     int *idx, H5P_iterate_int_t iter_func, void *iter_data);
165 H5_DLL int H5P_iterate_pclass(const H5P_genclass_t *pclass, int *idx,
166     H5P_iterate_int_t iter_func, void *iter_data);
167 H5_DLL herr_t H5P_copy_prop_plist(hid_t dst_id, hid_t src_id, const char *name);
168 H5_DLL herr_t H5P_copy_prop_pclass(hid_t dst_id, hid_t src_id, const char *name);
169 H5_DLL herr_t H5P_unregister(H5P_genclass_t *pclass, const char *name);
170 H5_DLL char *H5P_get_class_path(H5P_genclass_t *pclass);
171 H5_DLL H5P_genclass_t *H5P_open_class_path(const char *path);
172 H5_DLL H5P_genclass_t *H5P_get_class_parent(const H5P_genclass_t *pclass);
173 H5_DLL herr_t H5P_close_class(void *_pclass);
174 H5_DLL H5P_genprop_t *H5P__find_prop_plist(const H5P_genplist_t *plist, const char *name);
175 H5_DLL hid_t H5P__new_plist_of_type(H5P_plist_type_t type);
176 
177 /* Encode/decode routines */
178 H5_DLL herr_t H5P__encode(const H5P_genplist_t *plist, hbool_t enc_all_prop,
179     void *buf, size_t *nalloc);
180 H5_DLL hid_t H5P__decode(const void *buf);
181 H5_DLL herr_t H5P__encode_hsize_t(const void *value, void **_pp, size_t *size);
182 H5_DLL herr_t H5P__encode_size_t(const void *value, void **_pp, size_t *size);
183 H5_DLL herr_t H5P__encode_unsigned(const void *value, void **_pp, size_t *size);
184 H5_DLL herr_t H5P__encode_uint8_t(const void *value, void **_pp, size_t *size);
185 H5_DLL herr_t H5P__encode_hbool_t(const void *value, void **_pp, size_t *size);
186 H5_DLL herr_t H5P__encode_double(const void *value, void **_pp, size_t *size);
187 H5_DLL herr_t H5P__decode_hsize_t(const void **_pp, void *value);
188 H5_DLL herr_t H5P__decode_size_t(const void **_pp, void *value);
189 H5_DLL herr_t H5P__decode_unsigned(const void **_pp, void *value);
190 H5_DLL herr_t H5P__decode_uint8_t(const void **_pp, void *value);
191 H5_DLL herr_t H5P__decode_hbool_t(const void **_pp, void *value);
192 H5_DLL herr_t H5P__decode_double(const void **_pp, void *value);
193 H5_DLL herr_t H5P__encode_coll_md_read_flag_t(const void *value, void **_pp, size_t *size);
194 H5_DLL herr_t H5P__decode_coll_md_read_flag_t(const void **_pp, void *value);
195 
196 /* Private OCPL routines */
197 H5_DLL herr_t H5P_get_filter(const struct H5Z_filter_info_t *filter,
198     unsigned int *flags, size_t *cd_nelmts, unsigned cd_values[],
199     size_t namelen, char name[], unsigned *filter_config);
200 
201 /* Testing functions */
202 #ifdef H5P_TESTING
203 H5_DLL char *H5P_get_class_path_test(hid_t pclass_id);
204 H5_DLL hid_t H5P_open_class_path_test(const char *path);
205 #endif /* H5P_TESTING */
206 
207 #endif /* _H5Ppkg_H */
208 
209