CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Classes | Public Types | Public Member Functions | Static Public Attributes | Private Member Functions | Static Private Member Functions | Private Attributes
edm::soa::Table< Args > Class Template Reference

#include <Table.h>

Classes

struct  CtrFillerFromAOS
 
struct  CtrFillerFromContainers
 

Public Types

using const_iterator = ConstTableItr< Args...>
 
using iterator = TableItr< Args...>
 
using Layout = std::tuple< Args...>
 

Public Member Functions

const_iterator begin () const
 
iterator begin ()
 
template<typename U >
ColumnValues< typename U::typecolumn () const
 
template<typename U >
MutableColumnValues< typename
U::type
column ()
 
void const * columnAddressByIndex (unsigned int iIndex) const
 
template<typename U >
void const * columnAddressWorkaround (U const *) const
 
const_iterator end () const
 
iterator end ()
 
template<typename U >
U::type const & get (size_t iRow) const
 
template<typename U >
U::typeget (size_t iRow)
 
Table< Args...> & operator= (Table< Args...> &&iOther)
 
Table< Args...> & operator= (Table< Args...> const &iOther)
 
void resize (unsigned int iNewSize)
 
RowView< Args...> row (size_t iRow) const
 
MutableRowView< Args...> row (size_t iRow)
 
unsigned int size () const
 
 std::swap (m_values, iOther.m_values)
 
template<typename T , typename... CArgs>
 Table (T const &iContainer, CArgs...iArgs)
 
template<typename T , typename... CArgs>
 Table (T const &iContainer, ColumnFillers< CArgs...> iFiller)
 
 Table (Table< Args...> const &iOther)
 
 Table (Table< Args...> &&iOther)
 
 Table ()
 
 ~Table ()
 

Static Public Attributes

static constexpr const unsigned int kNColumns = sizeof...(Args)
 

Private Member Functions

template<typename U >
void const * columnAddress () const
 keep ROOT from trying to store this More...
 
template<typename U >
void * columnAddress ()
 

Static Private Member Functions

template<int I>
static void copyFromToWithResize (size_t iNElements, std::array< void *, sizeof...(Args)> const &iFrom, std::array< void *, sizeof...(Args)> &oTo)
 
template<size_t... I>
static void copyFromToWithResizeAll (size_t iNElements, std::array< void *, sizeof...(Args)> const &iFrom, std::array< void *, sizeof...(Args)> &oTo, std::index_sequence< I...>)
 
template<int I>
static void dtr (std::array< void *, sizeof...(Args)> &iArray)
 
template<int I>
static void resetStartingAt (size_t iStartIndex, size_t iEndIndex, std::array< void *, sizeof...(Args)> &ioArray)
 
template<int I>
static void resizeFromTo (size_t iOldSize, size_t iNewSize, std::array< void *, sizeof...(Args)> &ioArray)
 

Private Attributes

unsigned int m_size = 0
 
std::array< void *, sizeof...(Args)> m_values = {{nullptr}}
 

Detailed Description

template<typename... Args>
class edm::soa::Table< Args >

Definition at line 137 of file Table.h.

Member Typedef Documentation

template<typename... Args>
using edm::soa::Table< Args >::const_iterator = ConstTableItr<Args...>

Definition at line 141 of file Table.h.

template<typename... Args>
using edm::soa::Table< Args >::iterator = TableItr<Args...>

Definition at line 142 of file Table.h.

template<typename... Args>
using edm::soa::Table< Args >::Layout = std::tuple<Args...>

Definition at line 140 of file Table.h.

Constructor & Destructor Documentation

template<typename... Args>
template<typename T , typename... CArgs>
edm::soa::Table< Args >::Table ( T const &  iContainer,
CArgs...  iArgs 
)
inline

Definition at line 145 of file Table.h.

