g4tools  5.4.0
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
tools::hdf5::ntuple::column_ref< T > Class Template Reference
Inheritance diagram for tools::hdf5::ntuple::column_ref< T >:
Inheritance graph
[legend]
Collaboration diagram for tools::hdf5::ntuple::column_ref< T >:
Collaboration graph
[legend]

Public Member Functions

virtual void * cast (tools::cid a_class) const
 
virtual tools::cid id_cls () const
 
virtual bool add ()
 
virtual bool fetch_entry ()
 
virtual void reset ()
 
virtual const std::string & name () const
 
virtual bool set_basket_size (size_t a_size)
 
 column_ref (store &a_store, pages &a_pages, bool a_write, const std::string &a_name, size_t a_basket_size, T &a_ref)
 
virtual ~column_ref ()
 
- Public Member Functions inherited from tools::hdf5::ntuple::icol
virtual ~icol ()
 

Static Public Member Functions

static tools::cid id_class ()
 

Protected Member Functions

 column_ref (const column_ref &a_from)
 
column_refoperator= (const column_ref &a_from)
 

Protected Attributes

storem_store
 
pagesm_branch
 
bool m_write
 
std::string m_name
 
T & m_ref
 
size_t m_basket_size
 
size_t m_basket_pos
 
size_t m_basket_end
 
T * m_basket
 
size_t m_want_new_basket_size
 

Detailed Description

template<class T>
class tools::hdf5::ntuple::column_ref< T >

Definition at line 46 of file ntuple.

Constructor & Destructor Documentation

◆ column_ref() [1/2]

template<class T >
tools::hdf5::ntuple::column_ref< T >::column_ref ( store a_store,
pages a_pages,
bool  a_write,
const std::string &  a_name,
size_t  a_basket_size,
T &  a_ref 
)
inline

Definition at line 124 of file ntuple.

125  :m_store(a_store)
126  ,m_branch(a_pages)
127  ,m_write(a_write)
128  ,m_name(a_name)
129  ,m_ref(a_ref)
130  ,m_basket_size(a_basket_size?a_basket_size:32000)
131  ,m_basket_pos(0)
132  ,m_basket_end(0) //read.
133  ,m_basket(0)
135  {
136 #ifdef TOOLS_MEM
137  tools::mem::increment(s_class().c_str());
138 #endif
139  m_basket = new T[m_basket_size];
140  if(m_write) {
141  } else { //read.
142  tools::uint64 _entries = m_branch.entries();
143  size_t n = tools::mn<size_t>((size_t)_entries,m_basket_size);
144  if(_entries) {
145  if(!m_branch.read_page<T>(n,m_basket)) {
146  m_store.out() << "tools::hdf5::ntuple::column_ref:column_ref : read_page() failed." << std::endl;
147  m_basket_pos = 0;
148  m_basket_end = 0;
149  return;
150  }
151  }
152  m_basket_pos = 0;
153  m_basket_end = n;
154  }
155  }

◆ ~column_ref()

template<class T >
virtual tools::hdf5::ntuple::column_ref< T >::~column_ref ( )
inlinevirtual

Definition at line 156 of file ntuple.

156  {
157  if(m_write && m_basket_pos) {
159  m_store.out() << "tools::hdf5::ntuple::column_ref::~column_ref : write_page() failed." << std::endl;
160  }
161  }
162  delete [] m_basket;
163 #ifdef TOOLS_MEM
164  tools::mem::decrement(s_class().c_str());
165 #endif
166  }

◆ column_ref() [2/2]

template<class T >
tools::hdf5::ntuple::column_ref< T >::column_ref ( const column_ref< T > &  a_from)
inlineprotected

Definition at line 168 of file ntuple.

169  :icol(a_from)
170  ,m_store(a_from.m_store)
171  ,m_branch(a_from.m_branch)
172  ,m_write(a_from.m_write)
173  ,m_name(a_from.m_name)
174  ,m_ref(a_from.m_ref)
175  ,m_basket_size(a_from.m_basket_size)
176  ,m_basket_pos(0)
177  ,m_basket_end(0)
178  ,m_basket(0)
180  {}

