CMS 3D CMS Logo

TableView.h
Go to the documentation of this file.
1 #ifndef FWCore_SOA_TableView_h
2 #define FWCore_SOA_TableView_h
3 // -*- C++ -*-
4 //
5 // Package: FWCore/SOA
6 // Class : TableView
7 //
31 //
32 // Original Author: Chris Jones
33 // Created: Fri, 25 Aug 2017 19:31:50 GMT
34 //
35 
36 // system include files
37 #include <tuple>
38 #include <array>
39 
40 // user include files
43 
44 // forward declarations
45 
46 namespace edm {
47  namespace soa {
48 template <typename... Args>
49 class TableView {
50 
51 public:
52  using Layout = std::tuple<Args...>;
53  static constexpr const size_t kNColumns = sizeof...(Args);
54  using const_iterator = ConstTableItr<Args...>;
55 
56  template <typename... OArgs>
57  TableView( Table<OArgs...> const& iTable):
58  m_size(iTable.size()) {
59  fillArray<0>(iTable,std::true_type{});
60  }
61  TableView( unsigned int iSize, std::array<void*, sizeof...(Args)>& iArray):
62  m_size(iSize),
63  m_values(iArray) {}
64 
65  TableView( unsigned int iSize, std::array<void const*, sizeof...(Args)>& iArray):
66  m_size(iSize),
67  m_values(iArray) {}
68 
69  unsigned int size() const {
70  return m_size;
71  }
72 
73  template<typename U>
74  typename U::type const& get(size_t iRow) const {
75  return static_cast<typename U::type*>(columnAddress<U>())+iRow;
76  }
77 
78  template<typename U>
80  return ColumnValues<typename U::type>{static_cast<typename U::type const*>(columnAddress<U>()), m_size};
81  }
82 
85 
86 private:
87  std::array<void const*, sizeof...(Args)> m_values;
88  unsigned int m_size;
89 
90  template<typename U>
91  void const* columnAddress() const {
93  }
94 
95  template <int I, typename T>
96  void fillArray( T const& iTable, std::true_type) {
97  using ElementType = typename std::tuple_element<I, Layout>::type;
98  m_values[I] = iTable.columnAddressWorkaround(static_cast<ElementType const*>(nullptr));
99  fillArray<I+1>(iTable, std::conditional_t<I+1<sizeof...(Args), std::true_type, std::false_type>{});
100  }
101  template <int I, typename T>
102  void fillArray( T const& iTable, std::false_type) {}
103 
104 
105 };
106 
107 }
108 }
109 
110 #endif
type
Definition: HCALResponse.h:21
unsigned int size() const
Definition: TableView.h:69
unsigned int m_size
Definition: TableView.h:88
static constexpr const size_t kNColumns
Definition: TableView.h:53
std::tuple< Args... > Layout
Definition: TableView.h:52
#define constexpr
TableView(unsigned int iSize, std::array< void *, sizeof...(Args)> &iArray)
Definition: TableView.h:61
std::array< void const *, sizeof...(Args)> m_values
Definition: TableView.h:87
void fillArray(T const &iTable, std::true_type)
Definition: TableView.h:96
void fillArray(T const &iTable, std::false_type)
Definition: TableView.h:102
ColumnValues< typename U::type > column() const
Definition: TableView.h:79
const std::complex< double > I
Definition: I.h:8
void const * columnAddress() const
Definition: TableView.h:91
const_iterator end() const
Definition: TableView.h:84
TableView(unsigned int iSize, std::array< void const *, sizeof...(Args)> &iArray)
Definition: TableView.h:65
const_iterator begin() const
Definition: TableView.h:83
HLT enums.
TableView(Table< OArgs... > const &iTable)
Definition: TableView.h:57
long double T