|
inlib
1.2.0
|
Classes | |
| class | aida_base_col |
| class | aida_col |
| class | aida |
| class | aida_col_ntu |
| some special column that can't be done with aida_col<T> //// More... | |
| class | base_looper |
| class | stat_looper |
| class | base_col |
| class | base_ntu |
Functions | |
| bool | create_cols_from_vals (aida &a_ntu, const std::vector< value > &a_vars, bool a_verbose=false) |
| bool | create_col (aida &a_ntu, const std::string &a_type, const std::string &a_name, const std::string &a_s, bool a_is_ntu) |
| bool | create_cols_from_string (aida &a_ntu, const std::string &a_booking, bool a_verbose=false) |
| aida_col_ntu * | find_col_ntu (aida &a_ntu, const std::string &a_name) |
| base_col * | find_leaf_column (const base_ntu &a_ntu, const std::string &a_name) |
| bool inlib::ntu::create_col | ( | aida & | a_ntu, |
| const std::string & | a_type, | ||
| const std::string & | a_name, | ||
| const std::string & | a_s, | ||
| bool | a_is_ntu | ||
| ) | [inline] |
Definition at line 341 of file aida.
{
if(a_type==s_aida_type((char)0)) {
char v;
if(!to<char>(a_s,v)) {
a_ntu.out() << "inlib::ntu::create_col :"
<< " can't convert def " << sout(a_s)
<< " to a " << a_type
<< std::endl;
return false;
}
if(!a_ntu.create_col<char>(a_name,v)) {
a_ntu.out() << "inlib::ntu::create_col :"
<< " can't create column of type " << sout(a_type)
<< std::endl;
return false;
}
} else if(a_type==s_aida_type((short)0)) {
short v;
if(!to<short>(a_s,v)) {
a_ntu.out() << "inlib::ntu::create_col :"
<< " can't convert def " << sout(a_s)
<< " to a " << a_type
<< std::endl;
return false;
}
if(!a_ntu.create_col<short>(a_name,v)) {
a_ntu.out() << "inlib::ntu::create_col :"
<< " can't create column of type " << sout(a_type)
<< std::endl;
return false;
}
} else if(a_type==s_aida_type((int)0)) {
int v;
if(!to<int>(a_s,v)) {
a_ntu.out() << "inlib::ntu::create_col :"
<< " can't convert def " << sout(a_s)
<< " to a " << a_type
<< std::endl;
return false;
}
if(!a_ntu.create_col<int>(a_name,v)) {
a_ntu.out() << "inlib::ntu::create_col :"
<< " can't create column of type " << sout(a_type)
<< std::endl;
return false;
}
} else if(a_type==s_aida_type((int64)0)) {
int64 v;
if(!to<int64>(a_s,v)) {
a_ntu.out() << "inlib::ntu::create_col :"
<< " can't convert def " << sout(a_s)
<< " to a " << a_type
<< std::endl;
return false;
}
if(!a_ntu.create_col<int64>(a_name,v)) {
a_ntu.out() << "inlib::ntu::create_col :"
<< " can't create column of type " << sout(a_type)
<< std::endl;
return false;
}
} else if(a_type==s_aida_type((float)0)) {
float v;
if(!to<float>(a_s,v)) {
a_ntu.out() << "inlib::ntu::create_col :"
<< " can't convert def " << sout(a_s)
<< " to a " << a_type
<< std::endl;
return false;
}
if(!a_ntu.create_col<float>(a_name,v)) {
a_ntu.out() << "inlib::ntu::create_col :"
<< " can't create column of type " << sout(a_type)
<< std::endl;
return false;
}
} else if(a_type==s_aida_type((double)0)) {
double v;
if(!to<double>(a_s,v)) {
a_ntu.out() << "inlib::ntu::create_col :"
<< " can't convert def " << sout(a_s)
<< " to a " << a_type
<< std::endl;
return false;
}
if(!a_ntu.create_col<double>(a_name,v)) {
a_ntu.out() << "inlib::ntu::create_col :"
<< " can't create column of type " << sout(a_type)
<< std::endl;
return false;
}
} else if(a_type==s_aida_type((unsigned char)0)) {
unsigned char v;
if(!to<unsigned char>(a_s,v)) {
a_ntu.out() << "inlib::ntu::create_col :"
<< " can't convert def " << sout(a_s)
<< " to a " << a_type
<< std::endl;
return false;
}
if(!a_ntu.create_col<unsigned char>(a_name,v)) {
a_ntu.out() << "inlib::ntu::create_col :"
<< " can't create column of type " << sout(a_type)
<< std::endl;
return false;
}
} else if(a_type==s_aida_type((unsigned short)0)) {
unsigned short v;
if(!to<unsigned short>(a_s,v)) {
a_ntu.out() << "inlib::ntu::create_col :"
<< " can't convert def " << sout(a_s)
<< " to a " << a_type
<< std::endl;
return false;
}
if(!a_ntu.create_col<unsigned short>(a_name,v)) {
a_ntu.out() << "inlib::ntu::create_col :"
<< " can't create column of type " << sout(a_type)
<< std::endl;
return false;
}
} else if(a_type==s_aida_type((unsigned int)0)) {
unsigned int v;
if(!to<unsigned int>(a_s,v)) {
a_ntu.out() << "inlib::ntu::create_col :"
<< " can't convert def " << sout(a_s)
<< " to a " << a_type
<< std::endl;
return false;
}
if(!a_ntu.create_col<unsigned int>(a_name,v)) {
a_ntu.out() << "inlib::ntu::create_col :"
<< " can't create column of type " << sout(a_type)
<< std::endl;
return false;
}
} else if(a_type==s_aida_type((uint64)0)) {
uint64 v;
if(!to<uint64>(a_s,v)) {
a_ntu.out() << "inlib::ntu::create_col :"
<< " can't convert def " << sout(a_s)
<< " to a " << a_type
<< std::endl;
return false;
}
if(!a_ntu.create_col<uint64>(a_name,v)) {
a_ntu.out() << "inlib::ntu::create_col :"
<< " can't create column of type " << sout(a_type)
<< std::endl;
return false;
}
} else if(a_type==s_aida_type((bool)true)) {
bool v;
if(!to(a_s,v)) {
a_ntu.out() << "inlib::ntu::create_col :"
<< " can't convert def " << sout(a_s)
<< " to a " << a_type
<< std::endl;
return false;
}
if(!a_ntu.create_col<bool>(a_name,v)) {
a_ntu.out() << "inlib::ntu::create_col :"
<< " can't create column of type " << sout(a_type)
<< std::endl;
return false;
}
} else if(a_type==s_aida_type(std::string())) {
if(!a_ntu.create_col<std::string>(a_name,a_s)) {
a_ntu.out() << "inlib::ntu::create_col :"
<< " can't create column of type " << sout(a_type)
<< std::endl;
return false;
}
} else if(a_type==s_aida_type((int64)0)) {
int64 v;
if(!to<int64>(a_s,v)) {
a_ntu.out() << "inlib::ntu::create_col :"
<< " can't convert def " << sout(a_s)
<< " to a " << a_type
<< std::endl;
return false;
}
if(!a_ntu.create_col<int64>(a_name,v)) {
a_ntu.out() << "inlib::ntu::create_col :"
<< " can't create column of type " << sout(a_type)
<< std::endl;
return false;
}
} else if(a_type==s_aida_type_ituple()) {
// we expect a booking string on a_s.
if(!a_is_ntu) {
a_ntu.out() << "inlib::ntu::create_col :"
<< " mismatch a_is_ntu/a_type."
<< std::endl;
return false;
}
if(a_s.empty()) {
a_ntu.out() << "inlib::ntu::create_col :"
<< " empty booking string."
<< std::endl;
return false;
}
columns::finder f(a_ntu.out(),a_s);
if(!f.find_variables()) {
a_ntu.out() << "inlib::ntu::create_col :"
<< " find_variables() failed for " << sout(a_s) << "."
<< std::endl;
return false;
}
aida_col_ntu* col_ntu = new aida_col_ntu(a_ntu.out(),a_name);
//create columns on the fillable.
base_ntu* sub_base_ntu = col_ntu->get_to_fill();
if(!sub_base_ntu) {delete col_ntu;return false;}
aida* sub_aida = inlib::cast<base_ntu,aida>(*sub_base_ntu);
if(!sub_aida) {delete col_ntu;return false;}
std::vector<value> vars = f.result();
if(!create_cols_from_vals(*sub_aida,vars)) {
columns::delete_columns(vars);
delete col_ntu;
return false;
}
columns::delete_columns(vars);
a_ntu.add_column(col_ntu);
//FIXME : double[]
} else {
a_ntu.out() << "inlib::ntu::create_col :"
<< " col type " << sout(a_type)
<< " not yet handled."
<< std::endl;
return false;
}
return true;
}
| bool inlib::ntu::create_cols_from_string | ( | aida & | a_ntu, |
| const std::string & | a_booking, | ||
| bool | a_verbose = false |
||
| ) | [inline] |
Definition at line 603 of file aida.
{
a_ntu.clear();
if(a_booking.empty()) {
a_ntu.out() << "inlib::ntu::create_cols_from_string :"
<< " empty booking string."
<< std::endl;
return false;
}
columns::finder f(a_ntu.out(),a_booking);
if(!f.find_variables()) {
a_ntu.out() << "inlib::ntu::create_cols_from_string :"
<< " find_variables() failed."
<< std::endl;
return false;
}
std::vector<value> vars = f.result();
if(a_verbose) columns::dump_columns(a_ntu.out(),vars);
if(!create_cols_from_vals(a_ntu,vars)) {
columns::delete_columns(vars);
a_ntu.clear();
return false;
}
columns::delete_columns(vars);
return true;
}
| bool inlib::ntu::create_cols_from_vals | ( | aida & | a_ntu, |
| const std::vector< value > & | a_vars, | ||
| bool | a_verbose = false |
||
| ) | [inline] |
Definition at line 242 of file aida.
{
std::vector<value>::const_iterator it;
for(it=a_vars.begin();it!=a_vars.end();++it) {
if((*it).type()==value::VOID_STAR) {
if(a_verbose){
a_ntu.out() << "inlib::ntu::create_cols_from_vals :"
<< " ITuple : " << (*it).label() << " : begin "
<< std::endl;
}
std::vector<value>* vars =
(std::vector<value>*)(*it).get_void_star();
aida_col_ntu* col_ntu = new aida_col_ntu(a_ntu.out(),(*it).label());
// create sub columns on the the "fillable" of col_ntu :
base_ntu* sub_base_ntu = col_ntu->get_to_fill();
if(!sub_base_ntu) return false;
aida* sub_aida = inlib::cast<base_ntu,aida>(*sub_base_ntu);
if(!sub_aida) return false;
if(!create_cols_from_vals(*sub_aida,*vars,a_verbose)) {
delete col_ntu;
return false;
}
a_ntu.add_column(col_ntu);
} else {
if(a_verbose){
std::string stype;
(*it).s_type(stype);
std::string sval;
(*it).tos(sval);
a_ntu.out() << "inlib::ntu::create_cols_from_vals :"
<< " " << stype << " : "
<< (*it).label() << " : "
<< sval
<< std::endl;
}
// char,short,int,float,double
// byte,boolean,string,long(for int64)
// double[]
base_col* col = 0;
if((*it).type()==value::CHAR) {
col = a_ntu.create_col<char>((*it).label(),(*it).get_char());
} else if((*it).type()==value::SHORT) {
col = a_ntu.create_col<short>((*it).label(),(*it).get_short());
} else if((*it).type()==value::INT) {
col = a_ntu.create_col<int>((*it).label(),(*it).get_int());
} else if((*it).type()==value::INT64) {
col = a_ntu.create_col<int64>((*it).label(),(*it).get_int64());
} else if((*it).type()==value::FLOAT) {
col = a_ntu.create_col<float>((*it).label(),(*it).get_float());
} else if((*it).type()==value::DOUBLE) {
col = a_ntu.create_col<double>((*it).label(),(*it).get_double());
} else if((*it).type()==value::UNSIGNED_CHAR) {
col = a_ntu.create_col<unsigned char>
((*it).label(),(*it).get_unsigned_char());
} else if((*it).type()==value::UNSIGNED_SHORT) {
col = a_ntu.create_col<unsigned short>
((*it).label(),(*it).get_unsigned_short());
} else if((*it).type()==value::UNSIGNED_INT) {
col = a_ntu.create_col<unsigned int>
((*it).label(),(*it).get_unsigned_int());
} else if((*it).type()==value::UNSIGNED_INT64) {
col = a_ntu.create_col<uint64>
((*it).label(),(*it).get_unsigned_int64());
} else if((*it).type()==value::BOOL) {
col = a_ntu.create_col<bool>((*it).label(),(*it).get_bool());
} else if((*it).type()==value::STRING) {
col = a_ntu.create_col<std::string>
((*it).label(),(*it).get_string());
} else if((*it).type()==value::INT64) {
col = a_ntu.create_col<int64>((*it).label(),(*it).get_int64());
}
if(!col) {
std::string stype;
(*it).s_type(stype);
std::string sval;
(*it).tos(sval);
a_ntu.out() << "inlib::ntu::create_cols_from_vals :"
<< " failed for " << stype << " : "
<< (*it).label() << " : "
<< sval
<< std::endl;
return false;
}
}
}
return true;
}
| aida_col_ntu* inlib::ntu::find_col_ntu | ( | aida & | a_ntu, |
| const std::string & | a_name | ||
| ) | [inline] |
| base_col* inlib::ntu::find_leaf_column | ( | const base_ntu & | a_ntu, |
| const std::string & | a_name | ||
| ) | [inline] |
Definition at line 867 of file aida.
{
const std::vector<base_col*>& cols = a_ntu.cols();
std::vector<base_col*>::const_iterator it;
for(it=cols.begin();it!=cols.end();++it) {
aida_col_ntu* col = cast<base_col,aida_col_ntu>(*(*it));
if(col) {
base_ntu* sub = col->get_to_fill(); //it holds the "sub" cols schema.
if(!sub) return 0;
base_col* fcol = find_leaf_column(*sub,a_name);
if(fcol) return fcol;
} else {
if((*it)->name()==a_name) return *it;
}
}
return 0;
}
1.7.5.1