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(iTable, std::make_index_sequence<sizeof...(Args)>{});
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 <typename T, size_t... I>
96  void fillArray( T const& iTable, std::index_sequence<I...>) {
97  ( (m_values[I] = iTable.columnAddressWorkaround(static_cast<typename std::tuple_element<I, Layout>::type const*>(nullptr))), ...);
98  }
99 };
100 
101 }
102 }
103 
104 #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
void fillArray(T const &iTable, std::index_sequence< I... >)
Definition: TableView.h:96
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
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