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_branch_object 4 #ifndef tools_wroot_branch_object 5 #define tools_wroot_branch_object 5 #define tools_wroot_branch_object 6 6 7 #include "branch" 7 #include "branch" 8 8 9 namespace tools { 9 namespace tools { 10 namespace wroot { 10 namespace wroot { 11 11 12 class branch_object : public branch { 12 class branch_object : public branch { 13 typedef branch parent; 13 typedef branch parent; 14 #ifdef TOOLS_MEM 14 #ifdef TOOLS_MEM 15 static const std::string& s_class() { 15 static const std::string& s_class() { 16 static const std::string s_v("tools::wroot 16 static const std::string s_v("tools::wroot::branch_object"); 17 return s_v; 17 return s_v; 18 } 18 } 19 #endif 19 #endif 20 public: //ibo 20 public: //ibo 21 virtual const std::string& store_cls() const 21 virtual const std::string& store_cls() const { 22 static const std::string s_v("TBranchObjec 22 static const std::string s_v("TBranchObject"); 23 return s_v; 23 return s_v; 24 } 24 } 25 virtual bool stream(buffer& a_buffer) const 25 virtual bool stream(buffer& a_buffer) const { 26 if(fClassName.empty()) { 26 if(fClassName.empty()) { 27 m_out << "tools::wroot::branch_object::s 27 m_out << "tools::wroot::branch_object::stream : fClassName is empty." << std::endl; 28 return false; 28 return false; 29 } 29 } 30 unsigned int c; 30 unsigned int c; 31 if(!a_buffer.write_version(1,c)) return fa 31 if(!a_buffer.write_version(1,c)) return false; 32 if(!parent::stream(a_buffer)) return false 32 if(!parent::stream(a_buffer)) return false; 33 if(!a_buffer.write(fClassName)) return fal 33 if(!a_buffer.write(fClassName)) return false; 34 if(!a_buffer.set_byte_count(c)) return fal 34 if(!a_buffer.set_byte_count(c)) return false; 35 return true; 35 return true; 36 } 36 } 37 37 38 public: 38 public: 39 branch_object(std::ostream& a_out,bool a_byt 39 branch_object(std::ostream& a_out,bool a_byte_swap,uint32 a_compression, 40 seek a_seek_directory,const st 40 seek a_seek_directory,const std::string& a_name,const std::string& a_title, 41 bool a_verbose) 41 bool a_verbose) 42 :parent(a_out,a_byte_swap,a_compression,a_se 42 :parent(a_out,a_byte_swap,a_compression,a_seek_directory,a_name,a_title,a_verbose) 43 ,fClassName() 43 ,fClassName() 44 { 44 { 45 #ifdef TOOLS_MEM 45 #ifdef TOOLS_MEM 46 mem::increment(s_class().c_str()); 46 mem::increment(s_class().c_str()); 47 #endif 47 #endif 48 } 48 } 49 virtual ~branch_object(){ 49 virtual ~branch_object(){ 50 #ifdef TOOLS_MEM 50 #ifdef TOOLS_MEM 51 mem::decrement(s_class().c_str()); 51 mem::decrement(s_class().c_str()); 52 #endif 52 #endif 53 } 53 } 54 protected: 54 protected: 55 branch_object(const branch_object& a_from):i 55 branch_object(const branch_object& a_from):ibo(a_from),parent(a_from) {} 56 branch_object& operator=(const branch_object 56 branch_object& operator=(const branch_object& a_from){parent::operator=(a_from);return *this;} 57 public: 57 public: 58 leaf_object* create_leaf(const std::string& 58 leaf_object* create_leaf(const std::string& a_name,const iobject& a_obj){ 59 fClassName = a_obj.store_class_name(); 59 fClassName = a_obj.store_class_name(); 60 leaf_object* lf = new leaf_object(m_out,a_ 60 leaf_object* lf = new leaf_object(m_out,a_name,a_obj); 61 m_leaves.push_back(lf); 61 m_leaves.push_back(lf); 62 return lf; 62 return lf; 63 } 63 } 64 protected: 64 protected: 65 std::string fClassName; //Class name of refe 65 std::string fClassName; //Class name of referenced object 66 }; 66 }; 67 67 68 }} 68 }} 69 69 70 #endif 70 #endif