CMS 3D CMS Logo

TableItr.h
Go to the documentation of this file.
1 #ifndef FWCore_SOA_TableItr_h
2 #define FWCore_SOA_TableItr_h
3 // -*- C++ -*-
4 //
5 // Package: FWCore/SOA
6 // Class : TableItr
7 //
16 //
17 // Original Author: Chris Jones
18 // Created: Thu, 24 Aug 2017 19:49:27 GMT
19 //
20 
21 // system include files
22 #include <tuple>
23 #include <array>
24 #include <type_traits>
25 
26 // user include files
27 #include "RowView.h"
28 
29 // forward declarations
30 
31 namespace edm {
32  namespace soa {
33  namespace impl {
34 
35  template <int I, typename... Args>
36  struct TableItrAdvance {
37  using Layout = std::tuple<Args...>;
38  static void advance(std::array<void*, sizeof...(Args)>& iArray, long iStep) {
41  auto p = static_cast<Type*>(iArray[I]);
42  iArray[I] = p + iStep;
43  }
44  };
45 
46  template <typename... Args>
47  struct TableItrAdvance<0, Args...> {
48  using Layout = std::tuple<Args...>;
49  static void advance(std::array<void*, sizeof...(Args)>& iArray, long iStep) {
51  auto p = static_cast<Type*>(iArray[0]);
52  iArray[0] = p + iStep;
53  }
54  };
55 
56  template <int I, typename... Args>
58  using Layout = std::tuple<Args...>;
59  static void advance(std::array<void const*, sizeof...(Args)>& iArray, long iStep) {
62  auto p = static_cast<Type const*>(iArray[I]);
63  iArray[I] = p + iStep;
64  }
65  };
66 
67  template <typename... Args>
68  struct ConstTableItrAdvance<0, Args...> {
69  using Layout = std::tuple<Args...>;
70  static void advance(std::array<void const*, sizeof...(Args)>& iArray, long iStep) {
72  auto p = static_cast<Type const*>(iArray[0]);
73  iArray[0] = p + iStep;
74  }
75  };
76  } // namespace impl
77 
78  template <typename... Args>
79  class TableItr {
80  using Layout = std::tuple<Args...>;
81  std::array<void*, sizeof...(Args)> m_values;
82 
83  public:
84  using value_type = MutableRowView<Args...>;
85 
86  explicit TableItr(std::array<void*, sizeof...(Args)> const& iValues) : m_values{iValues} {}
87 
88  explicit TableItr(std::array<void*, sizeof...(Args)> const& iValues, long iOffset) : m_values{iValues} {
89  impl::TableItrAdvance<sizeof...(Args) - 1, Args...>::advance(m_values, iOffset);
90  }
91 
92  explicit TableItr(std::array<void*, sizeof...(Args)> const& iValues, unsigned int iOffset) : m_values{iValues} {
93  impl::TableItrAdvance<sizeof...(Args) - 1, Args...>::advance(m_values, static_cast<long>(iOffset));
94  }
95 
97 
99  impl::TableItrAdvance<sizeof...(Args) - 1, Args...>::advance(m_values, 1);
100  return *this;
101  }
102 
103  bool operator==(const TableItr<Args...>& iOther) { return m_values[0] == iOther.m_values[0]; }
104 
105  bool operator!=(const TableItr<Args...>& iOther) { return m_values[0] != iOther.m_values[0]; }
106 
107  TableItr<Args...> makeOffset(long iDiff) const { return TableItr<Args...>{m_values, iDiff}; }
108  };
109 
110  template <typename... Args>
111  TableItr<Args...> operator+(TableItr<Args...> const& iLHS, long iDiff) {
112  return iLHS.makeOffset(iDiff);
113  }
114 
115  template <typename... Args>
117  using Layout = std::tuple<Args...>;
118  std::array<void const*, sizeof...(Args)> m_values;
119 
120  public:
121  using value_type = RowView<Args...>;
122 
123  explicit ConstTableItr(std::array<void const*, sizeof...(Args)> const& iValues) : m_values{iValues} {}
124 
125  ConstTableItr(std::array<void const*, sizeof...(Args)> const& iValues, long iOffset) : m_values{iValues} {
126  impl::ConstTableItrAdvance<sizeof...(Args) - 1, Args...>::advance(m_values, iOffset);
127  }
128 
129  ConstTableItr(std::array<void const*, sizeof...(Args)> const& iValues, unsigned int iOffset) : m_values{iValues} {
130  impl::ConstTableItrAdvance<sizeof...(Args) - 1, Args...>::advance(m_values, static_cast<long>(iOffset));
131  }
132 
134 
136  impl::ConstTableItrAdvance<sizeof...(Args) - 1, Args...>::advance(m_values, 1);
137  return *this;
138  }
139 
140  bool operator==(const ConstTableItr<Args...>& iOther) { return m_values[0] == iOther.m_values[0]; }
141 
142  bool operator!=(const ConstTableItr<Args...>& iOther) { return m_values[0] != iOther.m_values[0]; }
143 
144  TableItr<Args...> makeOffset(long iDiff) const { return TableItr<Args...>{m_values, iDiff}; }
145  };
146 
147  template <typename... Args>
148  ConstTableItr<Args...> operator+(ConstTableItr<Args...> const& iLHS, long iDiff) {
149  return iLHS.makeOffset(iDiff);
150  }
151 
152  } // namespace soa
153 } // namespace edm
154 
155 #endif
edm::soa::TableItr::makeOffset
TableItr< Args... > makeOffset(long iDiff) const
Definition: TableItr.h:107
edm::soa::TableItr::TableItr
TableItr(std::array< void *, sizeof...(Args)> const &iValues, long iOffset)
Definition: TableItr.h:88
edm::soa::ConstTableItr::operator!=
bool operator!=(const ConstTableItr< Args... > &iOther)
Definition: TableItr.h:142
edm::soa::impl::ConstTableItrAdvance::advance
static void advance(std::array< void const *, sizeof...(Args)> &iArray, long iStep)
Definition: TableItr.h:59
edm::soa::impl::ConstTableItrAdvance
Definition: TableItr.h:57
edm::soa::ConstTableItr::operator++
ConstTableItr & operator++()
Definition: TableItr.h:135
edm::soa::ConstTableItr::ConstTableItr
ConstTableItr(std::array< void const *, sizeof...(Args)> const &iValues, unsigned int iOffset)
Definition: TableItr.h:129
edm::soa::ConstTableItr::Layout
std::tuple< Args... > Layout
Definition: TableItr.h:117
edm::soa::RowView
Definition: RowView.h:57
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::soa::impl::TableItrAdvance< 0, Args... >::Layout
std::tuple< Args... > Layout
Definition: TableItr.h:48
edm::soa::TableItr
Definition: TableItr.h:79
edm::soa::TableItr::TableItr
TableItr(std::array< void *, sizeof...(Args)> const &iValues)
Definition: TableItr.h:86
gpuVertexFinder::soa
ZVertexSoA * soa
Definition: gpuVertexFinder.cc:21
mps_check.array
array
Definition: mps_check.py:216
edm::soa::operator+
TableItr< Args... > operator+(TableItr< Args... > const &iLHS, long iDiff)
Definition: TableItr.h:111
edm::soa::ConstTableItr::operator==
bool operator==(const ConstTableItr< Args... > &iOther)
Definition: TableItr.h:140
edm::soa::TableItr::operator!=
bool operator!=(const TableItr< Args... > &iOther)
Definition: TableItr.h:105
edm::soa::TableItr::Layout
std::tuple< Args... > Layout
Definition: TableItr.h:80
edm::soa::TableItr::TableItr
TableItr(std::array< void *, sizeof...(Args)> const &iValues, unsigned int iOffset)
Definition: TableItr.h:92
edm::soa::impl::TableItrAdvance::Layout
std::tuple< Args... > Layout
Definition: TableItr.h:37
Exhume::I
const std::complex< double > I
Definition: I.h:8
susybsm::HSCParticleType::Type
Type
Definition: HSCParticle.h:20
edm::soa::TableItr::operator==
bool operator==(const TableItr< Args... > &iOther)
Definition: TableItr.h:103
edm::soa::TableItr::operator++
TableItr & operator++()
Definition: TableItr.h:98
edm::soa::TableItr::m_values
std::array< void *, sizeof...(Args)> m_values
Definition: TableItr.h:81
edm::soa::ConstTableItr
Definition: TableItr.h:116
edm::soa::impl::TableItrAdvance::advance
static void advance(std::array< void *, sizeof...(Args)> &iArray, long iStep)
Definition: TableItr.h:38
edm::soa::impl::ConstTableItrAdvance< 0, Args... >::Layout
std::tuple< Args... > Layout
Definition: TableItr.h:69
edm::soa::ConstTableItr::ConstTableItr
ConstTableItr(std::array< void const *, sizeof...(Args)> const &iValues)
Definition: TableItr.h:123
AlCaHLTBitMon_ParallelJobs.p
def p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
edm::soa::ConstTableItr::operator*
value_type operator*() const
Definition: TableItr.h:133
gainCalibHelper::gainCalibPI::type
type
Definition: SiPixelGainCalibHelper.h:40
edm::soa::MutableRowView
Definition: RowView.h:76
RowView.h
edm::soa::ConstTableItr::ConstTableItr
ConstTableItr(std::array< void const *, sizeof...(Args)> const &iValues, long iOffset)
Definition: TableItr.h:125
edm::soa::impl::ConstTableItrAdvance< 0, Args... >::advance
static void advance(std::array< void const *, sizeof...(Args)> &iArray, long iStep)
Definition: TableItr.h:70
impl
Definition: trackAlgoPriorityOrder.h:18
edm::soa::TableItr::operator*
value_type operator*()
Definition: TableItr.h:96
edm::soa::ConstTableItr::makeOffset
TableItr< Args... > makeOffset(long iDiff) const
Definition: TableItr.h:144
edm::soa::impl::TableItrAdvance
Definition: TableItr.h:36
edm::soa::impl::ConstTableItrAdvance::Layout
std::tuple< Args... > Layout
Definition: TableItr.h:58
edm::soa::impl::TableItrAdvance< 0, Args... >::advance
static void advance(std::array< void *, sizeof...(Args)> &iArray, long iStep)
Definition: TableItr.h:49
edm::soa::ConstTableItr::m_values
std::array< void const *, sizeof...(Args)> m_values
Definition: TableItr.h:118