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

Public Member Functions

virtual void * cast (const std::string &a_class) const
 
std::ostream & out () const
 
const std::vector< base_col * > & columns () const
 
size_t number_of_columns () const
 
const std::vector< base_col * > & cols () const
 
void column_names (std::vector< std::string > &a_names) const
 
const std::string & title () const
 
void set_title (const std::string &a_title)
 
uint64 rows () const
 
bool number_of_entries (uint64 &a_value) const
 
void clear ()
 
bool reset ()
 
void start ()
 
bool next ()
 
int64 row_index () const
 
bool add_row ()
 
base_colfind_column (const std::string &a_name)
 
void add_column (base_col *a_col)
 

Static Public Member Functions

static const std::string & s_class ()
 

Protected Member Functions

 base_ntu (std::ostream &a_out, const std::string &a_title)
 
virtual ~base_ntu ()
 
 base_ntu (const base_ntu &a_from)
 
base_ntuoperator= (const base_ntu &a_from)
 
void set_columns_index (uint64 a_index)
 

Protected Attributes

std::ostream & m_out
 
std::string m_title
 
int64 m_index
 
std::vector< base_col * > m_cols
 

Detailed Description

Definition at line 85 of file aida_ntuple.

Constructor & Destructor Documentation

◆ base_ntu() [1/2]

tools::aida::base_ntu::base_ntu ( std::ostream &  a_out,
const std::string &  a_title 
)
inlineprotected

Definition at line 96 of file aida_ntuple.

97  :m_out(a_out),m_title(a_title),m_index(-1){
98 #ifdef TOOLS_MEM
99  mem::increment(s_class().c_str());
100 #endif
101  }

◆ ~base_ntu()

virtual tools::aida::base_ntu::~base_ntu ( )
inlineprotectedvirtual

Definition at line 102 of file aida_ntuple.

102  {
103  clear();
104 #ifdef TOOLS_MEM
105  mem::decrement(s_class().c_str());
106 #endif
107  }

◆ base_ntu() [2/2]

tools::aida::base_ntu::base_ntu ( const base_ntu a_from)
inlineprotected

Definition at line 109 of file aida_ntuple.

110  :m_out(a_from.m_out)
111  ,m_title(a_from.m_title),m_index(a_from.m_index)
112  {
113 #ifdef TOOLS_MEM
114  mem::increment(s_class().c_str());
115 #endif
116  tools_vforcit(base_col*,a_from.m_cols,it) {
117  base_col* column = (*it)->copy();
118  if(!column) {
119  m_out << s_class() << "::cstor :"
120  << " can't copy column."
121  << std::endl;
122  safe_clear<base_col>(m_cols);
123  m_index = -1;
124  return; //throw
125  }
126  m_cols.push_back(column);
127  }
128  }

Member Function Documentation

◆ add_column()

void tools::aida::base_ntu::add_column ( base_col a_col)
inline

Definition at line 223 of file aida_ntuple.

223  { //we take ownership.
224  m_cols.push_back(a_col);
225  }

◆ add_row()

bool tools::aida::base_ntu::add_row ( )
inline

Definition at line 211 of file aida_ntuple.

211  {
212  bool status = true;
213  tools_vforit(base_col*,m_cols,it) {
214  if(!(*it)->add()) status = false;
215  }
216  return status;
217  }

◆ cast()

virtual void* tools::aida::base_ntu::cast ( const std::string &  a_class) const
inlinevirtual

Reimplemented in tools::aida::ntuple.

Definition at line 91 of file aida_ntuple.

91  {
92  if(void* p = cmp_cast<base_ntu>(this,a_class)) {return p;}
93  return 0;
94  }

◆ clear()

void tools::aida::base_ntu::clear ( )
inline

Definition at line 178 of file aida_ntuple.

178  { //must not be confused with reset().
179  safe_clear<base_col>(m_cols);
180  m_index = -1;
181  }

◆ cols()

const std::vector<base_col*>& tools::aida::base_ntu::cols ( ) const
inline

Definition at line 157 of file aida_ntuple.

157 {return m_cols;} //deprecated : use columns().

◆ column_names()

void tools::aida::base_ntu::column_names ( std::vector< std::string > &  a_names) const
inline

Definition at line 160 of file aida_ntuple.

160  {
161  a_names.clear();
162  tools_vforcit(base_col*,m_cols,it) a_names.push_back((*it)->name());
163  }

◆ columns()

const std::vector<base_col*>& tools::aida::base_ntu::columns ( ) const
inline

Definition at line 153 of file aida_ntuple.

153 {return m_cols;}

◆ find_column()

base_col* tools::aida::base_ntu::find_column ( const std::string &  a_name)
inline

Definition at line 219 of file aida_ntuple.

219  {
220  return find_named<base_col>(m_cols,a_name);
221  }

◆ next()

bool tools::aida::base_ntu::next ( )
inline

Definition at line 194 of file aida_ntuple.

