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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/wroot/branch_element (Version 11.3.0) and /externals/g4tools/include/tools/wroot/branch_element (Version 11.0.p2)


  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_branch_element                  4 #ifndef tools_wroot_branch_element
  5 #define tools_wroot_branch_element                  5 #define tools_wroot_branch_element
  6                                                     6 
  7 #include "branch"                                   7 #include "branch"
  8                                                     8 
  9 namespace tools {                                   9 namespace tools {
 10 namespace wroot {                                  10 namespace wroot {
 11                                                    11 
 12 inline const std::string& branch_element_store     12 inline const std::string& branch_element_store_class() {
 13   static const std::string s_v("TBranchElement     13   static const std::string s_v("TBranchElement");
 14   return s_v;                                      14   return s_v;
 15 }                                                  15 }
 16                                                    16 
 17 class branch_element : public branch {             17 class branch_element : public branch {
 18   typedef branch parent;                           18   typedef branch parent;
 19 #ifdef TOOLS_MEM                                   19 #ifdef TOOLS_MEM
 20   static const std::string& s_class() {            20   static const std::string& s_class() {
 21     static const std::string s_v("tools::wroot     21     static const std::string s_v("tools::wroot::branch_element");
 22     return s_v;                                    22     return s_v;
 23   }                                                23   }
 24 #endif                                             24 #endif
 25 public: //ibo                                      25 public: //ibo
 26   virtual const std::string& store_cls() const     26   virtual const std::string& store_cls() const {return branch_element_store_class();}
 27   virtual bool stream(buffer& a_buffer) const      27   virtual bool stream(buffer& a_buffer) const {
 28     unsigned int c;                                28     unsigned int c;
 29     if(!a_buffer.write_version(1,c)) return fa     29     if(!a_buffer.write_version(1,c)) return false;
 30     if(!parent::stream(a_buffer)) return false     30     if(!parent::stream(a_buffer)) return false;
 31                                                    31 
 32     if(!a_buffer.write(fClassName)) return fal     32     if(!a_buffer.write(fClassName)) return false;
 33     if(!a_buffer.write(fClassVersion)) return      33     if(!a_buffer.write(fClassVersion)) return false;
 34     if(!a_buffer.write(fID)) return false;         34     if(!a_buffer.write(fID)) return false;
 35     if(!a_buffer.write(fType)) return false;       35     if(!a_buffer.write(fType)) return false;
 36     if(!a_buffer.write(fStreamerType)) return      36     if(!a_buffer.write(fStreamerType)) return false;
 37                                                    37 
 38     if(!a_buffer.set_byte_count(c)) return fal     38     if(!a_buffer.set_byte_count(c)) return false;
 39     return true;                                   39     return true;
 40   }                                                40   }
 41                                                    41 
 42 public:                                            42 public:
 43   branch_element(std::ostream& a_out,bool a_by     43   branch_element(std::ostream& a_out,bool a_byte_swap,uint32 a_compression,
 44                  seek a_seek_directory,const s     44                  seek a_seek_directory,const std::string& a_name,const std::string& a_title,bool a_verbose)
 45   :parent(a_out,a_byte_swap,a_compression,a_se     45   :parent(a_out,a_byte_swap,a_compression,a_seek_directory,a_name,a_title,a_verbose)
 46   ,fClassVersion(0)                                46   ,fClassVersion(0)
 47   ,fID(0)                                          47   ,fID(0)
 48   ,fType(0)                                        48   ,fType(0)
 49   ,fStreamerType(-1)                               49   ,fStreamerType(-1)
 50   {                                                50   {
 51 #ifdef TOOLS_MEM                                   51 #ifdef TOOLS_MEM
 52     mem::increment(s_class().c_str());             52     mem::increment(s_class().c_str());
 53 #endif                                             53 #endif
 54   }                                                54   }
 55   virtual ~branch_element(){                       55   virtual ~branch_element(){
 56 #ifdef TOOLS_MEM                                   56 #ifdef TOOLS_MEM
 57     mem::decrement(s_class().c_str());             57     mem::decrement(s_class().c_str());
 58 #endif                                             58 #endif
 59   }                                                59   }
 60 protected:                                         60 protected:
 61   branch_element(const branch_element& a_from)     61   branch_element(const branch_element& a_from):ibo(a_from),parent(a_from) {}
 62   branch_element& operator=(const branch_eleme     62   branch_element& operator=(const branch_element& a_from){parent::operator=(a_from);return *this;}
 63 public:                                            63 public:
 64   leaf_element* create_leaf_element(const std:     64   leaf_element* create_leaf_element(const std::string& a_name){
 65     leaf_element* lf = new leaf_element(m_out,     65     leaf_element* lf = new leaf_element(m_out,a_name,fID,fType);
 66     m_leaves.push_back(lf);                        66     m_leaves.push_back(lf);
 67     return lf;                                     67     return lf;
 68   }                                                68   }
 69 protected:                                         69 protected:
 70   virtual bool fill_leaves(buffer&) {return fa     70   virtual bool fill_leaves(buffer&) {return false;} //must be derived.
 71 protected:                                         71 protected:
 72   std::string fClassName; //Class name of refe     72   std::string fClassName; //Class name of referenced object
 73   int fClassVersion;      //Version number of      73   int fClassVersion;      //Version number of class
 74   int fID;                //element serial num     74   int fID;                //element serial number in fInfo
 75   int fType;              //branch type            75   int fType;              //branch type
 76   int fStreamerType;      //branch streamer ty     76   int fStreamerType;      //branch streamer type
 77 };                                                 77 };
 78                                                    78 
 79 template <class T>                                 79 template <class T>
 80 class std_vector_be_ref : public branch_elemen     80 class std_vector_be_ref : public branch_element {
 81   typedef branch_element parent;                   81   typedef branch_element parent;
 82 #ifdef TOOLS_MEM                                   82 #ifdef TOOLS_MEM
 83   static const std::string& s_class() {            83   static const std::string& s_class() {
 84     static const std::string s_v("tools::wroot     84     static const std::string s_v("tools::wroot::std_vector_be_ref");
 85     return s_v;                                    85     return s_v;
 86   }                                                86   }
 87 #endif                                             87 #endif
 88 public:                                            88 public:
 89   std_vector_be_ref(std::ostream& a_out,bool a     89   std_vector_be_ref(std::ostream& a_out,bool a_byte_swap,uint32 a_compression,
 90                     seek a_seek_directory,         90                     seek a_seek_directory,
 91                     const std::string& a_name,     91                     const std::string& a_name,const std::string& a_title,const std::vector<T>& a_ref,bool a_verbose)
 92   :parent(a_out,a_byte_swap,a_compression,a_se     92   :parent(a_out,a_byte_swap,a_compression,a_seek_directory,a_name,a_title,a_verbose)
 93   ,m_ref(a_ref)                                    93   ,m_ref(a_ref)
 94   {                                                94   {
 95 #ifdef TOOLS_MEM                                   95 #ifdef TOOLS_MEM
 96     mem::increment(s_class().c_str());             96     mem::increment(s_class().c_str());
 97 #endif                                             97 #endif
 98     fClassName = "vector<"+stype(T())+">";         98     fClassName = "vector<"+stype(T())+">";
 99     fClassVersion = 0;                             99     fClassVersion = 0;
100     fID = -1;                                     100     fID = -1;
101     fType = 0;                                    101     fType = 0;
102     fStreamerType  = -1; // TStreamerInfo::kST    102     fStreamerType  = -1; // TStreamerInfo::kSTLp;
103   }                                               103   }
104   virtual ~std_vector_be_ref(){                   104   virtual ~std_vector_be_ref(){
105 #ifdef TOOLS_MEM                                  105 #ifdef TOOLS_MEM
106     mem::decrement(s_class().c_str());            106     mem::decrement(s_class().c_str());
107 #endif                                            107 #endif
108   }                                               108   }
109 protected:                                        109 protected:
110   std_vector_be_ref(const std_vector_be_ref& a    110   std_vector_be_ref(const std_vector_be_ref& a_from)
111   :ibo(a_from)                                    111   :ibo(a_from)
112   ,parent(a_from)                                 112   ,parent(a_from)
113   ,m_ref(a_from.m_ref)                            113   ,m_ref(a_from.m_ref)
114   {}                                              114   {}
115   std_vector_be_ref& operator=(const std_vecto    115   std_vector_be_ref& operator=(const std_vector_be_ref& a_from){
116     parent::operator=(a_from);                    116     parent::operator=(a_from);
117     return *this;                                 117     return *this;
118   }                                               118   }
119 protected:                                        119 protected:
120   virtual bool fill_leaves(buffer& a_buffer) {    120   virtual bool fill_leaves(buffer& a_buffer) {
121     unsigned int c;                               121     unsigned int c;
122     if(!a_buffer.write_version(4,c)) return fa    122     if(!a_buffer.write_version(4,c)) return false;
123     if(!a_buffer.write((int)m_ref.size())) ret    123     if(!a_buffer.write((int)m_ref.size())) return false;
124     if(m_ref.size()) {                            124     if(m_ref.size()) {
125       // The awfull below is to pass T=bool :     125       // The awfull below is to pass T=bool :
126       const T& vr = m_ref[0];                     126       const T& vr = m_ref[0];
127       if(!a_buffer.write_fast_array(&vr,(int)m    127       if(!a_buffer.write_fast_array(&vr,(int)m_ref.size())) return false;
128     }                                             128     }
129     if(!a_buffer.set_byte_count(c)) return fal    129     if(!a_buffer.set_byte_count(c)) return false;
130     return true;                                  130     return true;
131   }                                               131   }
132 public:                                           132 public:
133   const std::vector<T>& variable() const {retu    133   const std::vector<T>& variable() const {return m_ref;}
134   std::vector<T>& variable() {return const_cas    134   std::vector<T>& variable() {return const_cast< std::vector<T>& >(m_ref);}
135 protected:                                        135 protected:
136   const std::vector<T>& m_ref;                    136   const std::vector<T>& m_ref;
137 };                                                137 };
138                                                   138 
139 template <class T>                                139 template <class T>
140 class std_vector_be : public std_vector_be_ref    140 class std_vector_be : public std_vector_be_ref<T> {
141   typedef std_vector_be_ref<T> parent;            141   typedef std_vector_be_ref<T> parent;
142 #ifdef TOOLS_MEM                                  142 #ifdef TOOLS_MEM
143   static const std::string& s_class() {           143   static const std::string& s_class() {
144     static const std::string s_v("tools::wroot    144     static const std::string s_v("tools::wroot::std_vector_be");
145     return s_v;                                   145     return s_v;
146   }                                               146   }
147 #endif                                            147 #endif
148 public:                                           148 public:
149   std_vector_be(std::ostream& a_out,bool a_byt    149   std_vector_be(std::ostream& a_out,bool a_byte_swap,uint32 a_compression,
150                 seek a_seek_directory,            150                 seek a_seek_directory,
151                 const std::string& a_name,cons    151                 const std::string& a_name,const std::string& a_title,const std::vector<T>& a_def,bool a_verbose)
152   :parent(a_out,a_byte_swap,a_compression,a_se    152   :parent(a_out,a_byte_swap,a_compression,a_seek_directory,a_name,a_title,m_value,a_verbose)
153   ,m_def(a_def),m_value(a_def)                    153   ,m_def(a_def),m_value(a_def)
154   {                                               154   {
155 #ifdef TOOLS_MEM                                  155 #ifdef TOOLS_MEM
156     mem::increment(s_class().c_str());            156     mem::increment(s_class().c_str());
157 #endif                                            157 #endif
158   }                                               158   }
159   virtual ~std_vector_be(){                       159   virtual ~std_vector_be(){
160 #ifdef TOOLS_MEM                                  160 #ifdef TOOLS_MEM
161     mem::decrement(s_class().c_str());            161     mem::decrement(s_class().c_str());
162 #endif                                            162 #endif
163   }                                               163   }
164 protected:                                        164 protected:
165   std_vector_be(const std_vector_be& a_from)      165   std_vector_be(const std_vector_be& a_from)
166   :ibo(a_from)                                    166   :ibo(a_from)
167   ,parent(a_from)                                 167   ,parent(a_from)
168   ,m_def(a_from.m_def)                            168   ,m_def(a_from.m_def)
169   ,m_value(a_from.m_value)                        169   ,m_value(a_from.m_value)
170   {}                                              170   {}
171   std_vector_be& operator=(const std_vector_be    171   std_vector_be& operator=(const std_vector_be& a_from){
172     parent::operator=(a_from);                    172     parent::operator=(a_from);
173     m_def = a_from.m_def;                         173     m_def = a_from.m_def;
174     m_value = a_from.m_value;                     174     m_value = a_from.m_value;
175     return *this;                                 175     return *this;
176   }                                               176   }
177 protected:                                        177 protected:
178   std::vector<T> m_def;                           178   std::vector<T> m_def;
179   std::vector<T> m_value;                         179   std::vector<T> m_value;
180 };                                                180 };
181                                                   181 
182 template <class T>                                182 template <class T>
183 class std_vector_be_pointer : public branch_el    183 class std_vector_be_pointer : public branch_element {
184   typedef branch_element parent;                  184   typedef branch_element parent;
185 #ifdef TOOLS_MEM                                  185 #ifdef TOOLS_MEM
186   static const std::string& s_class() {           186   static const std::string& s_class() {
187     static const std::string s_v("tools::wroot    187     static const std::string s_v("tools::wroot::std_vector_be_pointer");
188     return s_v;                                   188     return s_v;
189   }                                               189   }
190 #endif                                            190 #endif
191 public:                                           191 public:
192   std_vector_be_pointer(std::ostream& a_out,bo    192   std_vector_be_pointer(std::ostream& a_out,bool a_byte_swap,uint32 a_compression,
193                     seek a_seek_directory,        193                     seek a_seek_directory,
194                     const std::string& a_name,    194                     const std::string& a_name,const std::string& a_title,std::vector<T>* a_pointer,bool a_verbose)
195   :parent(a_out,a_byte_swap,a_compression,a_se    195   :parent(a_out,a_byte_swap,a_compression,a_seek_directory,a_name,a_title,a_verbose)
196   ,m_pointer(a_pointer)                           196   ,m_pointer(a_pointer)
197   {                                               197   {
198 #ifdef TOOLS_MEM                                  198 #ifdef TOOLS_MEM
199     mem::increment(s_class().c_str());            199     mem::increment(s_class().c_str());
200 #endif                                            200 #endif
201     fClassName = "vector<"+stype(T())+">";        201     fClassName = "vector<"+stype(T())+">";
202     fClassVersion = 0;                            202     fClassVersion = 0;
203     fID = -1;                                     203     fID = -1;
204     fType = 0;                                    204     fType = 0;
205     fStreamerType  = -1; // TStreamerInfo::kST    205     fStreamerType  = -1; // TStreamerInfo::kSTLp;
206   }                                               206   }
207   virtual ~std_vector_be_pointer(){               207   virtual ~std_vector_be_pointer(){
208 #ifdef TOOLS_MEM                                  208 #ifdef TOOLS_MEM
209     mem::decrement(s_class().c_str());            209     mem::decrement(s_class().c_str());
210 #endif                                            210 #endif
211   }                                               211   }
212 protected:                                        212 protected:
213   std_vector_be_pointer(const std_vector_be_po    213   std_vector_be_pointer(const std_vector_be_pointer& a_from)
214   :ibo(a_from)                                    214   :ibo(a_from)
215   ,parent(a_from)                                 215   ,parent(a_from)
216   ,m_pointer(a_from.m_pointer)                    216   ,m_pointer(a_from.m_pointer)
217   {}                                              217   {}
218   std_vector_be_pointer& operator=(const std_v    218   std_vector_be_pointer& operator=(const std_vector_be_pointer& a_from){
219     parent::operator=(a_from);                    219     parent::operator=(a_from);
220     return *this;                                 220     return *this;
221   }                                               221   }
222 protected:                                        222 protected:
223   virtual bool fill_leaves(buffer& a_buffer) {    223   virtual bool fill_leaves(buffer& a_buffer) {
224     if(!m_pointer) return false;                  224     if(!m_pointer) return false;
225     unsigned int c;                               225     unsigned int c;
226     if(!a_buffer.write_version(4,c)) return fa    226     if(!a_buffer.write_version(4,c)) return false;
227     if(!a_buffer.write((int)m_pointer->size())    227     if(!a_buffer.write((int)m_pointer->size())) return false;
228     if(m_pointer->size()) {                       228     if(m_pointer->size()) {
229       // The awfull below is to pass T=bool :     229       // The awfull below is to pass T=bool :
230       T& vr = (*m_pointer)[0];                    230       T& vr = (*m_pointer)[0];
231       if(!a_buffer.write_fast_array(&vr,(int)m    231       if(!a_buffer.write_fast_array(&vr,(int)m_pointer->size())) return false;
232     }                                             232     }
233     if(!a_buffer.set_byte_count(c)) return fal    233     if(!a_buffer.set_byte_count(c)) return false;
234     return true;                                  234     return true;
235   }                                               235   }
236 public:                                           236 public:
237   void set_pointer(std::vector<T>* a_pointer)     237   void set_pointer(std::vector<T>* a_pointer) {m_pointer = a_pointer;}
238   const std::vector<T>* get_pointer() const {r    238   const std::vector<T>* get_pointer() const {return m_pointer;}
239   std::vector<T>* get_pointer() {return m_poin    239   std::vector<T>* get_pointer() {return m_pointer;}
240 protected:                                        240 protected:
241   std::vector<T>* m_pointer;                      241   std::vector<T>* m_pointer;
242 };                                                242 };
243                                                   243 
244 }}                                                244 }}
245                                                   245 
246 #endif                                            246 #endif