CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes
edm::SoATuple< Args > Class Template Reference

#include <SoATuple.h>

Public Types

typedef std::tuple< Args... > element
 

Public Member Functions

template<unsigned int I>
soahelper::AlignmentHelper< typename std::tuple_element< I, std::tuple< Args... > >::type >::Type * begin ()
 
template<unsigned int I>
soahelper::AlignmentHelper< typename std::tuple_element< I, std::tuple< Args... > >::type >::Type const * begin () const
 
size_t capacity () const
 
template<typename... FArgs>
void emplace_back (FArgs &&... values)
 
template<unsigned int I>
soahelper::AlignmentHelper< typename std::tuple_element< I, std::tuple< Args... > >::type >::Type * end ()
 
template<unsigned int I>
soahelper::AlignmentHelper< typename std::tuple_element< I, std::tuple< Args... > >::type >::Type const * end () const
 
template<unsigned int I>
soahelper::AlignmentHelper< typename std::tuple_element< I, std::tuple< Args... > >::type >::Type & get (unsigned int iIndex)
 
template<unsigned int I>
soahelper::AlignmentHelper< typename std::tuple_element< I, std::tuple< Args... > >::type >::Type const & get (unsigned int iIndex) const
 
const SoATuple< Args... > & operator= (const SoATuple< Args... > &iRHS)
 
SoATuple< Args... > & operator= (SoATuple< Args... > &&iRHS)
 
void push_back (element const &values)
 
void reserve (unsigned int iToSize)
 
void shrink_to_fit ()
 
size_t size () const
 
 SoATuple ()
 
 SoATuple (const SoATuple< Args... > &iOther)
 
 SoATuple (SoATuple< Args... > &&iOther)
 
void swap (SoATuple< Args... > &iOther)
 
 ~SoATuple ()
 

Private Member Functions

void changeSize (unsigned int iToSize)
 

Private Attributes

size_t m_reserved
 
size_t m_size
 
void * m_values [sizeof...(Args)]
 

Detailed Description

template<typename... Args>
class edm::SoATuple< Args >

Definition at line 108 of file SoATuple.h.

Member Typedef Documentation

◆ element

template<typename... Args>
typedef std::tuple<Args...> edm::SoATuple< Args >::element

Definition at line 110 of file SoATuple.h.

Constructor & Destructor Documentation

◆ SoATuple() [1/3]

template<typename... Args>
edm::SoATuple< Args >::SoATuple ( )
inline

Definition at line 112 of file SoATuple.h.

112  : m_size(0), m_reserved(0) {
113  for (auto& v : m_values) {
114  v = nullptr;
115  }
116  }

◆ SoATuple() [2/3]

template<typename... Args>
edm::SoATuple< Args >::SoATuple ( const SoATuple< Args... > &  iOther)
inline

Definition at line 117 of file SoATuple.h.

117  : m_size(0), m_reserved(0) {
118  for (auto& v : m_values) {
119  v = nullptr;
120  }
121  reserve(iOther.m_size);
122  soahelper::SoATupleHelper<sizeof...(Args), Args...>::copyToNew(
123  static_cast<char*>(m_values[0]), iOther.m_size, m_reserved, iOther.m_values, m_values);
124  m_size = iOther.m_size;
125  }

◆ SoATuple() [3/3]

template<typename... Args>
edm::SoATuple< Args >::SoATuple ( SoATuple< Args... > &&  iOther)
inline

Definition at line 127 of file SoATuple.h.

127  : m_size(0), m_reserved(0) {
128  for (auto& v : m_values) {
129  v = nullptr;
130  }
131  this->swap(iOther);
132  }

◆ ~SoATuple()

template<typename... Args>
edm::SoATuple< Args >::~SoATuple ( )
inline

Definition at line 146 of file SoATuple.h.

