inlib  1.2.0
Public Member Functions | Protected Member Functions | Protected Attributes
inlib::rroot::tree Class Reference
Collaboration diagram for inlib::rroot::tree:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 tree (ifile &a_file, ifac &a_fac)
virtual ~tree ()
ifilefile ()
const std::string & name () const
const std::string & title () const
const std::vector< branch * > & branches () const
bool find_entry (uint32 a_entry, uint32 &a_nbytes)
void dump (std::ostream &a_out, const std::string &a_spaces="", const std::string &a_indent=" ")
branchfind_branch (const std::string &a_name, bool a_recursive=false) const
std::vector< base_leaf * > find_leaves ()
bool show (std::ostream &a_out, uint32 a_entry)
uint64 entries () const
bool stream (buffer &a_buffer)

Protected Member Functions

 tree (const tree &a_from)
treeoperator= (const tree &)
void _dump_branches (std::ostream &a_out, const std::vector< branch * > &a_bs, const std::string &a_spaces="", const std::string &a_indent=" ")
branch_find_branch (const std::vector< branch * > &a_bs, const std::string &a_name, bool a_recursive) const
void _find_leaves (const std::vector< branch * > &a_bs, std::vector< base_leaf * > &a_leaves)

Protected Attributes

ifilem_file
ifacm_fac
std::ostream & m_out
std::string m_name
std::string m_title
ObjArray< branchm_branches
uint64 m_entries

Detailed Description

Definition at line 19 of file tree.


Constructor & Destructor Documentation

inlib::rroot::tree::tree ( ifile a_file,
ifac a_fac 
) [inline]

Definition at line 25 of file tree.

  :m_file(a_file)
  ,m_fac(a_fac)
  ,m_out(a_file.out())
  ,m_name("")
  ,m_title("")
  ,m_branches(true)
  ,m_entries(0)
  {
#ifdef INLIB_MEM
    mem::increment(s_class().c_str());
#endif
  }
virtual inlib::rroot::tree::~tree ( ) [inline, virtual]

Definition at line 38 of file tree.

                 {
#ifdef INLIB_MEM
    mem::decrement(s_class().c_str());
#endif
  }
inlib::rroot::tree::tree ( const tree a_from) [inline, protected]

Definition at line 44 of file tree.

  :m_file(a_from.m_file)
  ,m_fac(a_from.m_fac)
  ,m_out(a_from.m_out)
  ,m_branches(false)
  {}

Member Function Documentation

void inlib::rroot::tree::_dump_branches ( std::ostream &  a_out,
const std::vector< branch * > &  a_bs,
const std::string &  a_spaces = "",
const std::string &  a_indent = " " 
) [inline, protected]

Definition at line 347 of file tree.

                                                             {
    std::vector<branch*>::const_iterator it;
    for(it=a_bs.begin();it!=a_bs.end();++it) {
      if(branch_element* be = inlib::cast<branch,branch_element>(*(*it))) {
        a_out << a_spaces
              << "branch_element :"
              << " name=" << sout((*it)->name())
              << " title=" << sout((*it)->title())
              << " entry_number=" << be->entry_number()
              << " ref_cls=" << sout(be->class_name())
              << " (type=" << be->type()
              << ",id=" << be->id()
              << ",stype=" << be->streamer_type()
              << ")."
              << std::endl;
      } else {
        a_out << a_spaces
              << "branch :"
              << " name=" << sout((*it)->name())
              << " title=" << sout((*it)->title())
              << " entry_number=" << (*it)->entry_number()
              << std::endl;
      }
  
  
     {const std::vector<base_leaf*>& lvs = (*it)->leaves();
      std::vector<base_leaf*>::const_iterator itl;
      for(itl=lvs.begin();itl!=lvs.end();++itl) {
        a_out << a_spaces << a_indent
              << "leave :"
              << " name=" << sout((*itl)->name())
              << " title=" << sout((*itl)->title())
              << " cls=" << sout((*itl)->s_cls())
              << std::endl;
      }}

      _dump_branches(a_out,(*it)->branches(),a_spaces+a_indent,a_indent);
    }
  }
branch* inlib::rroot::tree::_find_branch ( const std::vector< branch * > &  a_bs,
const std::string &  a_name,
bool  a_recursive 
) const [inline, protected]

