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

Member Typedef Documentation

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

Definition at line 112 of file SoATuple.h.

Constructor & Destructor Documentation

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

Definition at line 114 of file SoATuple.h.

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

Definition at line 119 of file SoATuple.h.

119  :m_size(0),m_reserved(0) {
120  for(auto& v : m_values) {
121  v = nullptr;
122  }
123  reserve(iOther.m_size);
124  soahelper::SoATupleHelper<sizeof...(Args),Args...>::copyToNew(static_cast<char*>(m_values[0]),iOther.m_size,m_reserved,iOther.m_values,m_values);
125  m_size = iOther.m_size;
126  }
size_t m_reserved
Definition: SoATuple.h:274
size_t m_size
Definition: SoATuple.h:273
void reserve(unsigned int iToSize)
Definition: SoATuple.h:180
void * m_values[sizeof...(Args)]
Definition: SoATuple.h:272
template<typename... Args>
edm::SoATuple< Args >::SoATuple ( SoATuple< Args...> &&  iOther)
inline

Definition at line 128 of file SoATuple.h.

128  :m_size(0),m_reserved(0) {
129  for(auto& v : m_values) {
130  v = nullptr;
131  }
132  this->swap(iOther);
133  }
void swap(SoATuple< Args...> &iOther)
Definition: SoATuple.h:237
size_t m_reserved
Definition: SoATuple.h:274
size_t m_size
Definition: SoATuple.h:273
void * m_values[sizeof...(Args)]
Definition: SoATuple.h:272
template<typename... Args>
edm::SoATuple< Args >::~SoATuple ( )
inline

Definition at line 141 of file SoATuple.h.

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

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

162  {
163  typedef soahelper::AlignmentHelper<typename std::tuple_element<I, std::tuple<Args...>>::type> Helper;
164  typedef typename Helper::Type ReturnType;
165 #if GCC_PREREQUISITE(4,7,0)
166  return static_cast<ReturnType const*>(__builtin_assume_aligned(m_values[I],Helper::kAlignment));
167 #else
168  return static_cast<ReturnType const*>(m_values[I]);
169 #endif
170  }
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:272
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 221 of file SoATuple.h.

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

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

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

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

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

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

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

155  {
156  typedef typename soahelper::AlignmentHelper<typename std::tuple_element<I, std::tuple<Args...>>::type>::Type ReturnType;
157  return *(static_cast<ReturnType const*>(m_values[I])+iIndex);
158  }
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:272
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 214 of file SoATuple.h.

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

214  {
215  typedef typename soahelper::AlignmentHelper<typename std::tuple_element<I, std::tuple<Args...>>::type>::Type ReturnType;
216  return *(static_cast<ReturnType*>(m_values[I])+iIndex);
217  }
type
Definition: HCALResponse.h:21
const std::complex< double > I
Definition: I.h:8
void * m_values[sizeof...(Args)]
Definition: SoATuple.h:272
template<typename... Args>
const SoATuple<Args...>& edm::SoATuple< Args >::operator= ( const SoATuple< Args...> &  iRHS)
inline

Definition at line 135 of file SoATuple.h.

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

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

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

187  {
188  if(m_reserved > m_size) {
190  }
191  }
void changeSize(unsigned int iToSize)
Definition: SoATuple.h:246
size_t m_reserved
Definition: SoATuple.h:274
size_t m_size
Definition: SoATuple.h:273
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 237 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().

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

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