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

List of all members.

Public Member Functions

virtual const std::string & name () const
virtual const std::string & title () const
virtual const std::string & store_class_name () const
virtual bool stream (buffer &a_buffer) const
virtual void add_tot_bytes (uint32 a_n)
virtual void add_zip_bytes (uint32 a_n)
virtual idirdir ()
virtual const idirdir () const
 tree (idir &a_dir, const std::string &a_name, const std::string &a_title)
virtual ~tree ()
branchcreate_branch (const std::string &a_name)
bool fill (uint32 &a_nbytes)

Protected Member Functions

 tree (const tree &a_from)
treeoperator= (const tree &)

Protected Attributes

idirm_dir
std::ostream & m_out
std::string m_name
std::string m_title
ObjArray< branchm_branches
uint64 m_entries
uint64 m_tot_bytes
uint64 m_zip_bytes

Detailed Description

Definition at line 15 of file tree.


Constructor & Destructor Documentation

inlib::wroot::tree::tree ( idir a_dir,
const std::string &  a_name,
const std::string &  a_title 
) [inline]

Definition at line 86 of file tree.

  :m_dir(a_dir)
  ,m_out(a_dir.file().out())
  ,m_name(a_name)
  ,m_title(a_title)
  ,m_entries(0)
  ,m_tot_bytes(0)
  ,m_zip_bytes(0)
  {
#ifdef INLIB_MEM
    mem::increment(s_class().c_str());
#endif
    a_dir.append_object(this); //a_dir takes ownership of tree.
  }
virtual inlib::wroot::tree::~tree ( ) [inline, virtual]

Definition at line 102 of file tree.

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

Definition at line 108 of file tree.

  : iobject(a_from),itree(a_from)
  ,m_dir(a_from.m_dir)
  ,m_out(a_from.m_out)
  {}

Member Function Documentation

virtual void inlib::wroot::tree::add_tot_bytes ( uint32  a_n) [inline, virtual]

Implements inlib::wroot::itree.

Definition at line 81 of file tree.

{m_tot_bytes += a_n;}
virtual void inlib::wroot::tree::add_zip_bytes ( uint32  a_n) [inline, virtual]

Implements inlib::wroot::itree.

Definition at line 82 of file tree.

{m_zip_bytes += a_n;}
branch* inlib::wroot::tree::create_branch ( const std::string &  a_name) [inline]

Definition at line 117 of file tree.

                                                {
    branch* br = new branch(*this,a_name,m_name);
    m_branches.push_back(br);
    return br;
  }
virtual idir& inlib::wroot::tree::dir ( ) [inline, virtual]

Implements inlib::wroot::itree.

Definition at line 83 of file tree.

{return m_dir;}
virtual const idir& inlib::wroot::tree::dir ( ) const [inline, virtual]

Implements inlib::wroot::itree.

Definition at line 84 of file tree.

{return m_dir;}
bool inlib::wroot::tree::fill ( uint32 a_nbytes) [inline]

Definition at line 123 of file tree.

                              {
    // Fill all branches of a Tree :
    //   This function loops on all the branches of this tree.
    //   For each branch, it copies to the branch buffer (basket) the current
    //   values of the leaves data types.
    //   If a leaf is a simple data type, a simple conversion to a machine
    //   independent format has to be done.
    a_nbytes = 0;
    std::vector<branch*>::const_iterator it;
    for(it=m_branches.begin();it!=m_branches.end();++it) {
      //FIXME if ((*it)->testBit(kDoNotProcess)) continue;
      uint32 n;
      if(!(*it)->fill(n)) {a_nbytes = 0;return false;}
      a_nbytes += n;
    } 

    m_entries++;

    //if (fTotBytes - fSavedBytes > fAutoSave) {
    //  if(!autoSave()) return false;
    //}

    return true;
  }
virtual const std::string& inlib::wroot::tree::name ( ) const [inline, virtual]

Implements inlib::wroot::iobject.

Definition at line 23 of file tree.

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

Definition at line 113 of file tree.

{return *this;}
virtual const std::string& inlib::wroot::tree::store_class_name ( ) const [inline, virtual]

Implements inlib::wroot::iobject.

Definition at line 25 of file tree.

                                                    {
    static const std::string s_v("TTree");
    return s_v;
  }
virtual bool inlib::wroot::tree::stream ( buffer a_buffer) const [inline, virtual]

Implements inlib::wroot::iobject.

Definition at line 29 of file tree.

                                              {
    unsigned int c;
    if(!a_buffer.write_version(5,c)) return false;

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

    // Beurk.
    if(!AttLine_stream(a_buffer)) return false;
    if(!AttFill_stream(a_buffer)) return false;
    if(!AttMarker_stream(a_buffer)) return false;

    double fEntries = (double)m_entries;
    if(!a_buffer.write(fEntries)) return false;

    double fTotBytes = (double)m_tot_bytes;
    double fZipBytes = (double)m_zip_bytes;
    if(!a_buffer.write(fTotBytes)) return false;
    if(!a_buffer.write(fZipBytes)) return false;
    if(!a_buffer.write((double)0)) return false; //fSavedBytes
    if(!a_buffer.write((int)0)) return false;    //fTimerInterval
    if(!a_buffer.write((int)25)) return false;   //fScanField (25)
    if(!a_buffer.write((int)0)) return false;    //fUpdate
    if(!a_buffer.write((int)1000000000)) return false; //fMaxEntryLoop
    int fMaxVirtualSize = 0;
    int fAutoSave = 100000000;
    if(!a_buffer.write(fMaxVirtualSize)) return false;
    if(!a_buffer.write(fAutoSave)) return false;
    if(!a_buffer.write((int)1000000)) return false;    //fEstimate;

    if(!m_branches.stream(a_buffer)) return false;

   {ObjArray<base_leaf> m_leaves;
    std::vector<branch*>::const_iterator itb;
    for(itb=m_branches.begin();itb!=m_branches.end();++itb) {
      const std::vector<base_leaf*>& leaves = (*itb)->leaves();
      std::vector<base_leaf*>::const_iterator itl;
      for(itl=leaves.begin();itl!=leaves.end();++itl) {
        m_leaves.push_back(*itl); //WARNING : ownership touchy.
      }
    }
    if(!m_leaves.stream(a_buffer)) return false;
    m_leaves.clear();} //WARNING : important.

    // fIndexValues (TArrayD).
    if(!Array_stream(a_buffer,std::vector<double>())) return false; //TArrayD
    // fIndex (TArrayI).
    if(!Array_stream(a_buffer,std::vector<int>())) return false; //TArrayI

    if(!a_buffer.set_byte_count(c)) return false;
    return true;
  }    
virtual const std::string& inlib::wroot::tree::title ( ) const [inline, virtual]

Implements inlib::wroot::iobject.

Definition at line 24 of file tree.

{return m_title;}

Member Data Documentation

Definition at line 155 of file tree.

Definition at line 149 of file tree.

Definition at line 156 of file tree.

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

Definition at line 152 of file tree.

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

Definition at line 150 of file tree.

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

Definition at line 153 of file tree.

Definition at line 157 of file tree.

Definition at line 158 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