CMS 3D CMS Logo

Public Types | Public Member Functions | Private Member Functions | Private Attributes

edm::SoATuple< Args > Class Template Reference

#include <SoATuple.h>

List of all members.

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
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 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 (const SoATuple< Args...> &iOther)
 SoATuple ()
 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.

              : m_size(0),m_reserved(0){
      for(auto& v : m_values) {
        v = nullptr;
      }
    }
template<typename... Args>
edm::SoATuple< Args >::SoATuple ( const SoATuple< Args...> &  iOther) [inline]

Definition at line 119 of file SoATuple.h.

                                             :m_size(0),m_reserved(0) {
      for(auto& v : m_values) {
        v = nullptr;
      }
      reserve(iOther.m_size);
      soahelper::SoATupleHelper<sizeof...(Args),Args...>::copyToNew(static_cast<char*>(m_values[0]),iOther.m_size,m_reserved,iOther.m_values,m_values);
      m_size = iOther.m_size;
    }
template<typename... Args>
edm::SoATuple< Args >::SoATuple ( SoATuple< Args...> &&  iOther) [inline]

Definition at line 128 of file SoATuple.h.

                                        :m_size(0),m_reserved(0) {
      for(auto& v : m_values) {
        v = nullptr;
      }
      this->swap(iOther);
    }
template<typename... Args>
edm::SoATuple< Args >::~SoATuple ( ) [inline]

Definition at line 141 of file SoATuple.h.

                {
      soahelper::SoATupleHelper<sizeof...(Args),Args...>::destroy(m_values,m_size);
      typedef std::aligned_storage<soahelper::SoATupleHelper<sizeof...(Args),Args...>::max_alignment,
      soahelper::SoATupleHelper<sizeof...(Args),Args...>::max_alignment> AlignedType;

      delete [] static_cast<AlignedType*>(m_values[0]);
    }

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.

Referenced by edm::EDConsumerBase::itemsMayGet(), edm::EDConsumerBase::itemsToGet(), and edm::EDConsumerBase::updateLookup().

                                                                                                                    {
      typedef soahelper::AlignmentHelper<typename std::tuple_element<I, std::tuple<Args...>>::type> Helper;
      typedef typename Helper::Type ReturnType;
#if GCC_PREREQUISITE(4,7,0)
      return static_cast<ReturnType const*>(__builtin_assume_aligned(m_values[I],Helper::kAlignment));
#else
      return static_cast<ReturnType const*>(m_values[I]);
#endif
    }
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.

                                                                                                        {
      typedef soahelper::AlignmentHelper<typename std::tuple_element<I, std::tuple<Args...>>::type> Helper;
      typedef typename Helper::Type ReturnType;
#if GCC_PREREQUISITE(4,7,0)
      return static_cast<ReturnType*>(__builtin_assume_aligned(m_values[I],Helper::kAlignment));
#else
      return static_cast<ReturnType*>(m_values[I]);
#endif
    }
template<typename... Args>
size_t edm::SoATuple< Args >::capacity ( ) const [inline]
template<typename... Args>
void edm::SoATuple< Args >::changeSize ( unsigned int  iToSize) [inline, private]

