CMS 3D CMS Logo

TableExaminer.h
Go to the documentation of this file.
1 #ifndef FWCore_SOA_TableExaminer_h
2 #define FWCore_SOA_TableExaminer_h
3 // -*- C++ -*-
4 //
5 // Package: FWCore/SOA
6 // Class : TableExaminer
7 //
16 //
17 // Original Author: Chris Jones
18 // Created: Mon, 28 Aug 2017 14:22:29 GMT
19 //
20 
21 // system include files
22 
23 // user include files
25 
26 // forward declarations
27 namespace edm {
28  namespace soa {
29 
30  template <typename T>
32  public:
33  explicit TableExaminer(T const* iTable) : m_table(iTable) {}
34 
35  TableExaminer(const TableExaminer<T>&) = default;
36 
37  TableExaminer<T>& operator=(const TableExaminer<T>&) = default;
38 
39  ~TableExaminer() override {}
40 
41  // ---------- const member functions ---------------------
42 
43  size_t size() const final { return m_table->size(); }
44 
45  void const* columnAddress(unsigned int iColumnIndex) const final {
46  return m_table->columnAddressByIndex(iColumnIndex);
47  }
48 
49  std::vector<std::type_index> columnTypes() const final {
50  std::vector<std::type_index> returnValue;
51  returnValue.reserve(T::kNColumns);
52  columnTypesImpl<0, T::kNColumns>(returnValue);
53  return returnValue;
54  }
55 
56  std::vector<std::pair<char const*, std::type_index>> columnDescriptions() const final {
57  std::vector<std::pair<char const*, std::type_index>> returnValue;
58  returnValue.reserve(T::kNColumns);
59  columnDescImpl<0, T::kNColumns>(returnValue);
60  return returnValue;
61  }
62 
63  const std::type_info* typeID() const final { return &typeid(T); }
64 
65  private:
66  template <int I, int S>
67  void columnTypesImpl(std::vector<std::type_index>& iV) const {
68  if constexpr (I != S) {
69  using Layout = typename T::Layout;
70  iV.emplace_back(typeid(typename std::tuple_element<I, Layout>::type));
71  columnTypesImpl<I + 1, S>(iV);
72  }
73  }
74 
75  template <int I, int S>
76  void columnDescImpl(std::vector<std::pair<char const*, std::type_index>>& iV) const {
77  if constexpr (I != S) {
78  using Layout = typename T::Layout;
79  using ColumnType = typename std::tuple_element<I, Layout>::type;
80  iV.emplace_back(ColumnType::label(), typeid(typename ColumnType::type));
81  columnDescImpl<I + 1, S>(iV);
82  }
83  }
84 
85  // ---------- member data --------------------------------
86  T const* m_table;
87  };
88 
89  } // namespace soa
90 } // namespace edm
91 
92 #endif
void columnTypesImpl(std::vector< std::type_index > &iV) const
Definition: TableExaminer.h:67
TableExaminer< T > & operator=(const TableExaminer< T > &)=default
void const * columnAddress(unsigned int iColumnIndex) const final
Definition: TableExaminer.h:45
size_t size() const final
Definition: TableExaminer.h:43
char const * label
ZVertexSoA * soa
const std::complex< double > I
Definition: I.h:8
std::vector< std::pair< char const *, std::type_index > > columnDescriptions() const final
Definition: TableExaminer.h:56
TableExaminer(T const *iTable)
Definition: TableExaminer.h:33
std::vector< std::type_index > columnTypes() const final
Definition: TableExaminer.h:49
void columnDescImpl(std::vector< std::pair< char const *, std::type_index >> &iV) const
Definition: TableExaminer.h:76
HLT enums.
long double T
const std::type_info * typeID() const final
Definition: TableExaminer.h:63
static const unsigned int kNColumns