146  {
147  soahelper::SoATupleHelper<sizeof...(Args), Args...>::destroy(m_values, m_size);
148  typedef std::aligned_storage<soahelper::SoATupleHelper<sizeof...(Args), Args...>::max_alignment,
149  soahelper::SoATupleHelper<sizeof...(Args), Args...>::max_alignment>
150  AlignedType;
151 
152  delete[] static_cast<AlignedType*>(m_values[0]);
153  }

Member Function Documentation

◆ begin() [1/2]

template<typename... Args>
template<unsigned int I>
soahelper::AlignmentHelper<typename std::tuple_element<I, std::tuple<Args...> >::type>::Type* edm::SoATuple< Args >::begin ( void  )
inline

Returns the beginning of the container holding all Ith data elements

Definition at line 235 of file SoATuple.h.

235  {
236  typedef soahelper::AlignmentHelper<typename std::tuple_element<I, std::tuple<Args...>>::type> Helper;
237  typedef typename Helper::Type ReturnType;
238 #if GCC_PREREQUISITE(4, 7, 0)
239  return static_cast<ReturnType*>(__builtin_assume_aligned(m_values[I], Helper::kAlignment));
240 #else
241  return static_cast<ReturnType*>(m_values[I]);
242 #endif
243  }

◆ begin() [2/2]

template<typename... Args>
template<unsigned int I>
soahelper::AlignmentHelper<typename std::tuple_element<I, std::tuple<Args...> >::type>::Type const* edm::SoATuple< Args >::begin ( void  ) const
inline

Returns the beginning of the container holding all Ith data elements

Definition at line 170 of file SoATuple.h.

171  {
172  typedef soahelper::AlignmentHelper<typename std::tuple_element<I, std::tuple<Args...>>::type> Helper;
173  typedef typename Helper::Type ReturnType;
174 #if GCC_PREREQUISITE(4, 7, 0)
175  return static_cast<ReturnType const*>(__builtin_assume_aligned(m_values[I], Helper::kAlignment));
176 #else
177  return static_cast<ReturnType const*>(m_values[I]);
178 #endif
179  }

◆ capacity()

template<typename... Args>
size_t edm::SoATuple< Args >::capacity ( ) const
inline

◆ changeSize()

template<typename... Args>
void edm::SoATuple< Args >::changeSize ( unsigned int  iToSize)
inlineprivate

Definition at line 261 of file SoATuple.h.

261  {
262  assert(m_size <= iToSize);
263  const size_t memoryNeededInBytes = soahelper::SoATupleHelper<sizeof...(Args), Args...>::spaceNeededFor(iToSize);
264  //align memory of the array to be on the strictest alignment boundary for any type in the Tuple
265  // This is done by creating an array of a type that has that same alignment restriction and minimum size.
266  // This has the draw back of possibly padding the array by one extra element if the memoryNeededInBytes is not
267  // a strict multiple of max_alignment.
268  // NOTE: using new char[...] would likely cause more padding based on C++11 5.3.4 paragraph 10 where it
269  // says the alignment will be for the strictest requirement for an object whose size < size of array. So
270  // if the array were for 64 bytes and the strictest requirement of any object was 8 bytes then the entire
271  // char array would be aligned on an 8 byte boundary. However, if the SoATuple<char,char> only 1 byte alignment
272  // is needed. The following algorithm would require only 1 byte alignment
273  const std::size_t max_alignment = soahelper::SoATupleHelper<sizeof...(Args), Args...>::max_alignment;
274  typedef std::aligned_storage<soahelper::SoATupleHelper<sizeof...(Args), Args...>::max_alignment,
275  soahelper::SoATupleHelper<sizeof...(Args), Args...>::max_alignment>
276  AlignedType;
277  //If needed, pad the number of items by 1
278  const size_t itemsNeeded = (memoryNeededInBytes + max_alignment - 1) / sizeof(AlignedType);
279  char* newMemory = static_cast<char*>(static_cast<void*>(new AlignedType[itemsNeeded]));
280  void* oldMemory = m_values[0];
281  soahelper::SoATupleHelper<sizeof...(Args), Args...>::moveToNew(newMemory, m_size, iToSize, m_values);
282  m_reserved = iToSize;
283  delete[] static_cast<AlignedType*>(oldMemory);
284  }

