g4tools  5.4.0
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
tools::rroot::directory Class Reference
Inheritance diagram for tools::rroot::directory:
Inheritance graph
[legend]
Collaboration diagram for tools::rroot::directory:
Collaboration graph
[legend]

Public Member Functions

 directory (ifile &a_file)
 
virtual ~directory ()
 
ifilefile ()
 
const std::vector< key * > & keys () const
 
std::vector< key * > & keys ()
 
keyfind_key (const std::string &a_name)
 
keyfind_key_from_class (const std::string &a_class)
 
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 ()
 

Static Public Member Functions

static const std::string & s_class ()
 

Protected Member Functions

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

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

◆ directory() [1/2]

tools::rroot::directory::directory ( ifile a_file)
inline

Definition at line 24 of file directory.

25  :m_file(a_file)
26  {
27 #ifdef TOOLS_MEM
28  mem::increment(s_class().c_str());
29 #endif
30  m_date_C = 0; //.set();
31  m_date_M = 0; //.set();
32  m_nbytes_keys = 0;
33  m_nbytes_name = 0;
34  m_seek_directory = 0;
35  m_seek_parent = 0;
36  m_seek_keys = 0;
37  }

◆ ~directory()

virtual tools::rroot::directory::~directory ( )
inlinevirtual

Definition at line 38 of file directory.

38  {
39  clear_keys();
40 #ifdef TOOLS_MEM
41  mem::decrement(s_class().c_str());
42 #endif
43  }

◆ directory() [2/2]

tools::rroot::directory::directory ( const directory a_from)
inlineprotected

Definition at line 45 of file directory.

45  :m_file(a_from.m_file){
46 #ifdef TOOLS_MEM
47  mem::increment(s_class().c_str());
48 #endif
49  }

Member Function Documentation

◆ clear_keys()

void tools::rroot::directory::clear_keys ( )
inline

Definition at line 177 of file directory.

177  {
178  safe_clear<key>(m_keys);
179  }

◆ file()

ifile& tools::rroot::directory::file ( )
inline

Definition at line 52 of file directory.

52 {return m_file;}

◆ find_key()

key* tools::rroot::directory::find_key ( const std::string &  a_name)
inline

Definition at line 57 of file directory.

57  {
58  if(m_file.verbose()) {
59  m_file.out() << "tools::rroot::directory::find_key :"
60  << " " << sout(a_name) << " ..."
61  << std::endl;
62  }
63  tools_vforcit(key*,m_keys,it) {
64  if((*it)->object_name()==a_name) return *it;
65  }
66 
67  return 0;
68  }

◆ find_key_from_class()

key* tools::rroot::directory::find_key_from_class ( const std::string &  a_class)
inline

Definition at line 70 of file directory.

70  {
71  if(m_file.verbose()) {
72  m_file.out() << "tools::rroot::directory::find_key_from_class :"
73  << " " << sout(a_class) << " ..."
74  << std::endl;
75  }
76  tools_vforcit(key*,m_keys,it) {
77  if((*it)->object_class()==a_class) return *it;
78  }
79 
80  return 0;
81  }

◆ from_buffer()

bool tools::rroot::directory::from_buffer ( const char *  aEOB,
char *&  a_buffer 
)
inline

Definition at line 102 of file directory.

102  {
103  // Decode input buffer.
104  // (Name, title) are stored in the (name, title) of the associated key.
105  rbuf rb(m_file.out(),m_file.byte_swap(),aEOB,a_buffer);
106  short versiondir;
107  if(!rb.read(versiondir)) return false;
108  unsigned int _date;
109  if(!rb.read(_date)) return false;
110  //fDateC.setDate(_date);
111  if(!rb.read(_date)) return false;
112  //fDateM.setDate(_date);
113  {int v;
114  if(!rb.read(v)) return false;
115  m_nbytes_keys = v;}
116  {int v;
117  if(!rb.read(v)) return false;
118  m_nbytes_name = v;}
119  if(versiondir>(short)big_file_version_tag()) {
120  if(!rb.read(m_seek_directory)) return false;
121  if(!rb.read(m_seek_parent)) return false;
122  if(!rb.read(m_seek_keys)) return false;
123  } else {
124  {seek32 i;
125  if(!rb.read(i)) return false;
126  m_seek_directory = i;}
127 
128  {seek32 i;
129  if(!rb.read(i)) return false;
130  m_seek_parent = i;}
131 
132  {seek32 i;
133  if(!rb.read(i)) return false;
134  m_seek_keys = i;}
135  }
136  if(m_file.verbose()) {
137  m_file.out() << "tools::rroot::key::from_buffer :"
138  << " nbytes keys : " << m_nbytes_keys
139  << ", pos keys : " << m_seek_keys
140  << std::endl;
141  }
142  return true;
143  }

◆ keys() [1/2]

std::vector<key*>& tools::rroot::directory::keys ( )
inline

Definition at line 55 of file directory.

55 {return m_keys;}

◆ keys() [2/2]

const std::vector<key*>& tools::rroot::directory::keys ( ) const
inline

Definition at line 54 of file directory.

54 {return m_keys;}

◆ nbytes_name()

uint32 tools::rroot::directory::nbytes_name ( ) const
inline

Definition at line 83 of file directory.

83 {return m_nbytes_name;}

◆ operator=()

directory& tools::rroot::directory::operator= ( const directory )
inlineprotected

Definition at line 50 of file directory.

