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_element 4 #ifndef tools_wroot_element 5 #define tools_wroot_element 5 #define tools_wroot_element 6 6 7 #include "buffer" 7 #include "buffer" 8 #include "named" 8 #include "named" 9 #include "../snpf" 9 #include "../snpf" 10 10 11 namespace tools { 11 namespace tools { 12 namespace wroot { 12 namespace wroot { 13 13 14 namespace streamer__info { 14 namespace streamer__info { 15 15 16 enum Type { // sizeof : 16 enum Type { // sizeof : 17 BASE = 0, // x 17 BASE = 0, // x 18 ARRAY = 20, // ? 18 ARRAY = 20, // ? 19 POINTER = 40, // 4 19 POINTER = 40, // 4 20 POINTER_INT = 43, // 4 20 POINTER_INT = 43, // 4 21 POINTER_FLOAT = 45, // 4 21 POINTER_FLOAT = 45, // 4 22 POINTER_DOUBLE = 48, // 4 22 POINTER_DOUBLE = 48, // 4 23 COUNTER = 6, // 4 23 COUNTER = 6, // 4 24 CHAR = 1, // 1 24 CHAR = 1, // 1 25 SHORT = 2, // 2 25 SHORT = 2, // 2 26 INT = 3, // 4 26 INT = 3, // 4 27 FLOAT = 5, // 4 27 FLOAT = 5, // 4 28 DOUBLE = 8, // 8 28 DOUBLE = 8, // 8 29 UNSIGNED_CHAR = 11, // 1 29 UNSIGNED_CHAR = 11, // 1 30 UNSIGNED_SHORT = 12, // 2 30 UNSIGNED_SHORT = 12, // 2 31 UNSIGNED_INT = 13, // 4 31 UNSIGNED_INT = 13, // 4 32 BOOL = 18, // 1 ? 32 BOOL = 18, // 1 ? 33 OBJECT = 61, // ? 33 OBJECT = 61, // ? 34 OBJECT_ANY = 62, // ? 34 OBJECT_ANY = 62, // ? 35 OBJECT_ARROW = 63, // ? 35 OBJECT_ARROW = 63, // ? 36 OBJECT_POINTER = 64, // ? 36 OBJECT_POINTER = 64, // ? 37 _TSTRING = 65, // 8 //NOTE : TST 37 _TSTRING = 65, // 8 //NOTE : TSTRING clashes with a cpp macro in cfitsio. 38 TOBJECT = 66, // 12 38 TOBJECT = 66, // 12 39 TNAMED = 67 // 28 39 TNAMED = 67 // 28 40 }; 40 }; 41 41 42 const int size_FLOAT = 4; 42 const int size_FLOAT = 4; 43 const int size_DOUBLE = 8; 43 const int size_DOUBLE = 8; 44 const int size_INT = 4; 44 const int size_INT = 4; 45 const int size_UINT = 4; 45 const int size_UINT = 4; 46 const int size_SHORT = 2; 46 const int size_SHORT = 2; 47 const int size_BOOL = 4; //(Bool_t = 1 + 3 f 47 const int size_BOOL = 4; //(Bool_t = 1 + 3 for alignement) 48 //uuu ? const int size_BOOL = 1; 48 //uuu ? const int size_BOOL = 1; 49 49 50 const int size_TString = 8; 50 const int size_TString = 8; 51 } 51 } 52 52 53 53 54 class streamer_element : public virtual ibo { 54 class streamer_element : public virtual ibo { 55 static const std::string& s_class() { 55 static const std::string& s_class() { 56 static const std::string s_v("tools::wroot 56 static const std::string s_v("tools::wroot::streamer_element"); 57 return s_v; 57 return s_v; 58 } 58 } 59 public: //ibo 59 public: //ibo 60 virtual const std::string& store_cls() const 60 virtual const std::string& store_cls() const { 61 static const std::string s_v("TStreamerEle 61 static const std::string s_v("TStreamerElement"); 62 return s_v; 62 return s_v; 63 } 63 } 64 virtual bool stream(buffer& aBuffer) const { 64 virtual bool stream(buffer& aBuffer) const { 65 unsigned int c; 65 unsigned int c; 66 if(!aBuffer.write_version(2,c)) return fal 66 if(!aBuffer.write_version(2,c)) return false; 67 if(!Named_stream(aBuffer,fName,fTitle)) re 67 if(!Named_stream(aBuffer,fName,fTitle)) return false; 68 if(!aBuffer.write(fType)) return false; 68 if(!aBuffer.write(fType)) return false; 69 if(!aBuffer.write(fSize)) return false; 69 if(!aBuffer.write(fSize)) return false; 70 if(!aBuffer.write(fArrayLength)) return fa 70 if(!aBuffer.write(fArrayLength)) return false; 71 if(!aBuffer.write(fArrayDim)) return false 71 if(!aBuffer.write(fArrayDim)) return false; 72 if(!aBuffer.write_fast_array<int>(fMaxInde 72 if(!aBuffer.write_fast_array<int>(fMaxIndex,5)) return false; 73 if(!aBuffer.write(fTypeName)) return false 73 if(!aBuffer.write(fTypeName)) return false; 74 if(!aBuffer.set_byte_count(c)) return fals 74 if(!aBuffer.set_byte_count(c)) return false; 75 return true; 75 return true; 76 } 76 } 77 public: 77 public: 78 virtual streamer_element* copy() const = 0; 78 virtual streamer_element* copy() const = 0; 79 public: 79 public: 80 virtual void out(std::ostream& aOut) const { 80 virtual void out(std::ostream& aOut) const { 81 std::string _fname; 81 std::string _fname; 82 fullName(_fname); 82 fullName(_fname); 83 char _s[256]; << 83 char s[256]; 84 snpf(_s,sizeof(_s)," %-14s%-15s offset=%3 << 84 snpf(s,sizeof(s)," %-14s%-15s offset=%3d type=%2d %-20s",fTypeName.c_str(),_fname.c_str(),fOffset,fType,fTitle.c_str()); 85 aOut << _s << std::endl; << 85 aOut << s << std::endl; 86 } 86 } 87 public: 87 public: 88 streamer_element(const std::string& aName,co 88 streamer_element(const std::string& aName,const std::string& aTitle, 89 int aOffset,int aType,const 89 int aOffset,int aType,const std::string& aTypeName) 90 :fName(aName),fTitle(aTitle),fType(aType) 90 :fName(aName),fTitle(aTitle),fType(aType) 91 ,fSize(0),fArrayLength(0),fArrayDim(0),fOffs 91 ,fSize(0),fArrayLength(0),fArrayDim(0),fOffset(aOffset) 92 ,fTypeName(aTypeName){ 92 ,fTypeName(aTypeName){ 93 #ifdef TOOLS_MEM 93 #ifdef TOOLS_MEM 94 mem::increment(s_class().c_str()); 94 mem::increment(s_class().c_str()); 95 #endif 95 #endif 96 for(int i=0;i<5;i++) fMaxIndex[i] = 0; 96 for(int i=0;i<5;i++) fMaxIndex[i] = 0; 97 } 97 } 98 virtual ~streamer_element(){ 98 virtual ~streamer_element(){ 99 #ifdef TOOLS_MEM 99 #ifdef TOOLS_MEM 100 mem::decrement(s_class().c_str()); 100 mem::decrement(s_class().c_str()); 101 #endif 101 #endif 102 } 102 } 103 protected: 103 protected: 104 streamer_element(const streamer_element& a_f 104 streamer_element(const streamer_element& a_from) 105 :ibo(a_from) 105 :ibo(a_from) 106 ,fName(a_from.fName),fTitle(a_from.fTitle) 106 ,fName(a_from.fName),fTitle(a_from.fTitle) 107 ,fType(a_from.fType),fSize(a_from.fSize) 107 ,fType(a_from.fType),fSize(a_from.fSize) 108 ,fArrayLength(a_from.fArrayLength) 108 ,fArrayLength(a_from.fArrayLength) 109 ,fArrayDim(a_from.fArrayDim),fOffset(a_from. 109 ,fArrayDim(a_from.fArrayDim),fOffset(a_from.fOffset) 110 ,fTypeName(a_from.fTypeName){ 110 ,fTypeName(a_from.fTypeName){ 111 #ifdef TOOLS_MEM 111 #ifdef TOOLS_MEM 112 mem::increment(s_class().c_str()); 112 mem::increment(s_class().c_str()); 113 #endif 113 #endif 114 for(int i=0;i<5;i++) fMaxIndex[i] = a_from 114 for(int i=0;i<5;i++) fMaxIndex[i] = a_from.fMaxIndex[i]; 115 } 115 } 116 streamer_element& operator=(const streamer_e 116 streamer_element& operator=(const streamer_element& a_from){ 117 fName = a_from.fName; 117 fName = a_from.fName; 118 fTitle = a_from.fTitle; 118 fTitle = a_from.fTitle; 119 fType = a_from.fType; 119 fType = a_from.fType; 120 fSize = a_from.fSize; 120 fSize = a_from.fSize; 121 fArrayLength = a_from.fArrayLength; 121 fArrayLength = a_from.fArrayLength; 122 fArrayDim = a_from.fArrayDim; 122 fArrayDim = a_from.fArrayDim; 123 fOffset = a_from.fOffset; 123 fOffset = a_from.fOffset; 124 fTypeName = a_from.fTypeName; 124 fTypeName = a_from.fTypeName; 125 for(int i=0;i<5;i++) fMaxIndex[i] = a_from 125 for(int i=0;i<5;i++) fMaxIndex[i] = a_from.fMaxIndex[i]; 126 return *this; 126 return *this; 127 } 127 } 128 public: 128 public: 129 virtual void setArrayDimension(int aDimensio 129 virtual void setArrayDimension(int aDimension){ 130 fArrayDim = aDimension; 130 fArrayDim = aDimension; 131 if(aDimension) fType += streamer__info::AR 131 if(aDimension) fType += streamer__info::ARRAY; 132 //fNewType = fType; 132 //fNewType = fType; 133 } 133 } 134 virtual void setMaxIndex(int aDimension,int 134 virtual void setMaxIndex(int aDimension,int aMaximum){ 135 //set maximum index for array with dimensi 135 //set maximum index for array with dimension dim 136 if (aDimension < 0 || aDimension > 4) retu 136 if (aDimension < 0 || aDimension > 4) return; 137 fMaxIndex[aDimension] = aMaximum; 137 fMaxIndex[aDimension] = aMaximum; 138 if (fArrayLength == 0) fArrayLength = aM 138 if (fArrayLength == 0) fArrayLength = aMaximum; 139 else fArrayLength *= aM 139 else fArrayLength *= aMaximum; 140 } 140 } 141 141 142 virtual void fullName(std::string& a_s) cons 142 virtual void fullName(std::string& a_s) const { 143 a_s = fName; 143 a_s = fName; 144 for (int i=0;i<fArrayDim;i++) { 144 for (int i=0;i<fArrayDim;i++) { 145 char cdim[32]; 145 char cdim[32]; 146 snpf(cdim,sizeof(cdim),"[%d]",fMaxIndex[ 146 snpf(cdim,sizeof(cdim),"[%d]",fMaxIndex[i]); 147 a_s += cdim; 147 a_s += cdim; 148 } 148 } 149 } 149 } 150 protected: //Named 150 protected: //Named 151 std::string fName; 151 std::string fName; 152 std::string fTitle; 152 std::string fTitle; 153 protected: 153 protected: 154 int fType; //element type 154 int fType; //element type 155 int fSize; //sizeof element 155 int fSize; //sizeof element 156 int fArrayLength; //cumulative size of a 156 int fArrayLength; //cumulative size of all array dims 157 int fArrayDim; //number of array dime 157 int fArrayDim; //number of array dimensions 158 int fMaxIndex[5]; //Maximum array index 158 int fMaxIndex[5]; //Maximum array index for array dimension "dim" 159 int fOffset; //!element offset in c 159 int fOffset; //!element offset in class 160 //FIXME Int_t fNewType; //!n 160 //FIXME Int_t fNewType; //!new element type when reading 161 std::string fTypeName; //Data type na 161 std::string fTypeName; //Data type name of data member 162 }; 162 }; 163 163 164 class streamer_base : public streamer_element 164 class streamer_base : public streamer_element { 165 public: //ibo 165 public: //ibo 166 virtual const std::string& store_cls() const 166 virtual const std::string& store_cls() const { 167 static const std::string s_v("TStreamerBas 167 static const std::string s_v("TStreamerBase"); 168 return s_v; 168 return s_v; 169 } 169 } 170 virtual bool stream(buffer& aBuffer) const { 170 virtual bool stream(buffer& aBuffer) const { 171 unsigned int c; 171 unsigned int c; 172 if(!aBuffer.write_version(3,c)) return fal 172 if(!aBuffer.write_version(3,c)) return false; 173 if(!streamer_element::stream(aBuffer)) ret 173 if(!streamer_element::stream(aBuffer)) return false; 174 if(!aBuffer.write(fBaseVersion)) return fa 174 if(!aBuffer.write(fBaseVersion)) return false; 175 if(!aBuffer.set_byte_count(c)) return fals 175 if(!aBuffer.set_byte_count(c)) return false; 176 return true; 176 return true; 177 } 177 } 178 public: //streamer_element 178 public: //streamer_element 179 virtual streamer_element* copy() const {retu 179 virtual streamer_element* copy() const {return new streamer_base(*this);} 180 public: 180 public: 181 streamer_base(const std::string& aName,const 181 streamer_base(const std::string& aName,const std::string& aTitle,int aOffset,int aBaseVersion) 182 :streamer_element(aName,aTitle,aOffset,strea 182 :streamer_element(aName,aTitle,aOffset,streamer__info::BASE,"BASE") 183 ,fBaseVersion(aBaseVersion) 183 ,fBaseVersion(aBaseVersion) 184 { 184 { 185 if (aName=="TObject") fType = streamer__in 185 if (aName=="TObject") fType = streamer__info::TOBJECT; 186 if (aName=="TNamed") fType = streamer__inf 186 if (aName=="TNamed") fType = streamer__info::TNAMED; 187 } 187 } 188 virtual ~streamer_base(){} 188 virtual ~streamer_base(){} 189 public: 189 public: 190 streamer_base(const streamer_base& a_from) 190 streamer_base(const streamer_base& a_from) 191 :ibo(a_from) 191 :ibo(a_from) 192 ,streamer_element(a_from) 192 ,streamer_element(a_from) 193 ,fBaseVersion(a_from.fBaseVersion) 193 ,fBaseVersion(a_from.fBaseVersion) 194 {} 194 {} 195 streamer_base& operator=(const streamer_base 195 streamer_base& operator=(const streamer_base& a_from){ 196 streamer_element::operator=(a_from); 196 streamer_element::operator=(a_from); 197 fBaseVersion = a_from.fBaseVersion; 197 fBaseVersion = a_from.fBaseVersion; 198 return *this; 198 return *this; 199 } 199 } 200 protected: 200 protected: 201 int fBaseVersion; //version number o 201 int fBaseVersion; //version number of the base class 202 }; 202 }; 203 203 204 class streamer_basic_type : public streamer_el 204 class streamer_basic_type : public streamer_element { 205 public: //ibo 205 public: //ibo 206 virtual const std::string& store_cls() const 206 virtual const std::string& store_cls() const { 207 static const std::string s_v("TStreamerBas 207 static const std::string s_v("TStreamerBasicType"); 208 return s_v; 208 return s_v; 209 } 209 } 210 virtual bool stream(buffer& aBuffer) const { 210 virtual bool stream(buffer& aBuffer) const { 211 unsigned int c; 211 unsigned int c; 212 if(!aBuffer.write_version(2,c)) return fal 212 if(!aBuffer.write_version(2,c)) return false; 213 if(!streamer_element::stream(aBuffer)) ret 213 if(!streamer_element::stream(aBuffer)) return false; 214 if(!aBuffer.set_byte_count(c)) return fals 214 if(!aBuffer.set_byte_count(c)) return false; 215 return true; 215 return true; 216 } 216 } 217 public: //streamer_element 217 public: //streamer_element 218 virtual streamer_element* copy() const {retu 218 virtual streamer_element* copy() const {return new streamer_basic_type(*this);} 219 public: 219 public: 220 streamer_basic_type(const std::string& aName 220 streamer_basic_type(const std::string& aName,const std::string& aTitle, 221 int aOffset,int aType,co 221 int aOffset,int aType,const std::string& aTypeName) 222 :streamer_element(aName,aTitle,aOffset,aType 222 :streamer_element(aName,aTitle,aOffset,aType,aTypeName) 223 {} 223 {} 224 virtual ~streamer_basic_type(){} 224 virtual ~streamer_basic_type(){} 225 public: 225 public: 226 streamer_basic_type(const streamer_basic_typ 226 streamer_basic_type(const streamer_basic_type& a_from) 227 :ibo(a_from),streamer_element(a_from) 227 :ibo(a_from),streamer_element(a_from) 228 {} 228 {} 229 streamer_basic_type& operator=(const streame 229 streamer_basic_type& operator=(const streamer_basic_type& a_from){ 230 streamer_element::operator=(a_from); 230 streamer_element::operator=(a_from); 231 return *this; 231 return *this; 232 } 232 } 233 }; 233 }; 234 234 235 class streamer_short : public streamer_basic_t 235 class streamer_short : public streamer_basic_type { 236 public: //streamer_element 236 public: //streamer_element 237 virtual streamer_element* copy() const {retu 237 virtual streamer_element* copy() const {return new streamer_short(*this);} 238 public: 238 public: 239 streamer_short(const std::string& aName,cons 239 streamer_short(const std::string& aName,const std::string& aTitle,int aOffset) 240 :streamer_basic_type(aName,aTitle,aOffset,st 240 :streamer_basic_type(aName,aTitle,aOffset,streamer__info::SHORT,"Short_t") 241 {} 241 {} 242 streamer_short(int& aOffset,const std::strin 242 streamer_short(int& aOffset,const std::string& aName,const std::string& aTitle) 243 :streamer_basic_type(aName,aTitle,aOffset,st 243 :streamer_basic_type(aName,aTitle,aOffset,streamer__info::SHORT,"Short_t") 244 { 244 { 245 aOffset += streamer__info::size_SHORT; 245 aOffset += streamer__info::size_SHORT; 246 } 246 } 247 virtual ~streamer_short(){} 247 virtual ~streamer_short(){} 248 public: 248 public: 249 streamer_short(const streamer_short& a_from) 249 streamer_short(const streamer_short& a_from):ibo(a_from),streamer_basic_type(a_from){} 250 streamer_short& operator=(const streamer_sho 250 streamer_short& operator=(const streamer_short& a_from){streamer_basic_type::operator=(a_from);return *this;} 251 }; 251 }; 252 252 253 class streamer_int : public streamer_basic_typ 253 class streamer_int : public streamer_basic_type { 254 public: //streamer_element 254 public: //streamer_element 255 virtual streamer_element* copy() const {retu 255 virtual streamer_element* copy() const {return new streamer_int(*this);} 256 public: 256 public: 257 streamer_int(const std::string& aName,const 257 streamer_int(const std::string& aName,const std::string& aTitle,int aOffset) 258 :streamer_basic_type(aName,aTitle,aOffset,st 258 :streamer_basic_type(aName,aTitle,aOffset,streamer__info::INT,"Int_t") 259 {} 259 {} 260 streamer_int(int& aOffset,const std::string& 260 streamer_int(int& aOffset,const std::string& aName,const std::string& aTitle) 261 :streamer_basic_type(aName,aTitle,aOffset,st 261 :streamer_basic_type(aName,aTitle,aOffset,streamer__info::INT,"Int_t") 262 { 262 { 263 aOffset += streamer__info::size_INT; 263 aOffset += streamer__info::size_INT; 264 } 264 } 265 virtual ~streamer_int(){} 265 virtual ~streamer_int(){} 266 public: 266 public: 267 streamer_int(const streamer_int& a_from):ibo 267 streamer_int(const streamer_int& a_from):ibo(a_from),streamer_basic_type(a_from){} 268 streamer_int& operator=(const streamer_int& 268 streamer_int& operator=(const streamer_int& a_from){streamer_basic_type::operator=(a_from);return *this;} 269 }; 269 }; 270 270 271 class streamer_uint : public streamer_basic_ty 271 class streamer_uint : public streamer_basic_type { 272 public: //streamer_element 272 public: //streamer_element 273 virtual streamer_element* copy() const {retu 273 virtual streamer_element* copy() const {return new streamer_uint(*this);} 274 public: 274 public: 275 streamer_uint(const std::string& aName,const 275 streamer_uint(const std::string& aName,const std::string& aTitle,int aOffset) 276 :streamer_basic_type(aName,aTitle,aOffset,st 276 :streamer_basic_type(aName,aTitle,aOffset,streamer__info::UNSIGNED_INT,"UInt_t") 277 {} 277 {} 278 streamer_uint(int& aOffset,const std::string 278 streamer_uint(int& aOffset,const std::string& aName,const std::string& aTitle) 279 :streamer_basic_type(aName,aTitle,aOffset,st 279 :streamer_basic_type(aName,aTitle,aOffset,streamer__info::UNSIGNED_INT,"UInt_t") 280 { 280 { 281 aOffset += streamer__info::size_UINT; 281 aOffset += streamer__info::size_UINT; 282 } 282 } 283 virtual ~streamer_uint(){} 283 virtual ~streamer_uint(){} 284 public: 284 public: 285 streamer_uint(const streamer_uint& a_from):i 285 streamer_uint(const streamer_uint& a_from):ibo(a_from),streamer_basic_type(a_from){} 286 streamer_uint& operator=(const streamer_uint 286 streamer_uint& operator=(const streamer_uint& a_from){streamer_basic_type::operator=(a_from);return *this;} 287 }; 287 }; 288 288 289 class streamer_float : public streamer_basic_t 289 class streamer_float : public streamer_basic_type { 290 public: //streamer_element 290 public: //streamer_element 291 virtual streamer_element* copy() const {retu 291 virtual streamer_element* copy() const {return new streamer_float(*this);} 292 public: 292 public: 293 streamer_float(const std::string& aName,cons 293 streamer_float(const std::string& aName,const std::string& aTitle,int aOffset) 294 :streamer_basic_type(aName,aTitle,aOffset,st 294 :streamer_basic_type(aName,aTitle,aOffset,streamer__info::FLOAT,"Float_t") 295 {} 295 {} 296 streamer_float(int& aOffset,const std::strin 296 streamer_float(int& aOffset,const std::string& aName,const std::string& aTitle) 297 :streamer_basic_type(aName,aTitle,aOffset,st 297 :streamer_basic_type(aName,aTitle,aOffset,streamer__info::FLOAT,"Float_t") 298 { 298 { 299 aOffset += streamer__info::size_FLOAT; 299 aOffset += streamer__info::size_FLOAT; 300 } 300 } 301 virtual ~streamer_float(){} 301 virtual ~streamer_float(){} 302 public: 302 public: 303 streamer_float(const streamer_float& a_from) 303 streamer_float(const streamer_float& a_from):ibo(a_from),streamer_basic_type(a_from){} 304 streamer_float& operator=(const streamer_flo 304 streamer_float& operator=(const streamer_float& a_from){streamer_basic_type::operator=(a_from);return *this;} 305 }; 305 }; 306 306 307 class streamer_double : public streamer_basic_ 307 class streamer_double : public streamer_basic_type { 308 public: //streamer_element 308 public: //streamer_element 309 virtual streamer_element* copy() const {retu 309 virtual streamer_element* copy() const {return new streamer_double(*this);} 310 public: 310 public: 311 streamer_double(const std::string& aName,con 311 streamer_double(const std::string& aName,const std::string& aTitle,int aOffset) 312 :streamer_basic_type(aName,aTitle,aOffset,st 312 :streamer_basic_type(aName,aTitle,aOffset,streamer__info::DOUBLE,"Double_t") 313 {} 313 {} 314 streamer_double(int& aOffset,const std::stri 314 streamer_double(int& aOffset,const std::string& aName,const std::string& aTitle) 315 :streamer_basic_type(aName,aTitle,aOffset,st 315 :streamer_basic_type(aName,aTitle,aOffset,streamer__info::DOUBLE,"Double_t") 316 { 316 { 317 aOffset += streamer__info::size_DOUBLE; 317 aOffset += streamer__info::size_DOUBLE; 318 } 318 } 319 virtual ~streamer_double(){} 319 virtual ~streamer_double(){} 320 public: 320 public: 321 streamer_double(const streamer_double& a_fro 321 streamer_double(const streamer_double& a_from):ibo(a_from),streamer_basic_type(a_from){} 322 streamer_double& operator=(const streamer_do 322 streamer_double& operator=(const streamer_double& a_from){streamer_basic_type::operator=(a_from);return *this;} 323 }; 323 }; 324 324 325 class streamer_stat_t : public streamer_basic_ 325 class streamer_stat_t : public streamer_basic_type { 326 public: //streamer_element 326 public: //streamer_element 327 virtual streamer_element* copy() const {retu 327 virtual streamer_element* copy() const {return new streamer_stat_t(*this);} 328 public: 328 public: 329 streamer_stat_t(const std::string& aName,con 329 streamer_stat_t(const std::string& aName,const std::string& aTitle,int aOffset) 330 :streamer_basic_type(aName,aTitle,aOffset,st 330 :streamer_basic_type(aName,aTitle,aOffset,streamer__info::DOUBLE,"Stat_t") 331 {} 331 {} 332 streamer_stat_t(int& aOffset,const std::stri 332 streamer_stat_t(int& aOffset,const std::string& aName,const std::string& aTitle) 333 :streamer_basic_type(aName,aTitle,aOffset,st 333 :streamer_basic_type(aName,aTitle,aOffset,streamer__info::DOUBLE,"Stat_t") 334 { 334 { 335 aOffset += streamer__info::size_DOUBLE; 335 aOffset += streamer__info::size_DOUBLE; 336 } 336 } 337 virtual ~streamer_stat_t(){} 337 virtual ~streamer_stat_t(){} 338 public: 338 public: 339 streamer_stat_t(const streamer_stat_t& a_fro 339 streamer_stat_t(const streamer_stat_t& a_from):ibo(a_from),streamer_basic_type(a_from){} 340 streamer_stat_t& operator=(const streamer_st 340 streamer_stat_t& operator=(const streamer_stat_t& a_from){streamer_basic_type::operator=(a_from);return *this;} 341 }; 341 }; 342 342 343 class streamer_bool : public streamer_basic_ty 343 class streamer_bool : public streamer_basic_type { 344 public: //streamer_element 344 public: //streamer_element 345 virtual streamer_element* copy() const {retu 345 virtual streamer_element* copy() const {return new streamer_bool(*this);} 346 public: 346 public: 347 streamer_bool(const std::string& aName,const 347 streamer_bool(const std::string& aName,const std::string& aTitle,int aOffset) 348 :streamer_basic_type(aName,aTitle,aOffset,st 348 :streamer_basic_type(aName,aTitle,aOffset,streamer__info::UNSIGNED_CHAR,"Bool_t") 349 {} 349 {} 350 streamer_bool(int& aOffset,const std::string 350 streamer_bool(int& aOffset,const std::string& aName,const std::string& aTitle) 351 :streamer_basic_type(aName,aTitle,aOffset,st 351 :streamer_basic_type(aName,aTitle,aOffset,streamer__info::UNSIGNED_CHAR,"Bool_t") 352 { 352 { 353 aOffset += streamer__info::size_BOOL; 353 aOffset += streamer__info::size_BOOL; 354 } 354 } 355 virtual ~streamer_bool(){} 355 virtual ~streamer_bool(){} 356 public: 356 public: 357 streamer_bool(const streamer_bool& a_from):i 357 streamer_bool(const streamer_bool& a_from):ibo(a_from),streamer_basic_type(a_from){} 358 streamer_bool& operator=(const streamer_bool 358 streamer_bool& operator=(const streamer_bool& a_from){streamer_basic_type::operator=(a_from);return *this;} 359 }; 359 }; 360 360 361 class streamer_basic_pointer : public streamer 361 class streamer_basic_pointer : public streamer_element { 362 public: //ibo 362 public: //ibo 363 virtual const std::string& store_cls() const 363 virtual const std::string& store_cls() const { 364 static const std::string s_v("TStreamerBas 364 static const std::string s_v("TStreamerBasicPointer"); 365 return s_v; 365 return s_v; 366 } 366 } 367 virtual bool stream(buffer& aBuffer) const { 367 virtual bool stream(buffer& aBuffer) const { 368 unsigned int c; 368 unsigned int c; 369 if(!aBuffer.write_version(2,c)) return fal 369 if(!aBuffer.write_version(2,c)) return false; 370 if(!streamer_element::stream(aBuffer)) ret 370 if(!streamer_element::stream(aBuffer)) return false; 371 if(!aBuffer.write(fCountVersion)) return f 371 if(!aBuffer.write(fCountVersion)) return false; 372 if(!aBuffer.write(fCountName)) return fals 372 if(!aBuffer.write(fCountName)) return false; 373 if(!aBuffer.write(fCountClass)) return fal 373 if(!aBuffer.write(fCountClass)) return false; 374 if(!aBuffer.set_byte_count(c)) return fals 374 if(!aBuffer.set_byte_count(c)) return false; 375 return true; 375 return true; 376 } 376 } 377 public: //streamer_element 377 public: //streamer_element 378 virtual streamer_element* copy() const {retu 378 virtual streamer_element* copy() const {return new streamer_basic_pointer(*this);} 379 public: 379 public: 380 streamer_basic_pointer(const std::string& aN 380 streamer_basic_pointer(const std::string& aName,const std::string& aTitle, 381 int aOffset,int aType 381 int aOffset,int aType, 382 const std::string& aC 382 const std::string& aCountName, 383 const std::string& aC 383 const std::string& aCountClass, 384 int aCountVersion, 384 int aCountVersion, 385 const std::string& aT 385 const std::string& aTypeName) 386 :streamer_element(aName,aTitle,aOffset,aType 386 :streamer_element(aName,aTitle,aOffset,aType+streamer__info::POINTER,aTypeName) 387 ,fCountVersion(aCountVersion) 387 ,fCountVersion(aCountVersion) 388 ,fCountName(aCountName) 388 ,fCountName(aCountName) 389 ,fCountClass(aCountClass) 389 ,fCountClass(aCountClass) 390 {} 390 {} 391 virtual ~streamer_basic_pointer(){} 391 virtual ~streamer_basic_pointer(){} 392 public: 392 public: 393 streamer_basic_pointer(const streamer_basic_ 393 streamer_basic_pointer(const streamer_basic_pointer& a_from) 394 :ibo(a_from),streamer_element(a_from) 394 :ibo(a_from),streamer_element(a_from) 395 ,fCountVersion(a_from.fCountVersion) 395 ,fCountVersion(a_from.fCountVersion) 396 ,fCountName(a_from.fCountName) 396 ,fCountName(a_from.fCountName) 397 ,fCountClass(a_from.fCountClass) 397 ,fCountClass(a_from.fCountClass) 398 {} 398 {} 399 streamer_basic_pointer& operator=(const stre 399 streamer_basic_pointer& operator=(const streamer_basic_pointer& a_from){ 400 streamer_element::operator=(a_from); 400 streamer_element::operator=(a_from); 401 fCountVersion = a_from.fCountVersion; 401 fCountVersion = a_from.fCountVersion; 402 fCountName = a_from.fCountName; 402 fCountName = a_from.fCountName; 403 fCountClass = a_from.fCountClass; 403 fCountClass = a_from.fCountClass; 404 return *this; 404 return *this; 405 } 405 } 406 protected: 406 protected: 407 int fCountVersion; //version number of 407 int fCountVersion; //version number of the class with the counter 408 std::string fCountName; //name of data memb 408 std::string fCountName; //name of data member holding the array count 409 std::string fCountClass; //name of the class 409 std::string fCountClass; //name of the class with the counter 410 }; 410 }; 411 411 412 class streamer_string : public streamer_elemen 412 class streamer_string : public streamer_element { 413 public: //ibo 413 public: //ibo 414 virtual const std::string& store_cls() const 414 virtual const std::string& store_cls() const { 415 static const std::string s_v("TStreamerStr 415 static const std::string s_v("TStreamerString"); 416 return s_v; 416 return s_v; 417 } 417 } 418 virtual bool stream(buffer& aBuffer) const { 418 virtual bool stream(buffer& aBuffer) const { 419 unsigned int c; 419 unsigned int c; 420 if(!aBuffer.write_version(2,c)) return fal 420 if(!aBuffer.write_version(2,c)) return false; 421 if(!streamer_element::stream(aBuffer)) ret 421 if(!streamer_element::stream(aBuffer)) return false; 422 if(!aBuffer.set_byte_count(c)) return fals 422 if(!aBuffer.set_byte_count(c)) return false; 423 return true; 423 return true; 424 } 424 } 425 public: //streamer_element 425 public: //streamer_element 426 virtual streamer_element* copy() const {retu 426 virtual streamer_element* copy() const {return new streamer_string(*this);} 427 public: 427 public: 428 streamer_string(const std::string& aName,con 428 streamer_string(const std::string& aName,const std::string& aTitle,int aOffset) 429 :streamer_element(aName,aTitle,aOffset,strea 429 :streamer_element(aName,aTitle,aOffset,streamer__info::_TSTRING,"TString") 430 {} 430 {} 431 streamer_string(int& aOffset,const std::stri 431 streamer_string(int& aOffset,const std::string& aName,const std::string& aTitle) 432 :streamer_element(aName,aTitle,aOffset,strea 432 :streamer_element(aName,aTitle,aOffset,streamer__info::_TSTRING,"TString") 433 { 433 { 434 aOffset += streamer__info::size_TString; 434 aOffset += streamer__info::size_TString; 435 } 435 } 436 virtual ~streamer_string(){} 436 virtual ~streamer_string(){} 437 public: 437 public: 438 streamer_string(const streamer_string& a_fro 438 streamer_string(const streamer_string& a_from):ibo(a_from),streamer_element(a_from){} 439 streamer_string& operator=(const streamer_st 439 streamer_string& operator=(const streamer_string& a_from){streamer_element::operator=(a_from);return *this;} 440 }; 440 }; 441 441 442 442 443 class streamer_object : public streamer_elemen 443 class streamer_object : public streamer_element { 444 public: //ibo 444 public: //ibo 445 virtual const std::string& store_cls() const 445 virtual const std::string& store_cls() const { 446 static const std::string s_v("TStreamerObj 446 static const std::string s_v("TStreamerObject"); 447 return s_v; 447 return s_v; 448 } 448 } 449 virtual bool stream(buffer& aBuffer) const { 449 virtual bool stream(buffer& aBuffer) const { 450 unsigned int c; 450 unsigned int c; 451 if(!aBuffer.write_version(2,c)) return fal 451 if(!aBuffer.write_version(2,c)) return false; 452 if(!streamer_element::stream(aBuffer)) ret 452 if(!streamer_element::stream(aBuffer)) return false; 453 if(!aBuffer.set_byte_count(c)) return fals 453 if(!aBuffer.set_byte_count(c)) return false; 454 return true; 454 return true; 455 } 455 } 456 public: //streamer_element 456 public: //streamer_element 457 virtual streamer_element* copy() const {retu 457 virtual streamer_element* copy() const {return new streamer_object(*this);} 458 public: 458 public: 459 streamer_object(const std::string& aName,con 459 streamer_object(const std::string& aName,const std::string& aTitle,int aOffset,const std::string& aTypeName) 460 :streamer_element(aName,aTitle,aOffset,0,aTy 460 :streamer_element(aName,aTitle,aOffset,0,aTypeName){ 461 fType = streamer__info::OBJECT; 461 fType = streamer__info::OBJECT; 462 if (aName=="TObject") fType = streamer__in 462 if (aName=="TObject") fType = streamer__info::TOBJECT; 463 if (aName=="TNamed") fType = streamer__inf 463 if (aName=="TNamed") fType = streamer__info::TNAMED; 464 } 464 } 465 virtual ~streamer_object(){} 465 virtual ~streamer_object(){} 466 public: 466 public: 467 streamer_object(const streamer_object& a_fro 467 streamer_object(const streamer_object& a_from):ibo(a_from),streamer_element(a_from){} 468 streamer_object& operator=(const streamer_ob 468 streamer_object& operator=(const streamer_object& a_from){ 469 streamer_element::operator=(a_from); 469 streamer_element::operator=(a_from); 470 return *this; 470 return *this; 471 } 471 } 472 }; 472 }; 473 473 474 class streamer_object_pointer : public streame 474 class streamer_object_pointer : public streamer_element { 475 public: //ibo 475 public: //ibo 476 virtual const std::string& store_cls() const 476 virtual const std::string& store_cls() const { 477 static const std::string s_v("TStreamerObj 477 static const std::string s_v("TStreamerObjectPointer"); 478 return s_v; 478 return s_v; 479 } 479 } 480 virtual bool stream(buffer& aBuffer) const { 480 virtual bool stream(buffer& aBuffer) const { 481 unsigned int c; 481 unsigned int c; 482 if(!aBuffer.write_version(2,c)) return fal 482 if(!aBuffer.write_version(2,c)) return false; 483 if(!streamer_element::stream(aBuffer)) ret 483 if(!streamer_element::stream(aBuffer)) return false; 484 if(!aBuffer.set_byte_count(c)) return fals 484 if(!aBuffer.set_byte_count(c)) return false; 485 return true; 485 return true; 486 } 486 } 487 public: //streamer_element 487 public: //streamer_element 488 virtual streamer_element* copy() const {retu 488 virtual streamer_element* copy() const {return new streamer_object_pointer(*this);} 489 public: 489 public: 490 streamer_object_pointer(const std::string& a 490 streamer_object_pointer(const std::string& aName,const std::string& aTitle, 491 int aOffset,const st 491 int aOffset,const std::string& aTypeName) 492 :streamer_element(aName,aTitle,aOffset,strea 492 :streamer_element(aName,aTitle,aOffset,streamer__info::OBJECT_POINTER,aTypeName){ 493 if(aTitle.substr(0,2)=="->") fType = strea 493 if(aTitle.substr(0,2)=="->") fType = streamer__info::OBJECT_ARROW; 494 } 494 } 495 virtual ~streamer_object_pointer(){} 495 virtual ~streamer_object_pointer(){} 496 public: 496 public: 497 streamer_object_pointer(const streamer_objec 497 streamer_object_pointer(const streamer_object_pointer& a_from):ibo(a_from),streamer_element(a_from){} 498 streamer_object_pointer& operator=(const str 498 streamer_object_pointer& operator=(const streamer_object_pointer& a_from){ 499 streamer_element::operator=(a_from); 499 streamer_element::operator=(a_from); 500 return *this; 500 return *this; 501 } 501 } 502 }; 502 }; 503 503 504 class streamer_object_any : public streamer_el 504 class streamer_object_any : public streamer_element { 505 public: //ibo 505 public: //ibo 506 virtual const std::string& store_cls() const 506 virtual const std::string& store_cls() const { 507 static const std::string s_v("TStreamerObj 507 static const std::string s_v("TStreamerObjectAny"); 508 return s_v; 508 return s_v; 509 } 509 } 510 virtual bool stream(buffer& aBuffer) const { 510 virtual bool stream(buffer& aBuffer) const { 511 unsigned int c; 511 unsigned int c; 512 if(!aBuffer.write_version(2,c)) return fal 512 if(!aBuffer.write_version(2,c)) return false; 513 if(!streamer_element::stream(aBuffer)) ret 513 if(!streamer_element::stream(aBuffer)) return false; 514 if(!aBuffer.set_byte_count(c)) return fals 514 if(!aBuffer.set_byte_count(c)) return false; 515 return true; 515 return true; 516 } 516 } 517 public: //streamer_element 517 public: //streamer_element 518 virtual streamer_element* copy() const {retu 518 virtual streamer_element* copy() const {return new streamer_object_any(*this);} 519 public: 519 public: 520 streamer_object_any(const std::string& aName 520 streamer_object_any(const std::string& aName,const std::string& aTitle, 521 int aOffset,const std::s 521 int aOffset,const std::string& aTypeName) 522 :streamer_element(aName,aTitle,aOffset,strea 522 :streamer_element(aName,aTitle,aOffset,streamer__info::OBJECT_ANY,aTypeName) 523 {} 523 {} 524 virtual ~streamer_object_any(){} 524 virtual ~streamer_object_any(){} 525 public: 525 public: 526 streamer_object_any(const streamer_object_an 526 streamer_object_any(const streamer_object_any& a_from):ibo(a_from),streamer_element(a_from){} 527 streamer_object_any& operator=(const streame 527 streamer_object_any& operator=(const streamer_object_any& a_from){ 528 streamer_element::operator=(a_from); 528 streamer_element::operator=(a_from); 529 return *this; 529 return *this; 530 } 530 } 531 }; 531 }; 532 532 533 533 534 class streamer_STL : public streamer_element { 534 class streamer_STL : public streamer_element { 535 public: //ibo 535 public: //ibo 536 virtual const std::string& store_cls() const 536 virtual const std::string& store_cls() const { 537 static const std::string s_v("TStreamerSTL 537 static const std::string s_v("TStreamerSTL"); 538 return s_v; 538 return s_v; 539 } 539 } 540 virtual bool stream(buffer& aBuffer) const { 540 virtual bool stream(buffer& aBuffer) const { 541 unsigned int c; 541 unsigned int c; 542 if(!aBuffer.write_version(2,c)) return fal 542 if(!aBuffer.write_version(2,c)) return false; 543 if(!streamer_element::stream(aBuffer)) ret 543 if(!streamer_element::stream(aBuffer)) return false; 544 if(!aBuffer.write(fSTLtype)) return false; 544 if(!aBuffer.write(fSTLtype)) return false; 545 if(!aBuffer.write(fCtype)) return false; 545 if(!aBuffer.write(fCtype)) return false; 546 if(!aBuffer.set_byte_count(c)) return fals 546 if(!aBuffer.set_byte_count(c)) return false; 547 return true; 547 return true; 548 } 548 } 549 public: //streamer_element 549 public: //streamer_element 550 virtual streamer_element* copy() const {retu 550 virtual streamer_element* copy() const {return new streamer_STL(*this);} 551 protected: 551 protected: 552 enum ESTLtype { kSTL = 300, kSTLstring 552 enum ESTLtype { kSTL = 300, kSTLstring =365, kSTLvector = 1, 553 kSTLlist = 2, kSTLdeque 553 kSTLlist = 2, kSTLdeque = 3, kSTLmap = 4, 554 kSTLset = 5, kSTLmultim 554 kSTLset = 5, kSTLmultimap=6, kSTLmultiset=7}; 555 555 556 // Instead of EDataType, we use the streamer 556 // Instead of EDataType, we use the streamer__info::Type. 557 //enum EDataType { 557 //enum EDataType { 558 // kChar_t = 1, kUChar_t = 11, kShort_t 558 // kChar_t = 1, kUChar_t = 11, kShort_t = 2, kUShort_t = 12, 559 // kInt_t = 3, kUInt_t = 13, kLong_t 559 // kInt_t = 3, kUInt_t = 13, kLong_t = 4, kULong_t = 14, 560 // kFloat_t = 5, kDouble_t = 8, kchar = 560 // kFloat_t = 5, kDouble_t = 8, kchar = 10, kOther_t = -1 561 //}; 561 //}; 562 public: 562 public: 563 streamer_STL(const std::string& aName,const 563 streamer_STL(const std::string& aName,const std::string& aTitle, 564 int aOffset, 564 int aOffset, 565 streamer__info::Type aType, //M 565 streamer__info::Type aType, //Must match TDataType/EDataType 566 const std::string& aTypeName) 566 const std::string& aTypeName) 567 :streamer_element(aName,aTitle,aOffset,kSTL, 567 :streamer_element(aName,aTitle,aOffset,kSTL,aTypeName){ 568 fSTLtype = kSTLvector; 568 fSTLtype = kSTLvector; 569 fCtype = aType; 569 fCtype = aType; 570 } 570 } 571 virtual ~streamer_STL(){} 571 virtual ~streamer_STL(){} 572 public: 572 public: 573 streamer_STL(const streamer_STL& a_from) 573 streamer_STL(const streamer_STL& a_from) 574 :ibo(a_from),streamer_element(a_from) 574 :ibo(a_from),streamer_element(a_from) 575 ,fSTLtype(a_from.fSTLtype) 575 ,fSTLtype(a_from.fSTLtype) 576 ,fCtype(a_from.fCtype) 576 ,fCtype(a_from.fCtype) 577 {} 577 {} 578 streamer_STL& operator=(const streamer_STL& 578 streamer_STL& operator=(const streamer_STL& a_from){ 579 streamer_element::operator=(a_from); 579 streamer_element::operator=(a_from); 580 fSTLtype = a_from.fSTLtype; 580 fSTLtype = a_from.fSTLtype; 581 fCtype = a_from.fCtype; 581 fCtype = a_from.fCtype; 582 return *this; 582 return *this; 583 } 583 } 584 protected: 584 protected: 585 int fSTLtype; //type of STL vector 585 int fSTLtype; //type of STL vector 586 int fCtype; //STL contained type 586 int fCtype; //STL contained type 587 }; 587 }; 588 588 589 }} 589 }} 590 590 591 #endif 591 #endif