Referenced by edm::SoATuple< edm::EDConsumerBase::TokenLookupInfo, bool, edm::EDConsumerBase::LabelPlacement, edm::KindOfType >::reserve(), and edm::SoATuple< edm::EDConsumerBase::TokenLookupInfo, bool, edm::EDConsumerBase::LabelPlacement, edm::KindOfType >::shrink_to_fit().

◆ emplace_back()

template<typename... Args>
template<typename... FArgs>
void edm::SoATuple< Args >::emplace_back ( FArgs &&...  values)
inline

Adds one entry to the end of the list. The arguments are used to instantiate each data element in the order defined in the template arguments.

Definition at line 215 of file SoATuple.h.

215  {
216  if (size() + 1 > capacity()) {
217  reserve(size() * 2 + 1);
218  }
219  soahelper::SoATupleHelper<sizeof...(Args), Args...>::emplace_back(
220  m_values, m_size, std::forward<FArgs>(values)...);
221  ++m_size;
222  }

Referenced by edm::SoATuple< edm::EDConsumerBase::TokenLookupInfo, bool, edm::EDConsumerBase::LabelPlacement, edm::KindOfType >::emplace_back().

◆ end() [1/2]

template<typename... Args>
template<unsigned int I>
soahelper::AlignmentHelper<typename std::tuple_element<I, std::tuple<Args...> >::type>::Type* edm::SoATuple< Args >::end ( void  )
inline

Returns the end of the container holding all Ith data elements

Definition at line 246 of file SoATuple.h.

246  {
247  typedef typename soahelper::AlignmentHelper<typename std::tuple_element<I, std::tuple<Args...>>::type>::Type
248  ReturnType;
249  return static_cast<ReturnType*>(m_values[I]) + m_size;
250  }

◆ end() [2/2]

template<typename... Args>
template<unsigned int I>
soahelper::AlignmentHelper<typename std::tuple_element<I, std::tuple<Args...> >::type>::Type const* edm::SoATuple< Args >::end ( void  ) const
inline

Returns the end of the container holding all Ith data elements

Definition at line 182 of file SoATuple.h.

183  {
184  typedef typename soahelper::AlignmentHelper<typename std::tuple_element<I, std::tuple<Args...>>::type>::Type
185  ReturnType;
186  return static_cast<ReturnType const*>(m_values[I]) + m_size;
187  }

◆ get() [1/2]

template<typename... Args>
template<unsigned int I>
soahelper::AlignmentHelper<typename std::tuple_element<I, std::tuple<Args...> >::type>::Type& edm::SoATuple< Args >::get ( unsigned int  iIndex)
inline

◆ get() [2/2]

template<typename... Args>
template<unsigned int I>
soahelper::AlignmentHelper<typename std::tuple_element<I, std::tuple<Args...> >::type>::Type const& edm::SoATuple< Args >::get ( unsigned int  iIndex) const
inline

◆ operator=() [1/2]

template<typename... Args>
const SoATuple<Args...>& edm::SoATuple< Args >::operator= ( const SoATuple< Args... > &  iRHS)
inline

Definition at line 134 of file SoATuple.h.

134  {
135  SoATuple<Args...> temp(iRHS);
136  this->swap(temp);
137  return *this;
138  }

◆ operator=() [2/2]

template<typename... Args>
SoATuple<Args...>& edm::SoATuple< Args >::operator= ( SoATuple< Args... > &&  iRHS)
inline

Definition at line 140 of file SoATuple.h.

140  {
141  SoATuple<Args...> temp(std::move(iRHS));
142  this->swap(temp);
143  return *this;
144  }

◆ push_back()

template<typename... Args>
void edm::SoATuple< Args >::push_back ( element const &  values)
inline

Adds one entry to the end of the list. Memory grows as needed.

Definition at line 205 of file SoATuple.h.

