summaryrefslogtreecommitdiffstats
path: root/src/H5Pocpl.c
diff options
context:
space:
mode:
authorRaymond Lu <songyulu@hdfgroup.org>2013-03-13 19:35:26 (GMT)
committerRaymond Lu <songyulu@hdfgroup.org>2013-03-13 19:35:26 (GMT)
commit55822485c64197a6c2c4a623824fcdcd10a57d31 (patch)
tree1b790e029a613c3e87a4640f5f94406b1751ccd1 /src/H5Pocpl.c
parentd9baac8b0b857d82dd0e520a624d6396814417a9 (diff)
downloadhdf5-55822485c64197a6c2c4a623824fcdcd10a57d31.zip
hdf5-55822485c64197a6c2c4a623824fcdcd10a57d31.tar.gz
hdf5-55822485c64197a6c2c4a623824fcdcd10a57d31.tar.bz2
[svn-r23346] First commit for DESY project. It has the basic functionality of loading dynamically filter libraries and a simple test for it.
Tested on koala.
Diffstat (limited to 'src/H5Pocpl.c')
-rw-r--r--src/H5Pocpl.c91
1 files changed, 86 insertions, 5 deletions
diff --git a/src/H5Pocpl.c b/src/H5Pocpl.c
index d8ddfee..032162a 100644
--- a/src/H5Pocpl.c
+++ b/src/H5Pocpl.c
@@ -38,6 +38,8 @@
#include "H5Eprivate.h" /* Error handling */
#include "H5Iprivate.h" /* IDs */
#include "H5MMprivate.h" /* Memory management */
+#include "H5PLprivate.h" /* Dynamic plugin */
+#include "H5Zprivate.h" /* Filter pipeline */
#include "H5Opkg.h" /* Object headers */
#include "H5Ppkg.h" /* Property lists */
@@ -746,9 +748,9 @@ herr_t
H5Pset_filter(hid_t plist_id, H5Z_filter_t filter, unsigned int flags,
size_t cd_nelmts, const unsigned int cd_values[/*cd_nelmts*/])
{
- H5P_genplist_t *plist; /* Property list */
- H5O_pline_t pline; /* Filter pipeline */
- herr_t ret_value=SUCCEED; /* return value */
+ H5P_genplist_t *plist; /* Property list */
+ H5O_pline_t pline; /* Filter pipeline */
+ herr_t ret_value=SUCCEED; /* return value */
FUNC_ENTER_API(FAIL)
H5TRACE5("e", "iZfIuz*[a3]Iu", plist_id, filter, flags, cd_nelmts, cd_values);
@@ -765,6 +767,84 @@ H5Pset_filter(hid_t plist_id, H5Z_filter_t filter, unsigned int flags,
if(NULL == (plist = H5P_object_verify(plist_id, H5P_OBJECT_CREATE)))
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
+ /* Call the private function */
+ if(H5P_set_filter(plist, filter, flags, cd_nelmts, cd_values) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "failed to call private function")
+
+done:
+ FUNC_LEAVE_API(ret_value)
+} /* end H5Pset_filter() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5P_set_filter
+ *
+ * Purpose: Adds the specified FILTER and corresponding properties to the
+ * end of the data or link output filter pipeline
+ * depending on whether PLIST is a dataset creation or group
+ * creation property list. The FLAGS argument specifies certain
+ * general properties of the filter and is documented below.
+ * The CD_VALUES is an array of CD_NELMTS integers which are
+ * auxiliary data for the filter. The integer vlues will be
+ * stored in the dataset object header as part of the filter
+ * information.
+ *
+ * The FLAGS argument is a bit vector of the following fields:
+ *
+ * H5Z_FLAG_OPTIONAL(0x0001)
+ * If this bit is set then the filter is optional. If the
+ * filter fails during an H5Dwrite() operation then the filter
+ * is just excluded from the pipeline for the chunk for which it
+ * failed; the filter will not participate in the pipeline
+ * during an H5Dread() of the chunk. If this bit is clear and
+ * the filter fails then the entire I/O operation fails.
+ * If this bit is set but encoding is disabled for a filter,
+ * attempting to write will generate an error.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Robb Matzke
+ * Wednesday, April 15, 1998
+ *
+ * Modifications:
+ *
+ * Raymond Lu
+ * Tuesday, October 2, 2001
+ * Changed the way to check parameter and set property for
+ * generic property list.
+ *
+ * Neil Fortner
+ * Wednesday, May 20, 2009
+ * Overloaded to accept gcpl's as well as dcpl's and moved to
+ * H5Pocpl.c
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5P_set_filter(H5P_genplist_t *plist, H5Z_filter_t filter, unsigned int flags,
+ size_t cd_nelmts, const unsigned int cd_values[/*cd_nelmts*/])
+{
+ H5O_pline_t pline; /* Filter pipeline */
+ H5Z_class2_t *filter_info = NULL;
+ htri_t filter_avail = FALSE; /* Filter availability */
+ herr_t ret_value=SUCCEED; /* return value */
+
+ FUNC_ENTER_NOAPI(FAIL)
+
+ if((filter_avail = H5Z_filter_avail(filter)) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't check filter availability")
+
+ if(!filter_avail) {
+ if((filter_info = (H5Z_class2_t *)H5PL_load(H5PL_TYPE_FILTER, (int)filter)) == NULL)
+ HGOTO_ERROR(H5E_PLUGIN, H5E_CANTLOAD, FAIL, "failed to load dynamically loaded plugin")
+/*if(filter_info)
+fprintf(stderr, "%s: filter_info=%p, filter_info->id=%d\n", FUNC, filter_info, filter_info->id);*/
+ if (H5Z_register (filter_info)<0)
+ HGOTO_ERROR (H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register filter")
+
+ }
+
+#ifndef TMP
/* Get the pipeline property to append to */
if(H5P_get(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get pipeline")
@@ -776,10 +856,11 @@ H5Pset_filter(hid_t plist_id, H5Z_filter_t filter, unsigned int flags,
/* Put the I/O pipeline information back into the property list */
if(H5P_set(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set pipeline")
+#endif
done:
- FUNC_LEAVE_API(ret_value)
-} /* end H5Pset_filter() */
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5P_set_filter() */
/*-------------------------------------------------------------------------