Definition at line 390 of file tree.

                                                      {
    std::vector<branch*>::const_iterator it;
    for(it=a_bs.begin();it!=a_bs.end();++it) {
      if((*it)->name()==a_name) return *it;
      if(a_recursive) {
        branch* br = _find_branch((*it)->branches(),a_name,a_recursive);
        if(br) return br;
      }
    }
    return 0;
  }
void inlib::rroot::tree::_find_leaves ( const std::vector< branch * > &  a_bs,
std::vector< base_leaf * > &  a_leaves 
) [inline, protected]

Definition at line 404 of file tree.

                                                           {
    std::vector<branch*>::const_iterator it;
    for(it=a_bs.begin();it!=a_bs.end();++it) {
     {const std::vector<base_leaf*>& lvs = (*it)->leaves();
      std::vector<base_leaf*>::const_iterator itl;
      for(itl=lvs.begin();itl!=lvs.end();++itl) {
        a_leaves.push_back(*itl);
      }}

      _find_leaves((*it)->branches(),a_leaves);
    }
  }
const std::vector<branch*>& inlib::rroot::tree::branches ( ) const [inline]

Definition at line 57 of file tree.

{return m_branches;}
void inlib::rroot::tree::dump ( std::ostream &  a_out,
const std::string &  a_spaces = "",
const std::string &  a_indent = " " 
) [inline]

Definition at line 74 of file tree.

                                                   {
    a_out << a_spaces
          << "tree :"
          << " name=" << sout(m_name)
          << " title=" << sout(m_title)
          << " entries=" << m_entries
          << std::endl;
    _dump_branches(a_out,m_branches,a_spaces+a_indent,a_indent);
  }
uint64 inlib::rroot::tree::entries ( ) const [inline]

Definition at line 110 of file tree.

{return m_entries;}
ifile& inlib::rroot::tree::file ( ) [inline]

Definition at line 52 of file tree.

{return m_file;}
branch* inlib::rroot::tree::find_branch ( const std::string &  a_name,
bool  a_recursive = false 
) const [inline]

Definition at line 86 of file tree.

                                                             {
    return _find_branch(m_branches,a_name,a_recursive);
  }
bool inlib::rroot::tree::find_entry ( uint32  a_entry,
uint32 a_nbytes 
) [inline]

Definition at line 59 of file tree.

                                                   {
    a_nbytes = 0;
    if(a_entry>=m_entries) return false;
    int nbytes = 0;
    //fReadEntry = a_entry;
    std::vector<branch*>::const_iterator it;
    for(it=m_branches.begin();it!=m_branches.end();++it) {
      uint32 n;
      if(!(*it)->find_entry(a_entry,n)) return false;
      nbytes += n;
    }
    a_nbytes = nbytes;
    return true;
  }
std::vector<base_leaf*> inlib::rroot::tree::find_leaves ( ) [inline]

Definition at line 91 of file tree.

                                     {
    std::vector<base_leaf*> leaves;
    _find_leaves(m_branches,leaves);
    return leaves;
  }
const std::string& inlib::rroot::tree::name ( ) const [inline]

Definition at line 54 of file tree.

{return m_name;}
tree& inlib::rroot::tree::operator= ( const tree ) [inline, protected]

Definition at line 50 of file tree.

{return *this;}
bool inlib::rroot::tree::show ( std::ostream &  a_out,
uint32  a_entry 
) [inline]

Definition at line 101 of file tree.

                                             {
    a_out << "======> EVENT:" << a_entry << std::endl;
    std::vector<branch*>::const_iterator it;
    for(it=m_branches.begin();it!=m_branches.end();++it) {
      if(!(*it)->show(a_out,a_entry)) return false;
    }
    return true;
  }
bool inlib::rroot::tree::stream ( buffer a_buffer) [inline]