205  {
206  if (size() + 1 > capacity()) {
207  reserve(size() * 2 + 1);
208  }
209  soahelper::SoATupleHelper<sizeof...(Args), Args...>::push_back(m_values, m_size, values);
210  ++m_size;
211  }

Referenced by edm::SoATuple< edm::EDConsumerBase::TokenLookupInfo, bool, edm::EDConsumerBase::LabelPlacement, edm::KindOfType >::push_back().

◆ reserve()

template<typename... Args>
void edm::SoATuple< Args >::reserve ( unsigned int  iToSize)
inline

◆ shrink_to_fit()

template<typename... Args>
void edm::SoATuple< Args >::shrink_to_fit ( )
inline

Shrinks the amount of memory used so as to only have just enough to hold all entries.

Definition at line 198 of file SoATuple.h.

198  {
199  if (m_reserved > m_size) {
201  }
202  }

◆ size()

template<typename... Args>
size_t edm::SoATuple< Args >::size ( void  ) const
inline

◆ swap()

template<typename... Args>
void edm::SoATuple< Args >::swap ( SoATuple< Args... > &  iOther)
inline

Definition at line 252 of file SoATuple.h.

252  {
253  std::swap(m_size, iOther.m_size);
254  std::swap(m_reserved, iOther.m_reserved);
255  for (unsigned int i = 0; i < sizeof...(Args); ++i) {
256  std::swap(m_values[i], iOther.m_values[i]);
257  }
258  }

Referenced by edm::SoATuple< edm::EDConsumerBase::TokenLookupInfo, bool, edm::EDConsumerBase::LabelPlacement, edm::KindOfType >::operator=(), and edm::SoATuple< edm::EDConsumerBase::TokenLookupInfo, bool, edm::EDConsumerBase::LabelPlacement, edm::KindOfType >::SoATuple().

Member Data Documentation

◆ m_reserved

template<typename... Args>
size_t edm::SoATuple< Args >::m_reserved
private

◆ m_size

template<typename... Args>
size_t edm::SoATuple< Args >::m_size
private

◆ m_values

template<typename... Args>
void* edm::SoATuple< Args >::m_values[sizeof...(Args)]
private
mps_fire.i
i
Definition: mps_fire.py:355
SoATuple
edm::SoATuple::m_values
void * m_values[sizeof...(Args)]
Definition: SoATuple.h:288
edm::SoATuple::push_back
void push_back(element const &values)
Definition: SoATuple.h:205
cms::cuda::assert
assert(be >=bs)
findQualityFiles.v
v
Definition: findQualityFiles.py:179
groupFilesInBlocks.temp
list temp
Definition: groupFilesInBlocks.py:142
edm::SoATuple::capacity
size_t capacity() const
Definition: SoATuple.h:157
Exhume::I
const std::complex< double > I
Definition: I.h:8
susybsm::HSCParticleType::Type
Type
Definition: HSCParticle.h:20
std::swap
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
Definition: DataFrameContainer.h:209
contentValuesCheck.values
values
Definition: contentValuesCheck.py:38
edm::SoATuple::m_size
size_t m_size
Definition: SoATuple.h:289
ecaldqm::ReturnType
std::map< DetId, double > ReturnType
Definition: DBReaderWorkers.cc:54
edm::SoATuple::emplace_back
void emplace_back(FArgs &&... values)
Definition: SoATuple.h:215
edm::SoATuple::size
size_t size() const
Definition: SoATuple.h:156
edm::SoATuple::m_reserved
size_t m_reserved
Definition: SoATuple.h:290
edm::SoATuple::swap
void swap(SoATuple< Args... > &iOther)
Definition: SoATuple.h:252
type
type
Definition: HCALResponse.h:21
eostools.move
def move(src, dest)
Definition: eostools.py:511
edm::SoATuple::changeSize
void changeSize(unsigned int iToSize)
Definition: SoATuple.h:261
edm::SoATuple::reserve
void reserve(unsigned int iToSize)
Definition: SoATuple.h:191