Geant4 Cross Reference |
1 // Copyright (C) 2010, Guy Barrand. All rights reserved. 2 // See the file tools.license for terms. 3 4 #ifndef tools_wroot_mt_basket_add 5 #define tools_wroot_mt_basket_add 6 7 // used in pntuple. 8 9 #include "branch" 10 11 namespace tools { 12 namespace wroot { 13 14 class mt_basket_add : public virtual branch::iadd_basket { 15 typedef branch::iadd_basket parent; 16 public: 17 virtual bool add_basket(basket* a_basket) { //we take ownership of a_basket. 18 m_mutex.lock(); 19 uint32 add_bytes,nout; 20 if(!m_main_branch.add_basket(m_main_file,*a_basket,add_bytes,nout)) { 21 m_mutex.unlock(); 22 delete a_basket; 23 return false; 24 } 25 m_main_branch.set_tot_bytes(m_main_branch.tot_bytes()+add_bytes); 26 m_main_branch.set_zip_bytes(m_main_branch.zip_bytes()+nout); 27 m_mutex.unlock(); 28 delete a_basket; 29 return true; 30 } 31 public: 32 mt_basket_add(imutex& a_mutex,ifile& a_main_file,branch& a_main_branch) 33 :m_mutex(a_mutex),m_main_file(a_main_file),m_main_branch(a_main_branch) 34 {} 35 protected: 36 mt_basket_add(const mt_basket_add& a_from):parent() 37 ,m_mutex(a_from.m_mutex),m_main_file(a_from.m_main_file),m_main_branch(a_from.m_main_branch) 38 {} 39 mt_basket_add& operator=(const mt_basket_add&){return *this;} 40 protected: 41 imutex& m_mutex; 42 ifile& m_main_file; 43 branch& m_main_branch; 44 }; 45 46 }} 47 48 #endif