Definition at line 112 of file tree.

                               {
    uint64 m_tot_bytes;
    uint64 m_zip_bytes;
    uint64 m_saved_bytes;

    short v;
    unsigned int s, c;
    if(!a_buffer.read_version(v,s,c)) return false;

    //::printf("debug : tree::stream : version %d count %d\n",v,c);

    //if (v > 4) {
      //TTree::Class()->ReadBuffer(b, this, v, s, c);
      //if (fEstimate <= 10000) fEstimate = 1000000;
      //m_saved_bytes = m_tot_bytes;
      //fDirectory = gDirectory;
      //gDirectory->Append(this);
      //return;
    //}

    if(!Named_stream(a_buffer,m_name,m_title)) return false;

    if(!AttLine_stream(a_buffer)) return false;
    if(!AttFill_stream(a_buffer)) return false;
    if(!AttMarker_stream(a_buffer)) return false;

    if(v<=4) {
      int dummy_int;

      if(!a_buffer.read(dummy_int)) return false; //fScanField
      if(!a_buffer.read(dummy_int)) return false; //fMaxEntryLoop
     {int fMaxVirtualSize;
      if(!a_buffer.read(fMaxVirtualSize)) return false;}
     {double v;
      if(!a_buffer.read(v)) return false;
      m_entries = uint64(v);}
     {double v;
      if(!a_buffer.read(v)) return false;
      m_tot_bytes = uint64(v);}
     {double v;
      if(!a_buffer.read(v)) return false;
      m_zip_bytes = uint64(v);}
     {int fAutoSave;
      if(!a_buffer.read(fAutoSave)) return false;}
      if(!a_buffer.read(dummy_int)) return false; //fEstimate

    } else if(v<=9) {
     {double v;
      if(!a_buffer.read(v)) return false;
      m_entries = uint64(v);}
     {double v;
      if(!a_buffer.read(v)) return false;
      m_tot_bytes = uint64(v);}
     {double v;
      if(!a_buffer.read(v)) return false;
      m_zip_bytes = uint64(v);}
     {double v;
      if(!a_buffer.read(v)) return false;
      m_saved_bytes = uint64(v);}

      int dummy_int;
      if(!a_buffer.read(dummy_int)) return false; //fTimerInterval
      if(!a_buffer.read(dummy_int)) return false; //fScanField
      if(!a_buffer.read(dummy_int)) return false; //fUpdate
      if(!a_buffer.read(dummy_int)) return false; //fMaxEntryLoop

     {int fMaxVirtualSize;
      if(!a_buffer.read(fMaxVirtualSize)) return false;}
     {int fAutoSave;
      if(!a_buffer.read(fAutoSave)) return false;}
      if(!a_buffer.read(dummy_int)) return false; //fEstimate

    } else if(v<16) { //FIXME : what is the exact version ?
      double dummy_double;
      int dummy_int;

     {double v;
      if(!a_buffer.read(v)) return false;
      m_entries = uint64(v);}
     {double v;
      if(!a_buffer.read(v)) return false;
      m_tot_bytes = uint64(v);}
     {double v;
      if(!a_buffer.read(v)) return false;
      m_zip_bytes = uint64(v);}
     {double v;
      if(!a_buffer.read(v)) return false;
      m_saved_bytes = uint64(v);}
      if(!a_buffer.read(dummy_double)) return false; //fWeight
      if(!a_buffer.read(dummy_int)) return false; //fTimerInterval
      if(!a_buffer.read(dummy_int)) return false; //fScanField
      if(!a_buffer.read(dummy_int)) return false; //fUpdate
      if(!a_buffer.read(dummy_int)) return false; //fMaxEntryLoop

     {int fMaxVirtualSize;
      if(!a_buffer.read(fMaxVirtualSize)) return false;}
     {int fAutoSave;
      if(!a_buffer.read(fAutoSave)) return false;}
      if(!a_buffer.read(dummy_int)) return false; //fEstimate

    } else { //v>=16
      double dummy_double;
      int dummy_int;
      int64 dummy_int64;

     {uint64 v;
      if(!a_buffer.read(v)) return false;
      m_entries = v;}
     {uint64 v;
      if(!a_buffer.read(v)) return false;
      m_tot_bytes = v;}
     {uint64 v;
      if(!a_buffer.read(v)) return false;
      m_zip_bytes = v;}
     {uint64 v;
      if(!a_buffer.read(v)) return false;
      m_saved_bytes = v;}
      if(!a_buffer.read(dummy_double)) return false; //fWeight

      if(!a_buffer.read(dummy_int)) return false; //fTimerInterval
      if(!a_buffer.read(dummy_int)) return false; //fScanField
      if(!a_buffer.read(dummy_int)) return false; //fUpdate

      if(!a_buffer.read(dummy_int64)) return false; //fMaxEntries
      if(!a_buffer.read(dummy_int64)) return false; //fMaxEntryLoop
     {uint64 fMaxVirtualSize;
      if(!a_buffer.read(fMaxVirtualSize)) return false;}
     {uint64 fAutoSave;
      if(!a_buffer.read(fAutoSave)) return false;}
      if(!a_buffer.read(dummy_int64)) return false; //fEstimate

    }
    //FIXME if (fEstimate <= 10000) fEstimate = 1000000;

    //TObjArray
    //The below m_branches.read will create leaves.
    //::printf("debug : tree : read branches : begin\n");
   {ifac::args args;
    if(!m_branches.stream(a_buffer,m_fac,args)) {
      m_out << "inlib::rroot::tree::stream : "
            << "can't read branches."
            << std::endl;
      return false;
    }}
    //::printf("debug : tree : read branches : end\n");

    //TObjArray
    // We read leaves in order to keep streaming synchronisation.
    // In fact m_leaves are references to existing leaves read by 
    // the branches in the upper line of code.
    //::printf("debug : tree : read leaves : begin\n");
   {ObjArray<base_leaf> m_leaves(true);
    ifac::args args;
    if(!m_leaves.stream(a_buffer,m_fac,args)) {
      m_out << "inlib::rroot::tree::stream : "
            << "can't read leaves."
            << std::endl;
      return false;
    }}
    //::printf("debug : tree : read leaves : end\n");

    if(v>=10) {
      //TList* fAliases
      ifac::args args;
      iro* obj;
      if(!a_buffer.read_object(m_fac,args,obj)) {
        m_out << "inlib::rroot::tree::stream : "
              << "can't read fAliases."
              << std::endl;
        return false;
      }
      delete obj;
    } 

    m_saved_bytes = m_tot_bytes;
   {std::vector<double> v;
    if(!Array_stream<double>(a_buffer,v)) return false;} //fIndexValues TArrayD

   {std::vector<int> v;
    if(!Array_stream<int>(a_buffer,v)) return false;}    // fIndex (TArrayI).

    if(v>=16) {
      //TVirtualIndex* fTreeIndex //FIXME ???
      ifac::args args;
      iro* obj;
      if(!a_buffer.read_object(m_fac,args,obj)) {
        m_out << "inlib::rroot::tree::stream : "
              << "can't read fAliases."
              << std::endl;
        return false;
      }
      delete obj;
    }

    if(v>=6) {
      //TList* fFriends
      ifac::args args;
      iro* obj;
      if(!a_buffer.read_object(m_fac,args,obj)) {
        m_out << "inlib::rroot::tree::stream : "
              << "can't read fFriends."
              << std::endl;
        return false;
      }
      delete obj;
    } 
    
    if(v>=16) {
      //TList* fUserInfo
     {ifac::args args;
      iro* obj;
      if(!a_buffer.read_object(m_fac,args,obj)) {
        m_out << "inlib::rroot::tree::stream : "
              << "can't read fUserInfo."
              << std::endl;
        return false;
      }
      delete obj;}
      //TBranchRef* fBranchRef
     {ifac::args args;
      iro* obj;
      if(!a_buffer.read_object(m_fac,args,obj)) {
        m_out << "inlib::rroot::tree::stream : "
              << "can't read fUserInfo."
              << std::endl;
        return false;
      }
      delete obj;}
    } 
    
    if(!a_buffer.check_byte_count(s,c,TTree_cls())) return false;

    return true;
  }    
const std::string& inlib::rroot::tree::title ( ) const [inline]

Definition at line 55 of file tree.

{return m_title;}

Member Data Documentation

Definition at line 440 of file tree.

Definition at line 441 of file tree.

Definition at line 434 of file tree.

Definition at line 433 of file tree.

std::string inlib::rroot::tree::m_name [protected]

Definition at line 437 of file tree.

std::ostream& inlib::rroot::tree::m_out [protected]

Definition at line 435 of file tree.

std::string inlib::rroot::tree::m_title [protected]

Definition at line 438 of file tree.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines