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

List of all members.

Public Member Functions

virtual void * cast (const std::string &a_class) const
virtual bool stream (buffer &a_buffer)
virtual bool read_leaves (buffer &a_buffer)
virtual bool find_entry (uint32 a_entry, uint32 &a_nbytes)
 branch (ifile &a_file, ifac &a_fac)
virtual ~branch ()
uint32 entry_number () const
const std::string & name () const
const std::string & title () const
const std::vector< base_leaf * > & leaves () const
const std::vector< branch * > & branches () const
bool show (std::ostream &a_out, uint32 a_entry)

Static Public Member Functions

static const std::string & s_class ()

Protected Member Functions

 branch (const branch &a_from)
branchoperator= (const branch &)
basketget_basket (seek a_pos, uint32 a_len)
void _clear ()
void _dump_first_last ()

Static Protected Member Functions

static std::string sout (const std::string &a_string)

Protected Attributes

ifilem_file
std::ostream & m_out
ifacm_fac
std::vector< std::pair< uint32,
uint32 > > 
m_first_last
std::map< uint32, std::pair
< basket *, bool > > 
m_baskets
ObjArray< basketm_streamed_baskets
basketm__read_basket
std::string m_name
std::string m_title
bool fAutoDelete
ObjArray< branchm_branches
ObjArray< base_leafm_leaves
uint32 fEntryOffsetLen
uint32 m_write_basket
uint32 m_entry_number
uint32 m_read_basket
int * fBasketBytes
 Current basket number when reading.
int * fBasketEntry
seekfBasketSeek

Detailed Description

Definition at line 20 of file branch.


Constructor & Destructor Documentation

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

Definition at line 704 of file branch.

  :m_file(a_file)
  ,m_out(a_file.out())
  ,m_fac(a_fac)

  ,m_streamed_baskets(true)
  ,m__read_basket(0)

  //,m_bits(0)
  ,m_name("")
  ,m_title("")
  ,fAutoDelete(false)

  ,m_branches(true)
  ,m_leaves(true)

  ,fEntryOffsetLen(0)
  ,m_write_basket(0)
  ,m_entry_number(0)
  ,m_read_basket(0)
  ,fBasketBytes(0)
  ,fBasketEntry(0)
  ,fBasketSeek(0)
  {
#ifdef INLIB_MEM
    mem::increment(s_class().c_str());
#endif
  }
virtual inlib::rroot::branch::~branch ( ) [inline, virtual]

Definition at line 732 of file branch.

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

Definition at line 739 of file branch.

  : iro(a_from)
  ,m_file(a_from.m_file),m_out(a_from.m_out),m_fac(a_from.m_fac)
  ,m_streamed_baskets(false),m__read_basket(0)
  ,m_branches(false),m_leaves(false){}

Member Function Documentation

void inlib::rroot::branch::_clear ( ) [inline, protected]

Definition at line 843 of file branch.

                {
    delete [] fBasketEntry;
    delete [] fBasketBytes;
    delete [] fBasketSeek;
    fBasketEntry = 0;
    fBasketBytes = 0;
    fBasketSeek = 0;

   {std::map<uint32, std::pair<basket*,bool> >::iterator it;
    for(it=m_baskets.begin();it!=m_baskets.end();++it) {
      if((*it).second.second) delete (*it).second.first;
    }
    m_baskets.clear();}

    m_branches.cleanup();
    m_leaves.cleanup();
    m_streamed_baskets.cleanup();
  }
void inlib::rroot::branch::_dump_first_last ( ) [inline, protected]

Definition at line 862 of file branch.

                          {
    m_out << "inlib::rroot::branch::_dump_first_last :"
          << " first_last " << m_first_last.size()
          << std::endl;
    std::vector< std::pair<uint32,uint32> >::const_iterator it;
    for(it=m_first_last.begin();it!=m_first_last.end();++it) {
      uint32 first = (*it).first;
      uint32 last = (*it).second;
      m_out << "inlib::rroot::branch::stream :"
            << "   first " << first
            << "   last " << last
            << std::endl;
    }
  }
const std::vector<branch*>& inlib::rroot::branch::branches ( ) const [inline]

Definition at line 750 of file branch.

{return m_branches;}
virtual void* inlib::rroot::branch::cast ( const std::string &  a_class) const [inline, virtual]

Implements inlib::rroot::iro.

Reimplemented in inlib::rroot::branch_element.

