summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJerome Soumagne <jsoumagne@hdfgroup.org>2019-05-22 18:32:25 (GMT)
committerJerome Soumagne <jsoumagne@hdfgroup.org>2019-10-08 20:18:57 (GMT)
commitfd4f6253ce5ed029263dfa47681fcd48fe2d1bc7 (patch)
tree9e6d5e6b08e76220c4102313df59097c948c5754
parentf4bc0af55cfe3fdbf2e9963849e84cf166f6d41d (diff)
downloadhdf5-fd4f6253ce5ed029263dfa47681fcd48fe2d1bc7.zip
hdf5-fd4f6253ce5ed029263dfa47681fcd48fe2d1bc7.tar.gz
hdf5-fd4f6253ce5ed029263dfa47681fcd48fe2d1bc7.tar.bz2
Add H5VL_OBJECT_GET_TYPE to get object type
Add H5VL_OBJECT_LOOKUP to lookup objects
-rw-r--r--src/H5VLconnector.h4
-rw-r--r--src/H5VLnative_object.c54
-rw-r--r--src/H5trace.c6
3 files changed, 63 insertions, 1 deletions
diff --git a/src/H5VLconnector.h b/src/H5VLconnector.h
index 910136d..6ec0aac 100644
--- a/src/H5VLconnector.h
+++ b/src/H5VLconnector.h
@@ -162,13 +162,15 @@ typedef enum H5VL_object_get_t {
H5VL_REF_GET_NAME, /* object name, for reference */
H5VL_REF_GET_REGION, /* dataspace of region */
H5VL_REF_GET_TYPE, /* type of object */
- H5VL_OBJECT_GET_NAME /* object name */
+ H5VL_OBJECT_GET_NAME, /* object name */
+ H5VL_OBJECT_GET_TYPE /* object type */
} H5VL_object_get_t;
/* types for object SPECIFIC callback */
typedef enum H5VL_object_specific_t {
H5VL_OBJECT_CHANGE_REF_COUNT, /* H5Oincr/decr_refcount */
H5VL_OBJECT_EXISTS, /* H5Oexists_by_name */
+ H5VL_OBJECT_LOOKUP, /* Lookup object */
H5VL_OBJECT_VISIT, /* H5Ovisit(_by_name) */
H5VL_REF_CREATE, /* H5Rcreate */
H5VL_OBJECT_FLUSH, /* H5{D|G|O|T}flush */
diff --git a/src/H5VLnative_object.c b/src/H5VLnative_object.c
index ef8918d..a554a78 100644
--- a/src/H5VLnative_object.c
+++ b/src/H5VLnative_object.c
@@ -230,6 +230,29 @@ H5VL__native_object_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_obj
break;
}
+ /* Object type */
+ case H5VL_OBJECT_GET_TYPE:
+ {
+ H5O_type_t *obj_type = HDva_arg(arguments, H5O_type_t *);
+
+ if(loc_params->type == H5VL_OBJECT_BY_TOKEN) {
+ H5O_loc_t obj_oloc; /* Object location */
+ unsigned rc; /* Reference count of object */
+
+ /* Initialize the object location */
+ H5O_loc_reset(&obj_oloc);
+ obj_oloc.file = loc.oloc->file;
+ obj_oloc.addr = *(haddr_t *)loc_params->loc_data.loc_by_token.token;
+
+ /* Get the # of links for object, and its type */
+ /* (To check to make certain that this object hasn't been deleted) */
+ if(H5O_get_rc_and_type(&obj_oloc, &rc, obj_type) < 0 || 0 == rc)
+ HGOTO_ERROR(H5E_REFERENCE, H5E_LINKCOUNT, FAIL, "dereferencing deleted object")
+ } else
+ HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown get_type parameters")
+ break;
+ }
+
default:
HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information from object")
} /* end switch */
@@ -288,6 +311,37 @@ H5VL__native_object_specific(void *obj, const H5VL_loc_params_t *loc_params, H5V
break;
}
+ /* Lookup object */
+ case H5VL_OBJECT_LOOKUP:
+ {
+ void *token = va_arg(arguments, void *);
+
+ HDassert(token);
+
+ if(loc_params->type == H5VL_OBJECT_BY_NAME) {
+ H5G_loc_t obj_loc; /* Group hier. location of object */
+ H5G_name_t obj_path; /* Object group hier. path */
+ H5O_loc_t obj_oloc; /* Object object location */
+
+ /* Set up opened group location to fill in */
+ obj_loc.oloc = &obj_oloc;
+ obj_loc.path = &obj_path;
+ H5G_loc_reset(&obj_loc);
+
+ /* Find the object */
+ if(H5G_loc_find(&loc, loc_params->loc_data.loc_by_name.name, &obj_loc) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found")
+ *(haddr_t *)token = obj_loc.oloc->addr;
+
+ /* Release the object location */
+ if(H5G_loc_free(&obj_loc) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "can't free location")
+ } /* end if */
+ else
+ HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown object exists parameters")
+ break;
+ }
+
case H5VL_OBJECT_VISIT:
{
H5_index_t idx_type = (H5_index_t)HDva_arg(arguments, int); /* enum work-around */
diff --git a/src/H5trace.c b/src/H5trace.c
index fe2d622..038263c 100644
--- a/src/H5trace.c
+++ b/src/H5trace.c
@@ -2966,6 +2966,9 @@ H5_trace(const double *returning, const char *func, const char *type, ...)
case H5VL_OBJECT_GET_NAME:
HDfprintf(out, "H5VL_OBJECT_GET_NAME");
break;
+ case H5VL_OBJECT_GET_TYPE:
+ HDfprintf(out, "H5VL_OBJECT_GET_TYPE");
+ break;
default:
HDfprintf(out, "%ld", (long)get);
break;
@@ -2989,6 +2992,9 @@ H5_trace(const double *returning, const char *func, const char *type, ...)
case H5VL_OBJECT_EXISTS:
HDfprintf(out, "H5VL_OBJECT_EXISTS");
break;
+ case H5VL_OBJECT_LOOKUP:
+ HDfprintf(out, "H5VL_OBJECT_LOOKUP");
+ break;
case H5VL_OBJECT_VISIT:
HDfprintf(out, "H5VL_OBJECT_VISIT");
break;