50 {return *this;}

◆ read_keys()

bool tools::rroot::directory::read_keys ( uint32 a_number)
inline

Definition at line 144 of file directory.

144  {
145  // Read the KEYS :
146  // Every directory has a list (fKeys). This list has been
147  // written on the file via CERN-ROOT::TDirectory::writeKeys
148  // as a single data record.
149  a_number = 0;
150 
151  clear_keys();
152 
153  key headerkey(m_file.out(),m_seek_keys,m_nbytes_keys);
154  if(!headerkey.read_file(m_file)) return false;
155  char* buffer = headerkey.data_buffer();
156  if(!headerkey.from_buffer(m_file.byte_swap(),headerkey.eob(),buffer,m_file.verbose())) return false;
157  int nkeys = 0;
158  rbuf rb(m_file.out(),m_file.byte_swap(),headerkey.eob(),buffer);
159  if(!rb.read(nkeys)) return false;
160  if(m_file.verbose()) {
161  m_file.out() << "tools::rroot::directory::read_keys :"
162  << " nkeys " << nkeys
163  << "."
164  << std::endl;
165  }
166  for(int i=0;i<nkeys;i++) {
167  key* k = new key(m_file.out());
168  if(!k->from_buffer(m_file.byte_swap(),headerkey.eob(),buffer,m_file.verbose())) {
169  delete k;
170  return false;
171  }
172  m_keys.push_back(k);
173  }
174  a_number = nkeys;
175  return true;
176  }

◆ record_size()

uint32 tools::rroot::directory::record_size ( uint32  a_version) const
inline

Definition at line 85 of file directory.

85  {
86  uint32 nbytes = sizeof(short);
87  nbytes += sizeof(date); //m_date_C.record_size();
88  nbytes += sizeof(date); //m_date_M.record_size();
89  nbytes += sizeof(m_nbytes_keys);
90  nbytes += sizeof(m_nbytes_name);
91  if(a_version>=40000) {
92  nbytes += sizeof(seek);
93  nbytes += sizeof(seek);
94  nbytes += sizeof(seek);
95  } else {
96  nbytes += sizeof(seek32);
97  nbytes += sizeof(seek32);
98  nbytes += sizeof(seek32);
99  }
100  return nbytes;
101  }

◆ s_class()

static const std::string& tools::rroot::directory::s_class ( )
inlinestatic

Definition at line 19 of file directory.

19  {
20  static const std::string s_v("tools::rroot::directory");
21  return s_v;
22  }

◆ seek_keys()

seek tools::rroot::directory::seek_keys ( ) const
inline

Definition at line 84 of file directory.

84 {return m_seek_keys;}

Member Data Documentation

◆ m_date_C

date tools::rroot::directory::m_date_C
protected

Definition at line 184 of file directory.

◆ m_date_M

date tools::rroot::directory::m_date_M
protected

Definition at line 185 of file directory.

◆ m_file

ifile& tools::rroot::directory::m_file
protected

Definition at line 181 of file directory.

◆ m_keys

std::vector<key*> tools::rroot::directory::m_keys
protected

Definition at line 182 of file directory.

◆ m_nbytes_keys

uint32 tools::rroot::directory::m_nbytes_keys
protected

Definition at line 186 of file directory.

◆ m_nbytes_name

uint32 tools::rroot::directory::m_nbytes_name
protected

Definition at line 187 of file directory.

◆ m_seek_directory

seek tools::rroot::directory::m_seek_directory
protected

Definition at line 188 of file directory.

◆ m_seek_keys

seek tools::rroot::directory::m_seek_keys
protected

Definition at line 190 of file directory.

◆ m_seek_parent

seek tools::rroot::directory::m_seek_parent
protected

Definition at line 189 of file directory.


The documentation for this class was generated from the following file:
tools::rroot::directory::s_class
static const std::string & s_class()
Definition: directory:19
tools::rroot::seek32
int seek32
Definition: seek:17
tools::rroot::date
unsigned int date
Definition: date:10
tools::rroot::ifile::out
virtual std::ostream & out() const =0
tools::rroot::directory::clear_keys
void clear_keys()
Definition: directory:177
tools::rroot::directory::m_nbytes_name
uint32 m_nbytes_name
Definition: directory:187
tools::rroot::big_file_version_tag
uint32 big_file_version_tag()
Definition: seek:19
tools::rroot::directory::m_seek_directory
seek m_seek_directory
Definition: directory:188
tools::rroot::directory::m_keys
std::vector< key * > m_keys
Definition: directory:182
tools::rroot::directory::m_seek_keys
seek m_seek_keys
Definition: directory:190
tools::rroot::seek
int64 seek
Definition: seek:16
tools::rroot::directory::m_date_M
date m_date_M
Definition: directory:185
tools::rroot::directory::m_file
ifile & m_file
Definition: directory:181
tools::rroot::directory::m_seek_parent
seek m_seek_parent
Definition: directory:189
tools::rroot::directory::m_date_C
date m_date_C
Definition: directory:184
tools::rroot::ifile::byte_swap
virtual bool byte_swap() const =0
tools::rroot::directory::m_nbytes_keys
uint32 m_nbytes_keys
Definition: directory:186
tools_vforcit
#define tools_vforcit(a__T, a__v, a__it)
Definition: forit:7
tools::uint32
unsigned int uint32
Definition: typedefs:71
tools::rroot::ifile::verbose
virtual bool verbose() const =0