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 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /externals/g4tools/include/tools/rroot/info (Version 11.3.0) and /externals/g4tools/include/tools/rroot/info (Version 9.2.p4)


  1 // Copyright (C) 2010, Guy Barrand. All rights    
  2 // See the file tools.license for terms.          
  3                                                   
  4 #ifndef tools_rroot_info                          
  5 #define tools_rroot_info                          
  6                                                   
  7 //#include "buffer"                               
  8 //#include "element"                              
  9 #include "named"                                  
 10 #include "obj_array"                              
 11 #include "../forit"                               
 12                                                   
 13 namespace tools {                                 
 14 namespace rroot {                                 
 15                                                   
 16 class streamer_element : public virtual iro {     
 17   static const std::string& s_store_class() {     
 18     static const std::string s_v("TStreamerEle    
 19     return s_v;                                   
 20   }                                               
 21 public:                                           
 22   static const std::string& s_class() {           
 23     static const std::string s_v("tools::rroot    
 24     return s_v;                                   
 25   }                                               
 26   static cid id_class() {return streamer_eleme    
 27 public: //iro                                     
 28   virtual void* cast(const std::string& a_clas    
 29     if(void* p = cmp_cast<streamer_element>(th    
 30     return 0;                                     
 31   }                                               
 32   virtual void* cast(cid a_class) const {         
 33     if(void* p = cmp_cast<streamer_element>(th    
 34     else return 0;                                
 35   }                                               
 36   virtual const std::string& s_cls() const {re    
 37   virtual iro* copy() const {return new stream    
 38                                                   
 39   virtual bool stream(buffer& a_buffer) {         
 40     short v;                                      
 41     unsigned int _s,_c;                           
 42     if(!a_buffer.read_version(v,_s,_c)) return    
 43     if(!Named_stream(a_buffer,fName,fTitle)) r    
 44     if(!a_buffer.read(fType)) return false;       
 45     if(!a_buffer.read(fSize)) return false;       
 46     if(!a_buffer.read(fArrayLength)) return fa    
 47     if(!a_buffer.read(fArrayDim)) return false    
 48     if(!a_buffer.read_fast_array<int>(fMaxInde    
 49     if(!a_buffer.read(fTypeName)) return false    
 50     return a_buffer.check_byte_count(_s,_c,s_s    
 51   }                                               
 52 public:                                           
 53   virtual void out(std::ostream& aOut) const {    
 54     std::string _fname;                           
 55     fullName(_fname);                             
 56     char _s[128];                                 
 57     snpf(_s,sizeof(_s),"  %-14s%-15s offset=%3    
 58       fTypeName.c_str(),_fname.c_str(),fOffset    
 59     aOut << _s << std::endl;                      
 60   }                                               
 61 public:                                           
 62   streamer_element()                              
 63   :fName(),fTitle(),fType(-1)                     
 64   ,fSize(0),fArrayLength(0),fArrayDim(0),fOffs    
 65   ,fTypeName(){                                   
 66 #ifdef TOOLS_MEM                                  
 67     mem::increment(s_class().c_str());            
 68 #endif                                            
 69     for(int i=0;i<5;i++) fMaxIndex[i] = 0;        
 70   }                                               
 71   virtual ~streamer_element(){                    
 72 #ifdef TOOLS_MEM                                  
 73     mem::decrement(s_class().c_str());            
 74 #endif                                            
 75   }                                               
 76 protected:                                        
 77   streamer_element(const streamer_element& a_f    
 78   :iro(a_from)                                    
 79   ,fName(a_from.fName),fTitle(a_from.fTitle)      
 80   ,fType(a_from.fType),fSize(a_from.fSize)        
 81   ,fArrayLength(a_from.fArrayLength)              
 82   ,fArrayDim(a_from.fArrayDim),fOffset(a_from.    
 83   ,fTypeName(a_from.fTypeName){                   
 84 #ifdef TOOLS_MEM                                  
 85     mem::increment(s_class().c_str());            
 86 #endif                                            
 87     for(int i=0;i<5;i++) fMaxIndex[i] = a_from    
 88   }                                               
 89   streamer_element& operator=(const streamer_e    
 90     fName = a_from.fName;                         
 91     fTitle = a_from.fTitle;                       
 92     fType = a_from.fType;                         
 93     fSize = a_from.fSize;                         
 94     fArrayLength = a_from.fArrayLength;           
 95     fArrayDim = a_from.fArrayDim;                 
 96     fOffset = a_from.fOffset;                     
 97     fTypeName = a_from.fTypeName;                 
 98     for(int i=0;i<5;i++) fMaxIndex[i] = a_from    
 99     return *this;                                 
100   }                                               
101 public:                                           
102   virtual void fullName(std::string& a_s) cons    
103     a_s = fName;                                  
104     for (int i=0;i<fArrayDim;i++) {               
105       char cdim[32];                              
106       snpf(cdim,sizeof(cdim),"[%d]",fMaxIndex[    
107       a_s += cdim;                                
108     }                                             
109   }                                               
110   const std::string& type_name() const {return    
111 protected: //Named                                
112   std::string fName;                              
113   std::string fTitle;                             
114 protected:                                        
115   int fType;            //element type            
116   int fSize;            //sizeof element          
117   int fArrayLength;     //cumulative size of a    
118   int fArrayDim;        //number of array dime    
119   int fMaxIndex[5];     //Maximum array index     
120   int fOffset;          //!element offset in c    
121   //FIXME Int_t         fNewType;         //!n    
122   std::string fTypeName;        //Data type na    
123 };                                                
124                                                   
125 class dummy_streamer_element : public streamer    
126   typedef streamer_element parent;                
127 public: //iro                                     
128   virtual iro* copy() const {return new dummy_    
129   virtual bool stream(buffer& a_buffer) {         
130     //the below code skips correctly the data     
131     uint32 startpos = a_buffer.length();          
132     short v;                                      
133     unsigned int _s,_c;                           
134     if(!a_buffer.read_version(v,_s,_c)) return    
135                                                   
136     if(!parent::stream(a_buffer)) return false    
137                                                   
138     a_buffer.set_offset(startpos+_c+sizeof(uns    
139     if(!a_buffer.check_byte_count(_s,_c,"dummy    
140     return true;                                  
141   }                                               
142 public:                                           
143   dummy_streamer_element(){}                      
144   virtual ~dummy_streamer_element(){}             
145 protected:                                        
146   dummy_streamer_element(const dummy_streamer_    
147   dummy_streamer_element& operator=(const dumm    
148     parent::operator=(a_from);                    
149     return *this;                                 
150   }                                               
151 };                                                
152                                                   
153 class streamer_info : public virtual iro {        
154   static const std::string& s_store_class() {     
155     static const std::string s_v("TStreamerInf    
156     return s_v;                                   
157   }                                               
158 public:                                           
159   static const std::string& s_class() {           
160     static const std::string s_v("tools::rroot    
161     return s_v;                                   
162   }                                               
163   static cid id_class() {return streamer_info_    
164 public: //iro                                     
165   virtual void* cast(const std::string& a_clas    
166     if(void* p = cmp_cast<streamer_info>(this,    
167     return 0;                                     
168   }                                               
169   virtual void* cast(cid a_class) const {         
170     if(void* p = cmp_cast<streamer_info>(this,    
171     else return 0;                                
172   }                                               
173   virtual const std::string& s_cls() const {re    
174   virtual iro* copy() const {return new stream    
175                                                   
176   virtual bool stream(buffer& a_buffer) {         
177     short v;                                      
178     unsigned int _s,_c;                           
179     if(!a_buffer.read_version(v,_s,_c)) return    
180                                                   
181     if(!Named_stream(a_buffer,m_name,m_title))    
182     if(!a_buffer.read(m_check_sum)) return fal    
183     if(!a_buffer.read(m_streamed_class_version    
184                                                   
185     //TObjArray        *fElements;       //Arr    
186    {obj_array<streamer_element>* obj;             
187     ifac::args args;                              
188     args[ifac::arg_class()] = (void*)&(streame    
189     bool obj_created;                             
190     if(!pointer_stream(a_buffer,m_fac,args,obj    
191       a_buffer.out() << "tools::rroot::streame    
192                      << "can't read fElements.    
193                      << std::endl;                
194       return false;                               
195     }                                             
196     if(obj) m_elements.operator=(*obj);           
197     if(obj_created) delete obj;}                  
198                                                   
199     return a_buffer.check_byte_count(_s,_c,s_s    
200   }                                               
201 public:                                           
202   void out(std::ostream& a_out) const {           
203     a_out << "streamer_info for class :"          
204           << " " << m_name << ", version=" <<     
205           << std::endl;                           
206     tools_vforcit(streamer_element*,m_elements    
207   }                                               
208 public:                                           
209   streamer_info(ifac& a_fac)                      
210   :m_fac(a_fac)                                   
211   ,m_name()                                       
212   ,m_title()                                      
213   ,m_check_sum(0)                                 
214   ,m_streamed_class_version(0)                    
215   ,m_elements(a_fac)                              
216   {                                               
217 #ifdef TOOLS_MEM                                  
218     mem::increment(s_class().c_str());            
219 #endif                                            
220   }                                               
221   virtual ~streamer_info(){                       
222 #ifdef TOOLS_MEM                                  
223     mem::decrement(s_class().c_str());            
224 #endif                                            
225   }                                               
226 protected:                                        
227   streamer_info(const streamer_info& a_from)      
228   :iro(a_from)                                    
229   ,m_fac(a_from.m_fac)                            
230   ,m_name(a_from.m_name)                          
231   ,m_title(a_from.m_name)                         
232   ,m_check_sum(a_from.m_check_sum)                
233   ,m_streamed_class_version(a_from.m_streamed_    
234   ,m_elements(a_from.m_elements)                  
235   {                                               
236 #ifdef TOOLS_MEM                                  
237     mem::increment(s_class().c_str());            
238 #endif                                            
239   }                                               
240   streamer_info& operator=(const streamer_info    
241     m_name = a_from.m_name;                       
242     m_title = a_from.m_name;                      
243     m_check_sum = a_from.m_check_sum;             
244     m_streamed_class_version = a_from.m_stream    
245     m_elements = a_from.m_elements;               
246     return *this;                                 
247   }                                               
248 public:                                           
249   const std::string& name() const {return m_na    
250   streamer_element* find_streamer_element(size    
251     if(a_index>=m_elements.size()) return 0;      
252     return m_elements[a_index];                   
253   }                                               
254 protected:                                        
255   ifac& m_fac;                                    
256 protected: //Named                                
257   std::string m_name;                             
258   std::string m_title;                            
259 protected:                                        
260   unsigned int m_check_sum;    //checksum of o    
261   int m_streamed_class_version; //Class versio    
262   //int fNumber;               //!Unique ident    
263   obj_array<streamer_element> m_elements; //Ar    
264 };                                                
265                                                   
266 }}                                                
267                                                   
268 #endif