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_info 4 #ifndef tools_wroot_info 5 #define tools_wroot_info 5 #define tools_wroot_info 6 6 7 #include "buffer" 7 #include "buffer" 8 #include "element" 8 #include "element" 9 #include "named" 9 #include "named" 10 10 11 namespace tools { 11 namespace tools { 12 namespace wroot { 12 namespace wroot { 13 13 14 // sizeof(vtbl) = 4 14 // sizeof(vtbl) = 4 15 // sizeof(unsigned int) = 4 15 // sizeof(unsigned int) = 4 16 // sizeof(TObject) = 12 = 2 * (unsigned int 16 // sizeof(TObject) = 12 = 2 * (unsigned int) + vtbl. 17 // sizeof(TString) = 8 = char* + vtbl. 17 // sizeof(TString) = 8 = char* + vtbl. 18 // sizeof(TNamed) = 28 = TObject + 2 * TSt 18 // sizeof(TNamed) = 28 = TObject + 2 * TString. 19 // sizeof(TObjArray) = 40 19 // sizeof(TObjArray) = 40 20 20 21 class streamer_info : public virtual ibo { 21 class streamer_info : public virtual ibo { 22 static const std::string& s_class() { 22 static const std::string& s_class() { 23 static const std::string s_v("tools::wroot 23 static const std::string s_v("tools::wroot::streamer_info"); 24 return s_v; 24 return s_v; 25 } 25 } 26 public: //ibo 26 public: //ibo 27 virtual const std::string& store_cls() const 27 virtual const std::string& store_cls() const { 28 static const std::string s_v("TStreamerInf 28 static const std::string s_v("TStreamerInfo"); 29 return s_v; 29 return s_v; 30 } 30 } 31 virtual bool stream(buffer& a_buffer) const 31 virtual bool stream(buffer& a_buffer) const { 32 unsigned int c; 32 unsigned int c; 33 if(!a_buffer.write_version(2,c)) return fa 33 if(!a_buffer.write_version(2,c)) return false; 34 34 35 if(!Named_stream(a_buffer,fName,fTitle)) r 35 if(!Named_stream(a_buffer,fName,fTitle)) return false; 36 if(!a_buffer.write(fCheckSum)) return fals 36 if(!a_buffer.write(fCheckSum)) return false; 37 if(!a_buffer.write(fStreamedClassVersion)) 37 if(!a_buffer.write(fStreamedClassVersion)) return false; 38 38 39 //ObjArray 39 //ObjArray 40 if(!a_buffer.write_object(fElements)) retu 40 if(!a_buffer.write_object(fElements)) return false; 41 41 42 if(!a_buffer.set_byte_count(c)) return fal 42 if(!a_buffer.set_byte_count(c)) return false; 43 43 44 return true; 44 return true; 45 } 45 } 46 public: 46 public: 47 virtual void out(std::ostream& a_out) const 47 virtual void out(std::ostream& a_out) const { 48 a_out << "streamer_info for class :" 48 a_out << "streamer_info for class :" 49 << " " << fName << ", version=" << f 49 << " " << fName << ", version=" << fStreamedClassVersion 50 << std::endl; 50 << std::endl; 51 tools_vforcit(streamer_element*,fElements, 51 tools_vforcit(streamer_element*,fElements,it) (*it)->out(a_out); 52 } 52 } 53 public: 53 public: 54 streamer_info(const std::string& a_cls_store 54 streamer_info(const std::string& a_cls_store_name,int a_cls_vers,unsigned int a_cls_check_sum) 55 :fName(a_cls_store_name) 55 :fName(a_cls_store_name) 56 ,fTitle("") 56 ,fTitle("") 57 ,fCheckSum(a_cls_check_sum) 57 ,fCheckSum(a_cls_check_sum) 58 ,fStreamedClassVersion(a_cls_vers) 58 ,fStreamedClassVersion(a_cls_vers) 59 { 59 { 60 #ifdef TOOLS_MEM 60 #ifdef TOOLS_MEM 61 mem::increment(s_class().c_str()); 61 mem::increment(s_class().c_str()); 62 #endif 62 #endif 63 } 63 } 64 virtual ~streamer_info(){ 64 virtual ~streamer_info(){ 65 #ifdef TOOLS_MEM 65 #ifdef TOOLS_MEM 66 mem::decrement(s_class().c_str()); 66 mem::decrement(s_class().c_str()); 67 #endif 67 #endif 68 } 68 } 69 protected: 69 protected: 70 streamer_info(const streamer_info& a_from) 70 streamer_info(const streamer_info& a_from) 71 :ibo(a_from) 71 :ibo(a_from) 72 ,fName(a_from.fName) 72 ,fName(a_from.fName) 73 ,fTitle(a_from.fName) 73 ,fTitle(a_from.fName) 74 ,fCheckSum(a_from.fCheckSum) 74 ,fCheckSum(a_from.fCheckSum) 75 ,fStreamedClassVersion(a_from.fStreamedClass 75 ,fStreamedClassVersion(a_from.fStreamedClassVersion) 76 ,fElements(a_from.fElements) 76 ,fElements(a_from.fElements) 77 { 77 { 78 #ifdef TOOLS_MEM 78 #ifdef TOOLS_MEM 79 mem::increment(s_class().c_str()); 79 mem::increment(s_class().c_str()); 80 #endif 80 #endif 81 } 81 } 82 streamer_info& operator=(const streamer_info 82 streamer_info& operator=(const streamer_info& a_from){ 83 fName = a_from.fName; 83 fName = a_from.fName; 84 fTitle = a_from.fName; 84 fTitle = a_from.fName; 85 fCheckSum = a_from.fCheckSum; 85 fCheckSum = a_from.fCheckSum; 86 fStreamedClassVersion = a_from.fStreamedCl 86 fStreamedClassVersion = a_from.fStreamedClassVersion; 87 fElements = a_from.fElements; 87 fElements = a_from.fElements; 88 return *this; 88 return *this; 89 } 89 } 90 public: 90 public: 91 void add(streamer_element* a_elem){fElements 91 void add(streamer_element* a_elem){fElements.push_back(a_elem);} 92 protected: //Named 92 protected: //Named 93 std::string fName; 93 std::string fName; 94 std::string fTitle; 94 std::string fTitle; 95 protected: 95 protected: 96 unsigned int fCheckSum; //checksum of ori 96 unsigned int fCheckSum; //checksum of original class 97 int fStreamedClassVersion; //Class version i 97 int fStreamedClassVersion; //Class version identifier 98 //int fNumber; //!Unique ident 98 //int fNumber; //!Unique identifier 99 obj_array<streamer_element> fElements; //Arr 99 obj_array<streamer_element> fElements; //Array of TStreamerElements 100 }; 100 }; 101 101 102 }} 102 }} 103 103 104 #endif 104 #endif