|
ATLAS Offline Software
|
Go to the documentation of this file.
520 #ifndef ATHCONTAINERS_DATAVECTOR_H
521 #define ATHCONTAINERS_DATAVECTOR_H
525 #define HAVE_CONSTDATAVECTOR
541 #include "AthLinks/tools/selection_ns.h"
542 #include <boost/iterator/iterator_adaptor.hpp>
543 #include <type_traits>
546 #include <functional>
551 #include <initializer_list>
555 #ifdef XAOD_STANDALONE
557 # define SG_BASE(A, B) class ATHCONTAINERS_DUMMY
558 # endif // not SG_BASE
560 # define SG_BASES1(A, B) class ATHCONTAINERS_DUMMY
561 # endif // not SG_BASES1
563 # define SG_BASES2(A, B, C) class ATHCONTAINERS_DUMMY
564 # endif // not SG_BASES2
566 # define SG_BASES3(A, B, C, D) class ATHCONTAINERS_DUMMY
567 # endif // not SG_BASES3
569 # define SG_BASES4(A, B, C, D, E) class ATHCONTAINERS_DUMMY
570 # endif // not SG_BASES4
572 # define SG_VIRTUAL(X) X
573 # endif // not SG_VIRTUAL
611 template <
class ITERATOR,
class T>
613 std::enable_if_t<std::is_convertible_v<typename std::iterator_traits<ITERATOR>::value_type,
T*>,
bool>;
615 template <
class ITERATOR,
class T>
617 std::enable_if_t<std::is_convertible_v<typename std::iterator_traits<ITERATOR>::value_type, std::unique_ptr<T> >,
bool>;
648 #define DATAVECTOR_BASE(T, BASE) \
649 DATAVECTOR_BASE_FWD(T, BASE); \
650 template struct DataVector_detail::DVLEltBaseInit<T>
657 #define DATAVECTOR_BASE_FWD(T, BASE) \
658 template <> struct DataVectorBase<T> \
659 { typedef DataVector<BASE> Base; }; \
660 SG_BASE(DataVector<T>, DataVector<BASE>)
672 #define DATAVECTOR_VIRTBASES1(T, B1) \
673 DATAVECTOR_VIRTBASES1_FWD(T, B1); \
674 template struct DataVector_detail::DVLEltBaseInit<T>
682 #define DATAVECTOR_VIRTBASES1_FWD(T, B1) \
683 template <> struct DataVectorBase<T> \
684 { typedef DataVector_detail::VirtBases<B1> Base; }; \
685 SG_BASES1(DataVector<T>, SG_VIRTUAL(DataVector<B1>))
698 #define DATAVECTOR_VIRTBASES2(T, B1, B2) \
699 DATAVECTOR_VIRTBASES2_FWD(T, B1, B2); \
700 template struct DataVector_detail::DVLEltBaseInit<T>
707 #define DATAVECTOR_VIRTBASES2_FWD(T, B1, B2) \
708 template <> struct DataVectorBase<T> \
709 { typedef DataVector_detail::VirtBases<B1, B2> Base; }; \
710 SG_BASES2(DataVector<T>, SG_VIRTUAL(DataVector<B1>), \
711 SG_VIRTUAL(DataVector<B2>))
723 #define DATAVECTOR_VIRTBASES3(T, B1, B2, B3) \
724 DATAVECTOR_VIRTBASES3_FWD(T, B1, B2, B3); \
725 template struct DataVector_detail::DVLEltBaseInit<T>
732 #define DATAVECTOR_VIRTBASES3_FWD(T, B1, B2, B3) \
733 template <> struct DataVectorBase<T> \
734 { typedef DataVector_detail::VirtBases<B1, B2, B3> Base; }; \
735 SG_BASES3(DataVector<T>, SG_VIRTUAL(DataVector<B1>), \
736 SG_VIRTUAL(DataVector<B2>), \
737 SG_VIRTUAL(DataVector<B3>))
749 #define DATAVECTOR_VIRTBASES4(T, B1, B2, B3, B4) \
750 DATAVECTOR_VIRTBASES4_FWD(T, B1, B2, B3, B4); \
751 template struct DataVector_detail::DVLEltBaseInit<T>
758 #define DATAVECTOR_VIRTBASES4_FWD(T, B1, B2, B3, B4) \
759 template <> struct DataVectorBase<T> \
760 { typedef DataVector_detail::VirtBases<B1, B2, B3, B4> Base; }; \
761 SG_BASES4(DataVector<T>, SG_VIRTUAL(DataVector<B1>), \
762 SG_VIRTUAL(DataVector<B2>), \
763 SG_VIRTUAL(DataVector<B3>), \
764 SG_VIRTUAL(DataVector<B4>))
773 #define DATAVECTOR_BASE_FIN(T, B) \
774 template struct DataVector_detail::DVLEltBaseInit<T>
792 template <class T, class BASE = typename DataVectorBase<T>::Base>
845 typedef typename std::reverse_iterator<const_iterator>
850 typedef typename std::reverse_iterator<iterator>
937 template <
class InputIterator>
1007 template <
class InputIterator>
1839 #endif // not __cplusplus
1858 const std::type_info& ti);
1904 template <
class DV,
class ALLOC>
1906 friend void test2_assignelement1a<DataVector>();
1907 friend void test2_assignelement1<DataVector>();
1908 friend void test2_assignelement2<DataVector>();
1931 std::unique_ptr<base_value_type> newElem);
1943 typename BaseContainer::value_type newElem);
2042 ROOT_SELECTION_NS::DataVector<T, DataVector_BASE>::self
self;
2046 template <
class T,
class BASE>
2117 typedef typename std::reverse_iterator<const_iterator>
2122 typedef typename std::reverse_iterator<iterator>
2213 template <
class InputIterator>
2282 template <
class InputIterator>
3117 const std::type_info& ti);
3423 class
DataVector : KeepFirstTemplateArguments< 1 >, SelectNoInstance
3429 #ifndef XAOD_STANDALONE
3436 ROOT_SELECTION_NS::MemberAttributes< kTransient >
m_deleter;
3464 #ifndef XAOD_STANDALONE
3481 template <
class T,
class U>
3521 #include "boost/mpl/if.hpp"
3522 #include "boost/mpl/and.hpp"
3523 #include "boost/mpl/equal_to.hpp"
3524 #define if_ boost::mpl::if_
3525 #define and_ boost::mpl::and_
3526 #define equal_to boost::mpl::equal_to
3527 #define true_ boost::mpl::true_
3528 #define false_ boost::mpl::false_
3529 template <
class U>
struct not_virtual {
typedef true_
type; };
3530 template <
class U>
struct not_virtual<
SG::Virtual<U> > {
typedef false_
type; };
3531 template <
class U>
struct clean_type {
typedef U
type; };
3532 template <>
struct clean_type<
SG::NoBase>
3534 template <
class U>
struct clean_type<
SG::Virtual<U> >
3537 struct bases_from_sg
3540 if_<equal_to<typename SG::Bases<T>::Base1,
SG::NoBase>,
3542 if_<and_<equal_to<typename SG::Bases<T>::Base1,
SG::NoBase>,
3543 not_virtual<typename SG::Bases<T>::Base2> >,
3546 <clean_type<typename SG::Bases<T>::Base1>,
3547 clean_type<typename SG::Bases<T>::Base2>,
3548 clean_type<typename SG::Bases<T>::Base3>,
3549 clean_type<typename SG::Bases<T>::Base4> >
3558 #define DATAVECTOR_BASES_FROM_SG(T) \
3559 template <> struct DataVectorBase<T> \
3560 { typedef bases_from_sg<T>::type Base; };
3565 #endif // not ATHCONTAINERS_DATAVECTOR_H
void reserve(size_type n)
Attempt to preallocate enough memory for a specified number of elements.
virtual const std::type_info & dv_typeid() const
Find the most-derived DataVector class in the hierarchy.
JetConstituentVector::iterator iterator
std::reverse_iterator< iterator > reverse_iterator
Standard reverse_iterator.
DataVector(const DataVector &)=default
Copy constructor.
T *const & const_reference
SG::DVLDataBucket< U > type
DataModel_detail::iterator< DataVector > iterator
Standard iterator.
Const iterator class for DataVector/DataList.
ROOT_SELECTION_NS::MemberAttributes< kTransient > m_ownPolicy
We do not want to save this.
Holder for the is-most-derived flag.
value_type emplace_back(value_type pElem)
Add an element to the end of the collection.
ROOT_SELECTION_NS::DataVector< T, DataVector_BASE >::self self
DataModel_detail::iterator< DataVector > iterator
Standard iterator.
DataVector(DataVector &&rhs) noexcept
Move constructor.
std::reverse_iterator< const_iterator > const_reverse_iterator
Standard const_reverse_iterator.
DataModel_detail::const_iterator< DataVector > const_iterator
Standard const_iterator.
DataVector::PtrVector PtrVector
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
void test2_assignelement2()
const_reverse_iterator rend() const noexcept
Return a const_reverse_iterator pointing at the beginning of the collection.
Derivation information for DataVector.
ROOT_SELECTION_NS::MemberAttributes< kTransient > m_deleter
static T * do_cast_nc(typename PtrVector::value_type p)
Helper to shorten calls to DataModel_detail::DVLCast.
DataVector using a custom allocator for the elements.
Exceptions that can be thrown from AthContainers.
size_type size() const noexcept
Returns the number of elements in the collection.
const T * get(size_type n) const
Access an element, as an rvalue.
void shift(size_t pos, ptrdiff_t offs)
Shift the auxiliary elements of the container.
Holder to implement conversion copies for DataVector/DataList.
@ DEFAULT_TRACK_INDICES
Default value.
const_iterator cend() const noexcept
Return a const_iterator pointing past the end of the collection.
void testInsert(const char *op)
Test if we can insert; raise an exception if not.
void assignBaseElement(typename BaseContainer::iterator pos, typename BaseContainer::value_type newElem)
Handle element assignment from a base pointer.
bool const RAWDATA *ch2 const
std::unique_ptr< base_value_type > unique_type
Type of a unique_ptr that can be used to insert elements into this container.
DataVector & operator=(const DataVector &rhs)
Assignment operator.
void swapElement(size_type index, value_type newElem, reference oldElem)
Swap one element out of the container.
void test2_assignelement1a()
Manage index tracking and synchronization of auxiliary data.
Manage index tracking and synchronization of auxiliary data.
DataVector(SG::OwnershipPolicy ownPolicy=SG::OWN_ELEMENTS, SG::IndexTrackingPolicy trackIndices=SG::DEFAULT_TRACK_INDICES)
Default constructor.
A DataBucket specialized for DataVector/DataList.
BASE::PtrVector PtrVector
This is the type of the underlying std::vector (what stdcont returns).
virtual void setMostDerived()
Set m_isMostDerived for this instance and clear it for all bases.
const SG::AuxVectorBase & auxbase() const
Convert to AuxVectorBase.
virtual void doDelete(value_type p)=0
DataVector(size_type n, SG::OwnershipPolicy ownPolicy=SG::OWN_ELEMENTS, SG::IndexTrackingPolicy trackIndices=SG::DEFAULT_TRACK_INDICES)
Sized constructor.
OwnershipPolicy
describes the possible element ownership policies (see e.g. DataVector)
Specializations of iter_swap for DataVector/DataList.
const T * const_value_type
void assign(InputIterator first, InputIterator last)
Assign from iterators.
static const bool has_virtual
This is true for any DataVector class if we need to use virtual derivation to get to the base DataVec...
std::reverse_iterator< iterator > reverse_iterator
Standard reverse_iterator.
void test2_assignelement1()
T base_value_type
The T value used as the template parameter.
DataVector(SG::OwnershipPolicy ownPolicy=SG::OWN_ELEMENTS, SG::IndexTrackingPolicy trackIndices=SG::DEFAULT_TRACK_INDICES)
Default constructor.
static int baseOffset(const std::type_info &ti)
Return the offset of a base DataVector class.
Calculate topmost base accessible via SG_BASES.
friend void test2_assignelement1()
DataVector base_data_vector
DataVector::value_type value_type
DataVector(InputIterator first, InputIterator last, SG::OwnershipPolicy ownPolicy=SG::VIEW_ELEMENTS, SG::IndexTrackingPolicy trackIndices=SG::DEFAULT_TRACK_INDICES, SG::IAuxStore *store=0)
Constructor from iterators.
Marker for the base of the inheritance hierarchy.
static std::string name()
DataVector< T, DataModel_detail::NoBase > type
std::enable_if_t< std::is_convertible_v< typename std::iterator_traits< ITERATOR >::value_type, T * >, bool > enable_if_ptr_itr
Helpers for enabling the correct overloads for insert() methods taking a range, allowing us to handle...
(Non-const) Iterator class for DataVector/DataList.
@ OWN_ELEMENTS
this data object owns its elements
Provide an interface for finding inheritance information at run time.
Calculate topmost accessible base accessible via SG_BASES.
An interface for getting the name of a class as a string.
DataModel_detail::NoBase DVL_BASE
Base specialization for DataVector<T>.
Traits class to hold derivation information.
Marker for the base of the inheritance hierarchy.
const T * front() const
Access the first element in the collection as an rvalue.
Marker to indicate a nonexistent base class.
void swap(DataVector &rhs)
Swap this collection with another.
virtual void doDelete(typename PtrVector::iterator first, typename PtrVector::iterator last)=0
void assign(std::initializer_list< value_type > l)
iterator insert(iterator position, value_type pElem)
Add a new element to the collection.
SG::IsMostDerivedFlag m_isMostDerived
This flag is true if this DV instance is the most-derived one.
BASE::allocator_type allocator_type
void assignElement(typename BaseContainer::iterator pos, std::unique_ptr< base_value_type > newElem)
Handle element assignment.
DataVector(size_type n, SG::OwnershipPolicy ownPolicy=SG::OWN_ELEMENTS, SG::IndexTrackingPolicy trackIndices=SG::DEFAULT_TRACK_INDICES)
Sized constructor.
const_reverse_iterator crend() const noexcept
Return a const_reverse_iterator pointing at the beginning of the collection.
PtrVector::difference_type difference_type
T *const & const_reference
const T * back() const
Access the last element in the collection as an rvalue.
DataModel_detail::const_iterator< DataVector > const_iterator
Standard const_iterator.
const_reverse_iterator rbegin() const noexcept
Return a const_reverse_iterator pointing past the end of the collection.
void insertMove(iterator position, DataVector &other)
Insert the contents of another DataVector, with auxiliary data copied via move semantics.
void clear()
Erase all the elements in the collection.
DataVector(DataVector &&rhs) noexcept
Move constructor.
size_type capacity() const noexcept
Returns the total number of elements that the collection can hold before needing to allocate more mem...
DataVector(const DataVector &rhs)
Copy constructor.
std::unique_ptr< base_value_type > unique_type
Type of a unique_ptr that can be used to insert elements into this container.
void testInsertOol(const char *op)
Test if we can insert; raise an exception if not.
DataVector base_data_vector
void resize(size_type sz)
Resizes the collection to the specified number of elements.
std::reverse_iterator< const_iterator > const_reverse_iterator
Standard const_reverse_iterator.
BASE::PtrVector BaseContainer
value_type push_back(value_type pElem)
Add an element to the end of the collection.
static const T * do_cast(const typename PtrVector::value_type p)
Helper to shorten calls to DataModel_detail::DVLCast.
DataVector(std::initializer_list< value_type > l, SG::OwnershipPolicy ownPolicy=SG::VIEW_ELEMENTS, SG::IndexTrackingPolicy trackIndices=SG::DEFAULT_TRACK_INDICES, SG::IAuxStore *store=0)
Constructor from iterators.
std::vector< T * > BaseContainer
DataVector(InputIterator first, InputIterator last, SG::OwnershipPolicy ownPolicy=SG::VIEW_ELEMENTS, SG::IndexTrackingPolicy trackIndices=SG::DEFAULT_TRACK_INDICES, SG::IAuxStore *store=0)
Constructor from iterators.
PtrVector::size_type size_type
DataModel_detail::ElementProxy< DataVector > ElementProxy
This type is used to proxy lvalue accesses to DataVector elements, in order to handle ownership.
void assign(InputIterator first, InputIterator last)
Assign from iterators.
Interface for non-const operations on an auxiliary store.
std::vector< T * > PtrVector
This is the type of the underlying std::vector (what stdcont returns).
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const PtrVector & stdcont() const
Return the underlying std::vector of the container.
void sort()
Sort the container.
std::enable_if_t< std::is_convertible_v< typename std::iterator_traits< ITERATOR >::value_type, std::unique_ptr< T > >, bool > enable_if_up_itr
A DataBucket specialized for DataVector/DataList.
void assign(std::initializer_list< value_type > l)
Assign from an initializer list.
void clearMostDerived()
Clear m_isMostDerived for this instance and for all bases.
PtrVector::allocator_type allocator_type
DataVector adapter that acts like it holds const pointers.
T base_value_type
The T value used as the template parameter.
void pop_back()
Remove the last element from the collection.
static const DataModel_detail::DVLInfoBase & dvlinfo()
Return the DV/DL info struct for this class.
virtual ~Deleter()=default
typename BASE::Deleter Deleter
DataModel_detail::ElementProxy< DataVector > ElementProxy
This type is used to proxy lvalue accesses to DataVector elements, in order to handle ownership.
static constexpr bool must_own
If true, then this type must own its contents.
Specializations of STL algorithms to work with DataVector/List.
SG::OwnershipPolicy ownPolicy() const
Return the ownership policy setting for this container.
void resortAux(iterator beg, iterator end)
Reset indices / reorder aux data after elements have been permuted.
virtual ~DataVector()
Destructor.
const_iterator cbegin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
BASE::difference_type difference_type
DataVector(std::initializer_list< value_type > l, SG::OwnershipPolicy ownPolicy=SG::VIEW_ELEMENTS, SG::IndexTrackingPolicy trackIndices=SG::DEFAULT_TRACK_INDICES, SG::IAuxStore *store=0)
Constructor from an initializer list.
iterator emplace(iterator position, value_type pElem)
Add a new element to the collection.
static int baseOffset1(const char *p, const DataVector &dv, const std::type_info &ti)
Helper for baseOffset.
static void iter_swap(iterator a, iterator b)
Swap the referents of two DataVector iterators.
const T * at(size_type n) const
Access an element, as an rvalue.
friend void test2_assignelement2()
Proxy for lvalue access to DataVector/DataList elements.
size_type max_size() const noexcept
Returns the size() of the largest possible collection.
BASE::size_type size_type
iterator erase(iterator position)
Remove element at a given position.
DataModel_detail::NoBase DataVector_BASE
Metafunction to find the proper DataBucket class for T.
Holder for the is-most-derived flag.
size_type size() const noexcept
Returns the number of elements in the collection.
std::true_type isSequence
Mark as a sequence, for DataLink / ElementLink.
bool empty() const noexcept
Returns true if the collection is empty.
casting operations for DataVector/DataList.
friend void test2_assignelement1a()
const T * const_value_type
DataModel_detail::NoBase Base
void assignElement(typename BaseContainer::iterator pos, value_type newElem)
Handle element assignment.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
Proxy for lvalue access to DataVector/DataList elements.
const_reverse_iterator crbegin() const noexcept
Return a const_reverse_iterator pointing past the end of the collection.
virtual const DataModel_detail::DVLInfoBase & dvlinfo_v() const
Return the DV/DL info struct for this class.
Represent a list of base classes.