Definition at line 246 of file SoATuple.h.

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

                                          {
      assert(m_size<=iToSize);
      const size_t memoryNeededInBytes = soahelper::SoATupleHelper<sizeof...(Args),Args...>::spaceNeededFor(iToSize);
      //align memory of the array to be on the strictest alignment boundary for any type in the Tuple
      // This is done by creating an array of a type that has that same alignment restriction and minimum size.
      // This has the draw back of possibly padding the array by one extra element if the memoryNeededInBytes is not
      // a strict multiple of max_alignment.
      // NOTE: using new char[...] would likely cause more padding based on C++11 5.3.4 paragraph 10 where it
      // says the alignment will be for the strictest requirement for an object whose size < size of array. So
      // if the array were for 64 bytes and the strictest requirement of any object was 8 bytes then the entire
      // char array would be aligned on an 8 byte boundary. However, if the SoATuple<char,char> only 1 byte alignment
      // is needed. The following algorithm would require only 1 byte alignment
      const std::size_t max_alignment = soahelper::SoATupleHelper<sizeof...(Args),Args...>::max_alignment;
      typedef std::aligned_storage<soahelper::SoATupleHelper<sizeof...(Args),Args...>::max_alignment,
                                   soahelper::SoATupleHelper<sizeof...(Args),Args...>::max_alignment> AlignedType;
      //If needed, pad the number of items by 1
      const size_t itemsNeeded = (memoryNeededInBytes+max_alignment-1)/sizeof(AlignedType);
      char * newMemory = static_cast<char*>(static_cast<void*>(new AlignedType[itemsNeeded]));
      void * oldMemory =m_values[0];
      soahelper::SoATupleHelper<sizeof...(Args),Args...>::moveToNew(newMemory,m_size, iToSize, m_values);
      m_reserved = iToSize;
      delete [] static_cast<AlignedType*>(oldMemory);
    }
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< TokenLookupInfo, bool, LabelPlacement, edm::KindOfType >::emplace_back(), edm::EDConsumerBase::recordConsumes(), and edm::EDConsumerBase::updateLookup().

                                         {
      if(size()+1>capacity()) {
        reserve(size()*2+1);
      }
      soahelper::SoATupleHelper<sizeof...(Args),Args...>::emplace_back(m_values,m_size,std::forward<FArgs>(values)...);
      ++m_size;
    }
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.

                                                                                                      {
      typedef typename soahelper::AlignmentHelper<typename std::tuple_element<I, std::tuple<Args...>>::type>::Type ReturnType;
      return static_cast<ReturnType*>(m_values[I])+m_size;
    }
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.

Referenced by edm::EDConsumerBase::itemsMayGet(), edm::EDConsumerBase::itemsToGet(), and edm::EDConsumerBase::updateLookup().

                                                                                                                  {
      typedef typename soahelper::AlignmentHelper<typename std::tuple_element<I, std::tuple<Args...>>::type>::Type ReturnType;
      return static_cast<ReturnType const*>(m_values[I])+m_size;
    }
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 edm::EDConsumerBase::indexFrom(), edm::EDConsumerBase::labelsForToken(), edm::EDConsumerBase::throwBranchMismatch(), edm::EDConsumerBase::throwTypeMismatch(), and edm::EDConsumerBase::updateLookup().

                                                                                                                                     {
      typedef typename soahelper::AlignmentHelper<typename std::tuple_element<I, std::tuple<Args...>>::type>::Type ReturnType;
      return *(static_cast<ReturnType const*>(m_values[I])+iIndex);
    }
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.

                                                                                                                         {
      typedef typename soahelper::AlignmentHelper<typename std::tuple_element<I, std::tuple<Args...>>::type>::Type ReturnType;
      return *(static_cast<ReturnType*>(m_values[I])+iIndex);
    }
template<typename... Args>
const SoATuple<Args...>& edm::SoATuple< Args >::operator= ( const SoATuple< Args...> &  iRHS) [inline]

Definition at line 135 of file SoATuple.h.

                                                                      {
      SoATuple<Args...> temp(iRHS);
      this->swap(temp);
      return *this;
    }
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< TokenLookupInfo, bool, LabelPlacement, edm::KindOfType >::push_back().

                                          {
      if(size()+1>capacity()) {
        reserve(size()*2+1);
      }
      soahelper::SoATupleHelper<sizeof...(Args),Args...>::push_back(m_values,m_size,values);
      ++m_size;
    }
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.

Referenced by edm::EDConsumerBase::updateLookup().

template<typename... Args>
size_t edm::SoATuple< Args >::size ( void  ) const [inline]
template<typename... Args>
void edm::SoATuple< Args >::swap ( SoATuple< Args...> &  iOther) [inline]

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]