Go to the documentation of this file.
4 #ifndef tools_wcsv_ntuple
5 #define tools_wcsv_ntuple
26 static const std::string s_v(
"tools::wcsv::ntuple");
37 virtual void add() = 0;
38 virtual const std::string&
name()
const = 0;
46 static const T s_v = T();
47 return _cid(s_v)+10000;
50 if(
void* p = cmp_cast<column_ref>(
this,a_class)) {
return p;}
58 column_ref(std::ostream& a_writer,
const std::string& a_name,
const T& a_ref)
86 static const T s_v = T();
90 if(
void* p = cmp_cast<column>(
this,a_class)) {
return p;}
97 column(std::ostream& a_writer,
const std::string& a_name,
const T& a_def)
117 bool fill(
const T& a_value) {
m_tmp = a_value;
return true;}
136 if(
void* p = cmp_cast<std_vector_column>(
this,a_class)) {
return p;}
147 typedef typename std::vector<T>::const_iterator it_t;
148 for(it_t it=
m_ref.begin();it!=
m_ref.end();++it) {
158 std_vector_column(std::ostream& a_writer,
const std::string& a_name,
const std::vector<T>& a_ref,
char a_vec_sep)
186 ntuple(std::ostream& a_writer,
char a_sep =
',',
char a_vec_sep =
';')
195 char a_sep =
',',
char a_vec_sep =
';')
201 const std::vector<column_booking>& cols = a_bkg.
columns();
202 std::vector<column_booking>::const_iterator it;
203 for(it=cols.begin();it!=cols.end();++it){
205 #define TOOLS_WCSV_NTUPLE_CREATE_COL(a__type) \
206 if((*it).cls_id()==_cid(a__type())) {\
207 a__type* user = (a__type*)(*it).user_obj();\
209 if(!create_column_ref<a__type>((*it).name(),*user)) {\
210 a_out << "tools::wcsv_ntuple::wcsv_ntuple : create_column_ref(" << (*it).name() << ") failed." << std::endl;\
211 safe_clear<icol>(m_cols);\
215 if(!create_column<a__type>((*it).name())) {\
216 a_out << "tools::wcsv_ntuple::wcsv_ntuple : create_column(" << (*it).name() << ") failed." << std::endl;\
217 safe_clear<icol>(m_cols);\
223 #define TOOLS_WCSV_NTUPLE_CREATE_VEC_COL(a__type) \
224 if((*it).cls_id()==_cid_std_vector<a__type>()) {\
225 std::vector<a__type>* vec = (std::vector<a__type>*)(*it).user_obj();\
227 if(!create_column<a__type>((*it).name(),*vec)) {\
228 a_out << "tools::wcsv_ntuple::wcsv_ntuple : create_column(" << (*it).name() << ") failed." << std::endl;\
229 safe_clear<icol>(m_cols);\
233 a_out << "tools::wcsv_ntuple :"\
234 << " for std::vector column " << sout((*it).name())\
235 << ", the user vector pointer is null."\
237 safe_clear<icol>(m_cols);\
274 #undef TOOLS_WCSV_NTUPLE_CREATE_VEC_COL
275 #undef TOOLS_WCSV_NTUPLE_CREATE_COL
278 a_out <<
"tools::wcsv::ntuple :"
279 <<
" for column " <<
sout((*it).name())
280 <<
", type with cid " << (*it).cls_id() <<
" not yet handled."
308 std::vector<icol*>::const_iterator it;
320 m_writer <<
"#separator " << (
unsigned int)
m_sep << std::endl;
323 {
for(
unsigned int count=0;count<
m_cols.size();count++) {
327 a_out <<
"tools::wcsv::ntuple::write_commented_header :"
328 <<
" unknown column type id " << _col->
id_cls() << std::endl;
331 m_writer <<
"#column " << sid <<
" " << _col->
name() << std::endl;
339 if(find_named<icol>(
m_cols,a_name))
return 0;
348 if(find_named<icol>(
m_cols,a_name))
return 0;
358 if(find_named<icol>(
m_cols,a_name))
return 0;
369 return id_cast<icol, column_ref<T> >(*col);
376 return id_cast<icol, column<T> >(*col);
380 if(
m_cols.empty())
return false;
381 std::vector<icol*>::iterator it;
385 for(;it!=
m_cols.end();++it) {
#define TOOLS_WCSV_NTUPLE_CREATE_COL(a__type)
#define TOOLS_WCSV_NTUPLE_CREATE_VEC_COL(a__type)