194  {
195  // a tuple loop is of the form :
196  // tuple.start();
197  // while(tuple.next()) {
198  // ...
199  // double v;
200  // if(!col->get_entry(v)) {}
201  // ...
202  // }
203  if((m_index+1)>=(int64)rows()) return false;
204  m_index++;
206  return true;
207  }

◆ number_of_columns()

size_t tools::aida::base_ntu::number_of_columns ( ) const
inline

Definition at line 154 of file aida_ntuple.

154 {return m_cols.size();}

◆ number_of_entries()

bool tools::aida::base_ntu::number_of_entries ( uint64 a_value) const
inline

Definition at line 172 of file aida_ntuple.

172  {
173  if(m_cols.empty()) {a_value = 0;return false;}
174  a_value = m_cols.front()->num_elems();
175  return true;
176  }

◆ operator=()

base_ntu& tools::aida::base_ntu::operator= ( const base_ntu a_from)
inlineprotected

Definition at line 129 of file aida_ntuple.

129  {
130  if(&a_from==this) return *this;
131 
132  safe_clear<base_col>(m_cols);
133  m_index = a_from.m_index;
134 
135  m_title = a_from.m_title;
136  tools_vforcit(base_col*,a_from.m_cols,it) {
137  base_col* column = (*it)->copy();
138  if(!column) {
139  m_out << s_class() << "::operator=() :"
140  << " can't copy column."
141  << std::endl;
142  safe_clear<base_col>(m_cols);
143  m_index = -1;
144  return *this;
145  }
146  m_cols.push_back(column);
147  }
148 
149  return *this;
150  }

◆ out()

std::ostream& tools::aida::base_ntu::out ( ) const
inline

Definition at line 152 of file aida_ntuple.

152 {return m_out;}

◆ reset()

bool tools::aida::base_ntu::reset ( )
inline

Definition at line 183 of file aida_ntuple.

183  { //clear data in columns (but not the column set)
184  bool status = true;
185  tools_vforit(base_col*,m_cols,it) {
186  if(!(*it)->reset()) status = false;
187  }
188  m_index = -1;
189  return status;
190  }

◆ row_index()

int64 tools::aida::base_ntu::row_index ( ) const
inline

Definition at line 208 of file aida_ntuple.

208 {return m_index;}

◆ rows()

uint64 tools::aida::base_ntu::rows ( ) const
inline

Definition at line 168 of file aida_ntuple.

168  {
169  if(m_cols.empty()) return 0;
170  return m_cols.front()->num_elems();
171  }

◆ s_class()

static const std::string& tools::aida::base_ntu::s_class ( )
inlinestatic

Definition at line 87 of file aida_ntuple.

87  {
88  static const std::string s_v("tools::aida::base_ntu");
89  return s_v;
90  }

◆ set_columns_index()

void tools::aida::base_ntu::set_columns_index ( uint64  a_index)
inlineprotected

Definition at line 228 of file aida_ntuple.

228  {
229  tools_vforit(base_col*,m_cols,it) {
230  (*it)->set_index(a_index);
231  }
232  }

◆ set_title()

void tools::aida::base_ntu::set_title ( const std::string &  a_title)
inline

Definition at line 166 of file aida_ntuple.

166 {m_title = a_title;}

◆ start()

void tools::aida::base_ntu::start ( )
inline

Definition at line 193 of file aida_ntuple.

193 {m_index = -1;set_columns_index(0);}

◆ title()

const std::string& tools::aida::base_ntu::title ( ) const
inline

Definition at line 165 of file aida_ntuple.

165 {return m_title;}

Member Data Documentation

◆ m_cols

std::vector<base_col*> tools::aida::base_ntu::m_cols
protected

Definition at line 237 of file aida_ntuple.

◆ m_index

int64 tools::aida::base_ntu::m_index
protected

Definition at line 236 of file aida_ntuple.

◆ m_out

std::ostream& tools::aida::base_ntu::m_out
protected

Definition at line 234 of file aida_ntuple.

◆ m_title

std::string tools::aida::base_ntu::m_title
protected

Definition at line 235 of file aida_ntuple.


The documentation for this class was generated from the following file:
tools::aida::base_ntu::m_out
std::ostream & m_out
Definition: aida_ntuple:234
tools::int64
long long int64
Definition: typedefs:67
tools::aida::base_ntu::m_cols
std::vector< base_col * > m_cols
Definition: aida_ntuple:237
tools::aida::base_ntu::rows
uint64 rows() const
Definition: aida_ntuple:168
tools::aida::base_ntu::m_index
int64 m_index
Definition: aida_ntuple:236
tools_vforit
#define tools_vforit(a__T, a__v, a__it)
Definition: forit:13
tools::aida::base_ntu::set_columns_index
void set_columns_index(uint64 a_index)
Definition: aida_ntuple:228
tools::aida::base_ntu::s_class
static const std::string & s_class()
Definition: aida_ntuple:87
tools::aida::base_ntu::clear
void clear()
Definition: aida_ntuple:178
tools_vforcit
#define tools_vforcit(a__T, a__v, a__it)
Definition: forit:7
tools::aida::base_ntu::m_title
std::string m_title
Definition: aida_ntuple:235