Definition at line 28 of file branch.

                                                     {
    if(void* p = inlib::cmp_cast<branch>(this,a_class)) {return p;}
    else return 0;
  }
uint32 inlib::rroot::branch::entry_number ( ) const [inline]

Definition at line 746 of file branch.

{return m_entry_number;}
virtual bool inlib::rroot::branch::find_entry ( uint32  a_entry,
uint32 a_nbytes 
) [inline, virtual]

Reimplemented in inlib::rroot::branch_element.

Definition at line 498 of file branch.

                                                          {
    // Read all leaves of entry and return total number of bytes :
    // The input argument entry is the entry serial number in the current tree.
    a_nbytes = 0;
    //if(_test_bit(kDoNotProcess())) return true;

    //if(fReadEntry == (int)a_entry) return true;
    if(a_entry>=m_entry_number) {
      //m_out << "inlib::rroot::branch::find_entry :"
      //      << " for branch " << sout(m_name) << " :"
      //      << " a_entry not within [0," << m_entry_number << "[."
      //      << std::endl;
      //return false;
      return true; //CERN-ROOT does not consider it is an error.
    }
    if(!m_entry_number || m_first_last.empty() ) { //GB
      m_out << "inlib::rroot::branch::find_entry :"
            << " nothing to read."
            << std::endl;
      return false; //nothing to read.
    }

    if(m_read_basket>=m_first_last.size()) {
      m_out << "inlib::rroot::branch::find_entry :"
            << " bad m_first_last access."
            << std::endl;
      return false;
    }

    uint32 first = m_first_last[m_read_basket].first;
    uint32 last = m_first_last[m_read_basket].second;

    // Are we still in the same ReadBasket?
    if((a_entry<first)||(a_entry>last)) {
      m__read_basket = 0;
      uint32 old_read_basket = m_read_basket;

      //look first in the next basket window :
      bool found = false;
      if((m_read_basket+1)<m_first_last.size()) {
        first = m_first_last[m_read_basket+1].first;
        last = m_first_last[m_read_basket+1].second;
        if((a_entry>=first)&&(a_entry<=last)) {
          m_read_basket++;
          found = true;
        }   
      }
      if(!found) {
        uint32 count = 0;
        std::vector< std::pair<uint32,uint32> >::const_iterator it;
        for(it=m_first_last.begin();it!=m_first_last.end();++it,count++) {
          first = (*it).first;
          last = (*it).second;
          if((a_entry>=first)&&(a_entry<=last)) {
            m_read_basket = count;
            found = true;
            break;
          }   
        }
      }
      if(!found) { //something weird in fBasketEntry.
        m_out << "inlib::rroot::branch::find_entry :"
              << " fancy fBasketEntry."
              << std::endl;
        return false;
      } else {
        // if found, erase m_baskets[old_read_basket] to avoid
        // having all data in memory !
        std::map<uint32, std::pair<rroot::basket*,bool> >::iterator it =
          m_baskets.find(old_read_basket);
        if(it!=m_baskets.end()) {
          if((*it).second.second) {
            basket* bsk = (*it).second.first;
            m_baskets.erase(it);
            delete bsk;
            //::printf("debug : erase basket %d\n",old_read_basket);
          }
        }
      }
    }

    if(!m__read_basket) {

      rroot::basket* bsk = 0;
      std::map<uint32, std::pair<basket*,bool> >::iterator it =
        m_baskets.find(m_read_basket);
      if(it!=m_baskets.end()) {
        bsk = (*it).second.first;
      } else {
        if(m_read_basket>=m_write_basket) {
          m_out << "inlib::rroot::branch::find_entry :"
                << " basket lacking !"
                << " wanting index " << m_read_basket
                << ". fBasketSeek entries " << m_write_basket
                << std::endl;
          return false;
        }
        if(!fBasketSeek[m_read_basket]) {
          m_out << "inlib::rroot::branch::find_entry :"
                << " fBasketSeek is null for index " << m_read_basket
                << std::endl;
          return false;
        }
        if(!fBasketBytes[m_read_basket]) {
          m_out << "inlib::rroot::branch::find_entry :"
                << " fBasketBytes is null for index " << m_read_basket
                << std::endl;
          return false;
        }

        bsk = get_basket(fBasketSeek[m_read_basket],
                         fBasketBytes[m_read_basket]);
        if(!bsk) {
          m_out << "inlib::rroot::branch::find_entry :"
                << " can't read basket " << m_read_basket
                << " at file pos " << fBasketSeek[m_read_basket]
                << " and size " << fBasketBytes[m_read_basket]
                << std::endl;
          return false;
        }

        //m_out << "inlib::rroot::branch::find_entry :"
        //      << " got basket " << m_read_basket
        //      << " of size " << fBasketBytes[m_read_basket]
        //      << std::endl;

        m_baskets[m_read_basket] = std::pair<basket*,bool>(bsk,true);
      }

      m__read_basket = bsk;
    }

    // Set entry offset in buffer and read data from all leaves
    //buf->resetMap();
  
    uint32 bufbegin;
   {int* entry_offset = m__read_basket->entry_offset();
    if(entry_offset) {
      uint32 index = a_entry-first;
      if(index>=m__read_basket->nev()) {
        m_out << "inlib::rroot::branch::find_entry :"
              << " can't access entry offset " << index
              << ". nev " << m__read_basket->nev()
              << std::endl;
        return false;
      }
      bufbegin = entry_offset[index];
      //::printf("debug : xxx++ %u : %u\n",index,bufbegin);
    } else {
      bufbegin = m__read_basket->key_length() + 
                   (a_entry-first)*m__read_basket->nev_buf_size();
    }}

   {int* displacement = m__read_basket->displacement();
    if(displacement) {
      m_out << "inlib::rroot::branch::find_entry :"
            << " not null displacement. Not yet handled."
            << std::endl;
      //buf->setDisplacement(displacement[a_entry-first]);
    } else {
      //buf->setDisplacement();
    }}

/*
    if(bufbegin>=m__read_basket->buf_size()) {
      m_out << "inlib::rroot::branch::find_entry :"
            << " bad buffer access for entry " << a_entry
            << ". bufbegin " << bufbegin
            << ", buf_size " << basket->buf_size()
            << ", (entry-first) " << (a_entry-first)
            << std::endl;
     {int* entry_offset = m__read_basket->entry_offset();
      if(entry_offset) {
        uint32 nev = m__read_basket->nev();
        ::printf("debug : eoff : num %d\n",nev);
        for(uint32 i=0;i<nev;i++){        
          ::printf("debug : eoff %d : %d\n",i,entry_offset[i]);
        }
      }}
      return false;
    }
*/

    rroot::buffer buffer(m_out,m_file.byte_swap(),
                    m__read_basket->buf_size(),m__read_basket->buf(),0,false); 
    buffer.set_offset(bufbegin);

    if(!read_leaves(buffer)) {
      m_out << "inlib::rroot::branch::find_entry :"
            << " can't read leaves for entry " << a_entry
            << ". read_basket was " << m_read_basket
            << ", first " << first
            << ", last " << last
            << "."
            << std::endl;
      return false;
    }

    //fReadEntry = a_entry;

    a_nbytes = buffer.length() - bufbegin;

    return true;
  }
