static int scan_for_max_id( FileHandle* file_ptr, mhdf_Status* status ) { hid_t group_id; herr_t rval; /* Check for new format, with max_id as attrib of root group */ #if defined(H5Gopen_vers) && H5Gopen_vers > 1 group_id = H5Gopen2( file_ptr->hdf_handle, ROOT_GROUP, H5P_DEFAULT ); #else group_id = H5Gopen( file_ptr->hdf_handle, ROOT_GROUP ); #endif if (group_id < 0) { mhdf_setFail( status, "Internal error - invalid file."); return 0; } if (mhdf_read_scalar_attrib( group_id, MAX_ID_ATTRIB, H5T_NATIVE_ULONG, &file_ptr->max_id, status )) { H5Gclose( group_id ); return 1; } /* Didn't find it, scan the elements group */ rval = H5Giterate( group_id, ELEMENT_GROUP_NAME, 0, &max_id_iter, &file_ptr->max_id ); if (rval) { H5Gclose( group_id ); mhdf_setFail( status, "Internal error -- invalid file." ); return 0; } /* Check node table too */ rval = get_max_id( group_id, NODE_GROUP_NAME, "coordinates", (unsigned long*)(&file_ptr->max_id) ); if (rval) { H5Gclose( group_id ); mhdf_setFail( status, "Internal error -- invalid file." ); return 0; } /* Check set table, if it exists */ rval = mhdf_is_in_group( group_id, SET_GROUP_NAME, status ); if (rval < 1) { H5Gclose( group_id ); return !rval; } rval = get_max_id( group_id, SET_GROUP_NAME, SET_META_NAME, (unsigned long*)(&file_ptr->max_id) ); H5Gclose( group_id ); if (rval) { mhdf_setFail( status, "Internal error -- invalid file." ); return 0; } return 1; }
groupitem::groupitem() { p_stor_name = wxT("groupitem"); p_id_map[wxT("id")] = 1; p_id_map[wxT("name")] = 2; p_dont_show_map[1] = true; p_editable_map[2] = true; p_column_width[2] = 300; p_id = get_max_id(storage::list_groupitem,wxT("id")) + 1; p_name = wxT("New Group"); if(p_id < MAX_GROUPS)//Not good, memory leak if above MAX_GROUPS storage::list_groupitem.push_back(this); }
static herr_t max_id_iter( hid_t group_id, const char* name, void* data ) { return get_max_id( group_id, name, CONNECTIVITY_NAME, (unsigned long*)data ); }