Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/externals/g4tools/include/tools/store/osc_streamers

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 10.5 ] [ 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/store/osc_streamers (Version 11.3.0) and /externals/g4tools/include/tools/store/osc_streamers (Version 11.1.3)


  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_store_osc_streamers                   4 #ifndef tools_store_osc_streamers
  5 #define tools_store_osc_streamers                   5 #define tools_store_osc_streamers
  6                                                     6 
  7 #include "iobj_const_visitor"                       7 #include "iobj_const_visitor"
  8 #include "iobj_visitor"                             8 #include "iobj_visitor"
  9                                                     9 
 10 #include "../histo/h1d"                            10 #include "../histo/h1d"
 11 #include "../histo/h2d"                            11 #include "../histo/h2d"
 12 #include "../histo/h3d"                            12 #include "../histo/h3d"
 13 #include "../histo/p1d"                            13 #include "../histo/p1d"
 14 #include "../histo/p2d"                            14 #include "../histo/p2d"
 15 #include "../vmanip"                               15 #include "../vmanip"
 16 #include "../sto"                                  16 #include "../sto"
 17 #include "../num2s"                                17 #include "../num2s"
 18 #include "../S_STRING"                             18 #include "../S_STRING"
 19 #include "../scast"                                19 #include "../scast"
 20                                                    20 
 21 namespace tools {                                  21 namespace tools {
 22 namespace osc {                                    22 namespace osc {
 23                                                    23 
 24 inline const std::string& s_axis() {               24 inline const std::string& s_axis() {
 25   static const std::string s_v("BatchLab::Axis     25   static const std::string s_v("BatchLab::Axis");
 26   return s_v;                                      26   return s_v;
 27 }                                                  27 }
 28 inline const std::string& s_annotation() {         28 inline const std::string& s_annotation() {
 29   static const std::string s_v("BatchLab::Anno     29   static const std::string s_v("BatchLab::Annotation");
 30   return s_v;                                      30   return s_v;
 31 }                                                  31 }
 32 inline const std::string& s_base_histogram() {     32 inline const std::string& s_base_histogram() {
 33   static const std::string s_v("BatchLab::Base     33   static const std::string s_v("BatchLab::BaseHistogram");
 34   return s_v;                                      34   return s_v;
 35 }                                                  35 }
 36 inline const std::string& s_item() {               36 inline const std::string& s_item() {
 37   static const std::string s_v("BatchLab::Item     37   static const std::string s_v("BatchLab::Item");
 38   return s_v;                                      38   return s_v;
 39 }                                                  39 }
 40                                                    40 
 41 inline const std::string& s_h1d() {                41 inline const std::string& s_h1d() {
 42   static const std::string s_v("BatchLab::Hist     42   static const std::string s_v("BatchLab::Histogram1D");
 43   return s_v;                                      43   return s_v;
 44 }                                                  44 }
 45                                                    45 
 46 inline const std::string& s_h2d() {                46 inline const std::string& s_h2d() {
 47   static const std::string s_v("BatchLab::Hist     47   static const std::string s_v("BatchLab::Histogram2D");
 48   return s_v;                                      48   return s_v;
 49 }                                                  49 }
 50                                                    50 
 51 inline const std::string& s_h3d() {                51 inline const std::string& s_h3d() {
 52   static const std::string s_v("BatchLab::Hist     52   static const std::string s_v("BatchLab::Histogram3D");
 53   return s_v;                                      53   return s_v;
 54 }                                                  54 }
 55                                                    55 
 56 inline const std::string& s_p1d() {                56 inline const std::string& s_p1d() {
 57   static const std::string s_v("BatchLab::Prof     57   static const std::string s_v("BatchLab::Profile1D");
 58   return s_v;                                      58   return s_v;
 59 }                                                  59 }
 60                                                    60 
 61 inline const std::string& s_p2d() {                61 inline const std::string& s_p2d() {
 62   static const std::string s_v("BatchLab::Prof     62   static const std::string s_v("BatchLab::Profile2D");
 63   return s_v;                                      63   return s_v;
 64 }                                                  64 }
 65                                                    65 
 66 class Axis : public virtual istorable {            66 class Axis : public virtual istorable {
 67 public:                                            67 public:
 68   TOOLS_SCLASS(tools::osc::Axis)                   68   TOOLS_SCLASS(tools::osc::Axis)
 69 protected:                                         69 protected:
 70   virtual void* cast(const std::string& a_clas     70   virtual void* cast(const std::string& a_class) const {
 71     if(void* p = cmp_cast<Axis>(this,a_class))     71     if(void* p = cmp_cast<Axis>(this,a_class)) return p;
 72     return 0;                                      72     return 0;
 73   }                                                73   }
 74   virtual const std::string& store_cls() const     74   virtual const std::string& store_cls() const {return s_axis();}
 75   virtual bool visit(iobj_const_visitor& a_v)      75   virtual bool visit(iobj_const_visitor& a_v) const {
 76     if(!a_v.begin(*this,s_axis(),Axis::s_visit     76     if(!a_v.begin(*this,s_axis(),Axis::s_visit)) return false;
 77                                                    77 
 78     int version = 1;                               78     int version = 1;
 79     if(!a_v.visit("fVersion",version)) return      79     if(!a_v.visit("fVersion",version)) return false;
 80                                                    80 
 81     if(!a_v.visit("fOffset",m_axis.m_offset))      81     if(!a_v.visit("fOffset",m_axis.m_offset)) return false;
 82     if(!a_v.visit("fNumberOfBins",(int)m_axis.     82     if(!a_v.visit("fNumberOfBins",(int)m_axis.m_number_of_bins)) return false;
 83     if(!a_v.visit("fMinimumValue",m_axis.m_min     83     if(!a_v.visit("fMinimumValue",m_axis.m_minimum_value)) return false;
 84     if(!a_v.visit("fMaximumValue",m_axis.m_max     84     if(!a_v.visit("fMaximumValue",m_axis.m_maximum_value)) return false;
 85     if(!a_v.visit("fFixed",m_axis.m_fixed)) re     85     if(!a_v.visit("fFixed",m_axis.m_fixed)) return false;
 86     if(!a_v.visit("fBinWidth",m_axis.m_bin_wid     86     if(!a_v.visit("fBinWidth",m_axis.m_bin_width)) return false;
 87     if(!a_v.visit("fEdges",m_axis.m_edges)) re     87     if(!a_v.visit("fEdges",m_axis.m_edges)) return false;
 88                                                    88 
 89     if(!a_v.end(*this)) return false;              89     if(!a_v.end(*this)) return false;
 90     return true;                                   90     return true;
 91   }                                                91   }
 92   static bool s_visit(const istorable& a_o,iob     92   static bool s_visit(const istorable& a_o,iobj_const_visitor& a_v){
 93     const Axis* local = safe_cast<istorable,Ax     93     const Axis* local = safe_cast<istorable,Axis>(a_o);
 94     if(!local) return false;                       94     if(!local) return false;
 95     return local->Axis::visit(a_v); //IMPORTAN     95     return local->Axis::visit(a_v); //IMPORTANT : have Axis::
 96   }                                                96   }
 97 public:                                            97 public:
 98   Axis(const histo::axis<double,unsigned int>&     98   Axis(const histo::axis<double,unsigned int>& a_axis):m_axis(a_axis){}
 99   virtual ~Axis(){}                                99   virtual ~Axis(){}
100 private:                                          100 private:
101   Axis(const Axis& a_from):istorable(a_from),m    101   Axis(const Axis& a_from):istorable(a_from),m_axis(a_from.m_axis){}
102   Axis& operator=(const Axis&){return *this;}     102   Axis& operator=(const Axis&){return *this;}
103 protected:                                        103 protected:
104   const histo::axis<double,unsigned int>& m_ax    104   const histo::axis<double,unsigned int>& m_axis;
105 };                                                105 };
106                                                   106 
107                                                   107 
108 inline bool Axis_read(iobj_visitor& a_visitor,    108 inline bool Axis_read(iobj_visitor& a_visitor,histo::axis<double,unsigned int>& a_axis){
109   //if(!a_visitor.begin(*this)) return false;     109   //if(!a_visitor.begin(*this)) return false;
110                                                   110 
111   int version;                                    111   int version;
112   if(!a_visitor.visit(version)) return false;     112   if(!a_visitor.visit(version)) return false;
113                                                   113 
114   if(!a_visitor.visit(a_axis.m_offset)) return    114   if(!a_visitor.visit(a_axis.m_offset)) return false;
115                                                   115 
116  {int nbin;                                       116  {int nbin;
117   if(!a_visitor.visit(nbin)) return false;        117   if(!a_visitor.visit(nbin)) return false;
118   a_axis.m_number_of_bins = nbin;}                118   a_axis.m_number_of_bins = nbin;}
119                                                   119 
120   if(!a_visitor.visit(a_axis.m_minimum_value))    120   if(!a_visitor.visit(a_axis.m_minimum_value)) return false;
121   if(!a_visitor.visit(a_axis.m_maximum_value))    121   if(!a_visitor.visit(a_axis.m_maximum_value)) return false;
122   if(!a_visitor.visit(a_axis.m_fixed)) return     122   if(!a_visitor.visit(a_axis.m_fixed)) return false;
123   if(!a_visitor.visit(a_axis.m_bin_width)) ret    123   if(!a_visitor.visit(a_axis.m_bin_width)) return false;
124   if(!a_visitor.visit(a_axis.m_edges)) return     124   if(!a_visitor.visit(a_axis.m_edges)) return false;
125                                                   125 
126   //if(!a_visitor.end(*this)) return false;       126   //if(!a_visitor.end(*this)) return false;
127   return true;                                    127   return true;
128 }                                                 128 }
129                                                   129 
130 class Item : public virtual istorable {           130 class Item : public virtual istorable {
131 public:                                           131 public:
132   TOOLS_SCLASS(tools::osc::Item)                  132   TOOLS_SCLASS(tools::osc::Item)
133 protected:                                        133 protected:
134   virtual void* cast(const std::string& a_clas    134   virtual void* cast(const std::string& a_class) const {
135     if(void* p = cmp_cast<Item>(this,a_class))    135     if(void* p = cmp_cast<Item>(this,a_class)) return p;
136     return 0;                                     136     return 0;
137   }                                               137   }
138 public:                                           138 public:
139   virtual const std::string& store_cls() const    139   virtual const std::string& store_cls() const {return s_item();}
140   virtual bool visit(iobj_const_visitor& a_vis    140   virtual bool visit(iobj_const_visitor& a_visitor) const {
141     if(!a_visitor.begin(*this,s_item(),Item::s    141     if(!a_visitor.begin(*this,s_item(),Item::s_visit)) return false;
142                                                   142 
143     int version = 1;                              143     int version = 1;
144     if(!a_visitor.visit("fVersion",version)) r    144     if(!a_visitor.visit("fVersion",version)) return false;
145                                                   145 
146     if(!a_visitor.visit("fKey",fKey)) return f    146     if(!a_visitor.visit("fKey",fKey)) return false;
147     if(!a_visitor.visit("fValue",fValue)) retu    147     if(!a_visitor.visit("fValue",fValue)) return false;
148     if(!a_visitor.visit("fSticky",fSticky)) re    148     if(!a_visitor.visit("fSticky",fSticky)) return false;
149                                                   149 
150     if(!a_visitor.end(*this)) return false;       150     if(!a_visitor.end(*this)) return false;
151     return true;                                  151     return true;
152   }                                               152   }
153   static bool s_visit(const istorable& a_o,iob    153   static bool s_visit(const istorable& a_o,iobj_const_visitor& a_v){
154     const Item* local = safe_cast<istorable,It    154     const Item* local = safe_cast<istorable,Item>(a_o);
155     if(!local) return false;                      155     if(!local) return false;
156     return local->Item::visit(a_v); //IMPORTAN    156     return local->Item::visit(a_v); //IMPORTANT : have Item::
157   }                                               157   }
158 public:                                           158 public:
159   virtual bool read(iobj_visitor& a_visitor) {    159   virtual bool read(iobj_visitor& a_visitor) {
160     //if(!a_visitor.begin(*this)) return false    160     //if(!a_visitor.begin(*this)) return false;
161                                                   161 
162     int version;                                  162     int version;
163     if(!a_visitor.visit(version)) return false    163     if(!a_visitor.visit(version)) return false;
164                                                   164 
165     if(!a_visitor.visit(fKey)) return false;      165     if(!a_visitor.visit(fKey)) return false;
166     if(!a_visitor.visit(fValue)) return false;    166     if(!a_visitor.visit(fValue)) return false;
167     if(!a_visitor.visit(fSticky)) return false    167     if(!a_visitor.visit(fSticky)) return false;
168                                                   168 
169     //if(!a_visitor.end(*this)) return false;     169     //if(!a_visitor.end(*this)) return false;
170     return true;                                  170     return true;
171   }                                               171   }
172 public:                                           172 public:
173   Item(){}                                        173   Item(){}
174   Item(const std::string& aKey,const std::stri    174   Item(const std::string& aKey,const std::string& aValue,bool aSticky)
175   :fKey(aKey),fValue(aValue),fSticky(aSticky){    175   :fKey(aKey),fValue(aValue),fSticky(aSticky){}
176   virtual ~Item(){}                               176   virtual ~Item(){}
177 public:                                           177 public:
178   Item(const Item& a_from)                        178   Item(const Item& a_from)
179   :istorable(a_from)                              179   :istorable(a_from)
180   ,fKey(a_from.fKey)                              180   ,fKey(a_from.fKey)
181   ,fValue(a_from.fValue)                          181   ,fValue(a_from.fValue)
182   ,fSticky(a_from.fSticky)                        182   ,fSticky(a_from.fSticky)
183   {}                                              183   {}
184   Item& operator=(const Item& a_from) {           184   Item& operator=(const Item& a_from) {
185     if(&a_from==this) return *this;               185     if(&a_from==this) return *this;
186     fKey = a_from.fKey;                           186     fKey = a_from.fKey;
187     fValue = a_from.fValue;                       187     fValue = a_from.fValue;
188     fSticky = a_from.fSticky;                     188     fSticky = a_from.fSticky;
189     return *this;                                 189     return *this;
190   }                                               190   }
191 public:                                           191 public:
192   std::string fKey;                               192   std::string fKey;
193   std::string fValue;                             193   std::string fValue;
194   bool fSticky;                                   194   bool fSticky;
195 };                                                195 };
196                                                   196 
197                                                   197 
198 template <class T>                                198 template <class T>
199 class Vector : public virtual istorable {         199 class Vector : public virtual istorable {
200 public:                                           200 public:
201   TOOLS_T_SCLASS(T,tools::osc::Vector)            201   TOOLS_T_SCLASS(T,tools::osc::Vector)
202 protected:                                        202 protected:
203   virtual void* cast(const std::string& a_clas    203   virtual void* cast(const std::string& a_class) const {
204     if(void* p = cmp_cast<Vector>(this,a_class    204     if(void* p = cmp_cast<Vector>(this,a_class)) return p;
205     return 0;                                     205     return 0;
206   }                                               206   }
207   virtual const std::string& store_cls() const    207   virtual const std::string& store_cls() const {
208     static const std::string s_v("BatchLab::Ve    208     static const std::string s_v("BatchLab::Vector<"+m_T+">");
209     return s_v;                                   209     return s_v;
210   }                                               210   }
211   virtual bool visit(iobj_const_visitor& a_v)     211   virtual bool visit(iobj_const_visitor& a_v) const {
212     if(!a_v.begin(*this,Vector<T>::store_cls()    212     if(!a_v.begin(*this,Vector<T>::store_cls(),Vector<T>::s_visit)) return false;
213                                                   213 
214     int version = 1;                              214     int version = 1;
215     if(!a_v.visit("fVersion",version)) return     215     if(!a_v.visit("fVersion",version)) return false;
216                                                   216 
217     unsigned int number = (unsigned int)m_vec.    217     unsigned int number = (unsigned int)m_vec.size();
218     if(!a_v.visit("fSize",number)) return fals    218     if(!a_v.visit("fSize",number)) return false;
219                                                   219 
220     std::string stmp;                             220     std::string stmp;
221     for(unsigned int index=0;index<number;inde    221     for(unsigned int index=0;index<number;index++) {
222       const T& elem = m_vec[index];               222       const T& elem = m_vec[index];
223       if(!num2s(index,stmp)) return false;        223       if(!num2s(index,stmp)) return false;
224       if(!a_v.visit(stmp,elem)) return false;     224       if(!a_v.visit(stmp,elem)) return false;
225     }                                             225     }
226                                                   226 
227     if(!a_v.end(*this)) return false;             227     if(!a_v.end(*this)) return false;
228     return true;                                  228     return true;
229   }                                               229   }
230   static bool s_visit(const istorable& a_o,iob    230   static bool s_visit(const istorable& a_o,iobj_const_visitor& a_v){
231     const Vector* local = safe_cast<istorable,    231     const Vector* local = safe_cast<istorable,Vector>(a_o);
232     if(!local) return false;                      232     if(!local) return false;
233     return local->Vector<T>::visit(a_v); //IMP    233     return local->Vector<T>::visit(a_v); //IMPORTANT : have Vector::
234   }                                               234   }
235 public:                                           235 public:
236   Vector(const std::vector<T>& a_vec,const std    236   Vector(const std::vector<T>& a_vec,const std::string& a_T)
237   :m_vec(a_vec),m_T(a_T){}                        237   :m_vec(a_vec),m_T(a_T){}
238   virtual ~Vector(){}                             238   virtual ~Vector(){}
239 private:                                          239 private:
240   Vector(const Vector& a_from)                    240   Vector(const Vector& a_from)
241   :istorable(a_from),m_vec(a_from.m_vec),m_T(a    241   :istorable(a_from),m_vec(a_from.m_vec),m_T(a_from.m_T){}
242   Vector& operator=(const Vector&){return *thi    242   Vector& operator=(const Vector&){return *this;}
243 protected:                                        243 protected:
244   const std::vector<T>& m_vec;                    244   const std::vector<T>& m_vec;
245   std::string m_T;                                245   std::string m_T;
246 };                                                246 };
247                                                   247 
248                                                   248 
249 template <class T>                                249 template <class T>
250 inline bool std_vector_read(iobj_visitor& a_vi    250 inline bool std_vector_read(iobj_visitor& a_visitor,std::vector<T>& a_vec) {
251   a_vec.clear();                                  251   a_vec.clear();
252                                                   252 
253   //if(!a_visitor.begin(*this)) return false;     253   //if(!a_visitor.begin(*this)) return false;
254                                                   254 
255   int version;                                    255   int version;
256   if(!a_visitor.visit(version)) return false;     256   if(!a_visitor.visit(version)) return false;
257                                                   257 
258   unsigned int number;                            258   unsigned int number;
259   if(!a_visitor.visit(number)) return false;      259   if(!a_visitor.visit(number)) return false;
260                                                   260 
261   a_vec.resize(number);                           261   a_vec.resize(number);
262   for(unsigned int index=0;index<number;index+    262   for(unsigned int index=0;index<number;index++) {
263     T& elem = a_vec[index];                       263     T& elem = a_vec[index];
264     if(!elem.read(a_visitor)) return false;       264     if(!elem.read(a_visitor)) return false;
265   }                                               265   }
266                                                   266 
267   //if(!a_visitor.end(*this)) return false;       267   //if(!a_visitor.end(*this)) return false;
268   return true;                                    268   return true;
269 }                                                 269 }
270                                                   270 
271 class Annotation : public virtual istorable {     271 class Annotation : public virtual istorable {
272 public:                                           272 public:
273   TOOLS_SCLASS(tools::osc::Annotation)            273   TOOLS_SCLASS(tools::osc::Annotation)
274 protected:                                        274 protected:
275   virtual void* cast(const std::string& a_clas    275   virtual void* cast(const std::string& a_class) const {
276     if(void* p = cmp_cast<Annotation>(this,a_c    276     if(void* p = cmp_cast<Annotation>(this,a_class)) return p;
277     return 0;                                     277     return 0;
278   }                                               278   }
279   virtual const std::string& store_cls() const    279   virtual const std::string& store_cls() const {return s_annotation();}
280   virtual bool visit(iobj_const_visitor& a_v)     280   virtual bool visit(iobj_const_visitor& a_v) const {
281     if(!a_v.begin(*this,s_annotation(),Annotat    281     if(!a_v.begin(*this,s_annotation(),Annotation::s_visit)) return false;
282                                                   282 
283     int version = 1;                              283     int version = 1;
284     if(!a_v.visit("fVersion",version)) return     284     if(!a_v.visit("fVersion",version)) return false;
285                                                   285 
286     Vector<Item> v(m_items,s_item());             286     Vector<Item> v(m_items,s_item());
287     if(!a_v.visit("fItems",v)) return false;      287     if(!a_v.visit("fItems",v)) return false;
288                                                   288 
289     if(!a_v.end(*this)) return false;             289     if(!a_v.end(*this)) return false;
290     return true;                                  290     return true;
291   }                                               291   }
292   static bool s_visit(const istorable& a_o,iob    292   static bool s_visit(const istorable& a_o,iobj_const_visitor& a_v){
293     const Annotation* local = safe_cast<istora    293     const Annotation* local = safe_cast<istorable,Annotation>(a_o);
294     if(!local) return false;                      294     if(!local) return false;
295     return local->Annotation::visit(a_v); //IM    295     return local->Annotation::visit(a_v); //IMPORTANT : have Annotation::
296   }                                               296   }
297 public:                                           297 public:
298   Annotation(){}                                  298   Annotation(){}
299   virtual ~Annotation(){}                         299   virtual ~Annotation(){}
300 private:                                          300 private:
301   Annotation(const Annotation& a_from):istorab    301   Annotation(const Annotation& a_from):istorable(a_from){}
302   Annotation& operator=(const Annotation&){ret    302   Annotation& operator=(const Annotation&){return *this;}
303 public:                                           303 public:
304   std::vector<Item> m_items;                      304   std::vector<Item> m_items;
305 };                                                305 };
306                                                   306 
307 inline bool Annotation_read(iobj_visitor& a_vi    307 inline bool Annotation_read(iobj_visitor& a_visitor) {
308   //if(!a_visitor.begin(*this)) return false;     308   //if(!a_visitor.begin(*this)) return false;
309   int version;                                    309   int version;
310   if(!a_visitor.visit(version)) return false;     310   if(!a_visitor.visit(version)) return false;
311   std::vector<Item> fItems;                       311   std::vector<Item> fItems;
312   if(!std_vector_read<Item>(a_visitor,fItems))    312   if(!std_vector_read<Item>(a_visitor,fItems)) return false;
313   //if(!a_visitor.end(*this)) return false;       313   //if(!a_visitor.end(*this)) return false;
314   return true;                                    314   return true;
315 }                                                 315 }
316                                                   316 
317 inline void map2vec(const std::map<std::string    317 inline void map2vec(const std::map<std::string,std::string>& a_in,std::vector<Item>& a_out) {
318   a_out.clear();                                  318   a_out.clear();
319   std::map<std::string,std::string>::const_ite    319   std::map<std::string,std::string>::const_iterator it;
320   for(it=a_in.begin();it!=a_in.end();++it) {      320   for(it=a_in.begin();it!=a_in.end();++it) {
321     a_out.push_back(Item((*it).first,(*it).sec    321     a_out.push_back(Item((*it).first,(*it).second,false));
322   }                                               322   }
323 }                                                 323 }
324                                                   324 
325 typedef histo::histo_data<double,unsigned int,    325 typedef histo::histo_data<double,unsigned int,unsigned int,double> hd_data;
326                                                   326 
327 template <class HIST>                             327 template <class HIST>
328 class BaseHistogram : public virtual istorable    328 class BaseHistogram : public virtual istorable {
329 public:                                           329 public:
330   TOOLS_T_SCLASS(HIST,tools::osc::BaseHistogra    330   TOOLS_T_SCLASS(HIST,tools::osc::BaseHistogram)
331 protected:                                        331 protected:
332   virtual void* cast(const std::string& a_clas    332   virtual void* cast(const std::string& a_class) const {
333     if(void* p = cmp_cast<BaseHistogram>(this,    333     if(void* p = cmp_cast<BaseHistogram>(this,a_class)) return p;
334     return 0;                                     334     return 0;
335   }                                               335   }
336 public:                                           336 public:
337   virtual const std::string& store_cls() const    337   virtual const std::string& store_cls() const {return s_base_histogram();}
338   virtual bool visit(iobj_const_visitor& a_v)     338   virtual bool visit(iobj_const_visitor& a_v) const {
339     if(!a_v.begin(*this,s_base_histogram(),Bas    339     if(!a_v.begin(*this,s_base_histogram(),BaseHistogram::s_visit)) return false;
340                                                   340 
341     int version = 1;                              341     int version = 1;
342     if(!a_v.visit("fVersion",version)) return     342     if(!a_v.visit("fVersion",version)) return false;
343                                                   343 
344     Annotation ano;                               344     Annotation ano;
345     map2vec(m_hist.annotations(),ano.m_items);    345     map2vec(m_hist.annotations(),ano.m_items);
346     if(!a_v.visit("fAnnotation",ano)) return f    346     if(!a_v.visit("fAnnotation",ano)) return false;
347                                                   347 
348     if(!a_v.end(*this)) return false;             348     if(!a_v.end(*this)) return false;
349     return true;                                  349     return true;
350   }                                               350   }
351 protected:                                        351 protected:
352   static bool s_visit(const istorable& a_o,iob    352   static bool s_visit(const istorable& a_o,iobj_const_visitor& a_v){
353     const BaseHistogram* local =                  353     const BaseHistogram* local =
354       safe_cast<istorable,BaseHistogram>(a_o);    354       safe_cast<istorable,BaseHistogram>(a_o);
355     if(!local) return false;                      355     if(!local) return false;
356     return local->BaseHistogram::visit(a_v); /    356     return local->BaseHistogram::visit(a_v); //IMPORTANT : have BaseHistogram::
357   }                                               357   }
358 public:                                           358 public:
359   BaseHistogram(const HIST& a_hist):m_hist(a_h    359   BaseHistogram(const HIST& a_hist):m_hist(a_hist){}
360   virtual ~BaseHistogram(){}                      360   virtual ~BaseHistogram(){}
361 private:                                          361 private:
362   BaseHistogram(const BaseHistogram& a_from)      362   BaseHistogram(const BaseHistogram& a_from)
363   :istorable(a_from),m_hist(a_from.m_hist)        363   :istorable(a_from),m_hist(a_from.m_hist)
364   {}                                              364   {}
365   BaseHistogram& operator=(const BaseHistogram    365   BaseHistogram& operator=(const BaseHistogram&){return *this;}
366 protected:                                        366 protected:
367   const HIST& m_hist;                             367   const HIST& m_hist;
368 };                                                368 };
369                                                   369 
370 inline bool BaseHistogram_read(iobj_visitor& a    370 inline bool BaseHistogram_read(iobj_visitor& a_visitor){
371   //if(!a_visitor.begin(*this)) return false;     371   //if(!a_visitor.begin(*this)) return false;
372                                                   372 
373   int version;                                    373   int version;
374   if(!a_visitor.visit(version)) return false;     374   if(!a_visitor.visit(version)) return false;
375                                                   375 
376   if(!Annotation_read(a_visitor)) return false    376   if(!Annotation_read(a_visitor)) return false;
377                                                   377 
378   //if(!a_visitor.end(*this)) return false;       378   //if(!a_visitor.end(*this)) return false;
379   return true;                                    379   return true;
380 }                                                 380 }
381                                                   381 
382 template <class HIST>                             382 template <class HIST>
383 inline bool visitHistogram(const HIST& a_hist,    383 inline bool visitHistogram(const HIST& a_hist,iobj_const_visitor& a_visitor){
384   if(!a_visitor.visit("fTitle",a_hist.title())    384   if(!a_visitor.visit("fTitle",a_hist.title())) return false;
385   if(!a_visitor.visit("fDimension",(int)a_hist    385   if(!a_visitor.visit("fDimension",(int)a_hist.dimension())) return false;
386   if(!a_visitor.visit("fBinNumber",(int)a_hist    386   if(!a_visitor.visit("fBinNumber",(int)a_hist.get_bins())) return false;
387                                                   387 
388   std::vector<int> bins_entries;                  388   std::vector<int> bins_entries;
389   convert<unsigned int,int>(a_hist.bins_entrie    389   convert<unsigned int,int>(a_hist.bins_entries(),bins_entries);
390   if(!a_visitor.visit("fBinEntries",bins_entri    390   if(!a_visitor.visit("fBinEntries",bins_entries)) return false;
391                                                   391 
392   if(!a_visitor.visit("fBinSw",a_hist.bins_sum    392   if(!a_visitor.visit("fBinSw",a_hist.bins_sum_w())) return false;
393   if(!a_visitor.visit("fBinSw2",a_hist.bins_su    393   if(!a_visitor.visit("fBinSw2",a_hist.bins_sum_w2())) return false;
394   if(!a_visitor.visit("fBinSxw",a_hist.bins_su    394   if(!a_visitor.visit("fBinSxw",a_hist.bins_sum_xw())) return false;
395   if(!a_visitor.visit("fBinSx2w",a_hist.bins_s    395   if(!a_visitor.visit("fBinSx2w",a_hist.bins_sum_x2w())) return false;
396  {std::string name;                               396  {std::string name;
397   for(unsigned int iaxis=0;iaxis<a_hist.dimens    397   for(unsigned int iaxis=0;iaxis<a_hist.dimension();iaxis++) {
398     if(!num2s(iaxis,name)) return false;          398     if(!num2s(iaxis,name)) return false;
399     name = "fAxes_"+name;                         399     name = "fAxes_"+name;
400     Axis axis(a_hist.get_axis(iaxis));            400     Axis axis(a_hist.get_axis(iaxis));
401     if(!a_visitor.visit(name,axis)) return fal    401     if(!a_visitor.visit(name,axis)) return false;
402   }}                                              402   }}
403  {int dummy = 0;                                  403  {int dummy = 0;
404   if(!a_visitor.visit("fMode",dummy)) return f    404   if(!a_visitor.visit("fMode",dummy)) return false;} //m_mode
405   if(!a_visitor.visit("fProfile",false)) retur    405   if(!a_visitor.visit("fProfile",false)) return false;
406  {std::vector<double> dummy;                      406  {std::vector<double> dummy;
407   if(!a_visitor.visit("fBinSvw",dummy)) return    407   if(!a_visitor.visit("fBinSvw",dummy)) return false;
408   if(!a_visitor.visit("fBinSv2w",dummy)) retur    408   if(!a_visitor.visit("fBinSv2w",dummy)) return false;}
409   if(!a_visitor.visit("fCutV",false)) return f    409   if(!a_visitor.visit("fCutV",false)) return false;
410  {double dummy = 0;                               410  {double dummy = 0;
411   if(!a_visitor.visit("fMinV",dummy)) return f    411   if(!a_visitor.visit("fMinV",dummy)) return false;
412   if(!a_visitor.visit("fMaxV",dummy)) return f    412   if(!a_visitor.visit("fMaxV",dummy)) return false;}
413   // Not written :                                413   // Not written :
414   //a_hist.fDoubles                               414   //a_hist.fDoubles
415   //a_hist.fInts                                  415   //a_hist.fInts
416   return true;                                    416   return true;
417 }                                                 417 }
418                                                   418 
419 inline bool readHistogram(hd_data& aData,iobj_    419 inline bool readHistogram(hd_data& aData,iobj_visitor& a_visitor){
420   if(!a_visitor.visit(aData.m_title)) return f    420   if(!a_visitor.visit(aData.m_title)) return false;
421  {int dim;                                        421  {int dim;
422   if(!a_visitor.visit(dim)) return false;         422   if(!a_visitor.visit(dim)) return false;
423   aData.m_dimension = dim;}                       423   aData.m_dimension = dim;}
424                                                   424 
425  {int nbin;                                       425  {int nbin;
426   if(!a_visitor.visit(nbin)) return false;        426   if(!a_visitor.visit(nbin)) return false;
427   aData.m_bin_number = nbin;}                     427   aData.m_bin_number = nbin;}
428                                                   428 
429  {std::vector<int> vec;                           429  {std::vector<int> vec;
430   if(!a_visitor.visit(vec)) return false;         430   if(!a_visitor.visit(vec)) return false;
431   convert<int,unsigned int>(vec,aData.m_bin_en    431   convert<int,unsigned int>(vec,aData.m_bin_entries);}
432                                                   432 
433   if(!a_visitor.visit(aData.m_bin_Sw)) return     433   if(!a_visitor.visit(aData.m_bin_Sw)) return false;
434   if(!a_visitor.visit(aData.m_bin_Sw2)) return    434   if(!a_visitor.visit(aData.m_bin_Sw2)) return false;
435   if(!a_visitor.visit(aData.m_bin_Sxw)) return    435   if(!a_visitor.visit(aData.m_bin_Sxw)) return false;
436   if(!a_visitor.visit(aData.m_bin_Sx2w)) retur    436   if(!a_visitor.visit(aData.m_bin_Sx2w)) return false;
437   aData.m_axes.clear();                           437   aData.m_axes.clear();
438   for(unsigned int iaxis=0;iaxis<aData.m_dimen    438   for(unsigned int iaxis=0;iaxis<aData.m_dimension;iaxis++) {
439     histo::axis<double,unsigned int> baxis;       439     histo::axis<double,unsigned int> baxis;
440     if(!Axis_read(a_visitor,baxis)) return fal    440     if(!Axis_read(a_visitor,baxis)) return false;
441     aData.m_axes.push_back(baxis);                441     aData.m_axes.push_back(baxis);
442   }                                               442   }
443  {int dummy;                                      443  {int dummy;
444   if(!a_visitor.visit(dummy)) return false;} /    444   if(!a_visitor.visit(dummy)) return false;} //m_mode
445                                                   445 
446  {bool dummy;                                     446  {bool dummy;
447   if(!a_visitor.visit(dummy)) return false;} /    447   if(!a_visitor.visit(dummy)) return false;} //m_is_profile
448                                                   448 
449  {std::vector<double> dummy;                      449  {std::vector<double> dummy;
450   if(!a_visitor.visit(dummy)) return false;} /    450   if(!a_visitor.visit(dummy)) return false;} //m_bin_Svw
451                                                   451 
452  {std::vector<double> dummy;                      452  {std::vector<double> dummy;
453   if(!a_visitor.visit(dummy)) return false;} /    453   if(!a_visitor.visit(dummy)) return false;} //m_bin_Sv2w
454                                                   454 
455  {bool dummy;                                     455  {bool dummy;
456   if(!a_visitor.visit(dummy)) return false;} /    456   if(!a_visitor.visit(dummy)) return false;} //m_cut_v
457                                                   457 
458  {double dummy;                                   458  {double dummy;
459   if(!a_visitor.visit(dummy)) return false;} /    459   if(!a_visitor.visit(dummy)) return false;} //aData.m_min_v
460                                                   460 
461  {double dummy;                                   461  {double dummy;
462   if(!a_visitor.visit(dummy)) return false;} /    462   if(!a_visitor.visit(dummy)) return false;} //aData.m_max_v
463                                                   463 
464   //aData.fDoubles                                464   //aData.fDoubles
465   //aData.fInts                                   465   //aData.fInts
466   //aData.m_coords.resize(aData.m_dimension,0)    466   //aData.m_coords.resize(aData.m_dimension,0);
467   //aData.m_ints.resize(aData.m_dimension,0);     467   //aData.m_ints.resize(aData.m_dimension,0);
468                                                   468 
469   return true;                                    469   return true;
470 }                                                 470 }
471                                                   471 
472 template <class HIST>                             472 template <class HIST>
473 class Histogram : public virtual istorable {      473 class Histogram : public virtual istorable {
474 public:                                           474 public:
475   TOOLS_T_SCLASS(HIST,tools::osc::Histogram)      475   TOOLS_T_SCLASS(HIST,tools::osc::Histogram)
476 protected:                                        476 protected:
477   virtual void* cast(const std::string& a_clas    477   virtual void* cast(const std::string& a_class) const {
478     if(void* p = cmp_cast<Histogram>(this,a_cl    478     if(void* p = cmp_cast<Histogram>(this,a_class)) return p;
479     return 0;                                     479     return 0;
480   }                                               480   }
481 public:                                           481 public:
482   virtual const std::string& store_cls() const    482   virtual const std::string& store_cls() const {return m_cls;}
483   virtual bool visit(iobj_const_visitor& a_v)     483   virtual bool visit(iobj_const_visitor& a_v) const {
484     if(!a_v.begin(*this,m_cls,Histogram::s_vis    484     if(!a_v.begin(*this,m_cls,Histogram::s_visit)) return false;
485                                                   485 
486     int version = 1;                              486     int version = 1;
487     if(!a_v.visit("fVersion",version)) return     487     if(!a_v.visit("fVersion",version)) return false;
488                                                   488 
489     BaseHistogram<HIST> bh(m_hist);               489     BaseHistogram<HIST> bh(m_hist);
490     if(!bh.visit(a_v)) return false;              490     if(!bh.visit(a_v)) return false;
491                                                   491 
492     if(!visitHistogram(m_hist,a_v)) return fal    492     if(!visitHistogram(m_hist,a_v)) return false;
493                                                   493 
494     if(!a_v.end(*this)) return false;             494     if(!a_v.end(*this)) return false;
495     return true;                                  495     return true;
496   }                                               496   }
497 protected:                                        497 protected:
498   static bool s_visit(const istorable& a_o,iob    498   static bool s_visit(const istorable& a_o,iobj_const_visitor& a_v){
499     const Histogram* local = safe_cast<istorab    499     const Histogram* local = safe_cast<istorable,Histogram>(a_o);
500     if(!local) return false;                      500     if(!local) return false;
501     return local->Histogram::visit(a_v); //IMP    501     return local->Histogram::visit(a_v); //IMPORTANT : have Histogram::
502   }                                               502   }
503 public:                                           503 public:
504   Histogram(const HIST& a_hist,const std::stri    504   Histogram(const HIST& a_hist,const std::string& a_cls)
505   :m_hist(a_hist),m_cls(a_cls){}                  505   :m_hist(a_hist),m_cls(a_cls){}
506   virtual ~Histogram(){}                          506   virtual ~Histogram(){}
507 public:                                           507 public:
508   Histogram(const Histogram& a_from)              508   Histogram(const Histogram& a_from)
509   :istorable(a_from)                              509   :istorable(a_from)
510   ,m_hist(a_from.m_hist)                          510   ,m_hist(a_from.m_hist)
511   ,m_cls(a_from.m_cls)                            511   ,m_cls(a_from.m_cls)
512   {}                                              512   {}
513   Histogram& operator=(const Histogram& a_from    513   Histogram& operator=(const Histogram& a_from){
514     m_cls = a_from.m_cls;                         514     m_cls = a_from.m_cls;
515     return *this;                                 515     return *this;
516   }                                               516   }
517 protected:                                        517 protected:
518   const HIST& m_hist;                             518   const HIST& m_hist;
519   std::string m_cls;                              519   std::string m_cls;
520 };                                                520 };
521                                                   521 
522 inline bool visit(iobj_const_visitor& a_v,cons    522 inline bool visit(iobj_const_visitor& a_v,const histo::h1d& a_histo) {
523   Histogram<histo::h1d> h(a_histo,s_h1d());       523   Histogram<histo::h1d> h(a_histo,s_h1d());
524   return h.visit(a_v);                            524   return h.visit(a_v);
525 }                                                 525 }
526                                                   526 
527 inline bool read(iobj_visitor& a_visitor,histo    527 inline bool read(iobj_visitor& a_visitor,histo::h1d& a_histo){
528   //if(!a_visitor.begin(*this)) return false;     528   //if(!a_visitor.begin(*this)) return false;
529                                                   529 
530   int version;                                    530   int version;
531   if(!a_visitor.visit(version)) return false;     531   if(!a_visitor.visit(version)) return false;
532                                                   532 
533   if(version!=1) {                                533   if(version!=1) {
534     //this may come from an unexpected byteswa    534     //this may come from an unexpected byteswap.
535     a_visitor.out() << "tools::osc::read :"       535     a_visitor.out() << "tools::osc::read :"
536                     << " unexpected version "     536                     << " unexpected version " << version
537                     << std::endl;                 537                     << std::endl;
538     return false;                                 538     return false;
539   }                                               539   }
540                                                   540 
541   if(!BaseHistogram_read(a_visitor)) return fa    541   if(!BaseHistogram_read(a_visitor)) return false;
542                                                   542 
543   hd_data hdata;                                  543   hd_data hdata;
544   if(!readHistogram(hdata,a_visitor)) return f    544   if(!readHistogram(hdata,a_visitor)) return false;
545                                                   545 
546   hdata.update_fast_getters();                    546   hdata.update_fast_getters();
547   a_histo.copy_from_data(hdata);                  547   a_histo.copy_from_data(hdata);
548                                                   548 
549   //fAxis.copy(fHistogram.get_axis(0));           549   //fAxis.copy(fHistogram.get_axis(0));
550                                                   550 
551   //if(!a_visitor.end(*this)) return false;       551   //if(!a_visitor.end(*this)) return false;
552                                                   552 
553   return true;                                    553   return true;
554 }                                                 554 }
555                                                   555 
556 inline bool visit(iobj_const_visitor& a_v,cons    556 inline bool visit(iobj_const_visitor& a_v,const histo::h2d& a_histo) {
557   Histogram<histo::h2d> h(a_histo,s_h2d());       557   Histogram<histo::h2d> h(a_histo,s_h2d());
558   return h.visit(a_v);                            558   return h.visit(a_v);
559 }                                                 559 }
560                                                   560 
561 inline bool read(iobj_visitor& a_visitor,histo    561 inline bool read(iobj_visitor& a_visitor,histo::h2d& a_histo){
562   //if(!a_visitor.begin(*this)) return false;     562   //if(!a_visitor.begin(*this)) return false;
563                                                   563 
564   int version;                                    564   int version;
565   if(!a_visitor.visit(version)) return false;     565   if(!a_visitor.visit(version)) return false;
566                                                   566 
567   if(version!=1) {                                567   if(version!=1) {
568     //this may come from an unexpected byteswa    568     //this may come from an unexpected byteswap.
569     a_visitor.out() << "tools::osc::read :"       569     a_visitor.out() << "tools::osc::read :"
570                     << " unexpected version "     570                     << " unexpected version " << version
571                     << std::endl;                 571                     << std::endl;
572     return false;                                 572     return false;
573   }                                               573   }
574                                                   574 
575   if(!BaseHistogram_read(a_visitor)) return fa    575   if(!BaseHistogram_read(a_visitor)) return false;
576                                                   576 
577   hd_data hdata;                                  577   hd_data hdata;
578   if(!readHistogram(hdata,a_visitor)) return f    578   if(!readHistogram(hdata,a_visitor)) return false;
579                                                   579 
580   hdata.update_fast_getters();                    580   hdata.update_fast_getters();
581   a_histo.copy_from_data(hdata);                  581   a_histo.copy_from_data(hdata);
582                                                   582 
583   //fAxisX.copy(fHistogram.get_axis(0));          583   //fAxisX.copy(fHistogram.get_axis(0));
584   //fAxisY.copy(fHistogram.get_axis(1));          584   //fAxisY.copy(fHistogram.get_axis(1));
585                                                   585 
586   //if(!a_visitor.end(*this)) return false;       586   //if(!a_visitor.end(*this)) return false;
587                                                   587 
588   return true;                                    588   return true;
589 }                                                 589 }
590                                                   590 
591 inline bool visit(iobj_const_visitor& a_v,cons    591 inline bool visit(iobj_const_visitor& a_v,const histo::h3d& a_histo) {
592   Histogram<histo::h3d> h(a_histo,s_h3d());       592   Histogram<histo::h3d> h(a_histo,s_h3d());
593   return h.visit(a_v);                            593   return h.visit(a_v);
594 }                                                 594 }
595                                                   595 
596 inline bool read(iobj_visitor& a_visitor,histo    596 inline bool read(iobj_visitor& a_visitor,histo::h3d& a_histo){
597   //if(!a_visitor.begin(*this)) return false;     597   //if(!a_visitor.begin(*this)) return false;
598                                                   598 
599   int version;                                    599   int version;
600   if(!a_visitor.visit(version)) return false;     600   if(!a_visitor.visit(version)) return false;
601                                                   601 
602   if(version!=1) {                                602   if(version!=1) {
603     //this may come from an unexpected byteswa    603     //this may come from an unexpected byteswap.
604     a_visitor.out() << "tools::osc::read :"       604     a_visitor.out() << "tools::osc::read :"
605                     << " unexpected version "     605                     << " unexpected version " << version
606                     << std::endl;                 606                     << std::endl;
607     return false;                                 607     return false;
608   }                                               608   }
609                                                   609 
610   if(!BaseHistogram_read(a_visitor)) return fa    610   if(!BaseHistogram_read(a_visitor)) return false;
611                                                   611 
612   hd_data hdata;                                  612   hd_data hdata;
613   if(!readHistogram(hdata,a_visitor)) return f    613   if(!readHistogram(hdata,a_visitor)) return false;
614   hdata.update_fast_getters();                    614   hdata.update_fast_getters();
615   a_histo.copy_from_data(hdata);                  615   a_histo.copy_from_data(hdata);
616                                                   616 
617   //fAxisX.copy(fHistogram.get_axis(0));          617   //fAxisX.copy(fHistogram.get_axis(0));
618   //fAxisY.copy(fHistogram.get_axis(1));          618   //fAxisY.copy(fHistogram.get_axis(1));
619   //fAxisZ.copy(fHistogram.get_axis(2));          619   //fAxisZ.copy(fHistogram.get_axis(2));
620                                                   620 
621   //if(!a_visitor.end(*this)) return false;       621   //if(!a_visitor.end(*this)) return false;
622                                                   622 
623   return true;                                    623   return true;
624 }                                                 624 }
625                                                   625 
626 typedef histo::profile_data<double,unsigned in    626 typedef histo::profile_data<double,unsigned int,unsigned int,double,double> pd_data;
627                                                   627 
628 template <class PROF>                             628 template <class PROF>
629 inline bool visitProfile(const PROF& a_prof,io    629 inline bool visitProfile(const PROF& a_prof,iobj_const_visitor& a_visitor){
630   if(!a_visitor.visit("fTitle",a_prof.title())    630   if(!a_visitor.visit("fTitle",a_prof.title())) return false;
631   if(!a_visitor.visit("fDimension",(int)a_prof    631   if(!a_visitor.visit("fDimension",(int)a_prof.dimension())) return false;
632   if(!a_visitor.visit("fBinNumber",(int)a_prof    632   if(!a_visitor.visit("fBinNumber",(int)a_prof.get_bins())) return false;
633                                                   633 
634   std::vector<int> bins_entries;                  634   std::vector<int> bins_entries;
635   convert<unsigned int,int>(a_prof.bins_entrie    635   convert<unsigned int,int>(a_prof.bins_entries(),bins_entries);
636   if(!a_visitor.visit("fBinEntries",bins_entri    636   if(!a_visitor.visit("fBinEntries",bins_entries)) return false;
637                                                   637 
638   if(!a_visitor.visit("fBinSw",a_prof.bins_sum    638   if(!a_visitor.visit("fBinSw",a_prof.bins_sum_w())) return false;
639   if(!a_visitor.visit("fBinSw2",a_prof.bins_su    639   if(!a_visitor.visit("fBinSw2",a_prof.bins_sum_w2())) return false;
640   if(!a_visitor.visit("fBinSxw",a_prof.bins_su    640   if(!a_visitor.visit("fBinSxw",a_prof.bins_sum_xw())) return false;
641   if(!a_visitor.visit("fBinSx2w",a_prof.bins_s    641   if(!a_visitor.visit("fBinSx2w",a_prof.bins_sum_x2w())) return false;
642   std::string name;                               642   std::string name;
643   for(unsigned int iaxis=0;iaxis<a_prof.dimens    643   for(unsigned int iaxis=0;iaxis<a_prof.dimension();iaxis++) {
644     if(!num2s(iaxis,name)) return false;          644     if(!num2s(iaxis,name)) return false;
645     name = "fAxes_"+name;                         645     name = "fAxes_"+name;
646     Axis axis(a_prof.get_axis(iaxis));            646     Axis axis(a_prof.get_axis(iaxis));
647     if(!a_visitor.visit(name,axis)) return fal    647     if(!a_visitor.visit(name,axis)) return false;
648   }                                               648   }
649  {int dummy = 0;                                  649  {int dummy = 0;
650   if(!a_visitor.visit("fMode",dummy)) return f    650   if(!a_visitor.visit("fMode",dummy)) return false;} //m_mode
651   if(!a_visitor.visit("fProfile",true)) return    651   if(!a_visitor.visit("fProfile",true)) return false;
652   if(!a_visitor.visit("fBinSvw",a_prof.bins_su    652   if(!a_visitor.visit("fBinSvw",a_prof.bins_sum_vw())) return false;
653   if(!a_visitor.visit("fBinSv2w",a_prof.bins_s    653   if(!a_visitor.visit("fBinSv2w",a_prof.bins_sum_v2w())) return false;
654   if(!a_visitor.visit("fCutV",a_prof.cut_v()))    654   if(!a_visitor.visit("fCutV",a_prof.cut_v())) return false;
655   if(!a_visitor.visit("fMinV",a_prof.min_v()))    655   if(!a_visitor.visit("fMinV",a_prof.min_v())) return false;
656   if(!a_visitor.visit("fMaxV",a_prof.max_v()))    656   if(!a_visitor.visit("fMaxV",a_prof.max_v())) return false;
657   // Not written :                                657   // Not written :
658   //a_prof.fDoubles                               658   //a_prof.fDoubles
659   //a_prof.fInts                                  659   //a_prof.fInts
660   return true;                                    660   return true;
661 }                                                 661 }
662                                                   662 
663 template <class PROF>                             663 template <class PROF>
664 class Profile : public virtual istorable {        664 class Profile : public virtual istorable {
665 public:                                           665 public:
666   TOOLS_T_SCLASS(PROF,tools::osc::Profile)        666   TOOLS_T_SCLASS(PROF,tools::osc::Profile)
667 protected:                                        667 protected:
668   virtual void* cast(const std::string& a_clas    668   virtual void* cast(const std::string& a_class) const {
669     if(void* p = cmp_cast<Profile>(this,a_clas    669     if(void* p = cmp_cast<Profile>(this,a_class)) return p;
670     return 0;                                     670     return 0;
671   }                                               671   }
672 public:                                           672 public:
673   virtual const std::string& store_cls() const    673   virtual const std::string& store_cls() const {return m_cls;}
674   virtual bool visit(iobj_const_visitor& a_v)     674   virtual bool visit(iobj_const_visitor& a_v) const {
675     if(!a_v.begin(*this,m_cls,Profile::s_visit    675     if(!a_v.begin(*this,m_cls,Profile::s_visit)) return false;
676                                                   676 
677     int version = 1;                              677     int version = 1;
678     if(!a_v.visit("fVersion",version)) return     678     if(!a_v.visit("fVersion",version)) return false;
679                                                   679 
680     BaseHistogram<PROF> bh(m_hist);               680     BaseHistogram<PROF> bh(m_hist);
681     if(!bh.visit(a_v)) return false;              681     if(!bh.visit(a_v)) return false;
682                                                   682 
683     if(!visitProfile(m_hist,a_v)) return false    683     if(!visitProfile(m_hist,a_v)) return false;
684                                                   684 
685     if(!a_v.end(*this)) return false;             685     if(!a_v.end(*this)) return false;
686     return true;                                  686     return true;
687   }                                               687   }
688 protected:                                        688 protected:
689   static bool s_visit(const istorable& a_o,iob    689   static bool s_visit(const istorable& a_o,iobj_const_visitor& a_v){
690     const Profile* local = safe_cast<istorable    690     const Profile* local = safe_cast<istorable,Profile>(a_o);
691     if(!local) return false;                      691     if(!local) return false;
692     return local->Profile::visit(a_v); //IMPOR    692     return local->Profile::visit(a_v); //IMPORTANT : have Profile::
693   }                                               693   }
694 public:                                           694 public:
695   Profile(const PROF& a_hist,const std::string    695   Profile(const PROF& a_hist,const std::string& a_cls)
696   :m_hist(a_hist),m_cls(a_cls){}                  696   :m_hist(a_hist),m_cls(a_cls){}
697   virtual ~Profile(){}                            697   virtual ~Profile(){}
698 public:                                           698 public:
699   Profile(const Profile& a_from)                  699   Profile(const Profile& a_from)
700   :istorable(a_from)                              700   :istorable(a_from)
701   ,m_hist(a_from.m_hist)                          701   ,m_hist(a_from.m_hist)
702   ,m_cls(a_from.m_cls)                            702   ,m_cls(a_from.m_cls)
703   {}                                              703   {}
704   Profile& operator=(const Profile& a_from){      704   Profile& operator=(const Profile& a_from){
705     m_cls = a_from.m_cls;                         705     m_cls = a_from.m_cls;
706     return *this;                                 706     return *this;
707   }                                               707   }
708 protected:                                        708 protected:
709   const PROF& m_hist;                             709   const PROF& m_hist;
710   std::string m_cls;                              710   std::string m_cls;
711 };                                                711 };
712                                                   712 
713 inline bool readProfile(pd_data& aData,iobj_vi    713 inline bool readProfile(pd_data& aData,iobj_visitor& a_visitor){
714   if(!a_visitor.visit(aData.m_title)) return f    714   if(!a_visitor.visit(aData.m_title)) return false;
715                                                   715 
716  {int dim;                                        716  {int dim;
717   if(!a_visitor.visit(dim)) return false;         717   if(!a_visitor.visit(dim)) return false;
718   aData.m_dimension = dim;}                       718   aData.m_dimension = dim;}
719                                                   719 
720  {int nbin;                                       720  {int nbin;
721   if(!a_visitor.visit(nbin)) return false;        721   if(!a_visitor.visit(nbin)) return false;
722   aData.m_bin_number = nbin;}                     722   aData.m_bin_number = nbin;}
723                                                   723 
724  {std::vector<int> vec;                           724  {std::vector<int> vec;
725   if(!a_visitor.visit(vec)) return false;         725   if(!a_visitor.visit(vec)) return false;
726   convert<int,unsigned int>(vec,aData.m_bin_en    726   convert<int,unsigned int>(vec,aData.m_bin_entries);}
727                                                   727 
728   if(!a_visitor.visit(aData.m_bin_Sw)) return     728   if(!a_visitor.visit(aData.m_bin_Sw)) return false;
729   if(!a_visitor.visit(aData.m_bin_Sw2)) return    729   if(!a_visitor.visit(aData.m_bin_Sw2)) return false;
730   if(!a_visitor.visit(aData.m_bin_Sxw)) return    730   if(!a_visitor.visit(aData.m_bin_Sxw)) return false;
731   if(!a_visitor.visit(aData.m_bin_Sx2w)) retur    731   if(!a_visitor.visit(aData.m_bin_Sx2w)) return false;
732   aData.m_axes.clear();                           732   aData.m_axes.clear();
733   for(unsigned int iaxis=0;iaxis<aData.m_dimen    733   for(unsigned int iaxis=0;iaxis<aData.m_dimension;iaxis++) {
734     histo::axis<double,unsigned int> baxis;       734     histo::axis<double,unsigned int> baxis;
735     if(!Axis_read(a_visitor,baxis)) return fal    735     if(!Axis_read(a_visitor,baxis)) return false;
736     aData.m_axes.push_back(baxis);                736     aData.m_axes.push_back(baxis);
737   }                                               737   }
738  {int dummy;                                      738  {int dummy;
739   if(!a_visitor.visit(dummy)) return false;} /    739   if(!a_visitor.visit(dummy)) return false;} //m_mode
740   if(!a_visitor.visit(aData.m_is_profile)) ret    740   if(!a_visitor.visit(aData.m_is_profile)) return false;
741   if(!a_visitor.visit(aData.m_bin_Svw)) return    741   if(!a_visitor.visit(aData.m_bin_Svw)) return false;
742   if(!a_visitor.visit(aData.m_bin_Sv2w)) retur    742   if(!a_visitor.visit(aData.m_bin_Sv2w)) return false;
743   if(!a_visitor.visit(aData.m_cut_v)) return f    743   if(!a_visitor.visit(aData.m_cut_v)) return false;
744   if(!a_visitor.visit(aData.m_min_v)) return f    744   if(!a_visitor.visit(aData.m_min_v)) return false;
745   if(!a_visitor.visit(aData.m_max_v)) return f    745   if(!a_visitor.visit(aData.m_max_v)) return false;
746                                                   746 
747   // Not written :                                747   // Not written :
748   //aData.fDoubles                                748   //aData.fDoubles
749   //aData.fInts                                   749   //aData.fInts
750   //aData.m_coords.resize(aData.m_dimension,0)    750   //aData.m_coords.resize(aData.m_dimension,0);
751   //aData.m_ints.resize(aData.m_dimension,0);     751   //aData.m_ints.resize(aData.m_dimension,0);
752                                                   752 
753   return true;                                    753   return true;
754 }                                                 754 }
755                                                   755 
756 inline bool visit(iobj_const_visitor& a_v,cons    756 inline bool visit(iobj_const_visitor& a_v,const histo::p1d& a_histo) {
757   Profile<histo::p1d> h(a_histo,s_p1d());         757   Profile<histo::p1d> h(a_histo,s_p1d());
758   return h.visit(a_v);                            758   return h.visit(a_v);
759 }                                                 759 }
760                                                   760 
761 inline bool read(iobj_visitor& a_visitor,histo    761 inline bool read(iobj_visitor& a_visitor,histo::p1d& a_histo){
762   //if(!a_visitor.begin(*this)) return false;     762   //if(!a_visitor.begin(*this)) return false;
763                                                   763 
764   int version;                                    764   int version;
765   if(!a_visitor.visit(version)) return false;     765   if(!a_visitor.visit(version)) return false;
766                                                   766 
767   if(version!=1) {                                767   if(version!=1) {
768     //this may come from an unexpected byteswa    768     //this may come from an unexpected byteswap.
769     a_visitor.out() << "tools::osc::read :"       769     a_visitor.out() << "tools::osc::read :"
770                     << " unexpected version "     770                     << " unexpected version " << version
771                     << std::endl;                 771                     << std::endl;
772     return false;                                 772     return false;
773   }                                               773   }
774                                                   774 
775                                                   775 
776   if(!BaseHistogram_read(a_visitor)) return fa    776   if(!BaseHistogram_read(a_visitor)) return false;
777                                                   777 
778   pd_data hdata;                                  778   pd_data hdata;
779   if(!readProfile(hdata,a_visitor)) return fal    779   if(!readProfile(hdata,a_visitor)) return false;
780   hdata.update_fast_getters();                    780   hdata.update_fast_getters();
781   a_histo.copy_from_data(hdata);                  781   a_histo.copy_from_data(hdata);
782                                                   782 
783   //fAxis.copy(fHistogram.get_axis(0));           783   //fAxis.copy(fHistogram.get_axis(0));
784                                                   784 
785   //if(!a_visitor.end(*this)) return false;       785   //if(!a_visitor.end(*this)) return false;
786                                                   786 
787   return true;                                    787   return true;
788 }                                                 788 }
789                                                   789 
790 inline bool visit(iobj_const_visitor& a_v,cons    790 inline bool visit(iobj_const_visitor& a_v,const histo::p2d& a_histo) {
791   Profile<histo::p2d> h(a_histo,s_p2d());         791   Profile<histo::p2d> h(a_histo,s_p2d());
792   return h.visit(a_v);                            792   return h.visit(a_v);
793 }                                                 793 }
794                                                   794 
795 inline bool read(iobj_visitor& a_visitor,histo    795 inline bool read(iobj_visitor& a_visitor,histo::p2d& a_histo){
796   //if(!a_visitor.begin(*this)) return false;     796   //if(!a_visitor.begin(*this)) return false;
797                                                   797 
798   int version;                                    798   int version;
799   if(!a_visitor.visit(version)) return false;     799   if(!a_visitor.visit(version)) return false;
800                                                   800 
801   if(version!=1) {                                801   if(version!=1) {
802     //this may come from an unexpected byteswa    802     //this may come from an unexpected byteswap.
803     a_visitor.out() << "tools::osc::read :"       803     a_visitor.out() << "tools::osc::read :"
804                     << " unexpected version "     804                     << " unexpected version " << version
805                     << std::endl;                 805                     << std::endl;
806     return false;                                 806     return false;
807   }                                               807   }
808                                                   808 
809                                                   809 
810   if(!BaseHistogram_read(a_visitor)) return fa    810   if(!BaseHistogram_read(a_visitor)) return false;
811                                                   811 
812   pd_data hdata;                                  812   pd_data hdata;
813   if(!readProfile(hdata,a_visitor)) return fal    813   if(!readProfile(hdata,a_visitor)) return false;
814   hdata.update_fast_getters();                    814   hdata.update_fast_getters();
815   a_histo.copy_from_data(hdata);                  815   a_histo.copy_from_data(hdata);
816                                                   816 
817   //fAxisX.copy(a_histo.get_axis(0));             817   //fAxisX.copy(a_histo.get_axis(0));
818   //fAxisY.copy(a_histo.get_axis(1));             818   //fAxisY.copy(a_histo.get_axis(1));
819                                                   819 
820   //if(!a_visitor.end(*this)) return false;       820   //if(!a_visitor.end(*this)) return false;
821                                                   821 
822   return true;                                    822   return true;
823 }                                                 823 }
824                                                   824 
825 template <class HIST>                             825 template <class HIST>
826 class Histogram_cp : public Histogram<HIST> {     826 class Histogram_cp : public Histogram<HIST> {
827   typedef Histogram<HIST> parent;                 827   typedef Histogram<HIST> parent;
828 public:                                           828 public:
829   Histogram_cp(const HIST& a_h,const std::stri    829   Histogram_cp(const HIST& a_h,const std::string& a_cls)
830   :parent(m_cp,a_cls) //give ref of m_cp to Hi    830   :parent(m_cp,a_cls) //give ref of m_cp to Histogram.
831   ,m_cp(a_h)   //do a local copy.                 831   ,m_cp(a_h)   //do a local copy.
832   //WARNING : the upper is ok as long as Histo    832   //WARNING : the upper is ok as long as Histogram constructor does nothing
833   //          else than keeping the ref to m_c    833   //          else than keeping the ref to m_cp. Else it would do
834   //          something on an empty histo (and    834   //          something on an empty histo (and not on a copy of the
835   //          passed a_data).                     835   //          passed a_data).
836   {}                                              836   {}
837   virtual ~Histogram_cp(){}                       837   virtual ~Histogram_cp(){}
838 public:                                           838 public:
839   Histogram_cp(const Histogram_cp& a_from)        839   Histogram_cp(const Histogram_cp& a_from)
840   :istorable(a_from)                              840   :istorable(a_from)
841   ,parent(m_cp,a_from.m_cls)                      841   ,parent(m_cp,a_from.m_cls)
842   ,m_cp(a_from.m_cp)                              842   ,m_cp(a_from.m_cp)
843   {}                                              843   {}
844   Histogram_cp& operator=(const Histogram_cp&     844   Histogram_cp& operator=(const Histogram_cp& a_from){
845     parent::operator=(a_from);                    845     parent::operator=(a_from);
846     m_cp = a_from.m_cp;                           846     m_cp = a_from.m_cp;
847     return *this;                                 847     return *this;
848   }                                               848   }
849 protected:                                        849 protected:
850   HIST m_cp;                                      850   HIST m_cp;
851 };                                                851 };
852                                                   852 
853 template <class PROF>                             853 template <class PROF>
854 class Profile_cp : public Profile<PROF> {         854 class Profile_cp : public Profile<PROF> {
855   typedef Profile<PROF> parent;                   855   typedef Profile<PROF> parent;
856 public:                                           856 public:
857   Profile_cp(const PROF& a_p,const std::string    857   Profile_cp(const PROF& a_p,const std::string& a_cls)
858   :parent(m_cp,a_cls) //give ref of m_cp to Pr    858   :parent(m_cp,a_cls) //give ref of m_cp to Profile.
859   ,m_cp(a_p)   //do a local copy.                 859   ,m_cp(a_p)   //do a local copy.
860   //WARNING : the upper is ok as long as Profi    860   //WARNING : the upper is ok as long as Profile constructor does nothing
861   //          else than keeping the ref to m_c    861   //          else than keeping the ref to m_cp. Else it would do
862   //          something on an empty histo (and    862   //          something on an empty histo (and not on a copy of the
863   //          passed a_data).                     863   //          passed a_data).
864   {}                                              864   {}
865   virtual ~Profile_cp(){}                         865   virtual ~Profile_cp(){}
866 public:                                           866 public:
867   Profile_cp(const Profile_cp& a_from)            867   Profile_cp(const Profile_cp& a_from)
868   :istorable(a_from)                              868   :istorable(a_from)
869   ,parent(m_cp,a_from.m_cls)                      869   ,parent(m_cp,a_from.m_cls)
870   ,m_cp(a_from.m_cp)                              870   ,m_cp(a_from.m_cp)
871   {}                                              871   {}
872   Profile_cp& operator=(const Profile_cp& a_fr    872   Profile_cp& operator=(const Profile_cp& a_from){
873     parent::operator=(a_from);                    873     parent::operator=(a_from);
874     m_cp = a_from.m_cp;                           874     m_cp = a_from.m_cp;
875     return *this;                                 875     return *this;
876   }                                               876   }
877 protected:                                        877 protected:
878   PROF m_cp;                                      878   PROF m_cp;
879 };                                                879 };
880                                                   880 
881 }}                                                881 }}
882                                                   882 
883 #endif                                            883 #endif