H5DataSet * H5File::OpenDataSet(const std::string &name) { size_t id = mCurrentId; mCurrentId++; H5DataSet *ds = new H5DataSet(id); string groupName, dsName; FillInGroupFromName(name, groupName, dsName); hid_t group = GetOrCreateGroup(mHFile, groupName); ds->SetGroup(group); ds->SetParent(this); ds->SetName(dsName); /* Save old error handler */ herr_t (*old_func)(hid_t, void *); void *old_client_data; H5Eget_auto(H5E_DEFAULT, &old_func, &old_client_data); /* Turn off error handling */ H5Eset_auto(H5E_DEFAULT, NULL, NULL); if (ds->OpenDataSet()) { mDSMap[id] = ds; H5Eset_auto(H5E_DEFAULT, old_func, old_client_data); return mDSMap[id]; } /* Restore previous error handler */ H5Eset_auto(H5E_DEFAULT, old_func, old_client_data); delete ds; return NULL; }
H5DataSet * H5File::CreateDataSet ( const std::string &name, hsize_t rank, const hsize_t dims[], const hsize_t chunking[], int compression, hid_t type ) { size_t id = mCurrentId; mCurrentId++; H5DataSet *ds = new H5DataSet ( id ); string groupName, dsName; FillInGroupFromName ( name, groupName, dsName ); hid_t group = GetOrCreateGroup ( mHFile, groupName ); ds->SetGroup ( group ); ds->SetParent ( this ); ds->SetName ( dsName ); ds->SetCompression ( compression ); ds->SetDataspace ( rank, dims, chunking, type ); if ( ds->CreateDataSet() ) { mDSMap[id] = ds; return mDSMap[id]; } delete ds; return NULL; }