void data_ptr::push_back(const data_ptr& data) { if (!ptr) { ptr.reset(new DataList(data_list())); } data_list& list = ptr->getlist(); list.push_back(data); }
void data_float(TTPtr self, double value) { t_atom a; atom_setfloat(&a, value); data_list(self, _sym_float, 1, &a); }
void data_int(TTPtr self, long value) { t_atom a; atom_setlong(&a, value); // Forwards to data_float data_list(self, _sym_int, 1, &a); }
void WrappedDataClass_anything(TTPtr self, t_symbol *msg, long argc, t_atom *argv) { WrappedModularInstancePtr x = (WrappedModularInstancePtr)self; TTObject o; if (proxy_getinlet((t_object*)x)) wrappedModularClass_ArraySelect(self, msg, argc, argv); else data_list(self, msg, argc, argv); }
void data_bang(TTPtr self) { WrappedModularInstancePtr x = (WrappedModularInstancePtr)self; if (!x->internals->isEmpty()) { data_list(self, _sym_bang, 0, NULL); } else object_error((t_object*)x, "bang : the array is empty"); }
void data_float(TTPtr self, double value) { WrappedModularInstancePtr x = (WrappedModularInstancePtr)self; t_atom a; if (!x->internals->isEmpty()) { atom_setfloat(&a, value); data_list(self, _sym_float, 1, &a); } else object_error((t_object*)x, "float : the array is empty"); }
void data_int(TTPtr self, long value) { WrappedModularInstancePtr x = (WrappedModularInstancePtr)self; t_atom a; if (proxy_getinlet((t_object*)x)) { atom_setlong(&a, value); wrappedModularClass_ArraySelect(self, _sym_nothing, 1, &a); } else { if (!x->internals->isEmpty()) { atom_setlong(&a, value); data_list(self, _sym_int, 1, &a); } else object_error((t_object*)x, "int : the array is empty"); } }
com_ptr<ID3D11Texture2D> make_texture_cube(ID3D11Device* p_device, const texture_data& td, D3D11_USAGE usage, UINT bind_flags, UINT misc_flags) { assert(p_device); assert(td.type == texture_type::texture_cube); assert(td.array_size == 6); assert(is_valid_texture_data(td)); D3D11_TEXTURE2D_DESC desc = {}; desc.Width = td.size.x; desc.Height = td.size.y; desc.MipLevels = td.mipmap_count; desc.ArraySize = td.array_size; desc.Format = make_dxgi_format(td.format); desc.SampleDesc.Count = 1; desc.SampleDesc.Quality = 0; desc.Usage = usage; desc.BindFlags = bind_flags; desc.MiscFlags = D3D11_RESOURCE_MISC_TEXTURECUBE; if (misc_flags != 0) desc.MiscFlags |= misc_flags; const size_t fmt_byte_count = byte_count(td.format); const uint8_t* ptr = td.buffer.data(); std::vector<D3D11_SUBRESOURCE_DATA> data_list(desc.ArraySize * desc.MipLevels); for (UINT a = 0; a < desc.ArraySize; ++a) { for (UINT m = 0; m < desc.MipLevels; ++m) { const UINT w = desc.Width >> m; const UINT h = desc.Height >> m; const UINT index = a * desc.MipLevels + m; data_list[index].pSysMem = ptr; data_list[index].SysMemPitch = UINT(w * fmt_byte_count); data_list[index].SysMemSlicePitch = 0; ptr += w * h * fmt_byte_count; } } com_ptr<ID3D11Texture2D> p_tex; HRESULT hr = p_device->CreateTexture2D(&desc, data_list.data(), &p_tex.ptr); assert(hr == S_OK); return p_tex; }
void data_bang(TTPtr self) { data_list(self, _sym_bang, 0, NULL); }
END_TEST START_TEST(test_nsdata_list) { hid_t fid, sid; herr_t err; int iseed = 0xaa44; char **data_names; char **read_names; int gen_cnt, read_size, idx, num_found; int data; int size; generate_output_file(&fid,&sid); data = generate_random_int(&iseed); size = 1; gen_cnt = generate_random_bound_int(10,1024,&iseed); data_names = DANU_MALLOC(char *, gen_cnt); for(idx=0; idx < gen_cnt; idx++) { data_names[idx] = DANU_MALLOC(char, 32); sprintf(data_names[idx], "Data Mu %04d",idx); data_write_int(sid,data_names[idx],1,&size,&data); } read_names = DANU_MALLOC(char *, gen_cnt); err = data_list(sid,gen_cnt,read_names,&num_found); fail_unless(H5_RETURN_OK(err), "Failed to return success status"); fail_unless(num_found == gen_cnt, "Failed to find the correct number in data_list"); fail_unless(char_array_cmp(read_names,data_names,gen_cnt) == 0, "Failed to read data names"); DANU_FREE(read_names); read_size = gen_cnt / 2; read_names = DANU_MALLOC(char *, read_size); err = data_list(sid,read_size,read_names, &num_found); fail_unless(H5_RETURN_FAIL(err), "Failed to return fail status when array too small"); fail_unless(num_found == gen_cnt, "Failed to find correct number in data_list"); fail_unless(char_array_cmp(read_names,data_names,read_size) == 0, "Failed to read data names"); danu_group_close(sid); output_file_close(&fid); file_delete(); }
int main(int argc, char ** argv) { int num_errs; char root_file[] = FILE; char test_sim[] = SIM_NAME; char data_name[128]; char **names; int numpe; int i,dim, *size; size_t *nsizes; int ncnt; dsize_t num; double *data,*ref_data; hid_t fid, sid; if ( FILE_EXISTS(root_file) ) { danu_file_delete(root_file); } if ( H5_RETURN_FAIL(create_test_file(root_file) ) ) { DANU_ERROR_MESS("Failed to create the test file"); num_errs++; goto EXIT_NOW; } fid = danu_file_open_append(root_file); if ( H5_RETURN_FAIL(simulation_add(fid,test_sim,&sid) ) ) { DANU_ERROR_MESS("Failed to add simulation"); goto EXIT_NOW; } num_errs = 0; /* Arrays */ size = DANU_MALLOC(int,DIM); /* Write the data */ size[0] = 1; numpe = DUMMY_INT; sprintf(data_name,DATA_INT_NAME); if ( H5_RETURN_FAIL(data_write_int(sid,data_name,1,size,&numpe)) ) { DANU_ERROR_MESS("Failed to write int data"); num_errs++; goto EXIT_NOW; } dim = DIM; num = 1; for(i=0;i<dim;i++) { size[i] = NUMCELLS; num*=NUMCELLS; } data = DANU_MALLOC(double,num); sprintf(data_name,DATA_DBL_NAME); danu_rand_data_double(-5.0,5.0,num,data); if ( H5_RETURN_FAIL(data_write_double(sid,data_name,dim,size,data)) ) { DANU_ERROR_MESS("Failed to write double data"); num_errs++; goto EXIT_NOW; } /* Check data by reading */ ref_data = DANU_MALLOC(double,num); if ( H5_RETURN_FAIL(data_read_double(sid,data_name,dim,size,ref_data) ) ) { num_errs++; goto EXIT_NOW; } for(i=0;i<num;i++) { if ( ref_data[i] != data[i] ) { num_errs++; } } /* Find the number of datasets */ data_count(sid,&ncnt); printf("Found %d datasets\n",ncnt); names = DANU_MALLOC(char *,ncnt); nsizes = convert_int_to_size(ncnt,size); for(i=0;i<ncnt;i++) { size[i] = 128; names[i] = DANU_MALLOC(char,128); } data_list(sid,ncnt,nsizes,names); printf("Found the following datasets\n"); for(i=0;i<ncnt;i++) { printf("\t<%s>\n",names[i]); } /* Free memory */ for(i=0;i<ncnt;i++) { DANU_FREE(names[i]); } DANU_FREE(names); DANU_FREE(ref_data); DANU_FREE(data); DANU_FREE(size); /* Free HDF5 resources */ danu_group_close(sid); danu_file_close(fid); EXIT_NOW: printf("Found %d errors\n",num_errs); return num_errs; }