145  : m_size(iContainer.size()) {
146  if constexpr (sizeof...(CArgs) == 0) {
147  CtrFillerFromAOS::fill(m_values, iContainer);
148  } else {
149  CtrFillerFromContainers::fill(m_values, iContainer, std::forward<CArgs>(iArgs)...);
150  }
151  }
std::array< void *, sizeof...(Args)> m_values
Definition: Table.h:243
static size_t fill(std::array< void *, sizeof...(Args)> &oValues, T const &iContainer, U...iArgs)
Definition: Table.h:268
static size_t fill(std::array< void *, sizeof...(Args)> &oValues, T const &iContainer)
Definition: Table.h:297
unsigned int m_size
Definition: Table.h:242
template<typename... Args>
template<typename T , typename... CArgs>
edm::soa::Table< Args >::Table ( T const &  iContainer,
ColumnFillers< CArgs...>  iFiller 
)
inline

Definition at line 154 of file Table.h.

154  {
155  m_size = iContainer.size();
156  CtrFillerFromAOS::fillUsingFiller(iFiller, m_values, iContainer);
157  }
std::array< void *, sizeof...(Args)> m_values
Definition: Table.h:243
unsigned int m_size
Definition: Table.h:242
static size_t fillUsingFiller(F &iFiller, std::array< void *, sizeof...(Args)> &oValues, T const &iContainer)
Definition: Table.h:308
template<typename... Args>
edm::soa::Table< Args >::Table ( Table< Args...> const &  iOther)
inline

Definition at line 159 of file Table.h.