basket* inlib::rroot::branch::get_basket ( seek  a_pos,
uint32  a_len 
) [inline, protected]

Definition at line 782 of file branch.

                                              {
    //if(fBranch.tree().memoryFull(fBufferSize)) fBranch.dropBaskets();
    if(!a_len) return 0;  

    rroot::basket* basket = 
      new rroot::basket(m_file,a_pos,a_len); //basket is a key.
    if(!basket->read_file()) {
      m_out << "inlib::rroot::branch::get_basket :" 
            << " read_file() failed."
            << std::endl;
      delete basket;
      return 0;
    }
   {rroot::buffer buffer(m_out,m_file.byte_swap(),
                         a_len,basket->buf(),0,false); 
    if(!basket->stream(buffer)) {
      m_out << "inlib::rroot::branch::get_basket :" 
            << " basket stream failed."
            << std::endl;
      delete basket;
      return 0;
    }}
    unsigned int sz;    
    char* buf = basket->get_object_buffer(sz); //basket owns buf.
    if(!buf) {
      m_out << "inlib::rroot::branch::get_basket :" 
            << " get_object_buffer() failed."
            << std::endl;
      delete basket;
      return 0;
    }

    if(basket->seek_key()!=a_pos) { //consistency check.
      m_out << "inlib::rroot::branch::get_basket :" 
            << " seek anomaly."
            << " a_pos " << a_pos
            << " seek_key() " << basket->seek_key()
            << std::endl;
      delete basket;
      return 0;
    }
    //if(basket->nbytes()!=a_len) { //consistency check.
    //  m_out << "inlib::rroot::branch::get_basket :" 
    //        << " WARNING : length anomaly."
    //        << " a_len " << a_len
    //        << " nbytes() " << basket->nbytes()
    //       << std::endl;
    //}

    if(fEntryOffsetLen) {
    if(!basket->read_offset_tables()) {
      m_out << "inlib::rroot::branch::get_basket :" 
            << " read_offset_tables failed."
            << std::endl;
      delete basket;
      return 0;
    }}

    return basket;
  }
