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