159 : m_size(iOther.m_size), m_values{{nullptr}} {
std::array< void *, sizeof...(Args)> m_values
Definition: Table.h:243
unsigned int m_size
Definition: Table.h:242
template<typename... Args>
edm::soa::Table< Args >::Table ( Table< Args...> &&  iOther)
inline

Definition at line 163 of file Table.h.

163 : m_size(0), m_values{{nullptr}} {
std::array< void *, sizeof...(Args)> m_values
Definition: Table.h:243
unsigned int m_size
Definition: Table.h:242
template<typename... Args>
edm::soa::Table< Args >::Table ( )
inline

Definition at line 168 of file Table.h.

168 : m_size(0) {}
unsigned int m_size
Definition: Table.h:242
template<typename... Args>
edm::soa::Table< Args >::~Table ( )
inline

Definition at line 170 of file Table.h.

170 { dtr<0>(m_values); }
std::array< void *, sizeof...(Args)> m_values
Definition: Table.h:243

Member Function Documentation

template<typename... Args>
const_iterator edm::soa::Table< Args >::begin ( void  ) const
inline

Definition at line 215 of file Table.h.

Referenced by edm::soa::Table< edm::soa::col::Pt, edm::soa::col::Eta, edm::soa::col::Phi, edm::soa::col::Vz >::row().

215  {
216  std::array<void const*, sizeof...(Args)> t;
217  for (size_t i = 0; i < t.size(); ++i) {
218  t[i] = m_values[i];
219  }
220  return const_iterator{t};
221  }
tuple array
Definition: mps_check.py:216
std::array< void *, sizeof...(Args)> m_values
Definition: Table.h:243
ConstTableItr< Args...> const_iterator
Definition: Table.h:141
template<typename... Args>
iterator edm::soa::Table< Args >::begin ( void  )
inline

Definition at line 230 of file Table.h.

230 { return iterator{m_values}; }
TableItr< Args...> iterator
Definition: Table.h:142
std::array< void *, sizeof...(Args)> m_values
Definition: Table.h:243
template<typename... Args>
template<typename U >
ColumnValues<typename U::type> edm::soa::Table< Args >::column ( ) const
inline

Definition at line 204 of file Table.h.

204  {
205  return ColumnValues<typename U::type>{static_cast<typename U::type*>(columnAddress<U>()), m_size};
206  }
unsigned int m_size
Definition: Table.h:242
template<typename... Args>
template<typename U >
MutableColumnValues<typename U::type> edm::soa::Table< Args >::column ( )
inline

Definition at line 208 of file Table.h.

208  {
209  return MutableColumnValues<typename U::type>{static_cast<typename U::type*>(columnAddress<U>()), m_size};
210  }
unsigned int m_size
Definition: Table.h:242
template<typename... Args>
template<typename U >
void const* edm::soa::Table< Args >::columnAddress ( ) const
inlineprivate

keep ROOT from trying to store this

Definition at line 246 of file Table.h.

246  {
248  }
std::array< void *, sizeof...(Args)> m_values
Definition: Table.h:243
template<typename... Args>
template<typename U >
void* edm::soa::Table< Args >::columnAddress ( )
inlineprivate

Definition at line 251 of file Table.h.

251  {
253  }
std::array< void *, sizeof...(Args)> m_values
Definition: Table.h:243
template<typename... Args>
void const* edm::soa::Table< Args >::columnAddressByIndex ( unsigned int  iIndex) const
inline

Definition at line 238 of file Table.h.

238 { return m_values[iIndex]; }
std::array< void *, sizeof...(Args)> m_values
Definition: Table.h:243
template<typename... Args>
template<typename U >
void const* edm::soa::Table< Args >::columnAddressWorkaround ( U const *  ) const
inline

Definition at line 234 of file Table.h.

234  {
235  return columnAddress<U>();
236  }
template<typename... Args>
template<int I>
static void edm::soa::Table< Args >::copyFromToWithResize ( size_t  iNElements,
std::array< void *, sizeof...(Args)> const &  iFrom,
std::array< void *, sizeof...(Args)> &  oTo 
)
inlinestaticprivate

Definition at line 366 of file Table.h.

368  {
369  using Layout = std::tuple<Args...>;
371  Type* oldPtr = static_cast<Type*>(oTo[I]);
372  Type* ptr = new Type[iNElements];
373  oTo[I] = ptr;
374  std::copy(static_cast<Type const*>(iFrom[I]), static_cast<Type const*>(iFrom[I]) + iNElements, ptr);
375  delete[] oldPtr;
376  }
std::tuple< Args...> Layout
Definition: Table.h:140
const std::complex< double > I
Definition: I.h:8
template<typename... Args>
template<size_t... I>
static void edm::soa::Table< Args >::copyFromToWithResizeAll ( size_t  iNElements,
std::array< void *, sizeof...(Args)> const &  iFrom,
std::array< void *, sizeof...(Args)> &  oTo,
std::index_sequence< I...>   
)
inlinestaticprivate

Definition at line 358 of file Table.h.

361  {
362  (copyFromToWithResize<I>(iNElements, iFrom, oTo), ...);
363  }
template<typename... Args>
template<int I>
static void edm::soa::Table< Args >::dtr ( std::array< void *, sizeof...(Args)> &  iArray)
inlinestaticprivate

Definition at line 257 of file Table.h.

257  {
258  if constexpr (I < sizeof...(Args)) {
260  delete[] static_cast<Type*>(iArray[I]);
261  dtr<I + 1>(iArray);
262  }
263  }
const std::complex< double > I
Definition: I.h:8
template<typename... Args>
const_iterator edm::soa::Table< Args >::end ( void  ) const
inline

Definition at line 222 of file Table.h.

222  {
223  std::array<void const*, sizeof...(Args)> t;
224  for (size_t i = 0; i < t.size(); ++i) {
225  t[i] = m_values[i];
226  }
227  return const_iterator{t, size()};
228  }
tuple array
Definition: mps_check.py:216
std::array< void *, sizeof...(Args)> m_values
Definition: Table.h:243
ConstTableItr< Args...> const_iterator
Definition: Table.h:141
unsigned int size() const
Definition: Table.h:180
template<typename... Args>
iterator edm::soa::Table< Args >::end ( void  )
inline

Definition at line 231 of file Table.h.

231 { return iterator{m_values, size()}; }
TableItr< Args...> iterator
Definition: Table.h:142
std::array< void *, sizeof...(Args)> m_values
Definition: Table.h:243
unsigned int size() const
Definition: Table.h:180
template<typename... Args>
template<typename U >
U::type const& edm::soa::Table< Args >::get ( size_t  iRow) const
inline
template<typename... Args>
template<typename U >
U::type& edm::soa::Table< Args >::get ( size_t  iRow)
inline
template<typename... Args>
Table<Args...>& edm::soa::Table< Args >::operator= ( Table< Args...> &&  iOther)
inline

Definition at line 172 of file Table.h.

172  {
173  Table<Args...> cp(std::move(iOther));
174  std::swap(m_size, cp.m_size);
175  std::swap(m_values, cp.m_values);
176  return *this;
177  }
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
std::array< void *, sizeof...(Args)> m_values
Definition: Table.h:243
def move
Definition: eostools.py:511
unsigned int m_size
Definition: Table.h:242
template<typename... Args>
Table<Args...>& edm::soa::Table< Args >::operator= ( Table< Args...> const &  iOther)
inline

Definition at line 178 of file Table.h.

Referenced by edm::soa::Table< edm::soa::col::Pt, edm::soa::col::Eta, edm::soa::col::Phi, edm::soa::col::Vz >::operator=().

178 { return operator=(Table<Args...>(iOther)); }
Table< Args...> & operator=(Table< Args...> &&iOther)
Definition: Table.h:172
template<typename... Args>
template<int I>
static void edm::soa::Table< Args >::resetStartingAt ( size_t  iStartIndex,
size_t  iEndIndex,
std::array< void *, sizeof...(Args)> &  ioArray 
)
inlinestaticprivate

Definition at line 395 of file Table.h.

395  {
396  if constexpr (I < sizeof...(Args)) {
397  using Layout = std::tuple<Args...>;
399  auto ptr = static_cast<Type*>(ioArray[I]);
400  auto temp = Type{};
401  std::fill(ptr + iStartIndex, ptr + iEndIndex, temp);
402  resetStartingAt<I + 1>(iStartIndex, iEndIndex, ioArray);
403  }
404  }
std::tuple< Args...> Layout
Definition: Table.h:140
const std::complex< double > I
Definition: I.h:8
void fill(std::map< std::string, TH1 * > &h, const std::string &s, double x)
template<typename... Args>
void edm::soa::Table< Args >::resize ( unsigned int  iNewSize)
inline

Definition at line 182 of file Table.h.

182  {
183  if (m_size == iNewSize) {
184  return;
185  }
186  resizeFromTo<0>(m_size, iNewSize, m_values);
187  if (m_size < iNewSize) {
188  //initialize the extra values
189  resetStartingAt<0>(m_size, iNewSize, m_values);
190  }
191  m_size = iNewSize;
192  }
std::array< void *, sizeof...(Args)> m_values
Definition: Table.h:243
unsigned int m_size
Definition: Table.h:242
template<typename... Args>
template<int I>
static void edm::soa::Table< Args >::resizeFromTo ( size_t  iOldSize,
size_t  iNewSize,
std::array< void *, sizeof...(Args)> &  ioArray 
)
inlinestaticprivate

Definition at line 379 of file Table.h.

379  {
380  if constexpr (I < sizeof...(Args)) {
381  using Layout = std::tuple<Args...>;
383  Type* oldPtr = static_cast<Type*>(ioArray[I]);
384  auto ptr = new Type[iNewSize];
385  auto nToCopy = std::min(iOldSize, iNewSize);
386  std::copy(static_cast<Type const*>(ioArray[I]), static_cast<Type const*>(ioArray[I]) + nToCopy, ptr);
387  resizeFromTo<I + 1>(iOldSize, iNewSize, ioArray);
388 
389  delete[] oldPtr;
390  ioArray[I] = ptr;
391  }
392  }
std::tuple< Args...> Layout
Definition: Table.h:140
const std::complex< double > I
Definition: I.h:8
template<typename... Args>
RowView<Args...> edm::soa::Table< Args >::row ( size_t  iRow) const
inline

Definition at line 212 of file Table.h.

212 { return *(begin() + iRow); }
const_iterator begin() const
Definition: Table.h:215
template<typename... Args>
MutableRowView<Args...> edm::soa::Table< Args >::row ( size_t  iRow)
inline

Definition at line 213 of file Table.h.

213 { return *(begin() + iRow); }
const_iterator begin() const
Definition: Table.h:215
template<typename... Args>
unsigned int edm::soa::Table< Args >::size ( void  ) const
inline
template<typename... Args>
edm::soa::Table< Args >::std::swap ( m_values  ,
iOther.  m_values 
)

Member Data Documentation

template<typename... Args>
constexpr const unsigned int edm::soa::Table< Args >::kNColumns = sizeof...(Args)
static

Definition at line 139 of file Table.h.

template<typename... Args>
unsigned int edm::soa::Table< Args >::m_size = 0
private
template<typename... Args>
std::array<void*, sizeof...(Args)> edm::soa::Table< Args >::m_values = {{nullptr}}
private