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_leaf 4 #ifndef tools_wroot_leaf 5 #define tools_wroot_leaf 5 #define tools_wroot_leaf 6 6 7 #include "base_leaf" 7 #include "base_leaf" 8 8 9 #include "../cids" 9 #include "../cids" 10 #include "../vdata" 10 #include "../vdata" 11 11 12 namespace tools { 12 namespace tools { 13 namespace wroot { 13 namespace wroot { 14 14 15 inline const std::string& leaf_store_class(cha 15 inline const std::string& leaf_store_class(char) { 16 static const std::string s_v("TLeafB"); 16 static const std::string s_v("TLeafB"); 17 return s_v; 17 return s_v; 18 } 18 } 19 inline const std::string& leaf_store_class(sho 19 inline const std::string& leaf_store_class(short) { 20 static const std::string s_v("TLeafS"); 20 static const std::string s_v("TLeafS"); 21 return s_v; 21 return s_v; 22 } 22 } 23 inline const std::string& leaf_store_class(int 23 inline const std::string& leaf_store_class(int) { 24 static const std::string s_v("TLeafI"); 24 static const std::string s_v("TLeafI"); 25 return s_v; 25 return s_v; 26 } 26 } 27 inline const std::string& leaf_store_class(flo 27 inline const std::string& leaf_store_class(float) { 28 static const std::string s_v("TLeafF"); 28 static const std::string s_v("TLeafF"); 29 return s_v; 29 return s_v; 30 } 30 } 31 inline const std::string& leaf_store_class(dou 31 inline const std::string& leaf_store_class(double) { 32 static const std::string s_v("TLeafD"); 32 static const std::string s_v("TLeafD"); 33 return s_v; 33 return s_v; 34 } 34 } 35 inline const std::string& leaf_string_store_cl 35 inline const std::string& leaf_string_store_class() { 36 static const std::string s_v("TLeafC"); 36 static const std::string s_v("TLeafC"); 37 return s_v; 37 return s_v; 38 } 38 } 39 inline const std::string& leaf_element_store_c 39 inline const std::string& leaf_element_store_class() { 40 static const std::string s_v("TLeafElement") 40 static const std::string s_v("TLeafElement"); 41 return s_v; 41 return s_v; 42 } 42 } 43 inline const std::string& leaf_object_store_cl 43 inline const std::string& leaf_object_store_class() { 44 static const std::string s_v("TLeafObject"); 44 static const std::string s_v("TLeafObject"); 45 return s_v; 45 return s_v; 46 } 46 } 47 47 48 template <class T> 48 template <class T> 49 class leaf_ref : public base_leaf { 49 class leaf_ref : public base_leaf { 50 typedef base_leaf parent; 50 typedef base_leaf parent; 51 public: 51 public: 52 static cid id_class() {return base_leaf_cid( 52 static cid id_class() {return base_leaf_cid()+_cid(T())+10000;} //10000 same as in ntuple::column_ref. 53 virtual void* cast(cid a_class) const { 53 virtual void* cast(cid a_class) const { 54 if(void* p = cmp_cast<leaf_ref>(this,a_cla 54 if(void* p = cmp_cast<leaf_ref>(this,a_class)) {return p;} 55 return parent::cast(a_class); 55 return parent::cast(a_class); 56 } 56 } 57 virtual cid id_cls() const {return id_class( 57 virtual cid id_cls() const {return id_class();} 58 public: //ibo 58 public: //ibo 59 virtual const std::string& store_cls() const 59 virtual const std::string& store_cls() const {return leaf_store_class(T());} 60 virtual bool stream(buffer& a_buffer) const 60 virtual bool stream(buffer& a_buffer) const { 61 unsigned int c; 61 unsigned int c; 62 if(!a_buffer.write_version(1,c)) return fa 62 if(!a_buffer.write_version(1,c)) return false; 63 if(!parent::stream(a_buffer)) return false 63 if(!parent::stream(a_buffer)) return false; 64 if(!a_buffer.write(m_min)) return false; 64 if(!a_buffer.write(m_min)) return false; 65 if(!a_buffer.write(m_max)) return false; 65 if(!a_buffer.write(m_max)) return false; 66 if(!a_buffer.set_byte_count(c)) return fal 66 if(!a_buffer.set_byte_count(c)) return false; 67 return true; 67 return true; 68 } 68 } 69 public: //base_leaf 69 public: //base_leaf 70 virtual bool fill_buffer(buffer& a_buffer) c 70 virtual bool fill_buffer(buffer& a_buffer) const { 71 if(m_is_range) { 71 if(m_is_range) { 72 if(m_ref>=m_max) { 72 if(m_ref>=m_max) { 73 leaf_ref& self = const_cast<leaf_ref&> 73 leaf_ref& self = const_cast<leaf_ref&>(*this); 74 self.m_max = m_ref; 74 self.m_max = m_ref; 75 } 75 } 76 } 76 } 77 return a_buffer.write<T>(m_ref); 77 return a_buffer.write<T>(m_ref); 78 } 78 } 79 public: 79 public: 80 leaf_ref(std::ostream& a_out,const std::stri 80 leaf_ref(std::ostream& a_out,const std::string& a_name,const T& a_ref) 81 :parent(a_out,a_name,a_name) 81 :parent(a_out,a_name,a_name) 82 ,m_min(T()),m_max(T()) 82 ,m_min(T()),m_max(T()) 83 ,m_ref(a_ref) 83 ,m_ref(a_ref) 84 { 84 { 85 m_length = 1; 85 m_length = 1; 86 m_length_type = sizeof(T); 86 m_length_type = sizeof(T); 87 } 87 } 88 virtual ~leaf_ref(){} 88 virtual ~leaf_ref(){} 89 protected: 89 protected: 90 leaf_ref(const leaf_ref& a_from):ibo(a_from) 90 leaf_ref(const leaf_ref& a_from):ibo(a_from),parent(a_from),m_ref(a_from.m_ref){} 91 leaf_ref& operator=(const leaf_ref&){return 91 leaf_ref& operator=(const leaf_ref&){return *this;} 92 public: 92 public: 93 T get_max() const {return m_max;} 93 T get_max() const {return m_max;} 94 void set_max(const T& a_value) {m_max = a_va 94 void set_max(const T& a_value) {m_max = a_value;} 95 public: 95 public: 96 const T& variable() const {return m_ref;} 96 const T& variable() const {return m_ref;} 97 T& variable() {return const_cast<T&>(m_ref); 97 T& variable() {return const_cast<T&>(m_ref);} 98 protected: 98 protected: 99 T m_min; //Minimum value if leaf range is 99 T m_min; //Minimum value if leaf range is specified 100 T m_max; //Maximum value if leaf range is 100 T m_max; //Maximum value if leaf range is specified 101 const T& m_ref; 101 const T& m_ref; 102 }; 102 }; 103 103 104 template <class T> 104 template <class T> 105 class leaf : public leaf_ref<T> { 105 class leaf : public leaf_ref<T> { 106 typedef leaf_ref<T> parent; 106 typedef leaf_ref<T> parent; 107 public: 107 public: 108 static cid id_class() {return base_leaf_cid( 108 static cid id_class() {return base_leaf_cid()+_cid(T());} 109 virtual void* cast(cid a_class) const { 109 virtual void* cast(cid a_class) const { 110 if(void* p = cmp_cast<leaf>(this,a_class)) 110 if(void* p = cmp_cast<leaf>(this,a_class)) {return p;} 111 return parent::cast(a_class); 111 return parent::cast(a_class); 112 } 112 } 113 virtual cid id_cls() const {return id_class( 113 virtual cid id_cls() const {return id_class();} 114 public: 114 public: 115 leaf(std::ostream& a_out,const std::string& 115 leaf(std::ostream& a_out,const std::string& a_name) 116 :parent(a_out,a_name,m_value) 116 :parent(a_out,a_name,m_value) 117 ,m_value(T()) 117 ,m_value(T()) 118 {} 118 {} 119 virtual ~leaf(){} 119 virtual ~leaf(){} 120 protected: 120 protected: 121 leaf(const leaf& a_from):ibo(a_from),parent( 121 leaf(const leaf& a_from):ibo(a_from),parent(a_from){} 122 leaf& operator=(const leaf&){return *this;} 122 leaf& operator=(const leaf&){return *this;} 123 public: 123 public: 124 void fill(const T& a_value) {m_value = a_val 124 void fill(const T& a_value) {m_value = a_value;} 125 protected: 125 protected: 126 T m_value; 126 T m_value; 127 }; 127 }; 128 128 129 class leaf_string_ref : public base_leaf { 129 class leaf_string_ref : public base_leaf { 130 typedef base_leaf parent; 130 typedef base_leaf parent; 131 public: 131 public: 132 static cid id_class() {return leaf_string_ci 132 static cid id_class() {return leaf_string_cid()+10000;} 133 virtual void* cast(cid a_class) const { 133 virtual void* cast(cid a_class) const { 134 if(void* p = cmp_cast<leaf_string_ref>(thi 134 if(void* p = cmp_cast<leaf_string_ref>(this,a_class)) {return p;} 135 return parent::cast(a_class); 135 return parent::cast(a_class); 136 } 136 } 137 virtual cid id_cls() const {return id_class( 137 virtual cid id_cls() const {return id_class();} 138 public: //ibo 138 public: //ibo 139 virtual const std::string& store_cls() const 139 virtual const std::string& store_cls() const {return leaf_string_store_class();} 140 virtual bool stream(buffer& a_buffer) const 140 virtual bool stream(buffer& a_buffer) const { 141 unsigned int c; 141 unsigned int c; 142 if(!a_buffer.write_version(1,c)) return fa 142 if(!a_buffer.write_version(1,c)) return false; 143 if(!parent::stream(a_buffer)) return false 143 if(!parent::stream(a_buffer)) return false; 144 if(!a_buffer.write(m_min)) return false; 144 if(!a_buffer.write(m_min)) return false; 145 if(!a_buffer.write(m_max)) return false; 145 if(!a_buffer.write(m_max)) return false; 146 if(!a_buffer.set_byte_count(c)) return fal 146 if(!a_buffer.set_byte_count(c)) return false; 147 return true; 147 return true; 148 } 148 } 149 public: //base_leaf 149 public: //base_leaf 150 virtual bool fill_buffer(buffer& a_buffer) c 150 virtual bool fill_buffer(buffer& a_buffer) const { 151 leaf_string_ref& self = const_cast<leaf_st 151 leaf_string_ref& self = const_cast<leaf_string_ref&>(*this); 152 size_t len = ::strlen(m_ref.c_str()); 152 size_t len = ::strlen(m_ref.c_str()); 153 if(len >= (size_t)m_max) self.m_max = int( 153 if(len >= (size_t)m_max) self.m_max = int(len)+1; 154 if(len >= m_length) self.m_length = uint32 154 if(len >= m_length) self.m_length = uint32(len)+1; 155 if(len < 255) { 155 if(len < 255) { 156 if(!a_buffer.write<unsigned char>((unsig 156 if(!a_buffer.write<unsigned char>((unsigned char)len)) return false; 157 } else { 157 } else { 158 if(!a_buffer.write<unsigned char>(255)) 158 if(!a_buffer.write<unsigned char>(255)) return false; 159 if(!a_buffer.write<uint32>(uint32(len))) 159 if(!a_buffer.write<uint32>(uint32(len))) return false; 160 } 160 } 161 if(len) if(!a_buffer.write_fast_array(m_re 161 if(len) if(!a_buffer.write_fast_array(m_ref.c_str(),uint32(len))) return false; 162 return true; 162 return true; 163 } 163 } 164 public: 164 public: 165 leaf_string_ref(std::ostream& a_out,const st 165 leaf_string_ref(std::ostream& a_out,const std::string& a_name,const std::string& a_ref) 166 :parent(a_out,a_name,a_name) 166 :parent(a_out,a_name,a_name) 167 ,m_min(0),m_max(0) 167 ,m_min(0),m_max(0) 168 ,m_ref(a_ref) 168 ,m_ref(a_ref) 169 { 169 { 170 m_length_type = 1; 170 m_length_type = 1; 171 } 171 } 172 virtual ~leaf_string_ref(){} 172 virtual ~leaf_string_ref(){} 173 protected: 173 protected: 174 leaf_string_ref(const leaf_string_ref& a_fro 174 leaf_string_ref(const leaf_string_ref& a_from):ibo(a_from),parent(a_from),m_ref(a_from.m_ref){} 175 leaf_string_ref& operator=(const leaf_string 175 leaf_string_ref& operator=(const leaf_string_ref&){return *this;} 176 public: 176 public: 177 int get_max() const {return m_max;} 177 int get_max() const {return m_max;} 178 void set_max(int a_value) {m_max = a_value;} 178 void set_max(int a_value) {m_max = a_value;} 179 public: 179 public: 180 const std::string& variable() const {return 180 const std::string& variable() const {return m_ref;} 181 std::string& variable() {return const_cast<s 181 std::string& variable() {return const_cast<std::string&>(m_ref);} 182 protected: 182 protected: 183 int m_min; //Minimum value if leaf range is 183 int m_min; //Minimum value if leaf range is specified 184 int m_max; //Maximum value if leaf range is 184 int m_max; //Maximum value if leaf range is specified 185 const std::string& m_ref; 185 const std::string& m_ref; 186 }; 186 }; 187 187 188 class leaf_string : public leaf_string_ref { 188 class leaf_string : public leaf_string_ref { 189 typedef leaf_string_ref parent; 189 typedef leaf_string_ref parent; 190 public: 190 public: 191 static cid id_class() {return leaf_string_ci 191 static cid id_class() {return leaf_string_cid();} 192 virtual void* cast(cid a_class) const { 192 virtual void* cast(cid a_class) const { 193 if(void* p = cmp_cast<leaf_string>(this,a_ 193 if(void* p = cmp_cast<leaf_string>(this,a_class)) {return p;} 194 return parent::cast(a_class); 194 return parent::cast(a_class); 195 } 195 } 196 virtual cid id_cls() const {return id_class( 196 virtual cid id_cls() const {return id_class();} 197 public: 197 public: 198 leaf_string(std::ostream& a_out,const std::s 198 leaf_string(std::ostream& a_out,const std::string& a_name) 199 :parent(a_out,a_name,m_value) 199 :parent(a_out,a_name,m_value) 200 {} 200 {} 201 virtual ~leaf_string(){} 201 virtual ~leaf_string(){} 202 protected: 202 protected: 203 leaf_string(const leaf_string& a_from):ibo(a 203 leaf_string(const leaf_string& a_from):ibo(a_from),parent(a_from){} 204 leaf_string& operator=(const leaf_string&){r 204 leaf_string& operator=(const leaf_string&){return *this;} 205 public: 205 public: 206 void fill(const std::string& a_value) {m_val 206 void fill(const std::string& a_value) {m_value = a_value;} 207 protected: 207 protected: 208 std::string m_value; 208 std::string m_value; 209 }; 209 }; 210 210 211 // to store vector columns of a row_wise ntupl 211 // to store vector columns of a row_wise ntuple : 212 template <class T> 212 template <class T> 213 class leaf_std_vector_ref : public base_leaf { 213 class leaf_std_vector_ref : public base_leaf { 214 typedef base_leaf parent; 214 typedef base_leaf parent; 215 public: 215 public: 216 static cid id_class() {return base_leaf_cid( 216 static cid id_class() {return base_leaf_cid()+_cid(std::vector<T>())+10000;} //10000 same as in ntuple::column_ref. 217 virtual void* cast(cid a_class) const { 217 virtual void* cast(cid a_class) const { 218 if(void* p = cmp_cast<leaf_std_vector_ref> 218 if(void* p = cmp_cast<leaf_std_vector_ref>(this,a_class)) {return p;} 219 return parent::cast(a_class); 219 return parent::cast(a_class); 220 } 220 } 221 virtual cid id_cls() const {return id_class( 221 virtual cid id_cls() const {return id_class();} 222 public: //ibo 222 public: //ibo 223 virtual const std::string& store_cls() const 223 virtual const std::string& store_cls() const {return leaf_store_class(T());} 224 virtual bool stream(buffer& a_buffer) const 224 virtual bool stream(buffer& a_buffer) const { 225 unsigned int c; 225 unsigned int c; 226 if(!a_buffer.write_version(1,c)) return fa 226 if(!a_buffer.write_version(1,c)) return false; 227 if(!parent::stream(a_buffer)) return false 227 if(!parent::stream(a_buffer)) return false; 228 if(!a_buffer.write(m_min)) return false; 228 if(!a_buffer.write(m_min)) return false; 229 if(!a_buffer.write(m_max)) return false; 229 if(!a_buffer.write(m_max)) return false; 230 if(!a_buffer.set_byte_count(c)) return fal 230 if(!a_buffer.set_byte_count(c)) return false; 231 return true; 231 return true; 232 } 232 } 233 public: //base_leaf 233 public: //base_leaf 234 virtual bool fill_buffer(buffer& a_buffer) c 234 virtual bool fill_buffer(buffer& a_buffer) const { 235 if(!a_buffer.write_fast_array(vec_data(m_r 235 if(!a_buffer.write_fast_array(vec_data(m_ref),uint32(m_ref.size()))) return false; 236 return true; 236 return true; 237 } 237 } 238 public: 238 public: 239 leaf_std_vector_ref(std::ostream& a_out,cons 239 leaf_std_vector_ref(std::ostream& a_out,const std::string& a_name, 240 base_leaf& a_leaf_count, 240 base_leaf& a_leaf_count,const std::vector<T>& a_ref) 241 :parent(a_out,a_name,a_name) 241 :parent(a_out,a_name,a_name) 242 ,m_min(T()),m_max(T()) 242 ,m_min(T()),m_max(T()) 243 ,m_ref(a_ref) 243 ,m_ref(a_ref) 244 { 244 { 245 parent::m_leaf_count = &a_leaf_count; 245 parent::m_leaf_count = &a_leaf_count; 246 a_leaf_count.set_is_range(true); 246 a_leaf_count.set_is_range(true); 247 m_length = 1; 247 m_length = 1; 248 m_length_type = sizeof(T); 248 m_length_type = sizeof(T); 249 } 249 } 250 virtual ~leaf_std_vector_ref(){} 250 virtual ~leaf_std_vector_ref(){} 251 protected: 251 protected: 252 leaf_std_vector_ref(const leaf_std_vector_re 252 leaf_std_vector_ref(const leaf_std_vector_ref& a_from):ibo(a_from),parent(a_from),m_ref(a_from.m_ref){} 253 leaf_std_vector_ref& operator=(const leaf_st 253 leaf_std_vector_ref& operator=(const leaf_std_vector_ref&){return *this;} 254 public: 254 public: 255 T get_max() const {return m_max;} 255 T get_max() const {return m_max;} 256 void set_max(const T& a_value) {m_max = a_va 256 void set_max(const T& a_value) {m_max = a_value;} 257 public: 257 public: 258 const std::vector<T>& variable() const {retu 258 const std::vector<T>& variable() const {return m_ref;} 259 std::vector<T>& variable() {return const_cas 259 std::vector<T>& variable() {return const_cast< std::vector<T>& >(m_ref);} 260 protected: 260 protected: 261 T m_min; //Minimum value if leaf range is 261 T m_min; //Minimum value if leaf range is specified 262 T m_max; //Maximum value if leaf range is 262 T m_max; //Maximum value if leaf range is specified 263 const std::vector<T>& m_ref; 263 const std::vector<T>& m_ref; 264 }; 264 }; 265 265 266 class leaf_element : public base_leaf { 266 class leaf_element : public base_leaf { 267 typedef base_leaf parent; 267 typedef base_leaf parent; 268 public: 268 public: 269 static cid id_class() {return leaf_element_c 269 static cid id_class() {return leaf_element_cid();} 270 virtual void* cast(cid a_class) const { 270 virtual void* cast(cid a_class) const { 271 if(void* p = cmp_cast<leaf_element>(this,a 271 if(void* p = cmp_cast<leaf_element>(this,a_class)) {return p;} 272 return base_leaf::cast(a_class); 272 return base_leaf::cast(a_class); 273 } 273 } 274 virtual cid id_cls() const {return id_class( 274 virtual cid id_cls() const {return id_class();} 275 public: 275 public: 276 virtual const std::string& store_cls() const 276 virtual const std::string& store_cls() const {return leaf_element_store_class();} 277 virtual bool stream(buffer& a_buffer) const 277 virtual bool stream(buffer& a_buffer) const { 278 unsigned int c; 278 unsigned int c; 279 if(!a_buffer.write_version(1,c)) return fa 279 if(!a_buffer.write_version(1,c)) return false; 280 if(!parent::stream(a_buffer)) return false 280 if(!parent::stream(a_buffer)) return false; 281 281 282 if(!a_buffer.write(fID)) return false; 282 if(!a_buffer.write(fID)) return false; 283 if(!a_buffer.write(fType)) return false; 283 if(!a_buffer.write(fType)) return false; 284 284 285 if(!a_buffer.set_byte_count(c)) return fal 285 if(!a_buffer.set_byte_count(c)) return false; 286 return true; 286 return true; 287 } 287 } 288 public: //base_leaf 288 public: //base_leaf 289 virtual bool fill_buffer(buffer&) const { 289 virtual bool fill_buffer(buffer&) const { 290 m_out << "tools::wroot::leaf_element::fill 290 m_out << "tools::wroot::leaf_element::fill_buffer : dummy." << std::endl; 291 return false; 291 return false; 292 } 292 } 293 public: 293 public: 294 leaf_element(std::ostream& a_out,const std:: 294 leaf_element(std::ostream& a_out,const std::string& a_name,int a_id,int a_type) 295 :parent(a_out,a_name,a_name) 295 :parent(a_out,a_name,a_name) 296 ,fID(a_id) 296 ,fID(a_id) 297 ,fType(a_type) 297 ,fType(a_type) 298 {} 298 {} 299 virtual ~leaf_element(){} 299 virtual ~leaf_element(){} 300 protected: 300 protected: 301 leaf_element(const leaf_element& a_from):ibo 301 leaf_element(const leaf_element& a_from):ibo(a_from),parent(a_from){} 302 leaf_element& operator=(const leaf_element& 302 leaf_element& operator=(const leaf_element& a_from){ 303 parent::operator=(a_from); 303 parent::operator=(a_from); 304 return *this; 304 return *this; 305 } 305 } 306 protected: 306 protected: 307 int fID; //element serial number in fInfo 307 int fID; //element serial number in fInfo 308 int fType; //leaf type 308 int fType; //leaf type 309 }; 309 }; 310 310 311 }} 311 }} 312 312 313 #include "iobject" 313 #include "iobject" 314 314 315 namespace tools { 315 namespace tools { 316 namespace wroot { 316 namespace wroot { 317 317 318 class leaf_object : public base_leaf { 318 class leaf_object : public base_leaf { 319 typedef base_leaf parent; 319 typedef base_leaf parent; 320 public: 320 public: 321 static cid id_class() {return leaf_object_ci 321 static cid id_class() {return leaf_object_cid();} 322 virtual void* cast(cid a_class) const { 322 virtual void* cast(cid a_class) const { 323 if(void* p = cmp_cast<leaf_object>(this,a_ 323 if(void* p = cmp_cast<leaf_object>(this,a_class)) {return p;} 324 return base_leaf::cast(a_class); 324 return base_leaf::cast(a_class); 325 } 325 } 326 virtual cid id_cls() const {return id_class( 326 virtual cid id_cls() const {return id_class();} 327 public: 327 public: 328 virtual const std::string& store_cls() const 328 virtual const std::string& store_cls() const {return leaf_object_store_class();} 329 virtual bool stream(buffer& a_buffer) const 329 virtual bool stream(buffer& a_buffer) const { 330 unsigned int c; 330 unsigned int c; 331 if(!a_buffer.write_version(4,c)) return fa 331 if(!a_buffer.write_version(4,c)) return false; 332 if(!parent::stream(a_buffer)) return false 332 if(!parent::stream(a_buffer)) return false; 333 if(!a_buffer.write(fVirtual)) return false 333 if(!a_buffer.write(fVirtual)) return false; 334 if(!a_buffer.set_byte_count(c)) return fal 334 if(!a_buffer.set_byte_count(c)) return false; 335 return true; 335 return true; 336 } 336 } 337 public: //base_leaf 337 public: //base_leaf 338 virtual bool fill_buffer(buffer& a_buffer) c 338 virtual bool fill_buffer(buffer& a_buffer) const { 339 if(fVirtual) { 339 if(fVirtual) { 340 const std::string& _class = m_obj.store_ 340 const std::string& _class = m_obj.store_class_name(); 341 if(_class.size()>255) return false; 341 if(_class.size()>255) return false; 342 unsigned char n = (unsigned char)_class. 342 unsigned char n = (unsigned char)_class.size(); 343 if(!a_buffer.write(n)) return false; 343 if(!a_buffer.write(n)) return false; 344 if(!a_buffer.write_fast_array(_class.c_s 344 if(!a_buffer.write_fast_array(_class.c_str(),n+1)) return false; 345 } 345 } 346 return m_obj.stream(a_buffer); 346 return m_obj.stream(a_buffer); 347 } 347 } 348 public: 348 public: 349 leaf_object(std::ostream& a_out,const std::s 349 leaf_object(std::ostream& a_out,const std::string& a_name,const iobject& a_obj) 350 :parent(a_out,a_name,a_obj.store_class_name( 350 :parent(a_out,a_name,a_obj.store_class_name()) //CERN-ROOT/TLeafObject::Streamer() wants store class name on m_title. 351 ,m_obj(a_obj) 351 ,m_obj(a_obj) 352 ,fVirtual(true) 352 ,fVirtual(true) 353 {} 353 {} 354 virtual ~leaf_object(){} 354 virtual ~leaf_object(){} 355 protected: 355 protected: 356 leaf_object(const leaf_object& a_from):ibo(a 356 leaf_object(const leaf_object& a_from):ibo(a_from),parent(a_from),m_obj(a_from.m_obj),fVirtual(true){} 357 leaf_object& operator=(const leaf_object& a_ 357 leaf_object& operator=(const leaf_object& a_from){ 358 parent::operator=(a_from); 358 parent::operator=(a_from); 359 return *this; 359 return *this; 360 } 360 } 361 protected: 361 protected: 362 const iobject& m_obj; 362 const iobject& m_obj; 363 bool fVirtual; // Support for Virtuality 363 bool fVirtual; // Support for Virtuality 364 }; 364 }; 365 365 366 }} 366 }} 367 367 368 #endif 368 #endif