Пример #1
0
//--------------------------------------------------------------------------
// Function:    H5Object::getNumAttrs
///\brief       Returns the number of attributes attached to this HDF5 object.
///\return      Number of attributes
///\exception   H5::AttributeIException
// Programmer   Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
int H5Object::getNumAttrs() const
{
    H5O_info_t oinfo;    /* Object info */

    if(H5Oget_info2(getId(), &oinfo, H5O_INFO_NUM_ATTRS) < 0)
        throw AttributeIException(inMemFunc("getNumAttrs"), "H5Oget_info failed");
    else
        return(static_cast<int>(oinfo.num_attrs));
}
Пример #2
0
/*-------------------------------------------------------------------------
 * Function: trav_fileinfo_add
 *
 * Purpose: Add a file addr & fileno to info struct
 *
 * Return: void
 *-------------------------------------------------------------------------
 */
void
trav_fileinfo_add(trav_info_t *info, hid_t loc_id)
{
    H5O_info_t oinfo;
    size_t idx = info->nused - 1;

    if ( info->paths[idx].path && HDstrcmp(info->paths[idx].path, "."))
      H5Oget_info_by_name2(loc_id, info->paths[idx].path, &oinfo, H5O_INFO_BASIC, H5P_DEFAULT);
    else
      H5Oget_info2(loc_id, &oinfo, H5O_INFO_BASIC);

    info->paths[idx].objno = oinfo.addr;
    info->paths[idx].fileno = oinfo.fileno;
} /* end trav_fileinfo_add() */
Пример #3
0
//--------------------------------------------------------------------------
// Function:    H5Object::objVersion
///\brief       Returns the header version of this HDF5 object.
///\return      Object version, which can have the following values:
///             \li \c H5O_VERSION_1
///             \li \c H5O_VERSION_2
///\exception   H5::ObjHeaderIException
///             Exception will be thrown when:
///             - an error returned by the C API
///             - version number is not one of the valid values above
// Programmer   Binh-Minh Ribler - December, 2016
//--------------------------------------------------------------------------
unsigned H5Object::objVersion() const
{
    H5O_info_t objinfo;
    unsigned version = 0;

    // Use C API to get information of the object
    herr_t ret_value = H5Oget_info2(getId(), &objinfo, H5O_INFO_HDR);

    // Throw exception if C API returns failure
    if (ret_value < 0)
        throw Exception(inMemFunc("objVersion"), "H5Oget_info failed");
    // Return a valid version or throw an exception for invalid value
    else
    {
        version = objinfo.hdr.version;
        if (version != H5O_VERSION_1 && version != H5O_VERSION_2)
            throw ObjHeaderIException("objVersion", "Invalid version for object");
    }
    return(version);
}
Пример #4
0
/*
 * Class:     hdf_hdf5lib_H5
 * Method:    H5Oget_info
 * Signature: (JI)Lhdf/hdf5lib/structs/H5O_info_t;
 */
JNIEXPORT jobject JNICALL
Java_hdf_hdf5lib_H5_H5Oget_1info
    (JNIEnv *env, jclass clss, jlong loc_id, jint fields)
{
    H5O_info_t infobuf;
    jobject    hdrinfobuf;
    jobject    ihinfobuf1;
    jobject    ihinfobuf2;
    jvalue     args[12];
    herr_t     status = FAIL;
    jobject    ret_obj = NULL;

    UNUSED(clss);

    if ((status = H5Oget_info2((hid_t)loc_id, &infobuf, (unsigned)fields)) < 0)
        H5_LIBRARY_ERROR(ENVONLY);

    args[0].i = (jint)infobuf.hdr.version;
    args[1].i = (jint)infobuf.hdr.nmesgs;
    args[2].i = (jint)infobuf.hdr.nchunks;
    args[3].i = (jint)infobuf.hdr.flags;
    args[4].j = (jlong)infobuf.hdr.space.total;
    args[5].j = (jlong)infobuf.hdr.space.meta;
    args[6].j = (jlong)infobuf.hdr.space.mesg;
    args[7].j = (jlong)infobuf.hdr.space.free;
    args[8].j = (jlong)infobuf.hdr.mesg.present;
    args[9].j = (jlong)infobuf.hdr.mesg.shared;

    CALL_CONSTRUCTOR(ENVONLY, "hdf/hdf5lib/structs/H5O_hdr_info_t", "(IIIIJJJJJJ)V", args, ret_obj);
    hdrinfobuf = ret_obj;

    args[0].j = (jlong)infobuf.meta_size.obj.index_size;
    args[1].j = (jlong)infobuf.meta_size.obj.heap_size;

    CALL_CONSTRUCTOR(ENVONLY, "hdf/hdf5lib/structs/H5_ih_info_t", "(JJ)V", args, ret_obj);
    ihinfobuf1 = ret_obj;

    args[0].j = (jlong)infobuf.meta_size.attr.index_size;
    args[1].j = (jlong)infobuf.meta_size.attr.heap_size;

    CALL_CONSTRUCTOR(ENVONLY, "hdf/hdf5lib/structs/H5_ih_info_t", "(JJ)V", args, ret_obj);
    ihinfobuf2 = ret_obj;

    args[0].j = (jlong)infobuf.fileno;
    args[1].j = (jlong)infobuf.addr;
    args[2].i = infobuf.type;
    args[3].i = (jint)infobuf.rc;
    args[4].j = (jlong)infobuf.num_attrs;
    args[5].j = infobuf.atime;
    args[6].j = infobuf.mtime;
    args[7].j = infobuf.ctime;
    args[8].j = infobuf.btime;
    args[9].l = hdrinfobuf;
    args[10].l = ihinfobuf1;
    args[11].l = ihinfobuf2;

    CALL_CONSTRUCTOR(ENVONLY, "hdf/hdf5lib/structs/H5O_info_t", "(JJIIJJJJJLhdf/hdf5lib/structs/H5O_hdr_info_t;Lhdf/hdf5lib/structs/H5_ih_info_t;Lhdf/hdf5lib/structs/H5_ih_info_t;)V", args, ret_obj);

done:
    return ret_obj;
} /* end Java_hdf_hdf5lib_H5_H5Oget_1info */