LDMX Software
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
conditions::BaseTableCondition Class Reference

Public Member Functions

 BaseTableCondition (const std::string &name, const std::vector< std::string > &columns)
 Create table with given set of columns.
 
unsigned int getColumnNumber (const std::string &colname) const
 Get a the column number for the given column name.
 
unsigned int getColumnCount () const
 Get the number of columns.
 
const std::string & getColumnName (unsigned int icol) const
 Get the name of the given column.
 
unsigned int getRowId (unsigned int irow) const
 Get the id for the given row.
 
const std::vector< std::string > & getColumnNames () const
 Get the names of the columns.
 
std::size_t getRowCount () const
 Get the number of rows.
 
void setIdMask (unsigned int mask)
 Set an AND mask to be applied to the id.
 
unsigned int getIdMask () const
 Get the AND mask to be applied to the id.
 
virtual std::ostream & streamRow (std::ostream &s, int irow) const
 Streams a given row of this table.
 
- Public Member Functions inherited from framework::ConditionsObject
 ConditionsObject (const std::string &name)
 Class constructor.
 
virtual ~ConditionsObject ()
 Destructor.
 
std::string getName () const
 Get the name of this object.
 

Protected Member Functions

std::size_t findKey (unsigned int id) const
 
std::size_t findKeyInsert (unsigned int id) const
 

Protected Attributes

std::vector< std::string > columns_
 
unsigned int columnCount_
 
std::vector< uint32_t > keys_
 
unsigned int idMask_
 

Detailed Description

Definition at line 21 of file SimpleTableCondition.h.

Constructor & Destructor Documentation

◆ BaseTableCondition()

conditions::BaseTableCondition::BaseTableCondition ( const std::string &  name,
const std::vector< std::string > &  columns 
)
inline

Create table with given set of columns.

Definition at line 24 of file SimpleTableCondition.h.

27 columns_{columns},
28 idMask_{0xFFFFFFFFu} {
29 columnCount_ = (unsigned int)(columns.size());
30 }
Base class for all conditions objects, very simple.

Member Function Documentation

◆ findKey()

std::size_t conditions::BaseTableCondition::findKey ( unsigned int  id) const
protected

Definition at line 23 of file BaseTableCondition.cxx.

23 {
24 unsigned int effid = id & idMask_;
25 std::vector<unsigned int>::const_iterator ptr =
26 std::lower_bound(keys_.begin(), keys_.end(), effid);
27 if (ptr == keys_.end() || *ptr != effid)
28 return keys_.size();
29 else
30 return std::distance(keys_.begin(), ptr);
31}

◆ findKeyInsert()

std::size_t conditions::BaseTableCondition::findKeyInsert ( unsigned int  id) const
protected

Definition at line 33 of file BaseTableCondition.cxx.

33 {
34 unsigned int effid = id & idMask_;
35 std::vector<unsigned int>::const_iterator ptr =
36 std::lower_bound(keys_.begin(), keys_.end(), effid);
37 return std::distance(keys_.begin(), ptr);
38}

◆ getColumnCount()

unsigned int conditions::BaseTableCondition::getColumnCount ( ) const
inline

Get the number of columns.

Definition at line 44 of file SimpleTableCondition.h.

44{ return columnCount_; }

Referenced by ecal::EcalReconConditions::EcalReconConditions(), and ldmx::HgcrocTriggerConditions::HgcrocTriggerConditions().

◆ getColumnName()

const std::string & conditions::BaseTableCondition::getColumnName ( unsigned int  icol) const
inline

Get the name of the given column.

Definition at line 49 of file SimpleTableCondition.h.

49 {
50 if (icol >= columnCount_) {
51 EXCEPTION_RAISE("ConditionsException",
52 std::string("Column index out of range in ") + getName());
53 }
54 return columns_[icol];
55 }
std::string getName() const
Get the name of this object.

References framework::ConditionsObject::getName().

◆ getColumnNames()

const std::vector< std::string > & conditions::BaseTableCondition::getColumnNames ( ) const
inline

Get the names of the columns.

Definition at line 71 of file SimpleTableCondition.h.

71{ return columns_; }

Referenced by ecal::EcalReconConditions::EcalReconConditions(), and ldmx::HgcrocTriggerConditions::HgcrocTriggerConditions().

◆ getColumnNumber()

unsigned int conditions::BaseTableCondition::getColumnNumber ( const std::string &  colname) const
inline

Get a the column number for the given column name.

Definition at line 35 of file SimpleTableCondition.h.

35 {
36 for (unsigned int i = 0; i < columnCount_; i++)
37 if (colname == columns_[i]) return i;
38 return columnCount_;
39 }

Referenced by conditions::HomogenousTableCondition< T >::getByName(), and ldmx::HgcrocEmulator::getCondition().

◆ getIdMask()

unsigned int conditions::BaseTableCondition::getIdMask ( ) const
inline

Get the AND mask to be applied to the id.

Typically used to "flatten" a table in some manner.

Definition at line 88 of file SimpleTableCondition.h.

88{ return idMask_; }

◆ getRowCount()

std::size_t conditions::BaseTableCondition::getRowCount ( ) const
inline

◆ getRowId()

unsigned int conditions::BaseTableCondition::getRowId ( unsigned int  irow) const
inline

Get the id for the given row.

Definition at line 60 of file SimpleTableCondition.h.

60 {
61 if (irow >= getRowCount()) { // raise exception
62 EXCEPTION_RAISE("ConditionsException",
63 "Row out of range: " + std::to_string(irow));
64 }
65 return keys_[irow];
66 }
std::size_t getRowCount() const
Get the number of rows.

References getRowCount().

◆ setIdMask()

void conditions::BaseTableCondition::setIdMask ( unsigned int  mask)
inline

Set an AND mask to be applied to the id.

Typically used to "flatten" a table in some manner.

Definition at line 82 of file SimpleTableCondition.h.

82{ idMask_ = mask; }

Referenced by conditions::SimpleCSVTableProvider::getCondition().

◆ streamRow()

virtual std::ostream & conditions::BaseTableCondition::streamRow ( std::ostream &  s,
int  irow 
) const
inlinevirtual

Streams a given row of this table.

Reimplemented in conditions::HomogenousTableCondition< T >, conditions::HomogenousTableCondition< double >, and conditions::HomogenousTableCondition< int >.

Definition at line 93 of file SimpleTableCondition.h.

93 {
94 return s << keys_[irow];
95 }

Member Data Documentation

◆ columnCount_

unsigned int conditions::BaseTableCondition::columnCount_
protected

Definition at line 103 of file SimpleTableCondition.h.

◆ columns_

std::vector<std::string> conditions::BaseTableCondition::columns_
protected

Definition at line 102 of file SimpleTableCondition.h.

◆ idMask_

unsigned int conditions::BaseTableCondition::idMask_
protected

Definition at line 105 of file SimpleTableCondition.h.

◆ keys_

std::vector<uint32_t> conditions::BaseTableCondition::keys_
protected

Definition at line 104 of file SimpleTableCondition.h.


The documentation for this class was generated from the following files: