CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 111 of file SoATuple.h.

Constructor & Destructor Documentation

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

Definition at line 113 of file SoATuple.h.

113  : m_size(0),m_reserved(0){
114  for(auto& v : m_values) {
115  v = nullptr;
116  }
117  }
size_t m_reserved
Definition: SoATuple.h:273
size_t m_size
Definition: SoATuple.h:272
void * m_values[sizeof...(Args)]
Definition: SoATuple.h:271
template<typename... Args>
edm::SoATuple< Args >::SoATuple ( const SoATuple< Args...> &  iOther)
inline

Definition at line 118 of file SoATuple.h.

118  :m_size(0),m_reserved(0) {
119  for(auto& v : m_values) {
120  v = nullptr;
121  }
122  reserve(iOther.m_size);
123  soahelper::SoATupleHelper<sizeof...(Args),Args...>::copyToNew(static_cast<char*>(m_values[0]),iOther.m_size,m_reserved,iOther.m_values,m_values);
124  m_size = iOther.m_size;
125  }
size_t m_reserved
Definition: SoATuple.h:273
size_t m_size
Definition: SoATuple.h:272
void reserve(unsigned int iToSize)
Definition: SoATuple.h:179
void * m_values[sizeof...(Args)]
Definition: SoATuple.h:271
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  }
void swap(SoATuple< Args...> &iOther)
Definition: SoATuple.h:236
size_t m_reserved
Definition: SoATuple.h:273
size_t m_size
Definition: SoATuple.h:272
void * m_values[sizeof...(Args)]
Definition: SoATuple.h:271
template<typename... Args>
edm::SoATuple< Args >::~SoATuple ( )
inline

Definition at line 140 of file SoATuple.h.

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

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

161  {
162  typedef soahelper::AlignmentHelper<typename std::tuple_element<I, std::tuple<Args...>>::type> Helper;
163  typedef typename Helper::Type ReturnType;
164 #if GCC_PREREQUISITE(4,7,0)
165  return static_cast<ReturnType const*>(__builtin_assume_aligned(m_values[I],Helper::kAlignment));
166 #else
167  return static_cast<ReturnType const*>(m_values[I]);
168 #endif
169  }
type
Definition: HCALResponse.h:21
const std::complex< double > I
Definition: I.h:8
string const
Definition: compareJSON.py:14
void * m_values[sizeof...(Args)]
Definition: SoATuple.h:271
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 220 of file SoATuple.h.

220  {
221  typedef soahelper::AlignmentHelper<typename std::tuple_element<I, std::tuple<Args...>>::type> Helper;
222  typedef typename Helper::Type ReturnType;
223 #if GCC_PREREQUISITE(4,7,0)
224  return static_cast<ReturnType*>(__builtin_assume_aligned(m_values[I],Helper::kAlignment));
225 #else
226  return static_cast<ReturnType*>(m_values[I]);
227 #endif
228  }
type
Definition: HCALResponse.h:21
const std::complex< double > I
Definition: I.h:8
void * m_values[sizeof...(Args)]
Definition: SoATuple.h:271
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 245 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().

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

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

203  {
204  if(size()+1>capacity()) {
205  reserve(size()*2+1);
206  }
207  soahelper::SoATupleHelper<sizeof...(Args),Args...>::emplace_back(m_values,m_size,std::forward<FArgs>(values)...);
208  ++m_size;
209  }
size_t m_size
Definition: SoATuple.h:272
void emplace_back(FArgs &&...values)
Definition: SoATuple.h:203
size_t size() const
Definition: SoATuple.h:149
size_t capacity() const
Definition: SoATuple.h:150
void reserve(unsigned int iToSize)
Definition: SoATuple.h:179
void * m_values[sizeof...(Args)]
Definition: SoATuple.h:271
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 172 of file SoATuple.h.

