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 const*>(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  template <typename T>
97  struct ViewFromTable;
98 
99  template <typename... T>
100  struct ViewFromTable<Table<T...>> {
101  using type = TableView<T...>;
102  };
103  template <typename T>
105 
106  } // namespace soa
107 } // namespace edm
108 
109 #endif
edm::soa::TableView::end
const_iterator end() const
Definition: TableView.h:77
edm::soa::TableView::m_size
unsigned int m_size
Definition: TableView.h:81
edm::soa::TableView::kNColumns
static constexpr const size_t kNColumns
Definition: TableView.h:52
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::soa::TableView::fillArray
void fillArray(T const &iTable, std::index_sequence< I... >)
Definition: TableView.h:89
edm::soa::ViewFromTable_t
typename ViewFromTable< T >::type ViewFromTable_t
Definition: TableView.h:104
gpuVertexFinder::soa
ZVertexSoA * soa
Definition: gpuVertexFinder.cc:21
mps_check.array
array
Definition: mps_check.py:216
edm::soa::TableView::Layout
std::tuple< Args... > Layout
Definition: TableView.h:51
watchdog.const
const
Definition: watchdog.py:83
edm::soa::TableView::TableView
TableView(unsigned int iSize, std::array< void *, sizeof...(Args)> &iArray)
Definition: TableView.h:59
edm::soa::TableView::get
U::type const & get(size_t iRow) const
Definition: TableView.h:67
edm::soa::TableView::columnAddress
void const * columnAddress() const
Definition: TableView.h:84
edm::soa::TableView::size
unsigned int size() const
Definition: TableView.h:64
Exhume::I
const std::complex< double > I
Definition: I.h:8
edm::soa::TableView::m_values
std::array< void const *, sizeof...(Args)> m_values
Definition: TableView.h:80
edm::soa::TableView::begin
const_iterator begin() const
Definition: TableView.h:76
edm::soa::ConstTableItr
Definition: TableItr.h:116
gainCalibHelper::gainCalibPI::type
type
Definition: SiPixelGainCalibHelper.h:40
edm::soa::TableView
Definition: TableView.h:49
edm::soa::TableView::TableView
TableView(unsigned int iSize, std::array< void const *, sizeof...(Args)> &iArray)
Definition: TableView.h:61
edm::soa::ColumnValues
Definition: ColumnValues.h:30
edm::soa::ViewFromTable
Definition: TableView.h:97
T
long double T
Definition: Basic3DVectorLD.h:48
edm::soa::Table
Definition: Table.h:137
edm::soa::impl::GetIndex
Definition: tablehelpers.h:38
ColumnValues.h
edm::soa::TableView::column
ColumnValues< typename U::type > column() const
Definition: TableView.h:72
edm::soa::TableView::TableView
TableView(Table< OArgs... > const &iTable)
Definition: TableView.h:56
Table.h