Go to the documentation of this file.
4 #ifndef tools_store_osc_streamers
5 #define tools_store_osc_streamers
10 #include "../histo/h1d"
11 #include "../histo/h2d"
12 #include "../histo/h3d"
13 #include "../histo/p1d"
14 #include "../histo/p2d"
18 #include "../S_STRING"
25 static const std::string s_v(
"BatchLab::Axis");
29 static const std::string s_v(
"BatchLab::Annotation");
33 static const std::string s_v(
"BatchLab::BaseHistogram");
37 static const std::string s_v(
"BatchLab::Item");
41 inline const std::string&
s_h1d() {
42 static const std::string s_v(
"BatchLab::Histogram1D");
46 inline const std::string&
s_h2d() {
47 static const std::string s_v(
"BatchLab::Histogram2D");
51 inline const std::string&
s_h3d() {
52 static const std::string s_v(
"BatchLab::Histogram3D");
56 inline const std::string&
s_p1d() {
57 static const std::string s_v(
"BatchLab::Profile1D");
61 inline const std::string&
s_p2d() {
62 static const std::string s_v(
"BatchLab::Profile2D");
70 virtual void*
cast(
const std::string& a_class)
const {
71 if(
void* p = cmp_cast<Axis>(
this,a_class))
return p;
89 if(!a_v.
end(*
this))
return false;
93 const Axis* local = safe_cast<istorable,Axis>(a_o);
94 if(!local)
return false;
95 return local->Axis::visit(a_v);
102 Axis& operator=(
const Axis&){
return *
this;}
117 if(!a_visitor.
visit(nbin))
return false;
134 virtual void*
cast(
const std::string& a_class)
const {
135 if(
void* p = cmp_cast<Item>(
this,a_class))
return p;
146 if(!a_visitor.
visit(
"fKey",
fKey))
return false;
147 if(!a_visitor.
visit(
"fValue",
fValue))
return false;
150 if(!a_visitor.
end(*
this))
return false;
154 const Item* local = safe_cast<istorable,Item>(a_o);
155 if(!local)
return false;
156 return local->Item::visit(a_v);
174 Item(
const std::string& aKey,
const std::string& aValue,
bool aSticky)
185 if(&a_from==
this)
return *
this;
203 virtual void*
cast(
const std::string& a_class)
const {
204 if(
void* p = cmp_cast<Vector>(
this,a_class))
return p;
208 static const std::string s_v(
"BatchLab::Vector<"+
m_T+
">");
217 unsigned int number = (
unsigned int)
m_vec.size();
218 if(!a_v.
visit(
"fSize",number))
return false;
221 for(
unsigned int index=0;index<number;index++) {
222 const T& elem =
m_vec[index];
223 if(!
num2s(index,stmp))
return false;
224 if(!a_v.
visit(stmp,elem))
return false;
227 if(!a_v.
end(*
this))
return false;
231 const Vector* local = safe_cast<istorable,Vector>(a_o);
232 if(!local)
return false;
233 return local->Vector<T>::visit(a_v);
236 Vector(
const std::vector<T>& a_vec,
const std::string& a_T)
259 if(!a_visitor.
visit(number))
return false;
261 a_vec.resize(number);
262 for(
unsigned int index=0;index<number;index++) {
263 T& elem = a_vec[index];
264 if(!elem.read(a_visitor))
return false;
275 virtual void*
cast(
const std::string& a_class)
const {
276 if(
void* p = cmp_cast<Annotation>(
this,a_class))
return p;
287 if(!a_v.
visit(
"fItems",v))
return false;
289 if(!a_v.
end(*
this))
return false;
293 const Annotation* local = safe_cast<istorable,Annotation>(a_o);
294 if(!local)
return false;
295 return local->Annotation::visit(a_v);
311 std::vector<Item> fItems;
312 if(!std_vector_read<Item>(a_visitor,fItems))
return false;
317 inline void map2vec(
const std::map<std::string,std::string>& a_in,std::vector<Item>& a_out) {
319 std::map<std::string,std::string>::const_iterator it;
320 for(it=a_in.begin();it!=a_in.end();++it) {
321 a_out.push_back(
Item((*it).first,(*it).second,
false));
327 template <
class HIST>
332 virtual void*
cast(
const std::string& a_class)
const {
333 if(
void* p = cmp_cast<BaseHistogram>(
this,a_class))
return p;
346 if(!a_v.
visit(
"fAnnotation",ano))
return false;
348 if(!a_v.
end(*
this))
return false;
354 safe_cast<istorable,BaseHistogram>(a_o);
355 if(!local)
return false;
356 return local->BaseHistogram::visit(a_v);
382 template <
class HIST>
384 if(!a_visitor.
visit(
"fTitle",a_hist.title()))
return false;
385 if(!a_visitor.
visit(
"fDimension",(
int)a_hist.dimension()))
return false;
386 if(!a_visitor.
visit(
"fBinNumber",(
int)a_hist.get_bins()))
return false;
388 std::vector<int> bins_entries;
389 convert<unsigned int,int>(a_hist.bins_entries(),bins_entries);
390 if(!a_visitor.
visit(
"fBinEntries",bins_entries))
return false;
392 if(!a_visitor.
visit(
"fBinSw",a_hist.bins_sum_w()))
return false;
393 if(!a_visitor.
visit(
"fBinSw2",a_hist.bins_sum_w2()))
return false;
394 if(!a_visitor.
visit(
"fBinSxw",a_hist.bins_sum_xw()))
return false;
395 if(!a_visitor.
visit(
"fBinSx2w",a_hist.bins_sum_x2w()))
return false;
397 for(
unsigned int iaxis=0;iaxis<a_hist.dimension();iaxis++) {
398 if(!
num2s(iaxis,name))
return false;
399 name =
"fAxes_"+name;
400 Axis axis(a_hist.get_axis(iaxis));
401 if(!a_visitor.
visit(name,axis))
return false;
404 if(!a_visitor.
visit(
"fMode",dummy))
return false;}
405 if(!a_visitor.
visit(
"fProfile",
false))
return false;
406 {std::vector<double> dummy;
407 if(!a_visitor.
visit(
"fBinSvw",dummy))
return false;
408 if(!a_visitor.
visit(
"fBinSv2w",dummy))
return false;}
409 if(!a_visitor.
visit(
"fCutV",
false))
return false;
411 if(!a_visitor.
visit(
"fMinV",dummy))
return false;
412 if(!a_visitor.
visit(
"fMaxV",dummy))
return false;}
422 if(!a_visitor.
visit(dim))
return false;
426 if(!a_visitor.
visit(nbin))
return false;
429 {std::vector<int> vec;
430 if(!a_visitor.
visit(vec))
return false;
438 for(
unsigned int iaxis=0;iaxis<aData.
m_dimension;iaxis++) {
440 if(!
Axis_read(a_visitor,baxis))
return false;
441 aData.
m_axes.push_back(baxis);
444 if(!a_visitor.
visit(dummy))
return false;}
447 if(!a_visitor.
visit(dummy))
return false;}
449 {std::vector<double> dummy;
450 if(!a_visitor.
visit(dummy))
return false;}
452 {std::vector<double> dummy;
453 if(!a_visitor.
visit(dummy))
return false;}
456 if(!a_visitor.
visit(dummy))
return false;}
459 if(!a_visitor.
visit(dummy))
return false;}
462 if(!a_visitor.
visit(dummy))
return false;}
472 template <
class HIST>
477 virtual void*
cast(
const std::string& a_class)
const {
478 if(
void* p = cmp_cast<Histogram>(
this,a_class))
return p;
490 if(!bh.
visit(a_v))
return false;
494 if(!a_v.
end(*
this))
return false;
499 const Histogram* local = safe_cast<istorable,Histogram>(a_o);
500 if(!local)
return false;
501 return local->Histogram::visit(a_v);
535 a_visitor.
out() <<
"tools::osc::read :"
536 <<
" unexpected version " <<
version
569 a_visitor.
out() <<
"tools::osc::read :"
570 <<
" unexpected version " <<
version
604 a_visitor.
out() <<
"tools::osc::read :"
605 <<
" unexpected version " <<
version
628 template <
class PROF>
630 if(!a_visitor.
visit(
"fTitle",a_prof.title()))
return false;
631 if(!a_visitor.
visit(
"fDimension",(
int)a_prof.dimension()))
return false;
632 if(!a_visitor.
visit(
"fBinNumber",(
int)a_prof.get_bins()))
return false;
634 std::vector<int> bins_entries;
635 convert<unsigned int,int>(a_prof.bins_entries(),bins_entries);
636 if(!a_visitor.
visit(
"fBinEntries",bins_entries))
return false;
638 if(!a_visitor.
visit(
"fBinSw",a_prof.bins_sum_w()))
return false;
639 if(!a_visitor.
visit(
"fBinSw2",a_prof.bins_sum_w2()))
return false;
640 if(!a_visitor.
visit(
"fBinSxw",a_prof.bins_sum_xw()))
return false;
641 if(!a_visitor.
visit(
"fBinSx2w",a_prof.bins_sum_x2w()))
return false;
643 for(
unsigned int iaxis=0;iaxis<a_prof.dimension();iaxis++) {
644 if(!
num2s(iaxis,name))
return false;
645 name =
"fAxes_"+name;
646 Axis axis(a_prof.get_axis(iaxis));
647 if(!a_visitor.
visit(name,axis))
return false;
650 if(!a_visitor.
visit(
"fMode",dummy))
return false;}
651 if(!a_visitor.
visit(
"fProfile",
true))
return false;
652 if(!a_visitor.
visit(
"fBinSvw",a_prof.bins_sum_vw()))
return false;
653 if(!a_visitor.
visit(
"fBinSv2w",a_prof.bins_sum_v2w()))
return false;
654 if(!a_visitor.
visit(
"fCutV",a_prof.cut_v()))
return false;
655 if(!a_visitor.
visit(
"fMinV",a_prof.min_v()))
return false;
656 if(!a_visitor.
visit(
"fMaxV",a_prof.max_v()))
return false;
663 template <
class PROF>
668 virtual void*
cast(
const std::string& a_class)
const {
669 if(
void* p = cmp_cast<Profile>(
this,a_class))
return p;
681 if(!bh.
visit(a_v))
return false;
685 if(!a_v.
end(*
this))
return false;
690 const Profile* local = safe_cast<istorable,Profile>(a_o);
691 if(!local)
return false;
692 return local->Profile::visit(a_v);
695 Profile(
const PROF& a_hist,
const std::string& a_cls)
717 if(!a_visitor.
visit(dim))
return false;
721 if(!a_visitor.
visit(nbin))
return false;
724 {std::vector<int> vec;
725 if(!a_visitor.
visit(vec))
return false;
733 for(
unsigned int iaxis=0;iaxis<aData.
m_dimension;iaxis++) {
735 if(!
Axis_read(a_visitor,baxis))
return false;
736 aData.
m_axes.push_back(baxis);
739 if(!a_visitor.
visit(dummy))
return false;}
769 a_visitor.
out() <<
"tools::osc::read :"
770 <<
" unexpected version " <<
version
803 a_visitor.
out() <<
"tools::osc::read :"
804 <<
" unexpected version " <<
version
825 template <
class HIST>
853 template <
class PROF>
#define TOOLS_SCLASS(a_name)
#define TOOLS_T_SCLASS(a_T, a_name)