Geant4 Cross Reference |
1 // Copyright (C) 2010, Guy Barrand. All rights 1 // Copyright (C) 2010, Guy Barrand. All rights reserved. 2 // See the file tools.license for terms. 2 // See the file tools.license for terms. 3 3 4 #ifndef tools_wroot_mpi_create_basket 4 #ifndef tools_wroot_mpi_create_basket 5 #define tools_wroot_mpi_create_basket 5 #define tools_wroot_mpi_create_basket 6 6 7 #include "basket" 7 #include "basket" 8 #include "../impi" 8 #include "../impi" 9 9 10 namespace tools { 10 namespace tools { 11 namespace wroot { 11 namespace wroot { 12 12 13 inline basket* mpi_create_basket(std::ostream& 13 inline basket* mpi_create_basket(std::ostream& a_out,impi& a_mpi,bool a_byte_swap,seek a_seek_directory,uint32 a_basket_size) { 14 std::string oname; 14 std::string oname; 15 if(!a_mpi.sunpack(oname)) return 0; 15 if(!a_mpi.sunpack(oname)) return 0; 16 std::string otitle; 16 std::string otitle; 17 if(!a_mpi.sunpack(otitle)) return 0; 17 if(!a_mpi.sunpack(otitle)) return 0; 18 18 19 uint32 last,nev_buf_size,nev; 19 uint32 last,nev_buf_size,nev; 20 if(!a_mpi.unpack(last)) return 0; 20 if(!a_mpi.unpack(last)) return 0; 21 if(!a_mpi.unpack(nev_buf_size)) return 0; 21 if(!a_mpi.unpack(nev_buf_size)) return 0; 22 if(!a_mpi.unpack(nev)) return 0; 22 if(!a_mpi.unpack(nev)) return 0; 23 23 24 int* entry_offset = 0; 24 int* entry_offset = 0; 25 {bool not_null; 25 {bool not_null; 26 if(!a_mpi.bunpack(not_null)) return 0; 26 if(!a_mpi.bunpack(not_null)) return 0; 27 if(not_null) { 27 if(not_null) { 28 uint32 n; 28 uint32 n; 29 if(!a_mpi.unpack(n,entry_offset)) return 0 29 if(!a_mpi.unpack(n,entry_offset)) return 0; 30 }} 30 }} 31 31 32 int* displacement = 0; 32 int* displacement = 0; 33 {bool not_null; 33 {bool not_null; 34 if(!a_mpi.bunpack(not_null)) {delete [] entr 34 if(!a_mpi.bunpack(not_null)) {delete [] entry_offset;return 0;} 35 if(not_null) { 35 if(not_null) { 36 uint32 n; 36 uint32 n; 37 if(!a_mpi.unpack(n,displacement)) {delete 37 if(!a_mpi.unpack(n,displacement)) {delete [] entry_offset;return 0;} 38 }} 38 }} 39 39 40 uint32 _size; 40 uint32 _size; 41 char* _buffer; 41 char* _buffer; 42 if(!a_mpi.unpack(_size,_buffer)) { 42 if(!a_mpi.unpack(_size,_buffer)) { 43 a_out << "unpack(buffer) failed."<< std::e 43 a_out << "unpack(buffer) failed."<< std::endl; 44 delete [] entry_offset; 44 delete [] entry_offset; 45 delete [] displacement; 45 delete [] displacement; 46 return 0; 46 return 0; 47 } 47 } 48 48 49 // wbasket fields set at file writing : 49 // wbasket fields set at file writing : 50 //m_buf_size,m_buffer,m_nbytes,m_object_size 50 //m_buf_size,m_buffer,m_nbytes,m_object_size,m_date,m_cycle,m_seek_key 51 51 52 //::printf("debug : col = %d, %s, %s, %lu\n 52 //::printf("debug : col = %d, %s, %s, %lu\n", 53 // icol,rbasket.object_class().c_str(),rb 53 // icol,rbasket.object_class().c_str(),rbasket.object_name().c_str(),rbasket.seek_key()); 54 54 55 basket* _basket = new basket(a_out,a_byte_sw 55 basket* _basket = new basket(a_out,a_byte_swap,a_seek_directory, 56 oname,otitle,"T 56 oname,otitle,"TBasket",a_basket_size, 57 false/*verbose* 57 false/*verbose*/); 58 _basket->datbuf().write_fast_array(_buffer,_ 58 _basket->datbuf().write_fast_array(_buffer,_size); 59 _basket->set_nev(last,nev_buf_size,nev,entry 59 _basket->set_nev(last,nev_buf_size,nev,entry_offset,displacement); 60 60 61 delete [] entry_offset; 61 delete [] entry_offset; 62 delete [] displacement; 62 delete [] displacement; 63 63 64 delete [] _buffer; 64 delete [] _buffer; 65 65 66 return _basket; 66 return _basket; 67 } 67 } 68 68 69 }} 69 }} 70 70 71 #endif 71 #endif