LDMX Software
BaseTableCondition.cxx
1#include <algorithm>
2
3#include "Conditions/SimpleTableCondition.h"
4
5std::ostream& operator<<(std::ostream& s,
7 s << "[ TableCondition: " << btc.getName() << std::endl;
8 s << " DetID";
9 const std::vector<std::string>& names = btc.getColumnNames();
10 for (auto name : names) {
11 s << ",id:\"" << name << '"';
12 }
13 s << std::endl;
14 for (std::size_t i = 0; i < btc.getRowCount(); i++) {
15 s << " ";
16 btc.streamRow(s, i);
17 }
18 return s << ']';
19}
20
21namespace conditions {
22
23std::size_t BaseTableCondition::findKey(unsigned int id) const {
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}
32
33std::size_t BaseTableCondition::findKeyInsert(unsigned int id) const {
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}
39
40} // namespace conditions
virtual std::ostream & streamRow(std::ostream &s, int irow) const
Streams a given row of this table.
std::size_t getRowCount() const
Get the number of rows.
const std::vector< std::string > & getColumnNames() const
Get the names of the columns.
std::string getName() const
Get the name of this object.