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

List of all members.

Public Member Functions

 directory (ifile &a_file)
virtual ~directory ()
const std::vector< key * > & keys () const
std::vector< key * > & keys ()
keyfind_key (const std::string &a_name)
uint32 nbytes_name () const
seek seek_keys () const
uint32 record_size (uint32 a_version) const
bool from_buffer (const char *aEOB, char *&a_buffer)
bool read_keys (uint32 &a_number)
void clear_keys ()

Protected Member Functions

 directory (const directory &a_from)
directoryoperator= (const directory &)

Static Protected Member Functions

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

Protected Attributes

ifilem_file
std::vector< key * > m_keys
date m_date_C
date m_date_M
uint32 m_nbytes_keys
uint32 m_nbytes_name
seek m_seek_directory
seek m_seek_parent
seek m_seek_keys

Detailed Description

Definition at line 17 of file directory.


Constructor & Destructor Documentation

inlib::rroot::directory::directory ( ifile a_file) [inline]

Definition at line 19 of file directory.

  :m_file(a_file)
  {
#ifdef INLIB_MEM
    mem::increment(s_class().c_str());
#endif
    m_date_C = 0; //.set();
    m_date_M = 0; //.set();
    m_nbytes_keys = 0;
    m_nbytes_name = 0;
    m_seek_directory = 0;
    m_seek_parent = 0;
    m_seek_keys = 0;
  }
virtual inlib::rroot::directory::~directory ( ) [inline, virtual]

Definition at line 33 of file directory.

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

Definition at line 40 of file directory.

                                    :m_file(a_from.m_file){
#ifdef INLIB_MEM
    mem::increment(s_class().c_str());
#endif
  }

Member Function Documentation

void inlib::rroot::directory::clear_keys ( ) [inline]

Definition at line 158 of file directory.

                    {
    std::vector<key*>::iterator it;
    for(it=m_keys.begin();it!=m_keys.end();) {
      key* k = *it;
      it = m_keys.erase(it);
      delete k;
    }
    m_keys.clear();
  }
key* inlib::rroot::directory::find_key ( const std::string &  a_name) [inline]

Definition at line 50 of file directory.

                                         {
    if(m_file.verbose()) {
      m_file.out() << "inlib::rroot::directory::find_key :" 
                   << " " << sout(a_name) << " ..."
                   << std::endl;
    }
    std::vector<key*>::const_iterator it;
    for(it=m_keys.begin();it!=m_keys.end();++it) {
      if((*it)->object_name()==a_name) return *it;
    }

    return 0;
  }
bool inlib::rroot::directory::from_buffer ( const char *  aEOB,
char *&  a_buffer 
) [inline]

Definition at line 83 of file directory.

                                                    {
    // Decode input buffer.
    // (Name, title) are stored in the (name, title) of the associated key.
    rbuf rb(m_file.out(),m_file.byte_swap(),aEOB,a_buffer);
    short versiondir;
    if(!rb.read(versiondir)) return false;
    unsigned int date;
    if(!rb.read(date)) return false;
    //fDateC.setDate(date);
    if(!rb.read(date)) return false;
    //fDateM.setDate(date);
   {int v;
    if(!rb.read(v)) return false;
    m_nbytes_keys = v;}
   {int v;
    if(!rb.read(v)) return false;
    m_nbytes_name = v;}
    if(versiondir>1000) {
      if(!rb.read(m_seek_directory)) return false;
      if(!rb.read(m_seek_parent)) return false;
      if(!rb.read(m_seek_keys)) return false;
    } else {
     {seek32 i;
      if(!rb.read(i)) return false;
      m_seek_directory = i;}
  
     {seek32 i;
      if(!rb.read(i)) return false;
      m_seek_parent = i;}
  
     {seek32 i;
      if(!rb.read(i)) return false;
      m_seek_keys = i;}
    }
    if(m_file.verbose()) {
      m_file.out() << "inlib::rroot::key::from_buffer :"
                   << " nbytes keys : " << m_nbytes_keys 
                   << ", pos keys : " << m_seek_keys 
                   << std::endl;
    }
    return true;
  }
const std::vector<key*>& inlib::rroot::directory::keys ( ) const [inline]

Definition at line 47 of file directory.

{return m_keys;}
std::vector<key*>& inlib::rroot::directory::keys ( ) [inline]

Definition at line 48 of file directory.

{return m_keys;}
uint32 inlib::rroot::directory::nbytes_name ( ) const [inline]

Definition at line 64 of file directory.

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

Definition at line 45 of file directory.

{return *this;}
bool inlib::rroot::directory::read_keys ( uint32 a_number) [inline]

Definition at line 125 of file directory.

                                   {
    // Read the KEYS :
    //  Every directory has a list (fKeys). This list has been
    //  written on the file via CERN-ROOT::TDirectory::writeKeys
    //  as a single data record.
    a_number = 0;

    clear_keys();
  
    key headerkey(m_file,m_seek_keys,m_nbytes_keys);
    if(!headerkey.read_file()) return false;
    char* buffer = headerkey.data_buffer();
    if(!headerkey.from_buffer(headerkey.eob(),buffer)) return false;
    int nkeys = 0;
    rbuf rb(m_file.out(),m_file.byte_swap(),headerkey.eob(),buffer);
    if(!rb.read(nkeys)) return false;
    if(m_file.verbose()) {
      m_file.out() << "inlib::rroot::directory::read_keys :"
                   << " nkeys " << nkeys
                   << "."
                   << std::endl;
    }
    for(int i=0;i<nkeys;i++) {
      key* k = new key(m_file);
      if(!k->from_buffer(headerkey.eob(),buffer)) {
        delete k;
        return false;
      }
      m_keys.push_back(k);
    }
    a_number = nkeys;
    return true;
  }
uint32 inlib::rroot::directory::record_size ( uint32  a_version) const [inline]

Definition at line 66 of file directory.

                                             {
    uint32 nbytes = sizeof(short);
    nbytes += sizeof(date); //m_date_C.record_size();
    nbytes += sizeof(date); //m_date_M.record_size();
    nbytes += sizeof(m_nbytes_keys);
    nbytes += sizeof(m_nbytes_name);
    if(a_version>=40000) {
      nbytes += sizeof(seek);
      nbytes += sizeof(seek);
      nbytes += sizeof(seek);
    } else {
      nbytes += sizeof(seek32);
      nbytes += sizeof(seek32);
      nbytes += sizeof(seek32);
    }
    return nbytes;
  }
static const std::string& inlib::rroot::directory::s_class ( ) [inline, static, protected]

Definition at line 171 of file directory.

                                    {
    static const std::string s_v("inlib::rroot::directory");
    return s_v;
  }
seek inlib::rroot::directory::seek_keys ( ) const [inline]

Definition at line 65 of file directory.

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

Definition at line 168 of file directory.

                                                   {
    return std::string("\"")+a_string+"\"";
  }

Member Data Documentation

Definition at line 179 of file directory.

Definition at line 180 of file directory.

Definition at line 176 of file directory.

std::vector<key*> inlib::rroot::directory::m_keys [protected]

Definition at line 177 of file directory.

Definition at line 181 of file directory.

Definition at line 182 of file directory.

Definition at line 183 of file directory.

Definition at line 185 of file directory.

Definition at line 184 of file directory.


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