summaryrefslogtreecommitdiffstats
path: root/src/H5Pgcpl.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5Pgcpl.c')
-rw-r--r--src/H5Pgcpl.c195
1 files changed, 191 insertions, 4 deletions
diff --git a/src/H5Pgcpl.c b/src/H5Pgcpl.c
index 394cf8b..2bac037 100644
--- a/src/H5Pgcpl.c
+++ b/src/H5Pgcpl.c
@@ -42,6 +42,12 @@
/* Local Macros */
/****************/
+/* ========= Group Creation properties ============ */
+#define H5G_CRT_GROUP_INFO_ENC H5P__gcrt_group_info_enc
+#define H5G_CRT_GROUP_INFO_DEC H5P__gcrt_group_info_dec
+#define H5G_CRT_LINK_INFO_ENC H5P__gcrt_link_info_enc
+#define H5G_CRT_LINK_INFO_DEC H5P__gcrt_link_info_dec
+
/******************/
/* Local Typedefs */
@@ -60,6 +66,12 @@
/* Property class callbacks */
static herr_t H5P__gcrt_reg_prop(H5P_genclass_t *pclass);
+/* Property callbacks */
+static herr_t H5P__gcrt_group_info_enc(const void *value, uint8_t **pp, size_t *size);
+static herr_t H5P__gcrt_group_info_dec(const uint8_t **pp, void *value);
+static herr_t H5P__gcrt_link_info_enc(const void *value, uint8_t **pp, size_t *size);
+static herr_t H5P__gcrt_link_info_dec(const uint8_t **pp, void *value);
+
/*********************/
/* Package Variables */
@@ -91,6 +103,10 @@ const H5P_libclass_t H5P_CLS_GCRT[1] = {{
/* Local Variables */
/*******************/
+/* Property value defaults */
+static const H5O_ginfo_t H5G_def_ginfo_g = H5G_CRT_GROUP_INFO_DEF; /* Default group info settings */
+static const H5O_linfo_t H5G_def_linfo_g = H5G_CRT_LINK_INFO_DEF; /* Default link info settings */
+
/*-------------------------------------------------------------------------
@@ -107,18 +123,20 @@ const H5P_libclass_t H5P_CLS_GCRT[1] = {{
static herr_t
H5P__gcrt_reg_prop(H5P_genclass_t *pclass)
{
- H5O_ginfo_t ginfo = H5G_CRT_GROUP_INFO_DEF; /* Default group info settings */
- H5O_linfo_t linfo = H5G_CRT_LINK_INFO_DEF; /* Default link info settings */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_STATIC
/* Register group info property */
- if(H5P_register_real(pclass, H5G_CRT_GROUP_INFO_NAME, H5G_CRT_GROUP_INFO_SIZE, &ginfo, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0)
+ if(H5P_register_real(pclass, H5G_CRT_GROUP_INFO_NAME, H5G_CRT_GROUP_INFO_SIZE, &H5G_def_ginfo_g,
+ NULL, NULL, NULL, H5G_CRT_GROUP_INFO_ENC, H5G_CRT_GROUP_INFO_DEC,
+ NULL, NULL, NULL, NULL) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
/* Register link info property */
- if(H5P_register_real(pclass, H5G_CRT_LINK_INFO_NAME, H5G_CRT_LINK_INFO_SIZE, &linfo, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0)
+ if(H5P_register_real(pclass, H5G_CRT_LINK_INFO_NAME, H5G_CRT_LINK_INFO_SIZE, &H5G_def_linfo_g,
+ NULL, NULL, NULL, H5G_CRT_LINK_INFO_ENC, H5G_CRT_LINK_INFO_DEC,
+ NULL, NULL, NULL, NULL) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
done:
@@ -506,3 +524,172 @@ done:
FUNC_LEAVE_API(ret_value)
} /* end H5Pget_link_creation_order() */
+
+/*-------------------------------------------------------------------------
+ * Function: H5P__gcrt_group_info_enc
+ *
+ * Purpose: Callback routine which is called whenever the group
+ * property in the dataset access property list is
+ * encoded.
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ * Programmer: Mohamad Chaarawi
+ * Monday, October 10, 2011
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5P__gcrt_group_info_enc(const void *value, uint8_t **pp, size_t *size)
+{
+ const H5O_ginfo_t *ginfo = (const H5O_ginfo_t *)value; /* Create local aliases for values */
+
+ FUNC_ENTER_STATIC_NOERR
+
+ if(NULL != *pp) {
+ UINT32ENCODE(*pp, ginfo->lheap_size_hint)
+ UINT16ENCODE(*pp, ginfo->max_compact)
+ UINT16ENCODE(*pp, ginfo->min_dense)
+ UINT16ENCODE(*pp, ginfo->est_num_entries)
+ UINT16ENCODE(*pp, ginfo->est_name_len)
+ } /* end if */
+
+ *size += sizeof(uint16_t) * 4 + sizeof(uint32_t);
+
+ FUNC_LEAVE_NOAPI(SUCCEED)
+} /* end H5P__gcrt_group_info_enc() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5P__gcrt_group_info_dec
+ *
+ * Purpose: Callback routine which is called whenever the group info
+ * property in the dataset access property list is
+ * decoded.
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ * Programmer: Mohamad Chaarawi
+ * Monday, October 10, 2011
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5P__gcrt_group_info_dec(const uint8_t **pp, void *_value)
+{
+ H5O_ginfo_t *ginfo = (H5O_ginfo_t *)_value; /* Group info settings */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_STATIC_NOERR
+
+ /* Set property to default value */
+ *ginfo = H5G_def_ginfo_g;
+
+ UINT32DECODE(*pp, ginfo->lheap_size_hint)
+ UINT16DECODE(*pp, ginfo->max_compact)
+ UINT16DECODE(*pp, ginfo->min_dense)
+ UINT16DECODE(*pp, ginfo->est_num_entries)
+ UINT16DECODE(*pp, ginfo->est_name_len)
+
+ /* Update fields */
+ if(ginfo->max_compact != H5G_CRT_GINFO_MAX_COMPACT ||
+ ginfo->min_dense != H5G_CRT_GINFO_MIN_DENSE)
+ ginfo->store_link_phase_change = TRUE;
+ else
+ ginfo->store_link_phase_change = FALSE;
+
+ if(ginfo->est_num_entries != H5G_CRT_GINFO_EST_NUM_ENTRIES ||
+ ginfo->est_name_len != H5G_CRT_GINFO_EST_NAME_LEN)
+ ginfo->store_est_entry_info = TRUE;
+ else
+ ginfo->store_est_entry_info = FALSE;
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5P__gcrt_group_info_dec() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5P__gcrt_link_info_enc
+ *
+ * Purpose: Callback routine which is called whenever the link
+ * property in the dataset access property list is
+ * encoded.
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ * Programmer: Mohamad Chaarawi
+ * Monday, October 10, 2011
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5P__gcrt_link_info_enc(const void *value, uint8_t **pp, size_t *size)
+{
+ const H5O_linfo_t *linfo = (const H5O_linfo_t *)value; /* Create local aliases for values */
+
+ FUNC_ENTER_STATIC_NOERR
+
+ if(NULL != *pp) {
+ unsigned crt_order_flags = 0;
+
+ crt_order_flags |= linfo->track_corder ? H5P_CRT_ORDER_TRACKED : 0;
+ crt_order_flags |= linfo->index_corder ? H5P_CRT_ORDER_INDEXED : 0;
+
+ /* Encode the size of unsigned*/
+ *(*pp)++ = (uint8_t)sizeof(unsigned);
+
+ /* Encode the value */
+ H5_ENCODE_UNSIGNED(*pp, crt_order_flags)
+ } /* end if */
+
+ *size += (1 + sizeof(unsigned));
+
+ FUNC_LEAVE_NOAPI(SUCCEED)
+} /* end H5P__gcrt_link_info_enc() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5P__gcrt_link_info_dec
+ *
+ * Purpose: Callback routine which is called whenever the link info
+ * property in the dataset access property list is
+ * decoded.
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ * Programmer: Mohamad Chaarawi
+ * Monday, October 10, 2011
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5P__gcrt_link_info_dec(const uint8_t **pp, void *_value)
+{
+ H5O_linfo_t *linfo = (H5O_linfo_t *)_value; /* Link info settings */
+ unsigned crt_order_flags;
+ unsigned enc_size;
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_STATIC
+
+ enc_size = *(*pp)++;
+ if(enc_size != sizeof(unsigned))
+ HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "unsigned value can't be decoded")
+
+ /* Set property to default value */
+ *linfo = H5G_def_linfo_g;
+
+ H5_DECODE_UNSIGNED(*pp, crt_order_flags)
+
+ /* Update fields */
+ linfo->track_corder = (hbool_t)((crt_order_flags & H5P_CRT_ORDER_TRACKED) ? TRUE : FALSE);
+ linfo->index_corder = (hbool_t)((crt_order_flags & H5P_CRT_ORDER_INDEXED) ? TRUE : FALSE);
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5P__gcrt_link_info_dec() */
+