172  {
173  typedef typename soahelper::AlignmentHelper<typename std::tuple_element<I, std::tuple<Args...>>::type>::Type ReturnType;
174  return static_cast<ReturnType const*>(m_values[I])+m_size;
175  }
type
Definition: HCALResponse.h:21
size_t m_size
Definition: SoATuple.h:272
const std::complex< double > I
Definition: I.h:8
string const
Definition: compareJSON.py:14
void * m_values[sizeof...(Args)]
Definition: SoATuple.h:271
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 231 of file SoATuple.h.

231  {
232  typedef typename soahelper::AlignmentHelper<typename std::tuple_element<I, std::tuple<Args...>>::type>::Type ReturnType;
233  return static_cast<ReturnType*>(m_values[I])+m_size;
234  }
type
Definition: HCALResponse.h:21
size_t m_size
Definition: SoATuple.h:272
const std::complex< double > I
Definition: I.h:8
void * m_values[sizeof...(Args)]
Definition: SoATuple.h:271
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(), betterConfigParser.BetterConfigParser::getCompares(), betterConfigParser.BetterConfigParser::getGeneral(), and betterConfigParser.BetterConfigParser::getResultingSection().

154  {
155  typedef typename soahelper::AlignmentHelper<typename std::tuple_element<I, std::tuple<Args...>>::type>::Type ReturnType;
156  return *(static_cast<ReturnType const*>(m_values[I])+iIndex);
157  }
type
Definition: HCALResponse.h:21
const std::complex< double > I
Definition: I.h:8
string const
Definition: compareJSON.py:14
void * m_values[sizeof...(Args)]
Definition: SoATuple.h:271
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 213 of file SoATuple.h.

Referenced by Options.Options::__getitem__(), betterConfigParser.BetterConfigParser::__updateDict(), betterConfigParser.BetterConfigParser::getCompares(), betterConfigParser.BetterConfigParser::getGeneral(), and betterConfigParser.BetterConfigParser::getResultingSection().

213  {
214  typedef typename soahelper::AlignmentHelper<typename std::tuple_element<I, std::tuple<Args...>>::type>::Type ReturnType;
215  return *(static_cast<ReturnType*>(m_values[I])+iIndex);
216  }
type
Definition: HCALResponse.h:21
const std::complex< double > I
Definition: I.h:8
void * m_values[sizeof...(Args)]
Definition: SoATuple.h:271
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  }
void swap(SoATuple< Args...> &iOther)
Definition: SoATuple.h:236
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 193 of file SoATuple.h.

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

193  {
194  if(size()+1>capacity()) {
195  reserve(size()*2+1);
196  }
197  soahelper::SoATupleHelper<sizeof...(Args),Args...>::push_back(m_values,m_size,values);
198  ++m_size;
199  }
size_t m_size
Definition: SoATuple.h:272
void push_back(element const &values)
Definition: SoATuple.h:193
size_t size() const
Definition: SoATuple.h:149
size_t capacity() const
Definition: SoATuple.h:150
void reserve(unsigned int iToSize)
Definition: SoATuple.h:179
void * m_values[sizeof...(Args)]
Definition: SoATuple.h:271
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 186 of file SoATuple.h.

186  {
187  if(m_reserved > m_size) {
189  }
190  }
void changeSize(unsigned int iToSize)
Definition: SoATuple.h:245
size_t m_reserved
Definition: SoATuple.h:273
size_t m_size
Definition: SoATuple.h:272
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 236 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().

236  {
237  std::swap(m_size,iOther.m_size);
238  std::swap(m_reserved,iOther.m_reserved);
239  for(unsigned int i=0; i<sizeof...(Args);++i) {
240  std::swap(m_values[i],iOther.m_values[i]);
241  }
242  }
int i
Definition: DBlmapReader.cc:9
size_t m_reserved
Definition: SoATuple.h:273
size_t m_size
Definition: SoATuple.h:272
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
void * m_values[sizeof...(Args)]
Definition: SoATuple.h:271

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