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  public:
51  using Layout = std::tuple<Args...>;
52  static constexpr const size_t kNColumns = sizeof...(Args);
53  using const_iterator = ConstTableItr<Args...>;
54 
55  template <typename... OArgs>
56  TableView(Table<OArgs...> const& iTable) : m_size(iTable.size()) {
57  fillArray(iTable, std::make_index_sequence<sizeof...(Args)>{});
58  }
59  TableView(unsigned int iSize, std::array<void*, sizeof...(Args)>& iArray) : m_size(iSize), m_values(iArray) {}
60 
61  TableView(unsigned int iSize, std::array<void const*, sizeof...(Args)>& iArray)
62  : m_size(iSize), m_values(iArray) {}
63 
64  unsigned int size() const { return m_size; }
65 
66  template <typename U>
67  typename U::type const& get(size_t iRow) const {
68  return static_cast<typename U::type*>(columnAddress<U>()) + iRow;
69  }
70 
71  template <typename U>
73  return ColumnValues<typename U::type>{static_cast<typename U::type const*>(columnAddress<U>()), m_size};
74  }
75 
77  const_iterator end() const { return const_iterator{m_values, size()}; }
78 
79  private:
80  std::array<void const*, sizeof...(Args)> m_values;
81  unsigned int m_size;
82 
83  template <typename U>
84  void const* columnAddress() const {
86  }
87 
88  template <typename T, size_t... I>
89  void fillArray(T const& iTable, std::index_sequence<I...>) {
90  ((m_values[I] = iTable.columnAddressWorkaround(
91  static_cast<typename std::tuple_element<I, Layout>::type const*>(nullptr))),
92  ...);
93  }
94  };
95 
96  } // namespace soa
97 } // namespace edm
98 
99 #endif
type
Definition: HCALResponse.h:21
unsigned int size() const
Definition: TableView.h:64
unsigned int m_size
Definition: TableView.h:81
static constexpr const size_t kNColumns
Definition: TableView.h:52
void fillArray(T const &iTable, std::index_sequence< I... >)
Definition: TableView.h:89
std::tuple< Args... > Layout
Definition: TableView.h:51
TableView(unsigned int iSize, std::array< void *, sizeof...(Args)> &iArray)
Definition: TableView.h:59
std::array< void const *, sizeof...(Args)> m_values
Definition: TableView.h:80
ColumnValues< typename U::type > column() const
Definition: TableView.h:72
const std::complex< double > I
Definition: I.h:8
void const * columnAddress() const
Definition: TableView.h:84
const_iterator end() const
Definition: TableView.h:77
TableView(unsigned int iSize, std::array< void const *, sizeof...(Args)> &iArray)
Definition: TableView.h:61
const_iterator begin() const
Definition: TableView.h:76
HLT enums.
TableView(Table< OArgs... > const &iTable)
Definition: TableView.h:56
long double T
#define constexpr