const std::vector<base_leaf*>& inlib::rroot::branch::leaves ( ) const [inline]

Definition at line 749 of file branch.

{return m_leaves;}
const std::string& inlib::rroot::branch::name ( ) const [inline]

Definition at line 747 of file branch.

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

Definition at line 744 of file branch.

{return *this;}
virtual bool inlib::rroot::branch::read_leaves ( buffer a_buffer) [inline, virtual]

Reimplemented in inlib::rroot::branch_element.

Definition at line 485 of file branch.

                                            {
    std::vector<base_leaf*>::const_iterator it;
    for(it=m_leaves.begin();it!=m_leaves.end();++it) {
      if(!(*it)->read_basket(a_buffer)) {
        m_out << "inlib::rroot::branch::read_leaves :" 
              << " read_basket failed."
              << std::endl;
        return false;
      }
    }
    return true;
  }
static const std::string& inlib::rroot::branch::s_class ( ) [inline, static]

Reimplemented in inlib::rroot::branch_element.

Definition at line 23 of file branch.

                                    {
    static const std::string s_v("inlib::rroot::branch");
    return s_v;
  }
bool inlib::rroot::branch::show ( std::ostream &  a_out,
uint32  a_entry 
) [inline]

Definition at line 752 of file branch.

                                             {
    // Print values of all active leaves for entry :
    // if entry==-1, print current entry (default)
    uint32 n;
    if(!find_entry(a_entry,n)) return false;

    std::vector<base_leaf*>::const_iterator it;
    for(it=m_leaves.begin();it!=m_leaves.end();++it) {
      base_leaf* bl = *it;

      uint32 num = bl->num_elem();
      num = inlib::mn<uint32>(num,10);
      if(!num) continue;

     {std::string s;
      uint32 len = bl->name().size()+128;
      inlib::sprintf(s,len," %-15s = ",bl->name().c_str());
      a_out << s;}

      for(uint32 i=0;i<num;i++) {
        if(i) a_out << ", ";
        bl->print_value(a_out,i);
      }

      a_out << std::endl;
    }

    return true;
  }
static std::string inlib::rroot::branch::sout ( const std::string &  a_string) [inline, static, protected]

Definition at line 880 of file branch.

                                                   {
    return std::string("\"")+a_string+"\"";
  }
virtual bool inlib::rroot::branch::stream ( buffer a_buffer) [inline, virtual]

Implements inlib::rroot::iro.

Reimplemented in inlib::rroot::branch_element.

