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-2026 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 <type_traits>
543#include <vector>
544#include <typeinfo>
545#include <functional>
546#include <iostream>
547#include <algorithm>
548#include <stdexcept>
549#include <iterator>
550#include <initializer_list>
551#include <RootMetaSelection.h>
552
553
554
555#ifdef XAOD_STANDALONE
556# ifndef SG_BASE
557# define SG_BASE(A, B) class ATHCONTAINERS_DUMMY
558# endif // not SG_BASE
559# ifndef SG_BASES1
560# define SG_BASES1(A, B) class ATHCONTAINERS_DUMMY
561# endif // not SG_BASES1
562# ifndef SG_BASES2
563# define SG_BASES2(A, B, C) class ATHCONTAINERS_DUMMY
564# endif // not SG_BASES2
565# ifndef SG_BASES3
566# define SG_BASES3(A, B, C, D) class ATHCONTAINERS_DUMMY
567# endif // not SG_BASES3
568# ifndef SG_BASES4
569# define SG_BASES4(A, B, C, D, E) class ATHCONTAINERS_DUMMY
570# endif // not SG_BASES4
571# ifndef SG_VIRTUAL
572# define SG_VIRTUAL(X) X
573# endif // not SG_VIRTUAL
574namespace SG {
575template <class T> struct bi_destroy {};
576}
577#else
578# include "AthenaKernel/BaseInfo.h"
579#endif
580
581
582// Forward declarations.
583namespace ROOT { namespace Meta { namespace Selection {
584 template <class T, class BASE> class DataVector;
585}}}
586
587
589
590
591// These are the intermediate classes from which @c DataVector derives
592// in the case of multiple or virtual derivation. The actual
593// definitions are in the @c icc file. They have the following
594// properties:
595// - They derive from those of @c B1, @c B2, and @c B3 that are not
596// @c NoBase.
597// - They perform (static) checking to ensure that there's a unique
598// base class in the hierarchy.
599// - They make the following types available from the base classes:
600// - @c PtrVector
601// - @c BaseContainer
602// - @c size_type
603// - @c difference_type
604// - @c allocator_type
605// - @c has_virtual is defined as @c true.
606// - An override of @c dvlinfo_v is defined, to prevent ambiguities.
607template <class B1,
610
611
614template <class ITERATOR, class T>
616 std::enable_if_t<std::is_convertible_v<typename std::iterator_traits<ITERATOR>::value_type, T*>, bool>;
617
618template <class ITERATOR, class T>
620 std::enable_if_t<std::is_convertible_v<typename std::iterator_traits<ITERATOR>::value_type, std::unique_ptr<T> >, bool>;
621
622
623} // namespace DataVector_detail
624
625
626
635template <class T>
640
641
651#define DATAVECTOR_BASE(T, BASE) \
652DATAVECTOR_BASE_FWD(T, BASE); \
653DATAVECTOR_BASE_FIN(T, BASE);
654
655
663#define DATAVECTOR_BASE_FWD(T, BASE) \
664template <> struct DataVectorBase<T> \
665{ typedef DataVector<BASE> Base; }; \
666namespace SG { template<> struct bi_destroy<DataVector<T> > { static void destroy(void*); }; } \
667SG_BASE(DataVector<T>, DataVector<BASE>)
668
669
679#define DATAVECTOR_VIRTBASES1(T, B1) \
680DATAVECTOR_VIRTBASES1_FWD(T, B1); \
681DATAVECTOR_BASE_FIN(T, B1);
682
683
684
692#define DATAVECTOR_VIRTBASES1_FWD(T, B1) \
693template <> struct DataVectorBase<T> \
694{ typedef DataVector_detail::VirtBases<B1> Base; }; \
695namespace SG { template<> struct bi_destroy<DataVector<T> > { static void destroy(void*); }; } \
696SG_BASES1(DataVector<T>, SG_VIRTUAL(DataVector<B1>))
697
698
699
709#define DATAVECTOR_VIRTBASES2(T, B1, B2) \
710DATAVECTOR_VIRTBASES2_FWD(T, B1, B2); \
711DATAVECTOR_BASE_FIN(T, B1);
712
713
721#define DATAVECTOR_VIRTBASES2_FWD(T, B1, B2) \
722template <> struct DataVectorBase<T> \
723{ typedef DataVector_detail::VirtBases<B1, B2> Base; }; \
724namespace SG { template<> struct bi_destroy<DataVector<T> > { static void destroy(void*); }; } \
725SG_BASES2(DataVector<T>, SG_VIRTUAL(DataVector<B1>), \
726 SG_VIRTUAL(DataVector<B2>))
727
728
738#define DATAVECTOR_VIRTBASES3(T, B1, B2, B3) \
739DATAVECTOR_VIRTBASES3_FWD(T, B1, B2, B3); \
740DATAVECTOR_BASE_FIN(T, B1);
741
742
750#define DATAVECTOR_VIRTBASES3_FWD(T, B1, B2, B3) \
751template <> struct DataVectorBase<T> \
752{ typedef DataVector_detail::VirtBases<B1, B2, B3> Base; }; \
753namespace SG { template<> struct bi_destroy<DataVector<T> > { static void destroy(void*); }; } \
754SG_BASES3(DataVector<T>, SG_VIRTUAL(DataVector<B1>), \
755 SG_VIRTUAL(DataVector<B2>), \
756 SG_VIRTUAL(DataVector<B3>))
757
758
768#define DATAVECTOR_VIRTBASES4(T, B1, B2, B3, B4) \
769DATAVECTOR_VIRTBASES4_FWD(T, B1, B2, B3, B4); \
770DATAVECTOR_BASE_FIN(T, B1);
771
772
780#define DATAVECTOR_VIRTBASES4_FWD(T, B1, B2, B3, B4) \
781template <> struct DataVectorBase<T> \
782{ typedef DataVector_detail::VirtBases<B1, B2, B3, B4> Base; }; \
783namespace SG { template<> struct bi_destroy<DataVector<T> > { static void destroy(void*); }; } \
784SG_BASES4(DataVector<T>, SG_VIRTUAL(DataVector<B1>), \
785 SG_VIRTUAL(DataVector<B2>), \
786 SG_VIRTUAL(DataVector<B3>), \
787 SG_VIRTUAL(DataVector<B4>))
788
789
796#define DATAVECTOR_BASE_FIN(T, B) \
797 namespace SG { inline void bi_destroy<DataVector<T> >::destroy(void* p) { delete (DataVector<T>*)p; } } \
798template struct DataVector_detail::DVLEltBaseInit<T>
799
800
801template <class DV> class ConstDataVector;
802template <class DV> void test2_assignelement1();
803template <class DV> void test2_assignelement1a();
804template <class DV> void test2_assignelement2();
805
806
816template <class T, class BASE = typename DataVectorBase<T>::Base>
817class DataVector : public BASE
818{
819public:
820 typedef BASE DataVector_BASE;
821 typedef BASE DVL_BASE;
822
825 static const bool has_virtual = BASE::has_virtual;
826
829 typedef typename BASE::PtrVector PtrVector;
830 typedef typename BASE::PtrVector BaseContainer;
831
832
833public:
834 // Standard types required for the container interface.
835 typedef T*& reference;
836 typedef T* const & const_reference;
837 typedef typename BASE::size_type size_type;
838 typedef typename BASE::difference_type difference_type;
839 typedef T* value_type;
840 typedef typename BASE::allocator_type allocator_type;
841 typedef T** pointer;
842 typedef T* const * const_pointer;
843
844 typedef const T* const_value_type;
845
849
852 typedef std::unique_ptr<base_value_type> unique_type;
853
857
858
862
866
867
869 typedef typename std::reverse_iterator<const_iterator>
871
874 typedef typename std::reverse_iterator<iterator>
876
878
879
880 using Deleter = typename BASE::Deleter;
881
883 static constexpr bool must_own = BASE::must_own;
884
885
886 //========================================================================
889
890
900 SG::IndexTrackingPolicy trackIndices =
902
903
916 explicit DataVector(size_type n, /* value_type pElem = 0,*/
918 SG::IndexTrackingPolicy trackIndices =
920
921
928 // The copy constructor for derived classes is deliberately omitted,
929 // as otherwise we get warnings about not calling the copy constructors
930 // for base classes, which are problematic when we have virtual
931 // inheritance. Most of what needs doing is done in the base class anyway,
932 // except for setting @c m_isMostDerived. We arrange for these flags
933 // to all get set to false; they'll get set correctly when
934 // @c testInsert is called.
935 // Need this to get the default copy ctor defined when a move
936 // ctor is also present.
937 DataVector (const DataVector&) = default;
938
939
946 DataVector (DataVector&& rhs) noexcept;
947
948
961 template <class InputIterator>
962 DataVector(InputIterator first,
963 InputIterator last,
966 SG::IAuxStore* store = 0);
967
968
979 DataVector(std::initializer_list<value_type> l,
982 SG::IAuxStore* store = 0);
983
984
997 DataVector& operator= (const DataVector& rhs);
998
999
1007
1008
1019 DataVector& operator= (std::initializer_list<value_type> l);
1020
1021
1031 template <class InputIterator>
1032 void assign(InputIterator first, InputIterator last);
1033
1034
1042 void assign(std::initializer_list<value_type> l);
1043
1044
1045 // Destructor is inherited.
1046
1047
1049 //========================================================================
1052
1053
1062
1063
1068 // This is inherited from the base class.
1069
1070
1083
1084
1090 // This is inherited from the base class.
1091
1092
1097 // This is inherited from the base class.
1098
1099
1107
1108
1114 // This is inherited from the base class.
1115
1116
1118 //========================================================================
1121
1122
1131 const T* operator[] (size_type n) const;
1132
1133
1143
1144
1154 ElementProxy operator[] (size_type n);
1155
1156
1166
1167
1178
1179
1188
1189
1198
1199
1209
1210
1220
1221
1223 //========================================================================
1226
1227
1237
1238
1248
1249
1259 iterator begin() noexcept;
1260
1261
1271 iterator end() noexcept;
1272
1273
1283
1284
1294
1295
1306
1307
1318
1319
1329
1330
1340
1341
1351
1352
1362
1363
1365 //========================================================================
1368
1369
1383
1384
1397
1398
1415 template <CxxUtils::detail::AllocationFunction<T> F>
1417
1418
1434
1435
1449
1450
1463
1464
1481
1482
1498 template <class InputIterator,
1499 DataVector_detail::enable_if_ptr_itr<InputIterator, T> = true>
1500 void insert(iterator position, InputIterator first, InputIterator last);
1501
1502
1518 template <class InputIterator,
1519 DataVector_detail::enable_if_up_itr<InputIterator, T> = true>
1520 void insert(iterator position, InputIterator first, InputIterator last);
1521
1522
1534 void insert(iterator position, std::initializer_list<value_type> l);
1535
1536
1562 void insertMove (iterator position, DataVector& other);
1563
1564
1566 //========================================================================
1569
1570
1580
1581
1594
1595
1603 void pop_back();
1604
1605
1614 void clear();
1615
1616
1618 //========================================================================
1621
1622
1633 void swap(DataVector& rhs);
1634
1635
1641 static void iter_swap (iterator a, iterator b);
1642
1643
1649 void sort();
1650
1651
1656 template <class COMPARE>
1657 void sort(COMPARE comp);
1658
1659
1660
1662 //========================================================================
1665
1666
1685
1686
1704 void swapElement(iterator pos, value_type newElem, reference oldElem);
1705
1706
1727 std::unique_ptr<base_value_type> newElem,
1728 std::unique_ptr<base_value_type>& oldElem);
1729
1730
1751 std::unique_ptr<base_value_type> newElem,
1752 std::unique_ptr<base_value_type>& oldElem);
1753
1754
1755public:
1764 // This is inherited from the base class.
1765
1766
1771 // This is inherited from the base class.
1772
1773
1784 void clear (SG::OwnershipPolicy ownPolicy);
1785
1786
1798 void clear (SG::OwnershipPolicy ownPolicy,
1799 SG::IndexTrackingPolicy trackIndices);
1800
1801
1813 void clear (std::unique_ptr<Deleter> deleter);
1814
1815
1821 static const DataModel_detail::DVLInfoBase& dvlinfo();
1822
1823
1829 virtual const DataModel_detail::DVLInfoBase& dvlinfo_v() const override;
1830
1831
1843 static
1844 int baseOffset (const std::type_info& ti);
1845
1846
1857 const SG::AuxVectorBase& auxbase() const;
1858
1859
1861 //========================================================================
1862
1863
1864 // Doxygen trick. We want DataVector<T> to show the complete interface,
1865 // including inherited methods. Normally, doxygen would do this.
1866 // But it's not smart enough to figure out our inheritance relationships.
1867 // We can add a function with `fn', but doxygen won't actually
1868 // generate the documentation unless it also sees the declaration.
1869 // So here are declarations which should be visible to doxygen
1870 // but not to C++.
1871#ifndef __cplusplus
1875 [[nodiscard]] bool empty() const noexcept;
1877 void pop_back();
1878 void clear();
1880 SG::OwnershipPolicy ownPolicy() const;
1881 void clear (SG::OwnershipPolicy ownPolicy,
1882 SG::IndexTrackingPolicy trackIndices = SG::DEFAULT_TRACK_INDICES);
1883#endif // not __cplusplus
1884
1885
1888
1889
1900 static
1901 int baseOffset1 (const char* p, const DataVector& dv,
1902 const std::type_info& ti);
1903
1904
1916
1917
1928 void testInsert (const char* op);
1929
1930
1941 void testInsertOol (const char* op);
1942
1943
1944private:
1946 template <class DV>
1947 friend class ConstDataVector;
1948 template <class DV, class ALLOC>
1953
1954
1963 void assignElement (typename BaseContainer::iterator pos, value_type newElem);
1964
1965
1974 void assignElement (typename BaseContainer::iterator pos,
1975 std::unique_ptr<base_value_type> newElem);
1976
1977
1986 void assignBaseElement (typename BaseContainer::iterator pos,
1987 typename BaseContainer::value_type newElem);
1988
1989
2013 void shift (size_t pos, ptrdiff_t offs);
2014
2015
2016public:
2017 // Make this public so we can call it from DVCollectionProxy.
2026 static
2027 const T* do_cast (const typename PtrVector::value_type p);
2028
2029
2038 static
2039 T* do_cast_nc (typename PtrVector::value_type p);
2040
2041
2042private:
2053 virtual const std::type_info& dv_typeid() const override;
2054
2055
2056protected:
2063
2064
2072 virtual void setMostDerived() override;
2073
2074
2075private:
2077
2078
2083
2084
2085 typedef typename
2087};
2088
2089
2090template <class T, class BASE>
2092
2102template <class T>
2104 : public SG::AuxVectorBase
2105{
2106public:
2109
2111 typedef std::true_type isSequence;
2112
2115 typedef std::vector<T*> PtrVector;
2116 typedef std::vector<T*> BaseContainer;
2117
2122 static const bool has_virtual = false;
2123
2124 // Standard types required for the container interface.
2125 typedef T*& reference;
2126 typedef T* const & const_reference;
2127 typedef typename PtrVector::size_type size_type;
2128 typedef typename PtrVector::difference_type difference_type;
2129 typedef T* value_type;
2130 typedef typename PtrVector::allocator_type allocator_type;
2131 typedef T** pointer;
2132 typedef T* const * const_pointer;
2133
2134 typedef const T* const_value_type;
2135
2139
2142 typedef std::unique_ptr<base_value_type> unique_type;
2143
2147
2148
2152
2156
2158 // Note: we can't just use the underlying PtrVector::const_reverse_iterator
2159 // here; otherwise, const_reverse_iterator won't be convertable to
2160 // reverse_iterator.
2161 typedef typename std::reverse_iterator<const_iterator>
2163
2166 typedef typename std::reverse_iterator<iterator>
2168
2170
2171
2176 {
2177 public:
2180 virtual ~Deleter() = default;
2181 virtual void doDelete (value_type p) = 0;
2182 virtual void doDelete (typename PtrVector::iterator first,
2183 typename PtrVector::iterator last) = 0;
2184 };
2185
2186
2188 static constexpr bool must_own = false;
2189
2190
2191 //========================================================================
2194
2195
2207
2208
2221 explicit DataVector
2222 (size_type n, /* value_type pElem = 0,*/
2225
2226
2233 DataVector(const DataVector& rhs);
2234
2235
2242 DataVector (DataVector&& rhs) noexcept;
2243
2244
2257 template <class InputIterator>
2258 DataVector(InputIterator first, InputIterator last,
2261 SG::IAuxStore* store = 0);
2262
2263
2274 DataVector(std::initializer_list<value_type> l,
2277 SG::IAuxStore* store = 0);
2278
2279
2292 DataVector& operator= (const DataVector& rhs);
2293
2294
2302
2303
2314 DataVector& operator= (std::initializer_list<value_type> l);
2315
2316
2326 template <class InputIterator>
2327 void assign(InputIterator first, InputIterator last);
2328
2329
2338 void assign(std::initializer_list<value_type> l);
2339
2340
2350 virtual ~DataVector();
2351
2352
2354 //========================================================================
2357
2358
2363
2364
2371 virtual size_type size_v() const override;
2372
2373
2378
2379
2391
2392
2398
2399
2407 virtual size_type capacity_v() const override;
2408
2409
2413 [[nodiscard]] bool empty() const noexcept;
2414
2415
2422
2423
2430
2431
2433 //========================================================================
2436
2437
2446 const T* operator[] (size_type n) const;
2447
2448
2458
2459
2469 ElementProxy operator[] (size_type n);
2470
2471
2481
2482
2493
2494
2503
2504
2513
2514
2524
2525
2535
2536
2538 //========================================================================
2541
2542
2552
2553
2563
2564
2574 iterator begin() noexcept;
2575
2576
2586 iterator end() noexcept;
2587
2588
2598
2599
2609
2610
2621
2622
2633
2643
2644
2654
2655
2665
2666
2676
2677
2679 //========================================================================
2682
2683
2697
2698
2711
2712
2729 template <CxxUtils::detail::AllocationFunction<T> F>
2731
2732
2748
2749
2763
2764
2777
2778
2795
2796
2812 template <class InputIterator,
2813 DataVector_detail::enable_if_ptr_itr<InputIterator, T> = true>
2814 void insert(iterator position, InputIterator first, InputIterator last);
2815
2816
2832 template <class InputIterator,
2833 DataVector_detail::enable_if_up_itr<InputIterator, T> = true>
2834 void insert(iterator position, InputIterator first, InputIterator last);
2835
2836
2848 void insert(iterator position, std::initializer_list<value_type> l);
2849
2850
2876 void insertMove (iterator position, DataVector& other);
2877
2878
2880 //========================================================================
2883
2884
2894
2895
2908
2909
2916 void pop_back();
2917
2918
2926 void clear();
2927
2928
2930 //========================================================================
2933
2934
2945 void swap(DataVector& rhs);
2946
2947
2953 static void iter_swap (iterator a, iterator b);
2954
2955
2961 void sort();
2962
2963
2969 template <class COMPARE>
2970 void sort(COMPARE comp);
2971
2972
2974 //========================================================================
2977
2978
2997
2998
3016 void swapElement(iterator pos, value_type newElem, reference oldElem);
3017
3018
3039 std::unique_ptr<base_value_type> newElem,
3040 std::unique_ptr<base_value_type>& oldElem);
3041
3042
3062 std::unique_ptr<base_value_type> newElem,
3063 std::unique_ptr<base_value_type>& oldElem);
3064
3065
3066public:
3075
3076
3080 SG::OwnershipPolicy ownPolicy() const;
3081
3082
3092 void clear (SG::OwnershipPolicy ownPolicy);
3093
3094
3105 void clear (SG::OwnershipPolicy ownPolicy,
3106 SG::IndexTrackingPolicy trackIndices);
3107
3108
3120 void clear (std::unique_ptr<Deleter> deleter);
3121
3122
3128 static const DataModel_detail::DVLInfoBase& dvlinfo();
3129
3130
3136 virtual const DataModel_detail::DVLInfoBase& dvlinfo_v() const;
3137
3138
3150 static
3151 int baseOffset (const std::type_info& ti);
3152
3153
3161
3162
3164 //========================================================================
3167
3168
3179 static
3181 const std::type_info& ti);
3182
3183
3195
3196
3207 void testInsert (const char* op);
3208
3209
3220 void testInsertOol (const char* op);
3221
3222
3223private:
3225 template <class DV>
3226 friend class ConstDataVector;
3227 template <class DV, class ALLOC>
3232
3233
3242 void assignElement (typename BaseContainer::iterator pos, value_type newElem);
3243
3244
3254 std::unique_ptr<base_value_type> newElem);
3255
3256
3266 typename BaseContainer::value_type newElem);
3267
3268
3292 void shift (size_t pos, ptrdiff_t offs);
3293
3294
3295public:
3296 // Make this public so we can call it from DVCollectionProxy.
3304 static
3306
3307
3315 static
3317
3318
3319private:
3330 virtual const std::type_info& dv_typeid() const;
3331
3332
3333protected:
3343 typename PtrVector::iterator
3344 erase_base(typename PtrVector::iterator position);
3345
3346
3358 typename PtrVector::iterator
3360 typename PtrVector::iterator last);
3361
3362
3368
3369
3375 void doDelete (typename PtrVector::iterator first,
3376 typename PtrVector::iterator last);
3377
3378
3379protected:
3382 SG::OwnershipPolicy m_ownPolicy;
3383
3386
3389 // This should really be a unique_ptr --- but that causes problems
3390 // with ROOT persistency (even though this is tagged as transient).
3391 Deleter* m_deleter = nullptr;
3392
3393
3400
3401
3409 virtual void setMostDerived();
3410
3411
3412private:
3414
3415
3419 SG::IsMostDerivedFlag m_isMostDerived;
3420
3421
3422 typedef typename
3423 ROOT::Meta::Selection::DataVector<T, DataVector_BASE>::self self;
3424};
3425
3426template <class T>
3428
3429
3440template <class T>
3441bool operator== (const DataVector<T>& a, const DataVector<T>& b);
3442
3443
3445template <class T>
3446bool operator!= (const DataVector<T>& a, const DataVector<T>& b);
3447
3448
3460template <class T>
3461bool operator< (const DataVector<T>& a, const DataVector<T>& b);
3462
3463
3465template <class T>
3466bool operator> (const DataVector<T>& a, const DataVector<T>& b);
3467
3468
3470template <class T>
3471bool operator<= (const DataVector<T>& a, const DataVector<T>& b);
3472
3473
3475template <class T>
3476bool operator>= (const DataVector<T>& a, const DataVector<T>& b);
3477
3478
3480template <class T>
3481void swap (DataVector<T>& a, DataVector<T>& b);
3482
3483
3484namespace ROOT { namespace Meta { namespace Selection {
3485
3486template< class T, class BASE >
3487class DataVector : KeepFirstTemplateArguments< 1 >, SelectNoInstance
3488{
3489
3490public:
3493#ifndef XAOD_STANDALONE
3495 //MN: this causes massive dictionary duplication. Disabling for now.
3496 // ROOT::Meta::Selection::MemberAttributes< kAutoSelected > m_pCont;
3497#endif
3499 ROOT::Meta::Selection::MemberAttributes< kTransient > m_isMostDerived;
3500 ROOT::Meta::Selection::MemberAttributes< kTransient > m_deleter;
3501
3504 ROOT::Meta::Selection::MemberAttributes< kTransient > m_ownPolicy;
3505
3506};
3507
3508}}} // namespace
3509
3510
3512
3513
3520template <class T>
3522{
3523public:
3524 static std::string name();
3525};
3526
3527
3528#ifndef XAOD_STANDALONE
3529
3530
3533#include "AthenaKernel/TopBase.h"
3534
3535
3536namespace SG {
3537
3538
3545template <class T, class U>
3547{
3549 static void init() { DataVector<T>::dvlinfo(); }
3550};
3551
3552
3559template <class T>
3563template <class T>
3567
3568
3569} // namespace SG
3570
3571
3572#endif
3573
3574
3576#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.
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:47
(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
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.
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.
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.
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.
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.
size_type push_new(size_type n, F alloc)
Create and add a number of new elements to the end of the container.
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.
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 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.
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.
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...
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.
Derived DataVector<T>.
Definition DataVector.h:818
IAthenaPoolTestData *const & const_reference
Definition DataVector.h:836
typename DataVectorBase< IAthenaPoolTestData >::Base::allocator_type allocator_type
Definition DataVector.h:840
friend void test2_assignelement1a()
IAthenaPoolTestData * value_type
Definition DataVector.h:839
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:861
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:841
typename DataVectorBase< IAthenaPoolTestData >::Base::size_type size_type
Definition DataVector.h:837
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)
std::reverse_iterator< iterator > reverse_iterator
Definition DataVector.h:875
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:856
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:830
const IAthenaPoolTestData * const_value_type
Definition DataVector.h:844
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:865
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:835
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:838
DataVector & operator=(DataVector &&rhs)
Assignment operator.
const_iterator begin() const noexcept
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition DataVector.h:870
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:821
typename typename DataVectorBase< IAthenaPoolTestData >::Base::Deleter Deleter
Definition DataVector.h:880
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
Definition DataVector.h:829
size_type capacity() const noexcept
std::unique_ptr< base_value_type > unique_type
Definition DataVector.h:852
SG::IsMostDerivedFlag m_isMostDerived
IAthenaPoolTestData *const * const_pointer
Definition DataVector.h:842
typename DataVectorBase< IAthenaPoolTestData >::Base DataVector_BASE
Definition DataVector.h:820
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:848
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:883
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:51
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:615
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:619
Selection rules: declare transient members.
Definition DataVector.h:583
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.
Represent a list of base classes.
Definition Bases.h:79
Traits class to hold derivation information.
Definition Bases.h:115
Marker for the base of the inheritance hierarchy.
Definition DVLNoBase.h:32
Derivation information for DataVector.
Definition DataVector.h:637
DataModel_detail::NoBase Base
Definition DataVector.h:638
Marker to indicate a nonexistent base class.
Definition Bases.h:68
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.
Definition TopBase.h:46
#define protected
Definition testRead.cxx:26
#define private
Definition testRead.cxx:27