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 {
33 
34  public:
35  explicit TableExaminer( T const* iTable):
36  m_table (iTable) {}
37 
38  TableExaminer(const TableExaminer<T>&) = default;
39 
40  TableExaminer<T>& operator=(const TableExaminer<T>&) = default;
41 
42  ~TableExaminer() override {}
43 
44  // ---------- const member functions ---------------------
45 
46  size_t size() const override final { return m_table->size(); }
47 
48  void const* columnAddress(unsigned int iColumnIndex) const override final {
49  return m_table->columnAddressByIndex(iColumnIndex);
50  }
51 
52  std::vector<std::type_index> columnTypes() const override final {
53  std::vector<std::type_index> returnValue;
54  returnValue.reserve(T::kNColumns);
55  columnTypesImpl<0, T::kNColumns>(returnValue);
56  return returnValue;
57  }
58 
59  std::vector<std::pair<char const*, std::type_index>>
60  columnDescriptions() const override final {
61  std::vector<std::pair<char const*, std::type_index>> returnValue;
62  returnValue.reserve(T::kNColumns);
63  columnDescImpl<0, T::kNColumns>(returnValue);
64  return returnValue;
65  }
66 
67  const std::type_info* typeID() const override final {
68  return &typeid(T);
69  }
70 
71 private:
72  template <int I, int S>
73  void columnTypesImpl(std::vector<std::type_index>& iV) const {
74  if constexpr(I != S) {
75  using Layout = typename T::Layout;
76  iV.emplace_back( typeid( typename std::tuple_element<I,Layout>::type ) );
77  columnTypesImpl<I+1, S>(iV);
78  }
79  }
80 
81  template <int I, int S>
82  void columnDescImpl(std::vector<std::pair<char const*, std::type_index>>& iV) const {
83  if constexpr(I != S) {
84  using Layout = typename T::Layout;
85  using ColumnType = typename std::tuple_element<I,Layout>::type;
86  iV.emplace_back( ColumnType::label(), typeid( typename ColumnType::type ) );
87  columnDescImpl<I+1, S>(iV);
88  }
89  }
90 
91  // ---------- member data --------------------------------
92  T const* m_table;
93 
94 };
95 
96 }
97 }
98 
99 #endif
type
Definition: HCALResponse.h:21
size_t size() const override final
Definition: TableExaminer.h:46
std::vector< std::pair< char const *, std::type_index > > columnDescriptions() const override final
Definition: TableExaminer.h:60
void const * columnAddress(unsigned int iColumnIndex) const override final
Definition: TableExaminer.h:48
TableExaminer< T > & operator=(const TableExaminer< T > &)=default
void columnTypesImpl(std::vector< std::type_index > &iV) const
Definition: TableExaminer.h:73
#define constexpr
void columnDescImpl(std::vector< std::pair< char const *, std::type_index >> &iV) const
Definition: TableExaminer.h:82
char const * label
const std::complex< double > I
Definition: I.h:8
TableExaminer(T const *iTable)
Definition: TableExaminer.h:35
std::vector< std::type_index > columnTypes() const override final
Definition: TableExaminer.h:52
HLT enums.
const std::type_info * typeID() const override final
Definition: TableExaminer.h:67
long double T
static const unsigned int kNColumns