Member Function Documentation

◆ add()

template<class T >
virtual bool tools::hdf5::ntuple::column_ref< T >::add ( )
inlinevirtual

Implements tools::hdf5::ntuple::icol.

Definition at line 64 of file ntuple.

64  { //write.
65  if(!m_write) return false;
68  m_store.out() << "tools::hdf5::ntuple::column_ref::add : write_page() failed." << std::endl;
69  m_basket_pos = 0;
70  return false;
71  }
72  m_basket_pos = 0;
74  delete [] m_basket;
76  m_basket_pos = 0;
79  }
80  }
82  m_basket_pos++;
83  return true;
84  }

◆ cast()

template<class T >
virtual void* tools::hdf5::ntuple::column_ref< T >::cast ( tools::cid  a_class) const
inlinevirtual

Implements tools::hdf5::ntuple::icol.

Reimplemented in tools::hdf5::ntuple::column< T >.

Definition at line 58 of file ntuple.

58  {
59  if(void* p = tools::cmp_cast<column_ref>(this,a_class)) {return p;}
60  else return 0;
61  }

◆ fetch_entry()

template<class T >
virtual bool tools::hdf5::ntuple::column_ref< T >::fetch_entry ( )
inlinevirtual

Implements tools::hdf5::ntuple::icol.

Definition at line 85 of file ntuple.

85  { //read.
86  if(m_write) return false;
87  if(m_basket_pos>=m_basket_end) { //we need more data.
88  if(m_branch.pos()>=m_branch.entries()) {
89  m_store.out() << "tools::hdf5::ntuple::column_ref:fetch_entry : no more data." << std::endl;
90  m_basket_pos = 0;
91  m_basket_end = 0;
92  return false;
93  }
95  delete [] m_basket;
97  m_basket_pos = 0;
100  }
102  size_t n = tools::mn<size_t>((size_t)remain,m_basket_size);
103  if(!m_branch.read_page<T>(n,m_basket)) {
104  m_store.out() << "tools::hdf5::ntuple::column_ref:fetch_entry : read_page() failed." << std::endl;
105  m_basket_pos = 0;
106  m_basket_end = 0;
107  return false;
108  }
109  m_basket_pos = 0;
110  m_basket_end = n;
111  }
113  m_basket_pos++;
114  return true;
115  }

◆ id_class()

template<class T >
static tools::cid tools::hdf5::ntuple::column_ref< T >::id_class ( )
inlinestatic

Definition at line 54 of file ntuple.

54  {
55  static const T s_v = T(); //do that for T = std::string.
56  return tools::_cid(s_v)+10000;
57  }

◆ id_cls()

template<class T >
virtual tools::cid tools::hdf5::ntuple::column_ref< T >::id_cls ( ) const
inlinevirtual

Implements tools::hdf5::ntuple::icol.

Reimplemented in tools::hdf5::ntuple::column< T >.

Definition at line 62 of file ntuple.

62 {return id_class();}

◆ name()

template<class T >
virtual const std::string& tools::hdf5::ntuple::column_ref< T >::name ( ) const
inlinevirtual

Implements tools::hdf5::ntuple::icol.

Definition at line 117 of file ntuple.

117 {return m_name;}

◆ operator=()

template<class T >
column_ref& tools::hdf5::ntuple::column_ref< T >::operator= ( const column_ref< T > &  a_from)
inlineprotected

Definition at line 181 of file ntuple.

181  {
182  if(&a_from==this) return *this;
183  m_name = a_from.m_name;
184  m_basket_size = a_from.m_basket_size;
185  m_basket_pos = 0;
186  m_basket_end = 0;
188  return *this;
189  }

◆ reset()

template<class T >
virtual void tools::hdf5::ntuple::column_ref< T >::reset ( )
inlinevirtual

Implements tools::hdf5::ntuple::icol.

Definition at line 116 of file ntuple.

