//-------------------------------------------------------------------------- // Function: H5Location::p_get_ref_obj_type (protected) // Purpose Retrieves the type of object that an object reference points to. // Parameters // ref - IN: Reference to query // ref_type - IN: Type of reference to query // Return An object type, which can be one of the following: // H5O_TYPE_UNKNOWN - Unknown object type (-1) // H5O_TYPE_GROUP - Object is a group // H5O_TYPE_DATASET - Object is a dataset // H5O_TYPE_NAMED_DATATYPE - Object is a named datatype // H5O_TYPE_NTYPES - Number of object types // Exception H5::ReferenceException // Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- H5O_type_t H5Location::p_get_ref_obj_type(void *ref, H5R_type_t ref_type) const { H5O_type_t obj_type = H5O_TYPE_UNKNOWN; herr_t ret_value = H5Rget_obj_type2(getId(), ref_type, ref, &obj_type); if (ret_value < 0) { throw ReferenceException(inMemFunc("getRefObjType"), "H5Rget_obj_type2 failed"); } if (obj_type == H5O_TYPE_UNKNOWN || obj_type >= H5O_TYPE_NTYPES) { throw ReferenceException(inMemFunc("getRefObjType"), "H5Rget_obj_type2 returned invalid type"); } return(obj_type); }
//-------------------------------------------------------------------------- // Function: H5Location::getRegion ///\brief Retrieves a dataspace with the region pointed to selected. ///\param ref - IN: Reference to get region of ///\param ref_type - IN: Type of reference to get region of - default // to H5R_DATASET_REGION ///\return DataSpace object ///\exception H5::ReferenceException // Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- DataSpace H5Location::getRegion(void *ref, H5R_type_t ref_type) const { hid_t space_id = H5Rget_region(getId(), ref_type, ref); if (space_id < 0) { throw ReferenceException(inMemFunc("getRegion"), "H5Rget_region failed"); } try { DataSpace dataspace(space_id); return(dataspace); } catch (DataSpaceIException E) { throw ReferenceException(inMemFunc("getRegion"), E.getDetailMsg()); } }
//-------------------------------------------------------------------------- // Function: H5Location::p_reference (protected) // Purpose Creates a reference to an HDF5 object or a dataset region. // Parameters // name - IN: Name of the object to be referenced // dataspace - IN: Dataspace with selection // ref_type - IN: Type of reference; default to \c H5R_DATASET_REGION // Exception H5::ReferenceException // Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- void H5Location::p_reference(void* ref, const char* name, hid_t space_id, H5R_type_t ref_type) const { herr_t ret_value = H5Rcreate(ref, getId(), name, ref_type, space_id); if (ret_value < 0) { throw ReferenceException(inMemFunc("reference"), "H5Rcreate failed"); } }
//-------------------------------------------------------------------------- // Function: H5Location::getRefObjType ///\brief Retrieves the type of object that an object reference points to. ///\param ref - IN: Reference to query ///\param ref_type - IN: Type of reference to query, valid values are: /// \li \c H5R_OBJECT - Reference is an object reference. /// \li \c H5R_DATASET_REGION - Reference is a dataset region reference. ///\return An object type, which can be one of the following: /// \li \c H5O_TYPE_UNKNOWN - Unknown object type (-1) /// \li \c H5O_TYPE_GROUP - Object is a group /// \li \c H5O_TYPE_DATASET - Object is a dataset /// \li \c H5O_TYPE_NAMED_DATATYPE - Object is a named datatype /// \li \c H5O_TYPE_NTYPES - Number of different object types ///\exception H5::ReferenceException // Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- H5O_type_t H5Location::getRefObjType(void *ref, H5R_type_t ref_type) const { try { return(p_get_ref_obj_type(ref, ref_type)); } catch (ReferenceException E) { throw ReferenceException(inMemFunc("getRefObjType"), E.getDetailMsg()); } }
//-------------------------------------------------------------------------- // Function: H5Location::reference ///\brief This is an overloaded function, provided for your convenience. /// It differs from the above function in that it does not take /// a DataSpace object and the reference type must be specified. ///\param ref - IN: Reference pointer ///\param name - IN: Name of the object to be referenced ///\param ref_type - IN: Type of reference to query, valid values are: /// \li \c H5R_OBJECT - Reference is an object reference (default) /// \li \c H5R_DATASET_REGION - Reference is a dataset region ///\exception H5::ReferenceException ///\note This method is more suitable for an object reference. // Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- void H5Location::reference(void* ref, const char* name, H5R_type_t ref_type) const { try { p_reference(ref, name, -1, ref_type); } catch (ReferenceException E) { throw ReferenceException(inMemFunc("reference"), E.getDetailMsg()); } }
//-------------------------------------------------------------------------- // Function: H5Location::reference ///\brief This is an overloaded member function, provided for convenience. /// It differs from the above function in that it takes an /// \c H5std_string for \a name. ///\param ref - IN: Reference pointer ///\param name - IN: Name of the object to be referenced ///\param dataspace - IN: Dataspace with selection ///\param ref_type - IN: Type of reference to query, valid values are: /// \li \c H5R_OBJECT - Reference is an object reference. /// \li \c H5R_DATASET_REGION - Reference is a dataset region /// reference. (default) ///\exception H5::ReferenceException ///\note This method is more suitable for a dataset region reference. // Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- void H5Location::reference(void* ref, const H5std_string& name, const DataSpace& dataspace, H5R_type_t ref_type) const { try { p_reference(ref, name.c_str(), dataspace.getId(), ref_type); } catch (ReferenceException E) { throw ReferenceException(inMemFunc("reference"), E.getDetailMsg()); } }
//-------------------------------------------------------------------------- // Function: H5Location::p_get_obj_type (protected) // Purpose Retrieves the type of object that an object reference points to. // Parameters // ref - IN: Reference to query // ref_type - IN: Type of reference to query // Return An object type, which can be one of the following: // H5G_UNKNOWN \tFailure occurs (-1) // H5G_GROUP \tObject is a group. // H5G_DATASET \tObject is a dataset. // H5G_TYPE Object \tis a named datatype. // H5G_LINK \tObject is a symbolic link. // H5G_UDLINK \tObject is a user-defined link. // Exception H5::ReferenceException // Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- H5G_obj_t H5Location::p_get_obj_type(void *ref, H5R_type_t ref_type) const { H5G_obj_t obj_type = H5Rget_obj_type1(getId(), ref_type, ref); if (obj_type == H5G_UNKNOWN) { throw ReferenceException(inMemFunc("getObjType"), "H5Rget_obj_type1 failed"); } return(obj_type); }
//-------------------------------------------------------------------------- // Function: H5Location::p_dereference (protected) // Purpose Dereference a ref into an hdf5 object. // Parameters // loc_id - IN: An hdf5 identifier specifying the location of the // referenced object // ref - IN: Reference pointer // ref_type - IN: Reference type // Exception H5::ReferenceException // Programmer Binh-Minh Ribler - Oct, 2006 // Modification // May 2008 - BMR // Moved from IdComponent. //-------------------------------------------------------------------------- hid_t H5Location::p_dereference(hid_t loc_id, const void* ref, H5R_type_t ref_type, const char* from_func) { hid_t temp_id = H5Rdereference(loc_id, ref_type, ref); if (temp_id < 0) { throw ReferenceException(inMemFunc(from_func), "H5Rdereference failed"); } return(temp_id); }
//-------------------------------------------------------------------------- // Function: H5Object::dereference ///\brief Dereferences a reference into an HDF5 object, given an attribute. ///\param attr - IN: Attribute specifying the location of the referenced object ///\param ref - IN: Reference pointer ///\param ref_type - IN: Reference type ///\exception H5::ReferenceException // Programmer Binh-Minh Ribler - Oct, 2006 // Modification // May, 2008 // Corrected missing parameters. - BMR //-------------------------------------------------------------------------- void H5Object::dereference(Attribute& attr, const void* ref, H5R_type_t ref_type) { hid_t temp_id; try { temp_id = p_dereference(attr.getId(), ref, ref_type); } catch (ReferenceException E) { throw ReferenceException("H5Object::dereference - located by attribute", E.getDetailMsg()); } p_setId(temp_id); }
//-------------------------------------------------------------------------- // Function: H5Object::dereference ///\brief Dereferences a reference into an HDF5 object, given an HDF5 file. ///\param h5file - IN: HDF5 file specifying the location of the referenced object ///\param ref - IN: Reference pointer ///\param ref_type - IN: Reference type ///\exception H5::ReferenceException // Programmer Binh-Minh Ribler - Oct, 2006 // Modification // May, 2008 // Corrected missing parameters. - BMR //-------------------------------------------------------------------------- void H5Object::dereference(H5File& h5file, const void* ref, H5R_type_t ref_type) { hid_t temp_id; try { temp_id = p_dereference(h5file.getId(), ref, ref_type); } catch (ReferenceException E) { throw ReferenceException("H5Object::dereference - located by file", E.getDetailMsg()); } p_setId(temp_id); }
//-------------------------------------------------------------------------- // Function: H5Object::p_dereference (protected) // Purpose Dereference a ref into an hdf5 object. // Parameters // loc_id - IN: An hdf5 identifier specifying the location of the // referenced object // ref - IN: Reference pointer // ref_type - IN: Reference type // Exception H5::ReferenceException // Programmer Binh-Minh Ribler - Oct, 2006 // Modification // May 2008 - BMR // Moved from IdComponent. //-------------------------------------------------------------------------- hid_t H5Object::p_dereference(hid_t loc_id, const void* ref, H5R_type_t ref_type) { hid_t temp_id; temp_id = H5Rdereference2(loc_id, H5P_DEFAULT, ref_type, ref); if (temp_id < 0) { throw ReferenceException("", "H5Rdereference failed"); } // No failure, set id to the object return(temp_id); }
//-------------------------------------------------------------------------- // Function: H5Location::p_dereference (protected) // Purpose Dereference a ref into an hdf5 object. // Parameters // loc_id - IN: An hdf5 identifier specifying the location of the // referenced object // ref - IN: Reference pointer // ref_type - IN: Reference type // plist - IN: Property list - default to PropList::DEFAULT // from_func - IN: Name of the calling function // Exception H5::ReferenceException // Programmer Binh-Minh Ribler - Oct, 2006 // Modification // May 2008 - BMR // Moved from IdComponent. //-------------------------------------------------------------------------- hid_t H5Location::p_dereference(hid_t loc_id, const void* ref, H5R_type_t ref_type, const PropList& plist, const char* from_func) { hid_t plist_id; if (p_valid_id(plist.getId())) plist_id = plist.getId(); else plist_id = H5P_DEFAULT; hid_t temp_id = H5Rdereference2(loc_id, plist_id, ref_type, ref); if (temp_id < 0) { throw ReferenceException(inMemFunc(from_func), "H5Rdereference failed"); } return(temp_id); }