ATLAS Offline Software
Loading...
Searching...
No Matches
DataVector.h
Go to the documentation of this file.
1// This file's extension implies that it's C, but it's really -*- C++ -*-.
2
3/*
4 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
5*/
518
519
520#ifndef ATHCONTAINERS_DATAVECTOR_H
521#define ATHCONTAINERS_DATAVECTOR_H
522
523
524// For feature tests.
525#define HAVE_CONSTDATAVECTOR
526
527
541#include "CxxUtils/concepts.h"
542#include <boost/iterator/iterator_adaptor.hpp>
543#include <type_traits>
544#include <vector>
545#include <typeinfo>
546#include <functional>
547#include <iostream>
548#include <algorithm>
549#include <stdexcept>
550#include <iterator>
551#include <initializer_list>
552#include <RootMetaSelection.h>
553
554
555
556#ifdef XAOD_STANDALONE
557# ifndef SG_BASE
558# define SG_BASE(A, B) class ATHCONTAINERS_DUMMY
559# endif // not SG_BASE
560# ifndef SG_BASES1
561# define SG_BASES1(A, B) class ATHCONTAINERS_DUMMY
562# endif // not SG_BASES1
563# ifndef SG_BASES2
564# define SG_BASES2(A, B, C) class ATHCONTAINERS_DUMMY
565# endif // not SG_BASES2
566# ifndef SG_BASES3
567# define SG_BASES3(A, B, C, D) class ATHCONTAINERS_DUMMY
568# endif // not SG_BASES3
569# ifndef SG_BASES4
570# define SG_BASES4(A, B, C, D, E) class ATHCONTAINERS_DUMMY
571# endif // not SG_BASES4
572# ifndef SG_VIRTUAL
573# define SG_VIRTUAL(X) X
574# endif // not SG_VIRTUAL
575#else
576# include "AthenaKernel/BaseInfo.h"
577#endif
578
579
580// Forward declarations.
581namespace ROOT { namespace Meta { namespace Selection {
582 template <class T, class BASE> class DataVector;
583}}}
584
585
587
588
589// These are the intermediate classes from which @c DataVector derives
590// in the case of multiple or virtual derivation. The actual
591// definitions are in the @c icc file. They have the following
592// properties:
593// - They derive from those of @c B1, @c B2, and @c B3 that are not
594// @c NoBase.
595// - They perform (static) checking to ensure that there's a unique
596// base class in the hierarchy.
597// - They make the following types available from the base classes:
598// - @c PtrVector
599// - @c BaseContainer
600// - @c size_type
601// - @c difference_type
602// - @c allocator_type
603// - @c has_virtual is defined as @c true.
604// - An override of @c dvlinfo_v is defined, to prevent ambiguities.
605template <class B1,
608
609
612template <class ITERATOR, class T>
614 std::enable_if_t<std::is_convertible_v<typename std::iterator_traits<ITERATOR>::value_type, T*>, bool>;
615
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>;
619
620
621} // namespace DataVector_detail
622
623
624
633template <class T>
638
639
649#define DATAVECTOR_BASE(T, BASE) \
650DATAVECTOR_BASE_FWD(T, BASE); \
651template struct DataVector_detail::DVLEltBaseInit<T>
652
653
658#define DATAVECTOR_BASE_FWD(T, BASE) \
659template <> struct DataVectorBase<T> \
660{ typedef DataVector<BASE> Base; }; \
661SG_BASE(DataVector<T>, DataVector<BASE>)
662
663
673#define DATAVECTOR_VIRTBASES1(T, B1) \
674DATAVECTOR_VIRTBASES1_FWD(T, B1); \
675template struct DataVector_detail::DVLEltBaseInit<T>
676
677
678
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>))
687
688
689
699#define DATAVECTOR_VIRTBASES2(T, B1, B2) \
700DATAVECTOR_VIRTBASES2_FWD(T, B1, B2); \
701template struct DataVector_detail::DVLEltBaseInit<T>
702
703
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>))
713
714
724#define DATAVECTOR_VIRTBASES3(T, B1, B2, B3) \
725DATAVECTOR_VIRTBASES3_FWD(T, B1, B2, B3); \
726template struct DataVector_detail::DVLEltBaseInit<T>
727
728
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>))
739
740
750#define DATAVECTOR_VIRTBASES4(T, B1, B2, B3, B4) \
751DATAVECTOR_VIRTBASES4_FWD(T, B1, B2, B3, B4); \
752template struct DataVector_detail::DVLEltBaseInit<T>
753
754
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>))
766
767
774#define DATAVECTOR_BASE_FIN(T, B) \
775template struct DataVector_detail::DVLEltBaseInit<T>
776
777
778template <class DV> class ConstDataVector;
779template <class DV> void test2_assignelement1();
780template <class DV> void test2_assignelement1a();
781template <class DV> void test2_assignelement2();
782
783
793template <class T, class BASE = typename DataVectorBase<T>::Base>
794class DataVector : public BASE
795{
796public:
797 typedef BASE DataVector_BASE;
798 typedef BASE DVL_BASE;
799
802 static const bool has_virtual = BASE::has_virtual;
803
806 typedef typename BASE::PtrVector PtrVector;
807 typedef typename BASE::PtrVector BaseContainer;
808
809
810public:
811 // Standard types required for the container interface.
812 typedef T*& reference;
813 typedef T* const & const_reference;
814 typedef typename BASE::size_type size_type;
815 typedef typename BASE::difference_type difference_type;
816 typedef T* value_type;
817 typedef typename BASE::allocator_type allocator_type;
818 typedef T** pointer;
819 typedef T* const * const_pointer;
820
821 typedef const T* const_value_type;
822
826
829 typedef std::unique_ptr<base_value_type> unique_type;
830
834
835
839
843
844
846 typedef typename std::reverse_iterator<const_iterator>
848
851 typedef typename std::reverse_iterator<iterator>
853
855
856
857 using Deleter = typename BASE::Deleter;
858
860 static constexpr bool must_own = BASE::must_own;
861
862
863 //========================================================================
866
867
877 SG::IndexTrackingPolicy trackIndices =
879
880
893 explicit DataVector(size_type n, /* value_type pElem = 0,*/
895 SG::IndexTrackingPolicy trackIndices =
897
898
905 // The copy constructor for derived classes is deliberately omitted,
906 // as otherwise we get warnings about not calling the copy constructors
907 // for base classes, which are problematic when we have virtual
908 // inheritance. Most of what needs doing is done in the base class anyway,
909 // except for setting @c m_isMostDerived. We arrange for these flags
910 // to all get set to false; they'll get set correctly when
911 // @c testInsert is called.
912 // Need this to get the default copy ctor defined when a move
913 // ctor is also present.
914 DataVector (const DataVector&) = default;
915
916
923 DataVector (DataVector&& rhs) noexcept;
924
925
938 template <class InputIterator>
939 DataVector(InputIterator first,
940 InputIterator last,
943 SG::IAuxStore* store = 0);
944
945
956 DataVector(std::initializer_list<value_type> l,
959 SG::IAuxStore* store = 0);
960
961
975
976
984
985
996 DataVector& operator= (std::initializer_list<value_type> l);
997
998
1008 template <class InputIterator>
1009 void assign(InputIterator first, InputIterator last);
1010
1011
1019 void assign(std::initializer_list<value_type> l);
1020
1021
1022 // Destructor is inherited.
1023
1024
1026 //========================================================================
1029
1030
1039
1040
1045 // This is inherited from the base class.
1046
1047
1060
1061
1067 // This is inherited from the base class.
1068
1069
1074 // This is inherited from the base class.
1075
1076
1084
1085
1091 // This is inherited from the base class.
1092
1093
1095 //========================================================================
1098
1099
1108 const T* operator[] (size_type n) const;
1109
1110
1120
1121
1131 ElementProxy operator[] (size_type n);
1132
1133
1143
1144
1155
1156
1165
1166
1175
1176
1186
1187
1197
1198
1200 //========================================================================
1203
1204
1214
1215
1225
1226
1236 iterator begin() noexcept;
1237
1238
1248 iterator end() noexcept;
1249
1250
1260
1261
1271
1272
1283
1284
1295
1296
1306
1307
1317
1318
1328
1329
1339
1340
1342 //========================================================================
1345
1346
1360
1361
1374
1375
1392 template <CxxUtils::detail::AllocationFunction<T> F>
1394
1395
1411
1412
1426
1427
1440
1441
1458
1459
1475 template <class InputIterator,
1476 DataVector_detail::enable_if_ptr_itr<InputIterator, T> = true>
1477 void insert(iterator position, InputIterator first, InputIterator last);
1478
1479
1495 template <class InputIterator,
1496 DataVector_detail::enable_if_up_itr<InputIterator, T> = true>
1497 void insert(iterator position, InputIterator first, InputIterator last);
1498
1499
1511 void insert(iterator position, std::initializer_list<value_type> l);
1512
1513
1539 void insertMove (iterator position, DataVector& other);
1540
1541
1543 //========================================================================
1546
1547
1557
1558
1571
1572
1580 void pop_back();
1581
1582
1591 void clear();
1592
1593
1595 //========================================================================
1598
1599
1610 void swap(DataVector& rhs);
1611
1612
1618 static void iter_swap (iterator a, iterator b);
1619
1620
1626 void sort();
1627
1628
1633 template <class COMPARE>
1634 void sort(COMPARE comp);
1635
1636
1637
1639 //========================================================================
1642
1643
1662
1663
1681 void swapElement(iterator pos, value_type newElem, reference oldElem);
1682
1683
1704 std::unique_ptr<base_value_type> newElem,
1705 std::unique_ptr<base_value_type>& oldElem);
1706
1707
1728 std::unique_ptr<base_value_type> newElem,
1729 std::unique_ptr<base_value_type>& oldElem);
1730
1731
1732public:
1741 // This is inherited from the base class.
1742
1743
1748 // This is inherited from the base class.
1749
1750
1761 void clear (SG::OwnershipPolicy ownPolicy);
1762
1763
1775 void clear (SG::OwnershipPolicy ownPolicy,
1776 SG::IndexTrackingPolicy trackIndices);
1777
1778
1790 void clear (std::unique_ptr<Deleter> deleter);
1791
1792
1798 static const DataModel_detail::DVLInfoBase& dvlinfo();
1799
1800
1806 virtual const DataModel_detail::DVLInfoBase& dvlinfo_v() const override;
1807
1808
1820 static
1821 int baseOffset (const std::type_info& ti);
1822
1823
1834 const SG::AuxVectorBase& auxbase() const;
1835
1836
1838 //========================================================================
1839
1840
1841 // Doxygen trick. We want DataVector<T> to show the complete interface,
1842 // including inherited methods. Normally, doxygen would do this.
1843 // But it's not smart enough to figure out our inheritance relationships.
1844 // We can add a function with `fn', but doxygen won't actually
1845 // generate the documentation unless it also sees the declaration.
1846 // So here are declarations which should be visible to doxygen
1847 // but not to C++.
1848#ifndef __cplusplus
1852 [[nodiscard]] bool empty() const noexcept;
1854 void pop_back();
1855 void clear();
1857 SG::OwnershipPolicy ownPolicy() const;
1858 void clear (SG::OwnershipPolicy ownPolicy,
1859 SG::IndexTrackingPolicy trackIndices = SG::DEFAULT_TRACK_INDICES);
1860#endif // not __cplusplus
1861
1862
1865
1866
1877 static
1878 int baseOffset1 (const char* p, const DataVector& dv,
1879 const std::type_info& ti);
1880
1881
1893
1894
1905 void testInsert (const char* op);
1906
1907
1918 void testInsertOol (const char* op);
1919
1920
1921private:
1923 template <class DV>
1924 friend class ConstDataVector;
1925 template <class DV, class ALLOC>
1930
1931
1940 void assignElement (typename BaseContainer::iterator pos, value_type newElem);
1941
1942
1951 void assignElement (typename BaseContainer::iterator pos,
1952 std::unique_ptr<base_value_type> newElem);
1953
1954
1963 void assignBaseElement (typename BaseContainer::iterator pos,
1964 typename BaseContainer::value_type newElem);
1965
1966
1990 void shift (size_t pos, ptrdiff_t offs);
1991
1992
1993public:
1994 // Make this public so we can call it from DVCollectionProxy.
2003 static
2004 const T* do_cast (const typename PtrVector::value_type p);
2005
2006
2015 static
2016 T* do_cast_nc (typename PtrVector::value_type p);
2017
2018
2019private:
2030 virtual const std::type_info& dv_typeid() const override;
2031
2032
2033protected:
2040
2041
2049 virtual void setMostDerived() override;
2050
2051
2052private:
2054
2055
2060
2061
2062 typedef typename
2064};
2065
2066
2067template <class T, class BASE>
2069
2079template <class T>
2080class DataVector<T, DataModel_detail::NoBase>
2081 : public SG::AuxVectorBase
2082{
2083public:
2086
2088 typedef std::true_type isSequence;
2089
2092 typedef std::vector<T*> PtrVector;
2093 typedef std::vector<T*> BaseContainer;
2094
2099 static const bool has_virtual = false;
2100
2101 // Standard types required for the container interface.
2102 typedef T*& reference;
2103 typedef T* const & const_reference;
2104 typedef typename PtrVector::size_type size_type;
2105 typedef typename PtrVector::difference_type difference_type;
2106 typedef T* value_type;
2107 typedef typename PtrVector::allocator_type allocator_type;
2108 typedef T** pointer;
2109 typedef T* const * const_pointer;
2110
2111 typedef const T* const_value_type;
2112
2115 typedef T base_value_type;
2116
2119 typedef std::unique_ptr<base_value_type> unique_type;
2120
2124
2125
2129
2133
2135 // Note: we can't just use the underlying PtrVector::const_reverse_iterator
2136 // here; otherwise, const_reverse_iterator won't be convertable to
2137 // reverse_iterator.
2138 typedef typename std::reverse_iterator<const_iterator>
2140
2143 typedef typename std::reverse_iterator<iterator>
2145
2147
2148
2153 {
2154 public:
2157 virtual ~Deleter() = default;
2158 virtual void doDelete (value_type p) = 0;
2159 virtual void doDelete (typename PtrVector::iterator first,
2160 typename PtrVector::iterator last) = 0;
2161 };
2162
2163
2165 static constexpr bool must_own = false;
2166
2167
2168 //========================================================================
2171
2172
2181 explicit DataVector(SG::OwnershipPolicy ownPolicy = SG::OWN_ELEMENTS,
2184
2185
2198 explicit DataVector
2199 (size_type n, /* value_type pElem = 0,*/
2202
2203
2210 DataVector(const DataVector& rhs);
2211
2212
2219 DataVector (DataVector&& rhs) noexcept;
2220
2221
2234 template <class InputIterator>
2235 DataVector(InputIterator first, InputIterator last,
2238 SG::IAuxStore* store = 0);
2239
2240
2251 DataVector(std::initializer_list<value_type> l,
2254 SG::IAuxStore* store = 0);
2255
2256
2269 DataVector& operator= (const DataVector& rhs);
2270
2271
2278 DataVector& operator= (DataVector&& rhs);
2279
2280
2291 DataVector& operator= (std::initializer_list<value_type> l);
2292
2293
2303 template <class InputIterator>
2304 void assign(InputIterator first, InputIterator last);
2305
2306
2315 void assign(std::initializer_list<value_type> l);
2316
2317
2327 virtual ~DataVector();
2328
2329
2331 //========================================================================
2334
2335
2339 size_type size() const noexcept;
2340
2341
2348 virtual size_type size_v() const override;
2349
2350
2354 size_type max_size() const noexcept;
2355
2356
2367 void resize(size_type sz);
2368
2369
2374 size_type capacity() const noexcept;
2375
2376
2384 virtual size_type capacity_v() const override;
2385
2386
2390 [[nodiscard]] bool empty() const noexcept;
2391
2392
2398 void reserve (size_type n);
2399
2400
2406 void shrink_to_fit();
2407
2408
2410 //========================================================================
2413
2414
2423 const T* operator[] (size_type n) const;
2424
2425
2434 const T* get (size_type n) const;
2435
2436
2446 ElementProxy operator[] (size_type n);
2447
2448
2457 const T* at (size_type n) const;
2458
2459
2469 ElementProxy at (size_type n);
2470
2471
2479 const T* front() const;
2480
2481
2489 const T* back() const;
2490
2491
2500 ElementProxy front ();
2501
2502
2511 ElementProxy back ();
2512
2513
2515 //========================================================================
2518
2519
2528 const_iterator begin() const noexcept;
2529
2530
2539 const_iterator end() const noexcept;
2540
2541
2551 iterator begin() noexcept;
2552
2553
2563 iterator end() noexcept;
2564
2565
2574 const_reverse_iterator rbegin() const noexcept;
2575
2576
2585 const_reverse_iterator rend() const noexcept;
2586
2587
2597 reverse_iterator rbegin() noexcept;
2598
2599
2609 reverse_iterator rend() noexcept;
2610
2619 const_iterator cbegin() const noexcept;
2620
2621
2630 const_iterator cend() const noexcept;
2631
2632
2641 const_reverse_iterator crbegin() const noexcept;
2642
2643
2652 const_reverse_iterator crend() const noexcept;
2653
2654
2656 //========================================================================
2659
2660
2673 value_type push_back(value_type pElem);
2674
2675
2687 value_type push_back(std::unique_ptr<base_value_type> pElem);
2688
2689
2706 template <CxxUtils::detail::AllocationFunction<T> F>
2707 size_type push_new (size_type n, F alloc);
2708
2709
2724 value_type emplace_back(value_type pElem);
2725
2726
2739 iterator insert(iterator position, value_type pElem);
2740
2741
2753 iterator insert(iterator position, std::unique_ptr<base_value_type> pElem);
2754
2755
2771 iterator emplace(iterator position, value_type pElem);
2772
2773
2789 template <class InputIterator,
2790 DataVector_detail::enable_if_ptr_itr<InputIterator, T> = true>
2791 void insert(iterator position, InputIterator first, InputIterator last);
2792
2793
2809 template <class InputIterator,
2810 DataVector_detail::enable_if_up_itr<InputIterator, T> = true>
2811 void insert(iterator position, InputIterator first, InputIterator last);
2812
2813
2825 void insert(iterator position, std::initializer_list<value_type> l);
2826
2827
2853 void insertMove (iterator position, DataVector& other);
2854
2855
2857 //========================================================================
2860
2861
2870 iterator erase(iterator position);
2871
2872
2884 iterator erase(iterator first, iterator last);
2885
2886
2893 void pop_back();
2894
2895
2903 void clear();
2904
2905
2907 //========================================================================
2910
2911
2922 void swap(DataVector& rhs);
2923
2924
2930 static void iter_swap (iterator a, iterator b);
2931
2932
2938 void sort();
2939
2940
2946 template <class COMPARE>
2947 void sort(COMPARE comp);
2948
2949
2951 //========================================================================
2954
2955
2973 void swapElement(size_type index, value_type newElem, reference oldElem);
2974
2975
2993 void swapElement(iterator pos, value_type newElem, reference oldElem);
2994
2995
3015 void swapElement(size_type index,
3016 std::unique_ptr<base_value_type> newElem,
3017 std::unique_ptr<base_value_type>& oldElem);
3018
3019
3038 void swapElement(iterator pos,
3039 std::unique_ptr<base_value_type> newElem,
3040 std::unique_ptr<base_value_type>& oldElem);
3041
3042
3043public:
3051 const PtrVector& stdcont() const;
3052
3053
3057 SG::OwnershipPolicy ownPolicy() const;
3058
3059
3069 void clear (SG::OwnershipPolicy ownPolicy);
3070
3071
3082 void clear (SG::OwnershipPolicy ownPolicy,
3083 SG::IndexTrackingPolicy trackIndices);
3084
3085
3097 void clear (std::unique_ptr<Deleter> deleter);
3098
3099
3105 static const DataModel_detail::DVLInfoBase& dvlinfo();
3106
3107
3113 virtual const DataModel_detail::DVLInfoBase& dvlinfo_v() const;
3114
3115
3127 static
3128 int baseOffset (const std::type_info& ti);
3129
3130
3137 const SG::AuxVectorBase& auxbase() const;
3138
3139
3141 //========================================================================
3144
3145
3156 static
3157 int baseOffset1 (const char* p, const DataVector& dv,
3158 const std::type_info& ti);
3159
3160
3171 void resortAux (iterator beg, iterator end);
3172
3173
3184 void testInsert (const char* op);
3185
3186
3197 void testInsertOol (const char* op);
3198
3199
3200private:
3201 friend class DataModel_detail::ElementProxy<DataVector>;
3202 template <class DV>
3203 friend class ConstDataVector;
3204 template <class DV, class ALLOC>
3205 friend class DataVectorWithAlloc;
3206 friend void test2_assignelement1a<DataVector>();
3207 friend void test2_assignelement1<DataVector>();
3208 friend void test2_assignelement2<DataVector>();
3209
3210
3219 void assignElement (typename BaseContainer::iterator pos, value_type newElem);
3220
3221
3230 void assignElement (typename BaseContainer::iterator pos,
3231 std::unique_ptr<base_value_type> newElem);
3232
3233
3242 void assignBaseElement (typename BaseContainer::iterator pos,
3243 typename BaseContainer::value_type newElem);
3244
3245
3269 void shift (size_t pos, ptrdiff_t offs);
3270
3271
3272public:
3273 // Make this public so we can call it from DVCollectionProxy.
3281 static
3282 const T* do_cast (const typename PtrVector::value_type p);
3283
3284
3292 static
3293 T* do_cast_nc (typename PtrVector::value_type p);
3294
3295
3296private:
3307 virtual const std::type_info& dv_typeid() const;
3308
3309
3310protected:
3320 typename PtrVector::iterator
3321 erase_base(typename PtrVector::iterator position);
3322
3323
3335 typename PtrVector::iterator
3336 erase_base(typename PtrVector::iterator first,
3337 typename PtrVector::iterator last);
3338
3339
3344 void doDelete (value_type p);
3345
3346
3352 void doDelete (typename PtrVector::iterator first,
3353 typename PtrVector::iterator last);
3354
3355
3356protected:
3359 SG::OwnershipPolicy m_ownPolicy;
3360
3362 PtrVector m_pCont;
3363
3366 // This should really be a unique_ptr --- but that causes problems
3367 // with ROOT persistency (even though this is tagged as transient).
3368 Deleter* m_deleter = nullptr;
3369
3370
3376 void clearMostDerived();
3377
3378
3386 virtual void setMostDerived();
3387
3388
3389private:
3391
3392
3396 SG::IsMostDerivedFlag m_isMostDerived;
3397
3398
3399 typedef typename
3400 ROOT::Meta::Selection::DataVector<T, DataVector_BASE>::self self;
3401};
3402
3403template <class T>
3405
3406
3417template <class T>
3418bool operator== (const DataVector<T>& a, const DataVector<T>& b);
3419
3420
3422template <class T>
3423bool operator!= (const DataVector<T>& a, const DataVector<T>& b);
3424
3425
3437template <class T>
3438bool operator< (const DataVector<T>& a, const DataVector<T>& b);
3439
3440
3442template <class T>
3443bool operator> (const DataVector<T>& a, const DataVector<T>& b);
3444
3445
3447template <class T>
3448bool operator<= (const DataVector<T>& a, const DataVector<T>& b);
3449
3450
3452template <class T>
3453bool operator>= (const DataVector<T>& a, const DataVector<T>& b);
3454
3455
3457template <class T>
3458void swap (DataVector<T>& a, DataVector<T>& b);
3459
3460
3461namespace ROOT { namespace Meta { namespace Selection {
3462
3463template< class T, class BASE >
3464class DataVector : KeepFirstTemplateArguments< 1 >, SelectNoInstance
3465{
3466
3467public:
3470#ifndef XAOD_STANDALONE
3472 //MN: this causes massive dictionary duplication. Disabling for now.
3473 // ROOT::Meta::Selection::MemberAttributes< kAutoSelected > m_pCont;
3474#endif
3476 ROOT::Meta::Selection::MemberAttributes< kTransient > m_isMostDerived;
3477 ROOT::Meta::Selection::MemberAttributes< kTransient > m_deleter;
3478
3481 ROOT::Meta::Selection::MemberAttributes< kTransient > m_ownPolicy;
3482
3483};
3484
3485}}} // namespace
3486
3487
3489
3490
3497template <class T>
3499{
3500public:
3501 static std::string name();
3502};
3503
3504
3505#ifndef XAOD_STANDALONE
3506
3507
3510#include "AthenaKernel/TopBase.h"
3511
3512
3513namespace SG {
3514
3515
3522template <class T, class U>
3524{
3526 static void init() { DataVector<T>::dvlinfo(); }
3527};
3528
3529
3536template <class T>
3540template <class T>
3544
3545
3546} // namespace SG
3547
3548
3549#endif
3550
3551
3553#endif // not ATHCONTAINERS_DATAVECTOR_H
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.
#define protected
Describes the possible index tracking policies.
Holder for the is-most-derived flag.
static Double_t sz
static Double_t a
#define F(x, y, z)
Definition MD5.cxx:112
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.
Definition DVLIterator.h:82
(Non-const) Iterator class for DataVector/DataList.
Interface to allow customizing how elements are to be deleted.
virtual void doDelete(typename PtrVector::iterator first, typename PtrVector::iterator last)=0
Derived DataVector<T>.
Definition DataVector.h:795
IAthenaPoolTestData *const & const_reference
Definition DataVector.h:813
typename DataVectorBase< IAthenaPoolTestData >::Base::allocator_type allocator_type
Definition DataVector.h:817
friend void test2_assignelement1a()
IAthenaPoolTestData * value_type
Definition DataVector.h:816
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
DataVector(size_type n, SG::OwnershipPolicy ownPolicy=SG::OWN_ELEMENTS, SG::IndexTrackingPolicy trackIndices=SG::DEFAULT_TRACK_INDICES)
Sized constructor.
friend void test2_assignelement1()
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
Definition DataVector.h:818
typename DataVectorBase< IAthenaPoolTestData >::Base::size_type size_type
Definition DataVector.h:814
const_reverse_iterator rend() const noexcept
void testInsert(const char *op)
Test if we can insert; raise an exception if not.
value_type emplace_back(value_type pElem)
DataVector(const DataVector &)=default
Copy constructor.
std::reverse_iterator< iterator > reverse_iterator
Definition DataVector.h:852
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
Definition DataVector.h:833
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)
typename DataVectorBase< IAthenaPoolTestData >::Base::PtrVector BaseContainer
Definition DataVector.h:807
const IAthenaPoolTestData * const_value_type
Definition DataVector.h:821
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.
size_type push_new(size_type n, F alloc)
DataModel_detail::iterator< DataVector > iterator
Definition DataVector.h:842
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.
const PtrVector & stdcont() const
const_iterator end() const noexcept
const_reverse_iterator rbegin() const noexcept
iterator erase(iterator position)
IAthenaPoolTestData *& reference
Definition DataVector.h:812
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
Definition DataVector.h:815
const_iterator begin() const noexcept
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition DataVector.h:847
const IAthenaPoolTestData * front() const
virtual const DataModel_detail::DVLInfoBase & dvlinfo_v() const override
SG::OwnershipPolicy ownPolicy() const
typename DataVectorBase< IAthenaPoolTestData >::Base DVL_BASE
Definition DataVector.h:798
typename typename DataVectorBase< IAthenaPoolTestData >::Base::Deleter Deleter
Definition DataVector.h:857
size_type size() const noexcept
Returns the number of elements in the collection.
DataVector(DataVector &&rhs) noexcept
Move constructor.
void assign(InputIterator first, InputIterator last)
Assign from iterators.
DataVector & operator=(const DataVector &rhs)
Assignment operator.
static void iter_swap(iterator a, iterator b)
typename DataVectorBase< IAthenaPoolTestData >::Base::PtrVector PtrVector
Definition DataVector.h:806
size_type capacity() const noexcept
std::unique_ptr< base_value_type > unique_type
Definition DataVector.h:829
SG::IsMostDerivedFlag m_isMostDerived
IAthenaPoolTestData *const * const_pointer
Definition DataVector.h:819
typename DataVectorBase< IAthenaPoolTestData >::Base DataVector_BASE
Definition DataVector.h:797
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
Definition DataVector.h:825
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
Definition DataVector.h:860
DataVector< T, BASE > self
A helper typedef.
ROOT::Meta::Selection::MemberAttributes< kTransient > m_isMostDerived
ROOT::Meta::Selection::MemberAttributes< kTransient > m_deleter
ROOT::Meta::Selection::MemberAttributes< kTransient > m_ownPolicy
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.
Definition IAuxStore.h:48
Holder for the is-most-derived flag.
STL class.
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...
Definition DataVector.h:613
std::enable_if_t< std::is_convertible_v< typename std::iterator_traits< ITERATOR >::value_type, std::unique_ptr< T > >, bool > enable_if_up_itr
Definition DataVector.h:617
Selection rules: declare transient members.
Definition DataVector.h:581
Forward declaration.
@ DEFAULT_TRACK_INDICES
Default value.
OwnershipPolicy
@ OWN_ELEMENTS
this data object owns its elements
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Definition index.py:1
STL namespace.
Marker for the base of the inheritance hierarchy.
Definition DVLNoBase.h:32
Derivation information for DataVector.
Definition DataVector.h:635
DataModel_detail::NoBase Base
Definition DataVector.h:636
Represent a list of base classes.
Definition Bases.h:79
Traits class to hold derivation information.
Definition Bases.h:115
Metafunction to find the proper DataBucket class for T.
Marker to indicate a nonexistent base class.
Definition Bases.h:68
DataVector< T, DataModel_detail::NoBase > type
Calculate topmost base accessible via SG_BASES.
Definition TopBase.h:38
#define private