520#ifndef ATHCONTAINERS_DATAVECTOR_H
521#define ATHCONTAINERS_DATAVECTOR_H
525#define HAVE_CONSTDATAVECTOR
542#include <boost/iterator/iterator_adaptor.hpp>
543#include <type_traits>
551#include <initializer_list>
552#include <RootMetaSelection.h>
556#ifdef XAOD_STANDALONE
558# define SG_BASE(A, B) class ATHCONTAINERS_DUMMY
561# define SG_BASES1(A, B) class ATHCONTAINERS_DUMMY
564# define SG_BASES2(A, B, C) class ATHCONTAINERS_DUMMY
567# define SG_BASES3(A, B, C, D) class ATHCONTAINERS_DUMMY
570# define SG_BASES4(A, B, C, D, E) class ATHCONTAINERS_DUMMY
573# define SG_VIRTUAL(X) X
581namespace ROOT {
namespace Meta {
namespace Selection {
582 template <
class T,
class BASE>
class DataVector;
612template <
class ITERATOR,
class T>
614 std::enable_if_t<std::is_convertible_v<typename std::iterator_traits<ITERATOR>::value_type, T*>,
bool>;
616template <
class ITERATOR,
class T>
618 std::enable_if_t<std::is_convertible_v<typename std::iterator_traits<ITERATOR>::value_type, std::unique_ptr<T> >,
bool>;
649#define DATAVECTOR_BASE(T, BASE) \
650DATAVECTOR_BASE_FWD(T, BASE); \
651template struct DataVector_detail::DVLEltBaseInit<T>
658#define DATAVECTOR_BASE_FWD(T, BASE) \
659template <> struct DataVectorBase<T> \
660{ typedef DataVector<BASE> Base; }; \
661SG_BASE(DataVector<T>, DataVector<BASE>)
673#define DATAVECTOR_VIRTBASES1(T, B1) \
674DATAVECTOR_VIRTBASES1_FWD(T, B1); \
675template struct DataVector_detail::DVLEltBaseInit<T>
683#define DATAVECTOR_VIRTBASES1_FWD(T, B1) \
684template <> struct DataVectorBase<T> \
685{ typedef DataVector_detail::VirtBases<B1> Base; }; \
686SG_BASES1(DataVector<T>, SG_VIRTUAL(DataVector<B1>))
699#define DATAVECTOR_VIRTBASES2(T, B1, B2) \
700DATAVECTOR_VIRTBASES2_FWD(T, B1, B2); \
701template struct DataVector_detail::DVLEltBaseInit<T>
708#define DATAVECTOR_VIRTBASES2_FWD(T, B1, B2) \
709template <> struct DataVectorBase<T> \
710{ typedef DataVector_detail::VirtBases<B1, B2> Base; }; \
711SG_BASES2(DataVector<T>, SG_VIRTUAL(DataVector<B1>), \
712 SG_VIRTUAL(DataVector<B2>))
724#define DATAVECTOR_VIRTBASES3(T, B1, B2, B3) \
725DATAVECTOR_VIRTBASES3_FWD(T, B1, B2, B3); \
726template struct DataVector_detail::DVLEltBaseInit<T>
733#define DATAVECTOR_VIRTBASES3_FWD(T, B1, B2, B3) \
734template <> struct DataVectorBase<T> \
735{ typedef DataVector_detail::VirtBases<B1, B2, B3> Base; }; \
736SG_BASES3(DataVector<T>, SG_VIRTUAL(DataVector<B1>), \
737 SG_VIRTUAL(DataVector<B2>), \
738 SG_VIRTUAL(DataVector<B3>))
750#define DATAVECTOR_VIRTBASES4(T, B1, B2, B3, B4) \
751DATAVECTOR_VIRTBASES4_FWD(T, B1, B2, B3, B4); \
752template struct DataVector_detail::DVLEltBaseInit<T>
759#define DATAVECTOR_VIRTBASES4_FWD(T, B1, B2, B3, B4) \
760template <> struct DataVectorBase<T> \
761{ typedef DataVector_detail::VirtBases<B1, B2, B3, B4> Base; }; \
762SG_BASES4(DataVector<T>, SG_VIRTUAL(DataVector<B1>), \
763 SG_VIRTUAL(DataVector<B2>), \
764 SG_VIRTUAL(DataVector<B3>), \
765 SG_VIRTUAL(DataVector<B4>))
774#define DATAVECTOR_BASE_FIN(T, B) \
775template struct DataVector_detail::DVLEltBaseInit<T>
793template <class T, class BASE = typename DataVectorBase<T>::Base>
846 typedef typename std::reverse_iterator<const_iterator>
851 typedef typename std::reverse_iterator<iterator>
938 template <
class InputIterator>
1008 template <
class InputIterator>
1009 void assign(InputIterator first, InputIterator last);
1019 void assign(std::initializer_list<value_type> l);
1475 template <class InputIterator,
1495 template <class InputIterator,
1633 template <class COMPARE>
1776 SG::IndexTrackingPolicy trackIndices);
1859 SG::IndexTrackingPolicy trackIndices =
SG::DEFAULT_TRACK_INDICES);
1879 const std::type_info& ti);
1925 template <
class DV,
class ALLOC>
1952 std::unique_ptr<base_value_type> newElem);
1964 typename BaseContainer::value_type newElem);
1990 void shift (
size_t pos, ptrdiff_t offs);
2004 const T*
do_cast (
const typename PtrVector::value_type p);
2067template <
class T,
class BASE>
2138 typedef typename std::reverse_iterator<const_iterator>
2143 typedef typename std::reverse_iterator<iterator>
2159 virtual void doDelete (
typename PtrVector::iterator first,
2160 typename PtrVector::iterator last) = 0;
2234 template <
class InputIterator>
2303 template <
class InputIterator>
2304 void assign(InputIterator first, InputIterator last);
2315 void assign(std::initializer_list<value_type> l);
2789 template <class InputIterator,
2809 template <class InputIterator,
2946 template <class COMPARE>
3204 template <class DV, class ALLOC>
3269 void shift (
size_t pos, ptrdiff_t offs);
3461namespace
ROOT {
namespace Meta {
namespace Selection {
3463template<
class T,
class BASE >
3464class DataVector : KeepFirstTemplateArguments< 1 >, SelectNoInstance
3470#ifndef XAOD_STANDALONE
3477 ROOT::Meta::Selection::MemberAttributes< kTransient >
m_deleter;
3505#ifndef XAOD_STANDALONE
3522template <
class T,
class U>
Manage index tracking and synchronization of auxiliary data.
Exceptions that can be thrown from AthContainers.
Provide an interface for finding inheritance information at run time.
casting operations for DataVector/DataList.
A DataBucket specialized for DataVector/DataList.
Holder to implement conversion copies for DataVector/DataList.
Marker for the base of the inheritance hierarchy.
Specializations of STL algorithms to work with DataVector/List.
Specializations of iter_swap for DataVector/DataList.
void test2_assignelement1a()
const bool DataVector< T, BASE >::has_virtual
void test2_assignelement1()
void test2_assignelement2()
void swap(DataVector< T > &a, DataVector< T > &b)
See DataVector<T, BASE>::swap().
Proxy for lvalue access to DataVector/DataList elements.
Holder for the is-most-derived flag.
Calculate topmost accessible base accessible via SG_BASES.
static std::string name()
An interface for getting the name of a class as a string.
DataVector adapter that acts like it holds const pointers.
Proxy for lvalue access to DataVector/DataList elements.
Const iterator class for DataVector/DataList.
(Non-const) Iterator class for DataVector/DataList.
Interface to allow customizing how elements are to be deleted.
DataVector::value_type value_type
DataVector::PtrVector PtrVector
virtual void doDelete(value_type p)=0
virtual ~Deleter()=default
virtual void doDelete(typename PtrVector::iterator first, typename PtrVector::iterator last)=0
DataModel_detail::const_iterator< DataVector > const_iterator
Standard const_iterator.
PtrVector m_pCont
This actually holds the elements.
PtrVector::iterator erase_base(typename PtrVector::iterator position)
Helper for erase().
DataModel_detail::iterator< DataVector > iterator
Standard iterator.
PtrVector::size_type size_type
friend void test2_assignelement1a()
Deleter * m_deleter
Interface telling us how to delete objects.
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.
friend void test2_assignelement1()
static T * do_cast_nc(typename PtrVector::value_type p)
Helper to shorten calls to DataModel_detail::DVLCast.
static int baseOffset1(const char *p, const DataVector &dv, const std::type_info &ti)
Helper for baseOffset.
void shrink_to_fit()
Change the vector capacity to match the current size.
static const T * do_cast(const typename PtrVector::value_type p)
Helper to shorten calls to DataModel_detail::DVLCast.
void testInsert(const char *op)
Test if we can insert; raise an exception if not.
static void iter_swap(iterator a, iterator b)
Swap the referents of two DataVector iterators.
const_iterator cend() const noexcept
Return a const_iterator pointing past the end of the collection.
SG::OwnershipPolicy m_ownPolicy
The ownership policy of this container — either SG::OWNS_ELEMENTS or SG::VIEW_ELEMENTS.
void doDelete(value_type p)
Delete an element.
value_type emplace_back(value_type pElem)
Add an element to the end of the collection.
iterator insert(iterator position, value_type pElem)
Add a new element to the collection.
void assign(std::initializer_list< value_type > l)
Assign from an initializer list.
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::allocator_type allocator_type
const T * at(size_type n) const
Access an element, as an rvalue.
void clear()
Erase all the elements in the collection.
std::reverse_iterator< iterator > reverse_iterator
Standard reverse_iterator.
ROOT::Meta::Selection::DataVector< T, DataVector_BASE >::self self
const_reverse_iterator crend() const noexcept
Return a const_reverse_iterator pointing at the beginning of the collection.
static constexpr bool must_own
If true, then this type must own its contents.
const T * get(size_type n) const
Access an element, as an rvalue.
void resize(size_type sz)
Resizes the collection to the specified number of elements.
const PtrVector & stdcont() const
Return the underlying std::vector of the container.
DataVector base_data_vector
size_type size() const noexcept
Returns the number of elements in the collection.
void assignBaseElement(typename BaseContainer::iterator pos, typename BaseContainer::value_type newElem)
Handle element assignment from a base pointer.
DataVector(SG::OwnershipPolicy ownPolicy=SG::OWN_ELEMENTS, SG::IndexTrackingPolicy trackIndices=SG::DEFAULT_TRACK_INDICES)
Default constructor.
void pop_back()
Remove the last element from the collection.
static int baseOffset(const std::type_info &ti)
Return the offset of a base DataVector class.
DataVector(DataVector &&rhs) noexcept
Copy constructor.
friend void test2_assignelement2()
iterator erase(iterator position)
Remove element at a given position.
std::reverse_iterator< const_iterator > const_reverse_iterator
Standard const_reverse_iterator.
void testInsertOol(const char *op)
Test if we can insert; raise an exception if not.
void shift(size_t pos, ptrdiff_t offs)
Shift the auxiliary elements of the container.
const_reverse_iterator crbegin() const noexcept
Return a const_reverse_iterator pointing past the end of the collection.
friend class DataVectorWithAlloc
size_type push_new(size_type n, F alloc)
Create and add a number of new elements to the end of the container.
friend class ConstDataVector
iterator emplace(iterator position, value_type pElem)
Add a new element to the collection.
virtual size_type capacity_v() const override
Returns the total number of elements that the collection can hold before needing to allocate more mem...
void clearMostDerived()
Clear m_isMostDerived for this instance and for all bases.
const T * const_value_type
void insertMove(iterator position, DataVector &other)
Insert the contents of another DataVector, with auxiliary data copied via move semantics.
void assign(InputIterator first, InputIterator last)
Assign from iterators.
const_iterator cbegin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
const_reverse_iterator rbegin() const noexcept
Return a const_reverse_iterator pointing past the end of the collection.
std::vector< T * > PtrVector
This is the type of the underlying std::vector (what stdcont returns).
virtual size_type size_v() const override
Returns the number of elements in the collection.
DataModel_detail::ElementProxy< DataVector > ElementProxy
This type is used to proxy lvalue accesses to DataVector elements, in order to handle ownership.
value_type push_back(value_type pElem)
Add an element to the end of the collection.
size_type max_size() const noexcept
Returns the size() of the largest possible collection.
PtrVector::difference_type difference_type
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...
void sort()
Sort the container.
void resortAux(iterator beg, iterator end)
Reset indices / reorder aux data after elements have been permuted.
virtual const DataModel_detail::DVLInfoBase & dvlinfo_v() const
Return the DV/DL info struct for this class.
virtual ~DataVector()
Destructor.
SG::IsMostDerivedFlag m_isMostDerived
This flag is true if this DV instance is the most-derived one.
virtual void setMostDerived()
Set m_isMostDerived for this instance and clear it for all bases.
void swapElement(size_type index, value_type newElem, reference oldElem)
Swap one element out of the container.
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
DataModel_detail::NoBase DataVector_BASE
SG::OwnershipPolicy ownPolicy() const
Return the ownership policy setting for this container.
const T * front() const
Access the first element in the collection as an rvalue.
std::true_type isSequence
Mark as a sequence, for DataLink / ElementLink.
DataVector(size_type n, SG::OwnershipPolicy ownPolicy=SG::OWN_ELEMENTS, SG::IndexTrackingPolicy trackIndices=SG::DEFAULT_TRACK_INDICES)
Sized constructor.
void swap(DataVector &rhs)
Swap this collection with another.
const_reverse_iterator rend() const noexcept
Return a const_reverse_iterator pointing at the beginning of the collection.
void reserve(size_type n)
Attempt to preallocate enough memory for a specified number of elements.
const SG::AuxVectorBase & auxbase() const
Convert to AuxVectorBase.
T base_value_type
The T value used as the template parameter.
static const DataModel_detail::DVLInfoBase & dvlinfo()
Return the DV/DL info struct for this class.
std::unique_ptr< base_value_type > unique_type
Type of a unique_ptr that can be used to insert elements into this container.
std::vector< T * > BaseContainer
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
void assignElement(typename BaseContainer::iterator pos, value_type newElem)
Handle element assignment.
const T * back() const
Access the last element in the collection as an rvalue.
size_type capacity() const noexcept
Returns the total number of elements that the collection can hold before needing to allocate more mem...
T *const & const_reference
DataModel_detail::NoBase DVL_BASE
bool empty() const noexcept
Returns true if the collection is empty.
virtual const std::type_info & dv_typeid() const
Find the most-derived DataVector class in the hierarchy.
IAthenaPoolTestData *const & const_reference
typename DataVectorBase< IAthenaPoolTestData >::Base::allocator_type allocator_type
friend void test2_assignelement1a()
IAthenaPoolTestData * value_type
DataModel_detail::const_iterator< DataVector > const_iterator
DataVector(size_type n, SG::OwnershipPolicy ownPolicy=SG::OWN_ELEMENTS, SG::IndexTrackingPolicy trackIndices=SG::DEFAULT_TRACK_INDICES)
Sized constructor.
friend void test2_assignelement1()
void resize(size_type sz)
void assign(std::initializer_list< value_type > l)
static const DataModel_detail::DVLInfoBase & dvlinfo()
const IAthenaPoolTestData * get(size_type n) const
const SG::AuxVectorBase & auxbase() const
iterator emplace(iterator position, value_type pElem)
void shift(size_t pos, ptrdiff_t offs)
Shift the auxiliary elements of the container.
const IAthenaPoolTestData * back() const
IAthenaPoolTestData ** pointer
typename DataVectorBase< IAthenaPoolTestData >::Base::size_type size_type
const_reverse_iterator rend() const noexcept
static const bool has_virtual
void reserve(size_type n)
void testInsert(const char *op)
Test if we can insert; raise an exception if not.
value_type emplace_back(value_type pElem)
std::reverse_iterator< iterator > reverse_iterator
const IAthenaPoolTestData * at(size_type n) const
static int baseOffset(const std::type_info &ti)
virtual void setMostDerived() override
Set m_isMostDerived for this instance and clear it for all bases.
DataModel_detail::ElementProxy< DataVector > ElementProxy
void swap(DataVector &rhs)
virtual const std::type_info & dv_typeid() const override
Find the most-derived DataVector class in the hierarchy.
void assignElement(typename BaseContainer::iterator pos, std::unique_ptr< base_value_type > newElem)
Handle element assignment.
friend void test2_assignelement2()
static int baseOffset1(const char *p, const DataVector &dv, const std::type_info &ti)
Helper for baseOffset.
value_type push_back(value_type pElem)
friend class DataVectorWithAlloc
typename DataVectorBase< IAthenaPoolTestData >::Base::PtrVector BaseContainer
const IAthenaPoolTestData * const_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.
friend class ConstDataVector
size_type push_new(size_type n, F alloc)
DataModel_detail::iterator< DataVector > iterator
static const T * do_cast(const typename PtrVector::value_type p)
Helper to shorten calls to DataModel_detail::DVLCast.
iterator insert(iterator position, value_type pElem)
static T * do_cast_nc(typename PtrVector::value_type p)
Helper to shorten calls to DataModel_detail::DVLCast.
DataVector(SG::OwnershipPolicy ownPolicy=SG::OWN_ELEMENTS, SG::IndexTrackingPolicy trackIndices=SG::DEFAULT_TRACK_INDICES)
Default constructor.
ROOT::Meta::Selection::DataVector< IAthenaPoolTestData, DataVector_BASE >::self self
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.
DataVector base_data_vector
const PtrVector & stdcont() const
const_iterator end() const noexcept
const_reverse_iterator rbegin() const noexcept
iterator erase(iterator position)
IAthenaPoolTestData *& reference
void clearMostDerived()
Clear m_isMostDerived for this instance and for all bases.
void swapElement(size_type index, value_type newElem, reference oldElem)
const_iterator cbegin() const noexcept
const_reverse_iterator crend() const noexcept
typename DataVectorBase< IAthenaPoolTestData >::Base::difference_type difference_type
DataVector & operator=(DataVector &&rhs)
Assignment operator.
const_iterator begin() const noexcept
std::reverse_iterator< const_iterator > const_reverse_iterator
const IAthenaPoolTestData * front() const
virtual const DataModel_detail::DVLInfoBase & dvlinfo_v() const override
SG::OwnershipPolicy ownPolicy() const
typename DataVectorBase< IAthenaPoolTestData >::Base DVL_BASE
typename typename DataVectorBase< IAthenaPoolTestData >::Base::Deleter Deleter
size_type size() const noexcept
Returns the number of elements in the collection.
DataVector(DataVector &&rhs) noexcept
Copy constructor.
void assign(InputIterator first, InputIterator last)
Assign from iterators.
static void iter_swap(iterator a, iterator b)
typename DataVectorBase< IAthenaPoolTestData >::Base::PtrVector PtrVector
size_type capacity() const noexcept
std::unique_ptr< base_value_type > unique_type
SG::IsMostDerivedFlag m_isMostDerived
IAthenaPoolTestData *const * const_pointer
typename DataVectorBase< IAthenaPoolTestData >::Base DataVector_BASE
const_iterator cend() const noexcept
void insertMove(iterator position, DataVector &other)
void testInsertOol(const char *op)
Test if we can insert; raise an exception if not.
void assignElement(typename BaseContainer::iterator pos, value_type newElem)
Handle element assignment.
size_type max_size() const noexcept
Returns the size() of the largest possible collection.
void resortAux(iterator beg, iterator end)
Reset indices / reorder aux data after elements have been permuted.
const_reverse_iterator crbegin() const noexcept
IAthenaPoolTestData base_value_type
void assignBaseElement(typename BaseContainer::iterator pos, typename BaseContainer::value_type newElem)
Handle element assignment from a base pointer.
bool empty() const noexcept
static constexpr bool must_own
Manage index tracking and synchronization of auxiliary data.
AuxVectorBase()
Default constructor.
bool trackIndices() const
Return true if index tracking is enabled for this container.
A DataBucket specialized for DataVector/DataList.
Interface for non-const operations on an auxiliary store.
Holder for the is-most-derived flag.
A couple standard-library related concepts.
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...
std::enable_if_t< std::is_convertible_v< typename std::iterator_traits< ITERATOR >::value_type, std::unique_ptr< T > >, bool > enable_if_up_itr
Selection rules: declare transient members.
@ DEFAULT_TRACK_INDICES
Default value.
@ OWN_ELEMENTS
this data object owns its elements
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Represent a list of base classes.
Traits class to hold derivation information.
Marker for the base of the inheritance hierarchy.
Derivation information for DataVector.
DataModel_detail::NoBase Base
Marker to indicate a nonexistent base class.
BaseList< SG::AuxVectorBase > bases
SG::DVLDataBucket< U > type
Metafunction to find the proper DataBucket class for T.
DataVector< T, DataModel_detail::NoBase > type
Calculate topmost base accessible via SG_BASES that also has a defined CLID.