Definition at line 32 of file branch.

                                        {
    _clear();

    int fCompress;
    int fBasketSize;
    int fNleaves;
    uint64 m_entries;

    uint64 m_tot_bytes;
    uint64 m_zip_bytes;
    int fSplitLevel;
    uint32 fMaxBaskets;
    int fOffset;

    unsigned int s,c;
    //FIXME gROOT->SetReadingObject(kTRUE);
    short v;
    if(!a_buffer.read_version(v,s,c)) return false;

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

    if (v > 5) {
      //TBranch::Class()->ReadBuffer(b, this, v, s, c);
      //gBranch = branchSave;
      //fDirectory = gDirectory;
      //fNleaves = m_leaves.GetEntriesFast();
      //if (fFileName.Length() != 0) fDirectory = 0;
      //gROOT->SetReadingObject(kFALSE);
      //return;
    }
    //====process old versions before automatic schema evolution

   {uint32 old = a_buffer.length();
    uint32 id;
    uint32 m_bits;
    if(!Object_stream(a_buffer,id,m_bits)) return false;
    a_buffer.set_offset(old);}
    
    if(!Named_stream(a_buffer,m_name,m_title)) return false;

    //::printf("debug : branch::stream %s %s\n",
    //   m_name.c_str(),m_title.c_str());

    if(v<=5) {
      if(!a_buffer.read(fCompress)) return false;
      if(!a_buffer.read(fBasketSize)) return false;
      if(!a_buffer.read(fEntryOffsetLen)) return false;
      if(!a_buffer.read(fMaxBaskets)) return false;
      if(!a_buffer.read(m_write_basket)) return false;
      if(!a_buffer.read(m_entry_number)) 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);}
      if(!a_buffer.read(fOffset)) return false;

    } else if(v<=6) {
      if(!a_buffer.read(fCompress)) return false;
      if(!a_buffer.read(fBasketSize)) return false;
      if(!a_buffer.read(fEntryOffsetLen)) return false;
      if(!a_buffer.read(m_write_basket)) return false;
      if(!a_buffer.read(m_entry_number)) return false;
      if(!a_buffer.read(fOffset)) return false;
      if(!a_buffer.read(fMaxBaskets)) 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);}

    } else if(v<=7) {
      if(!a_buffer.read(fCompress)) return false;
      if(!a_buffer.read(fBasketSize)) return false;
      if(!a_buffer.read(fEntryOffsetLen)) return false;
      if(!a_buffer.read(m_write_basket)) return false;
      if(!a_buffer.read(m_entry_number)) return false;
      if(!a_buffer.read(fOffset)) return false;
      if(!a_buffer.read(fMaxBaskets)) return false;
      if(!a_buffer.read(fSplitLevel)) 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);}

    } else if(v<=9) {
      if(!AttFill_stream(a_buffer)) return false;
      if(!a_buffer.read(fCompress)) return false;
      if(!a_buffer.read(fBasketSize)) return false;
      if(!a_buffer.read(fEntryOffsetLen)) return false;
      if(!a_buffer.read(m_write_basket)) return false;
      if(!a_buffer.read(m_entry_number)) return false;
      if(!a_buffer.read(fOffset)) return false;
      if(!a_buffer.read(fMaxBaskets)) return false;
      if(!a_buffer.read(fSplitLevel)) 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);}

    } else if(v<=10) {
      if(!AttFill_stream(a_buffer)) return false;

      if(!a_buffer.read(fCompress)) return false;
      if(!a_buffer.read(fBasketSize)) return false;
      if(!a_buffer.read(fEntryOffsetLen)) return false;
      if(!a_buffer.read(m_write_basket)) return false;
     {uint64 v;
      if(!a_buffer.read(v)) return false;
      m_entry_number = uint32(v);}
      if(!a_buffer.read(fOffset)) return false;
      if(!a_buffer.read(fMaxBaskets)) return false;
      if(!a_buffer.read(fSplitLevel)) return false;

     {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;}

    } else { //v>=11

      if(!AttFill_stream(a_buffer)) return false;
      if(!a_buffer.read(fCompress)) return false;
      if(!a_buffer.read(fBasketSize)) return false;
      if(!a_buffer.read(fEntryOffsetLen)) return false;
      if(!a_buffer.read(m_write_basket)) return false;
     {uint64 v;
      if(!a_buffer.read(v)) return false;
      m_entry_number = uint32(v);}
      if(!a_buffer.read(fOffset)) return false;
      if(!a_buffer.read(fMaxBaskets)) return false;
      if(!a_buffer.read(fSplitLevel)) return false;
     {uint64 v;
      if(!a_buffer.read(v)) return false;
      m_entries = v;}
     {uint64 v;
      if(!a_buffer.read(v)) return false;} //fFirstEntry
     {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;}
    }

    //::printf("debug : branch::stream : %s : fSplitLevel %d\n",m_name.c_str(),fSplitLevel);

    //TObjArray
    //::printf("debug : branch::stream : branches : begin\n");
   {ifac::args args;
    if(!m_branches.stream(a_buffer,m_fac,args)) {
      m_out << "inlib::rroot::branch::stream :"
            << " can't read branches."
            << std::endl;
      return false;
    }}
    //::printf("debug : branch::stream : branches : end %d\n",
    //    m_branches.size());