116 {m_branch.reset_pos();}

◆ set_basket_size()

template<class T >
virtual bool tools::hdf5::ntuple::column_ref< T >::set_basket_size ( size_t  a_size)
inlinevirtual

Implements tools::hdf5::ntuple::icol.

Definition at line 118 of file ntuple.

118  {
119  if(!a_size) return false;
120  m_want_new_basket_size = a_size;
121  return true;
122  }

Member Data Documentation

◆ m_basket

template<class T >
T* tools::hdf5::ntuple::column_ref< T >::m_basket
protected

Definition at line 199 of file ntuple.

◆ m_basket_end

template<class T >
size_t tools::hdf5::ntuple::column_ref< T >::m_basket_end
protected

Definition at line 198 of file ntuple.

◆ m_basket_pos

template<class T >
size_t tools::hdf5::ntuple::column_ref< T >::m_basket_pos
protected

Definition at line 197 of file ntuple.

◆ m_basket_size

template<class T >
size_t tools::hdf5::ntuple::column_ref< T >::m_basket_size
protected

Definition at line 196 of file ntuple.

◆ m_branch

template<class T >
pages& tools::hdf5::ntuple::column_ref< T >::m_branch
protected

Definition at line 192 of file ntuple.

◆ m_name

template<class T >
std::string tools::hdf5::ntuple::column_ref< T >::m_name
protected

Definition at line 194 of file ntuple.

◆ m_ref

template<class T >
T& tools::hdf5::ntuple::column_ref< T >::m_ref
protected

Definition at line 195 of file ntuple.

◆ m_store

template<class T >
store& tools::hdf5::ntuple::column_ref< T >::m_store
protected

Definition at line 191 of file ntuple.

◆ m_want_new_basket_size

template<class T >
size_t tools::hdf5::ntuple::column_ref< T >::m_want_new_basket_size
protected

Definition at line 200 of file ntuple.

◆ m_write

template<class T >
bool tools::hdf5::ntuple::column_ref< T >::m_write
protected

Definition at line 193 of file ntuple.


The documentation for this class was generated from the following file:
tools::hdf5::pages::read_page
bool read_page(size_t a_size, TYPE *a_array)
Definition: pages:128
tools::uint64
unsigned long long uint64
Definition: typedefs:72
tools::hdf5::ntuple::column_ref::id_class
static tools::cid id_class()
Definition: ntuple:54
tools::_cid
cid _cid(byte)
Definition: cids:14
tools::hdf5::ntuple::column_ref::m_basket_end
size_t m_basket_end
Definition: ntuple:198
tools::hdf5::pages::pos
tools::uint64 pos() const
Definition: pages:101
tools::hdf5::ntuple::column_ref::m_store
store & m_store
Definition: ntuple:191
tools::hdf5::ntuple::column_ref::m_branch
pages & m_branch
Definition: ntuple:192
tools::hdf5::pages::reset_pos
void reset_pos()
Definition: pages:102
tools::hdf5::ntuple::column_ref::m_want_new_basket_size
size_t m_want_new_basket_size
Definition: ntuple:200
tools::hdf5::ntuple::column_ref::m_basket_pos
size_t m_basket_pos
Definition: ntuple:197
tools::hdf5::store::out
std::ostream & out() const
Definition: store:154
tools::hdf5::ntuple::column_ref::m_name
std::string m_name
Definition: ntuple:194
tools::hdf5::ntuple::column_ref::m_basket
T * m_basket
Definition: ntuple:199
tools::hdf5::ntuple::column_ref::m_ref
T & m_ref
Definition: ntuple:195
tools::hdf5::ntuple::column_ref::m_basket_size
size_t m_basket_size
Definition: ntuple:196
tools::hdf5::ntuple::column_ref::m_write
bool m_write
Definition: ntuple:193
tools::hdf5::pages::write_page
bool write_page(size_t a_size, const TYPE *a_array)
Definition: pages:105
tools::hdf5::pages::entries
tools::uint64 entries() const
Definition: pages:100