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  using Layout = typename T::Layout;
56  columnTypesImpl<0, T::kNColumns>(returnValue, static_cast<std::true_type*>(nullptr));
57  return returnValue;
58  }
59 
60  std::vector<std::pair<char const*, std::type_index>>
61  columnDescriptions() const override final {
62  std::vector<std::pair<char const*, std::type_index>> returnValue;
63  returnValue.reserve(T::kNColumns);
64  using Layout = typename T::Layout;
65  columnDescImpl<0, T::kNColumns>(returnValue, static_cast<std::true_type*>(nullptr));
66  return returnValue;
67  }
68 
69  const std::type_info* typeID() const override final {
70  return &typeid(T);
71  }
72 
73 private:
74  template <int I, int S>
75  void columnTypesImpl(std::vector<std::type_index>& iV, std::true_type*) const {
76  using Layout = typename T::Layout;
77  iV.emplace_back( typeid( typename std::tuple_element<I,Layout>::type ) );
78  columnTypesImpl<I+1, S>(iV,
79  static_cast<typename std::conditional< I+1 != S,
80  std::true_type,
81  std::false_type>::type*>(nullptr));
82  }
83 
84  template <int I, int S>
85  void columnTypesImpl(std::vector<std::type_index>&, std::false_type*) const {};
86 
87  template <int I, int S>
88  void columnDescImpl(std::vector<std::pair<char const*, std::type_index>>& iV,
89  std::true_type*) const {
90  using Layout = typename T::Layout;
91  using ColumnType = typename std::tuple_element<I,Layout>::type;
92  iV.emplace_back( ColumnType::label(), typeid( typename ColumnType::type ) );
93  columnDescImpl<I+1, S>(iV,
94  static_cast<typename std::conditional< I+1 != S,
95  std::true_type,
96  std::false_type>::type*>(nullptr));
97  }
98 
99  template <int I, int S>
100  void columnDescImpl(std::vector<std::pair<char const*, std::type_index>>&,
101  std::false_type*) const {};
102 
103  // ---------- member data --------------------------------
104  T const* m_table;
105 
106 };
107 
108 }
109 }
110 
111 #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:46
std::vector< std::pair< char const *, std::type_index > > columnDescriptions() const override final
Definition: TableExaminer.h:61
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, std::true_type *) const
Definition: TableExaminer.h:75
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
void columnDescImpl(std::vector< std::pair< char const *, std::type_index >> &iV, std::true_type *) const
Definition: TableExaminer.h:88
HLT enums.
const std::type_info * typeID() const override final
Definition: TableExaminer.h:69
long double T
void columnTypesImpl(std::vector< std::type_index > &, std::false_type *) const
Definition: TableExaminer.h:85
static const unsigned int kNColumns