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 const * begin () const
 
template<unsigned int I>
soahelper::AlignmentHelper< typename std::tuple_element< I, std::tuple< Args... > >::type >::Type * begin ()
 
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 const * end () const
 
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 & get (unsigned int iIndex) const
 
template<unsigned int I>
soahelper::AlignmentHelper< typename std::tuple_element< I, std::tuple< Args... > >::type >::Type & get (unsigned int iIndex)
 
const SoATuple< Args... > & operator= (const 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 107 of file SoATuple.h.

Member Typedef Documentation

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

Definition at line 109 of file SoATuple.h.

Constructor & Destructor Documentation

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

Definition at line 111 of file SoATuple.h.

111  : m_size(0), m_reserved(0) {
112  for (auto& v : m_values) {
113  v = nullptr;
114  }
115  }
size_t m_reserved
Definition: SoATuple.h:283
size_t m_size
Definition: SoATuple.h:282
void * m_values[sizeof...(Args)]
Definition: SoATuple.h:281
template<typename... Args>
edm::SoATuple< Args >::SoATuple ( const SoATuple< Args... > &  iOther)
inline

Definition at line 116 of file SoATuple.h.

116  : m_size(0), m_reserved(0) {
117  for (auto& v : m_values) {
118  v = nullptr;
119  }
120  reserve(iOther.m_size);
121  soahelper::SoATupleHelper<sizeof...(Args), Args...>::copyToNew(
122  static_cast<char*>(m_values[0]), iOther.m_size, m_reserved, iOther.m_values, m_values);
123  m_size = iOther.m_size;
124  }
size_t m_reserved
Definition: SoATuple.h:283
size_t m_size
Definition: SoATuple.h:282
void reserve(unsigned int iToSize)
Definition: SoATuple.h:184
void * m_values[sizeof...(Args)]
Definition: SoATuple.h:281
template<typename... Args>
edm::SoATuple< Args >::SoATuple ( SoATuple< Args... > &&  iOther)
inline

Definition at line 126 of file SoATuple.h.

126  : m_size(0), m_reserved(0) {
127  for (auto& v : m_values) {
128  v = nullptr;
129  }
130  this->swap(iOther);
131  }
void swap(SoATuple< Args... > &iOther)
Definition: SoATuple.h:245
size_t m_reserved
Definition: SoATuple.h:283
size_t m_size
Definition: SoATuple.h:282
void * m_values[sizeof...(Args)]
Definition: SoATuple.h:281
template<typename... Args>
edm::SoATuple< Args >::~SoATuple ( )
inline

Definition at line 139 of file SoATuple.h.

139  {
140  soahelper::SoATupleHelper<sizeof...(Args), Args...>::destroy(m_values, m_size);
141  typedef std::aligned_storage<soahelper::SoATupleHelper<sizeof...(Args), Args...>::max_alignment,
142  soahelper::SoATupleHelper<sizeof...(Args), Args...>::max_alignment>
143  AlignedType;
144 
145  delete[] static_cast<AlignedType*>(m_values[0]);
146  }
def destroy(e)
Definition: pyrootRender.py:15
size_t m_size
Definition: SoATuple.h:282
void * m_values[sizeof...(Args)]
Definition: SoATuple.h:281

Member Function Documentation

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 163 of file SoATuple.h.

164  {
165  typedef soahelper::AlignmentHelper<typename std::tuple_element<I, std::tuple<Args...>>::type> Helper;
166  typedef typename Helper::Type ReturnType;
167 #if GCC_PREREQUISITE(4, 7, 0)
168  return static_cast<ReturnType const*>(__builtin_assume_aligned(m_values[I], Helper::kAlignment));
169 #else
170  return static_cast<ReturnType const*>(m_values[I]);
171 #endif
172  }
type
Definition: HCALResponse.h:21
std::map< DetId, double > ReturnType
const std::complex< double > I
Definition: I.h:8
void * m_values[sizeof...(Args)]
Definition: SoATuple.h:281
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 228 of file SoATuple.h.

228  {
229  typedef soahelper::AlignmentHelper<typename std::tuple_element<I, std::tuple<Args...>>::type> Helper;
230  typedef typename Helper::Type ReturnType;
231 #if GCC_PREREQUISITE(4, 7, 0)
232  return static_cast<ReturnType*>(__builtin_assume_aligned(m_values[I], Helper::kAlignment));
233 #else
234  return static_cast<ReturnType*>(m_values[I]);
235 #endif
236  }
type
Definition: HCALResponse.h:21
std::map< DetId, double > ReturnType
const std::complex< double > I
Definition: I.h:8
void * m_values[sizeof...(Args)]
Definition: SoATuple.h:281
template<typename... Args>
size_t edm::SoATuple< Args >::capacity ( ) const
inline
template<typename... Args>
void edm::SoATuple< Args >::changeSize ( unsigned int  iToSize)
inlineprivate

Definition at line 254 of file SoATuple.h.

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().

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

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

208  {
209  if (size() + 1 > capacity()) {
210  reserve(size() * 2 + 1);
211  }
212  soahelper::SoATupleHelper<sizeof...(Args), Args...>::emplace_back(
213  m_values, m_size, std::forward<FArgs>(values)...);
214  ++m_size;
215  }
size_t m_size
Definition: SoATuple.h:282
void emplace_back(FArgs &&...values)
Definition: SoATuple.h:208
size_t size() const
Definition: SoATuple.h:149
size_t capacity() const
Definition: SoATuple.h:150
void reserve(unsigned int iToSize)
Definition: SoATuple.h:184
void * m_values[sizeof...(Args)]
Definition: SoATuple.h:281
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 175 of file SoATuple.h.

176  {
177  typedef typename soahelper::AlignmentHelper<typename std::tuple_element<I, std::tuple<Args...>>::type>::Type
178  ReturnType;
179  return static_cast<ReturnType const*>(m_values[I]) + m_size;
180  }
type
Definition: HCALResponse.h:21
size_t m_size
Definition: SoATuple.h:282
std::map< DetId, double > ReturnType
const std::complex< double > I
Definition: I.h:8
void * m_values[sizeof...(Args)]
Definition: SoATuple.h:281
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 239 of file SoATuple.h.

239  {
240  typedef typename soahelper::AlignmentHelper<typename std::tuple_element<I, std::tuple<Args...>>::type>::Type
241  ReturnType;
242  return static_cast<ReturnType*>(m_values[I]) + m_size;
243  }
type
Definition: HCALResponse.h:21
size_t m_size
Definition: SoATuple.h:282
std::map< DetId, double > ReturnType
const std::complex< double > I
Definition: I.h:8
void * m_values[sizeof...(Args)]
Definition: SoATuple.h:281
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

Returns const access to data element I of item iIndex

Definition at line 154 of file SoATuple.h.

Referenced by Options.Options::__getitem__(), betterConfigParser.BetterConfigParser::__updateDict(), rrapi.RRApi::columns(), rrapi.RRApi::count(), rrapi.RRApi::data(), betterConfigParser.BetterConfigParser::getCompares(), betterConfigParser.BetterConfigParser::getGeneral(), betterConfigParser.BetterConfigParser::getResultingSection(), rrapi.RRApi::report(), rrapi.RRApi::reports(), rrapi.RRApi::tables(), rrapi.RRApi::tags(), rrapi.RRApi::templates(), and rrapi.RRApi::workspaces().

155  {
156  typedef typename soahelper::AlignmentHelper<typename std::tuple_element<I, std::tuple<Args...>>::type>::Type
157  ReturnType;
158  return *(static_cast<ReturnType const*>(m_values[I]) + iIndex);
159  }
type
Definition: HCALResponse.h:21
std::map< DetId, double > ReturnType
const std::complex< double > I
Definition: I.h:8
void * m_values[sizeof...(Args)]
Definition: SoATuple.h:281
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

Returns access to data element I of item iIndex

Definition at line 219 of file SoATuple.h.

Referenced by Options.Options::__getitem__(), betterConfigParser.BetterConfigParser::__updateDict(), rrapi.RRApi::columns(), rrapi.RRApi::count(), rrapi.RRApi::data(), betterConfigParser.BetterConfigParser::getCompares(), betterConfigParser.BetterConfigParser::getGeneral(), betterConfigParser.BetterConfigParser::getResultingSection(), rrapi.RRApi::report(), rrapi.RRApi::reports(), rrapi.RRApi::tables(), rrapi.RRApi::tags(), rrapi.RRApi::templates(), and rrapi.RRApi::workspaces().

220  {
221  typedef typename soahelper::AlignmentHelper<typename std::tuple_element<I, std::tuple<Args...>>::type>::Type
222  ReturnType;
223  return *(static_cast<ReturnType*>(m_values[I]) + iIndex);
224  }
type
Definition: HCALResponse.h:21
std::map< DetId, double > ReturnType
const std::complex< double > I
Definition: I.h:8
void * m_values[sizeof...(Args)]
Definition: SoATuple.h:281
template<typename... Args>
const SoATuple<Args...>& edm::SoATuple< Args >::operator= ( const SoATuple< Args... > &  iRHS)
inline

Definition at line 133 of file SoATuple.h.

133  {
134  SoATuple<Args...> temp(iRHS);
135  this->swap(temp);
136  return *this;
137  }
void swap(SoATuple< Args... > &iOther)
Definition: SoATuple.h:245
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 198 of file SoATuple.h.

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

198  {
199  if (size() + 1 > capacity()) {
200  reserve(size() * 2 + 1);
201  }
202  soahelper::SoATupleHelper<sizeof...(Args), Args...>::push_back(m_values, m_size, values);
203  ++m_size;
204  }
size_t m_size
Definition: SoATuple.h:282
void push_back(element const &values)
Definition: SoATuple.h:198
size_t size() const
Definition: SoATuple.h:149
size_t capacity() const
Definition: SoATuple.h:150
void reserve(unsigned int iToSize)
Definition: SoATuple.h:184
void * m_values[sizeof...(Args)]
Definition: SoATuple.h:281
template<typename... Args>
void edm::SoATuple< Args >::reserve ( unsigned int  iToSize)
inline
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 191 of file SoATuple.h.

191  {
192  if (m_reserved > m_size) {
194  }
195  }
void changeSize(unsigned int iToSize)
Definition: SoATuple.h:254
size_t m_reserved
Definition: SoATuple.h:283
size_t m_size
Definition: SoATuple.h:282
template<typename... Args>
size_t edm::SoATuple< Args >::size ( void  ) const
inline
template<typename... Args>
void edm::SoATuple< Args >::swap ( SoATuple< Args... > &  iOther)
inline

Definition at line 245 of file SoATuple.h.

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().

245  {
246  std::swap(m_size, iOther.m_size);
247  std::swap(m_reserved, iOther.m_reserved);
248  for (unsigned int i = 0; i < sizeof...(Args); ++i) {
249  std::swap(m_values[i], iOther.m_values[i]);
250  }
251  }
size_t m_reserved
Definition: SoATuple.h:283
size_t m_size
Definition: SoATuple.h:282
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
void * m_values[sizeof...(Args)]
Definition: SoATuple.h:281

Member Data Documentation

template<typename... Args>
size_t edm::SoATuple< Args >::m_reserved
private
template<typename... Args>
size_t edm::SoATuple< Args >::m_size
private
template<typename... Args>
void* edm::SoATuple< Args >::m_values[sizeof...(Args)]
private