inlib
1.2.0
|
Public Member Functions | |
base_looper (base_ntu &a_ntu, const base_col &a_col) | |
virtual | ~base_looper () |
base_looper (const base_looper &a_from) | |
base_looper & | operator= (const base_looper &a_from) |
bool | process () |
Static Public Member Functions | |
static const std::string & | s_class () |
Protected Member Functions | |
virtual bool | action (const T &a_value)=0 |
bool | _looper (base_ntu &a_sub, const std::vector< unsigned int > &a_is, unsigned int a_depth, bool &a_stop) |
Static Protected Member Functions | |
static bool | find_is (const base_ntu &a_ntu, const base_col *a_col, std::vector< unsigned int > &a_is, bool &a_found) |
Protected Attributes | |
base_ntu & | m_ntu |
const base_col & | m_col |
inlib::ntu::base_looper< T >::base_looper | ( | base_ntu & | a_ntu, |
const base_col & | a_col | ||
) | [inline] |
virtual inlib::ntu::base_looper< T >::~base_looper | ( | ) | [inline, virtual] |
inlib::ntu::base_looper< T >::base_looper | ( | const base_looper< T > & | a_from | ) | [inline] |
bool inlib::ntu::base_looper< T >::_looper | ( | base_ntu & | a_sub, |
const std::vector< unsigned int > & | a_is, | ||
unsigned int | a_depth, | ||
bool & | a_stop | ||
) | [inline, protected] |
Definition at line 742 of file aida.
{ if(a_depth>=a_is.size()) return false; unsigned int coli = a_is[a_depth]; const std::vector<base_col*>& cols = a_sub.cols(); if(coli>=cols.size()) return false; if(a_depth==(a_is.size()-1)) { //we reach the leaf. aida_col<T>* col = cast<base_col, aida_col<T> >(*(cols[coli])); if(!col) return false; a_sub.start(); while(a_sub.next()) { T v; if(!col->get_entry(v)) return false; if(!action(v)) {a_stop = true;break;} } } else { aida_col_ntu* col = cast<base_col,aida_col_ntu>(*(cols[coli])); if(!col) return false; a_sub.start(); while(a_sub.next()) { base_ntu* ntu = col->get_entry(); //not const. if(!ntu) return false; ntu->start(); while(ntu->next()) { if(!_looper(*ntu,a_is,a_depth+1,a_stop)) return false; if(a_stop) break; } } } return true; }
virtual bool inlib::ntu::base_looper< T >::action | ( | const T & | a_value | ) | [protected, pure virtual] |
Implemented in inlib::ntu::stat_looper< T >.
static bool inlib::ntu::base_looper< T >::find_is | ( | const base_ntu & | a_ntu, |
const base_col * | a_col, | ||
std::vector< unsigned int > & | a_is, | ||
bool & | a_found | ||
) | [inline, static, protected] |
Definition at line 707 of file aida.
{ // search the indices to reach the sub leaf a_col from the main a_ntu. // Note : it is assumed that a_is is empty and a_found = false before // calling with function. const std::vector<base_col*>& cols = a_ntu.cols(); std::vector<base_col*>::const_iterator it; // look if a_col is a leaf col of a_ntu : {unsigned int index = 0; for(it=cols.begin();it!=cols.end();++it,index++) { if(*it==a_col) { a_is.push_back(index); //leaf index is the last one in a_is. a_found = true; return true; } }} // go down sub ntu : {unsigned int index = 0; for(it=cols.begin();it!=cols.end();++it,index++) { aida_col_ntu* col = cast<base_col,aida_col_ntu>(*(*it)); if(!col) continue; base_ntu* sub = col->get_to_fill(); //it holds the "sub" cols schema. if(!sub) {a_is.clear();return false;} a_is.push_back(index); if(!find_is(*sub,a_col,a_is,a_found)) {a_is.clear();return false;} if(a_found) return true; a_is.pop_back(); }} return true; }
base_looper& inlib::ntu::base_looper< T >::operator= | ( | const base_looper< T > & | a_from | ) | [inline] |
bool inlib::ntu::base_looper< T >::process | ( | ) | [inline] |
Reimplemented in inlib::ntu::stat_looper< T >.
Definition at line 669 of file aida.
{ std::vector<unsigned int> is; bool found = false; if(!find_is(m_ntu,&m_col,is,found)) { m_ntu.out() << s_class() << "::process :" << " find_is failed." << std::endl; return false; } if(!found) { m_ntu.out() << s_class() << "::process :" << " find_is : col not found." << std::endl; return false; } if(is.empty()) { m_ntu.out() << s_class() << "::process :" << " is vec empty." << std::endl; return false; } //{m_ntu.out() << "debug : sz " << is.size() << std::endl; // std::vector<unsigned int>::const_iterator it; // for(it=is.begin();it!=is.end();++it){ // m_ntu.out() << " " << *it << std::endl; //}} bool stop = false; if(!_looper(m_ntu,is,0,stop)) { m_ntu.out() << s_class() << "::process :" << " _looper failed." << std::endl; return false; } return true; }
static const std::string& inlib::ntu::base_looper< T >::s_class | ( | ) | [inline, static] |
const base_col& inlib::ntu::base_looper< T >::m_col [protected] |
base_ntu& inlib::ntu::base_looper< T >::m_ntu [protected] |