inlib
1.2.0
|
00001 // Copyright (C) 2010, Guy Barrand. All rights reserved. 00002 // See the file inlib.license for terms. 00003 00004 #ifndef inlib_wroot_info 00005 #define inlib_wroot_info 00006 00007 #include "buffer" 00008 #include "element" 00009 #include "named" 00010 00011 namespace inlib { 00012 namespace wroot { 00013 00014 // sizeof(vtbl) = 4 00015 // sizeof(unsigned int) = 4 00016 // sizeof(TObject) = 12 = 2 * (unsigned int) + vtbl. 00017 // sizeof(TString) = 8 = char* + vtbl. 00018 // sizeof(TNamed) = 28 = TObject + 2 * TString. 00019 // sizeof(TObjArray) = 40 00020 00021 class StreamerInfo : public virtual ibo { 00022 static const std::string& s_class() { 00023 static const std::string s_v("inlib::wroot::StreamerInfo"); 00024 return s_v; 00025 } 00026 public: //ibo 00027 virtual const std::string& store_cls() const { 00028 static const std::string s_v("TStreamerInfo"); 00029 return s_v; 00030 } 00031 virtual bool stream(buffer& a_buffer) const { 00032 unsigned int c; 00033 if(!a_buffer.write_version(2,c)) return false; 00034 00035 if(!Named_stream(a_buffer,fName,fTitle)) return false; 00036 if(!a_buffer.write(fCheckSum)) return false; 00037 if(!a_buffer.write(fStreamedClassVersion)) return false; 00038 00039 //ObjArray 00040 if(!a_buffer.write_object(fElements)) return false; 00041 00042 if(!a_buffer.set_byte_count(c)) return false; 00043 00044 return true; 00045 } 00046 public: 00047 virtual void out(std::ostream& a_out) const { 00048 a_out << "StreamerInfo for class :" 00049 << " " << fName << ", version=" << fStreamedClassVersion 00050 << std::endl; 00051 std::vector<streamer_element*>::const_iterator it; 00052 for(it=fElements.begin();it!=fElements.end();++it) { 00053 (*it)->out(a_out); 00054 } 00055 } 00056 public: 00057 StreamerInfo(const std::string& a_cls_store_name, 00058 int a_cls_vers, 00059 unsigned int a_cls_check_sum) 00060 :fName(a_cls_store_name) 00061 ,fTitle("") 00062 ,fCheckSum(a_cls_check_sum) 00063 ,fStreamedClassVersion(a_cls_vers) 00064 { 00065 #ifdef INLIB_MEM 00066 mem::increment(s_class().c_str()); 00067 #endif 00068 } 00069 virtual ~StreamerInfo(){ 00070 #ifdef INLIB_MEM 00071 mem::decrement(s_class().c_str()); 00072 #endif 00073 } 00074 protected: 00075 StreamerInfo(const StreamerInfo& a_from) 00076 : ibo(a_from) 00077 ,fName(a_from.fName) 00078 ,fTitle(a_from.fName) 00079 ,fCheckSum(a_from.fCheckSum) 00080 ,fStreamedClassVersion(a_from.fStreamedClassVersion) 00081 ,fElements(a_from.fElements) 00082 { 00083 #ifdef INLIB_MEM 00084 mem::increment(s_class().c_str()); 00085 #endif 00086 } 00087 StreamerInfo& operator=(const StreamerInfo& a_from){ 00088 fName = a_from.fName; 00089 fTitle = a_from.fName; 00090 fCheckSum = a_from.fCheckSum; 00091 fStreamedClassVersion = a_from.fStreamedClassVersion; 00092 fElements = a_from.fElements; 00093 return *this; 00094 } 00095 public: 00096 void add(streamer_element* a_elem){fElements.push_back(a_elem);} 00097 protected: //Named 00098 std::string fName; 00099 std::string fTitle; 00100 protected: 00101 unsigned int fCheckSum; //checksum of original class 00102 int fStreamedClassVersion; //Class version identifier 00103 //int fNumber; //!Unique identifier 00104 ObjArray<streamer_element> fElements; //Array of TStreamerElements 00105 }; 00106 00107 }} 00108 00109 #endif