/* We see that with LHCb files.
    if(m_entry_number!=m_entries) {
      m_out << "inlib::rroot::branch::stream :"
            << " for branch " << sout(m_name) << " :"
            << " WARNING : m_entry_number!=m_entries."
            << " m_entry_number " << m_entry_number
            << " m_entries " << m_entries
            << std::endl;
      //return false;
    }
*/

    //TObjArray
    //::printf("debug : branch::stream : leaves : begin\n");
   {ifac::args args;
    args[ifac::arg_branch()] = this;
    if(!m_leaves.stream(a_buffer,m_fac,args)) {
      m_out << "inlib::rroot::branch::stream :"
            << " can't read leaves."
            << std::endl;
      return false;
    }}
    //::printf("debug : branch::stream : leaves : end\n");

    //TObjArray
    //IMPORTANT : accept_null=true
    //::printf("debug : branch::stream : streamed_baskets : begin\n");
   {ifac::args args;
    if(!m_streamed_baskets.stream(a_buffer,m_fac,args,true)) {
      m_out << "inlib::rroot::branch::stream :"
            << " can't read baskets."
            << std::endl;
      return false;
    }}
    //::printf("debug : branch::stream : streamed_baskets : end\n");
    
    fNleaves = m_leaves.size();

    if(fMaxBaskets<=0) {
      m_out << "inlib::rroot::branch::stream :"
            << " fMaxBaskets null."
            << std::endl;
      return false;
    }
    
    fBasketEntry = new int[fMaxBaskets];
    fBasketBytes = new int[fMaxBaskets];
    fBasketSeek = new seek[fMaxBaskets];
   {for(uint32 i=0;i<fMaxBaskets;i++) {
      fBasketEntry[i] = 0;
      fBasketBytes[i] = 0;
      fBasketSeek[i] = 0;
    }}

    if(v<6) {
     {uint32 n;
      if(!a_buffer.read_array<int>(fMaxBaskets,fBasketEntry,n)) {
        _clear();
        return false;
      }}
      if(v<=4) {
        for (uint32 i=0;i<fMaxBaskets;i++) fBasketBytes[i] = 0;
      } else {
        uint32 n;
        if(!a_buffer.read_array<int>(fMaxBaskets,fBasketBytes,n)) {
          _clear();
          return false;
        }
      }
      if(v<2) {
        //GB : comment.
        //for(int i=0;i<m_write_basket;i++) {
        //  fBasketSeek[i] = getBasket(i)->seekKey();
        //}
        m_out << "inlib::rroot::branch::stream :"
              << " v < 2. Not (yet) handled."
              << std::endl;
        _clear();
        return false;
      } else {
        int n;
        if(!a_buffer.read(n)) {
          _clear();
          return false;
        }
        for(int i=0;i<n;i++) {
          seek32 s;
          if(!a_buffer.read(s)) {
            _clear();
            return false;
          }
          fBasketSeek[i] = s;
        }
      }

    } else if(v<=9) {
      // See TStreamerInfo::ReadBuffer::ReadBasicPointer

      //Int_t[fMaxBaskets]
     {char isArray;
      if(!a_buffer.read(isArray)) {
        _clear();
        return false;
      }
      if(isArray) {
        if(!a_buffer.read_fast_array<int>(fBasketBytes,fMaxBaskets)) {
          _clear();
          return false;
        }
      }}

      //Int_t[fMaxBaskets]
     {char isArray;
      if(!a_buffer.read(isArray)) {
        _clear();
        return false;
      }
      if(isArray) {
        if(!a_buffer.read_fast_array<int>(fBasketEntry,fMaxBaskets)) {
          _clear();
          return false;
        }
      }}

      //Seek_t[fMaxBaskets]
     {char isBigFile;
      if(!a_buffer.read(isBigFile)) {
        _clear();
        return false;
      }
      if(isBigFile==2) {
        if(!a_buffer.read_fast_array<seek>(fBasketSeek,fMaxBaskets)) {
          _clear();
          return false;
        }
      } else {
        for(uint32 i=0;i<fMaxBaskets;i++) {
          seek32 s;
          if(!a_buffer.read(s)) {
            _clear();
            return false;
          }
          fBasketSeek[i] = s;
        }
      }}

    } else { //v>=10
      // See TStreamerInfo::ReadBuffer::ReadBasicPointer

      //Int_t[fMaxBaskets]
     {char isArray;
      if(!a_buffer.read(isArray)) {
        _clear();
        return false;
      }
      if(isArray) {
        if(!a_buffer.read_fast_array<int>(fBasketBytes,fMaxBaskets)) {
          _clear();
          return false;
        }
      }}

      //Long64_t[fMaxBaskets]
     {char isArray;
      if(!a_buffer.read(isArray)) {
        _clear();
        return false;
      }
      if(isArray) {
        uint64* v = new uint64[fMaxBaskets];
        if(!a_buffer.read_fast_array<uint64>(v,fMaxBaskets)) {
          _clear();
          return false;
        }
        for(uint32 i=0;i<fMaxBaskets;i++) fBasketEntry[i] = int(v[i]);
        delete [] v;
      }}

      //Long64_t[fMaxBaskets]
     {char isArray;
      if(!a_buffer.read(isArray)) {
        _clear();
        return false;
      }
      if(isArray) {
        uint64* v = new uint64[fMaxBaskets];
        if(!a_buffer.read_fast_array<uint64>(v,fMaxBaskets)) {
          _clear();
          return false;
        }
        for(uint32 i=0;i<fMaxBaskets;i++) fBasketSeek[i] = v[i];
        delete [] v;
      }}
    }
    
    if(v>2) {
      //TString
      std::string fileName;
      if(!a_buffer.read(fileName)) {
        _clear();
        return false;
      }
    }

    //FIXME if (v < 4) SetAutoDelete(kTRUE);
    //FIXME gROOT->SetReadingObject(kFALSE);
    if(!a_buffer.check_byte_count(s, c,"TBranch")) {
      _clear();
      return false;
    }

    //GB : analyse fBasketEntry.
    m_first_last.clear();
   {// There are (m_write_basket+1) sensitive elements in fBasketEntry :
    // (Do we have to check that ?)
    for(uint32 i=0;i<m_write_basket;i++) {
      uint32 first = fBasketEntry[i];
      uint32 last = fBasketEntry[i+1]-1;
      m_first_last.push_back(std::pair<uint32,uint32>(first,last));
    }
    if(m_entry_number) {
      uint32 first = fBasketEntry[m_write_basket];
      uint32 last = m_entry_number-1;
      m_first_last.push_back(std::pair<uint32,uint32>(first,last));
    }}
    //_dump_first_last();

    //GB : analyse fBasketSeek :
   {uint32 num = 0;
    uint32 mxi = 0;
    for(uint32 i=0;i<fMaxBaskets;i++) {
      if(!fBasketSeek[i]) continue;
      num++;
      mxi = inlib::mx(i,mxi);      
    }
    if(m_write_basket) {
      if((num!=m_write_basket)||(mxi!=(m_write_basket-1))) {
        m_out << "inlib::rroot::branch::stream :"
              << " fBasketSeek[] inconsistent with m_write_basket."
              << " m_write_basket " << m_write_basket
              << " num " << num
              << " mxi " << mxi
              << std::endl;
        _clear();
        return false;
      }
    }}

    //GB : analyse m_streamed_baskets :
   {std::vector<basket*>::iterator it;
    int index=0;
    for(it=m_streamed_baskets.begin();
        it!=m_streamed_baskets.end();++it,index++) {
      if(*it) {
        if(!(*it)->buf()||!(*it)->buf_size()) {
          m_out << "inlib::rroot::branch::stream :"
                << " expect a basket with a not empty buffer."
                << std::endl;
          return false;
        }
        //in the below, false is to say m_baskets is not owner of *it.
        m_baskets[index] = std::pair<basket*,bool>(*it,false);
      } 
    }}
    
    return true;
  }
const std::string& inlib::rroot::branch::title ( ) const [inline]

Definition at line 748 of file branch.

{return m_title;}

Member Data Documentation

Definition at line 901 of file branch.

Current basket number when reading.

Definition at line 908 of file branch.

Definition at line 909 of file branch.

Definition at line 910 of file branch.

Definition at line 904 of file branch.

Definition at line 893 of file branch.

std::map<uint32, std::pair<basket*,bool> > inlib::rroot::branch::m_baskets [protected]

Definition at line 891 of file branch.

Definition at line 902 of file branch.

Definition at line 906 of file branch.

Definition at line 889 of file branch.

Definition at line 887 of file branch.

std::vector< std::pair<uint32,uint32> > inlib::rroot::branch::m_first_last [protected]

Definition at line 890 of file branch.

Definition at line 903 of file branch.

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

Definition at line 898 of file branch.

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

Definition at line 888 of file branch.

Definition at line 907 of file branch.

Definition at line 892 of file branch.

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

Definition at line 899 of file branch.

Definition at line 905 of file branch.


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