ATLAS Offline Software
Loading...
Searching...
No Matches
ConstDataVector.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 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
4*/
60
61
62#ifndef ATHCONTAINERS_CONSTDATAVECTOR_H
63#define ATHCONTAINERS_CONSTDATAVECTOR_H
64
66#include "AthLinks/ElementLink.h"
67#include <initializer_list>
68#include <type_traits>
69
73template <class DV>
75 : private DV
76{
77public:
79 typedef typename DV::size_type size_type;
80 typedef typename DV::difference_type difference_type;
81 typedef typename DV::allocator_type allocator_type;
82 typedef typename DV::base_value_type base_value_type;
83 typedef typename DV::BaseContainer BaseContainer;
84 typedef typename DV::DVL_BASE DVL_BASE;
85 typedef typename DV::const_iterator const_iterator;
86 typedef typename DV::const_reverse_iterator const_reverse_iterator;
87
88 // Not necessarily DV; DV may be an intermediate class.
90
93 typedef typename DV::const_value_type value_type;
94 typedef typename DV::const_value_type const_value_type;
95 typedef typename DV::const_value_type & reference;
96 typedef typename DV::const_value_type const & const_reference;
97 typedef typename DV::const_value_type * pointer;
98 typedef typename DV::const_value_type const * const_pointer;
99
101 // cppcheck-suppress duplInheritedMember
102 static const bool has_virtual = DV::has_virtual;
103
106 typedef std::unique_ptr<const base_value_type> unique_type;
107
111
114
117 typedef typename std::reverse_iterator<iterator>
119
120 typedef std::true_type isSequence;
121
123 // cppcheck-suppress duplInheritedMember
124 static constexpr bool must_own = DV::must_own;
125
126
129 using DV::size;
130 using DV::max_size;
131 using DV::resize;
132 using DV::capacity;
133 using DV::empty;
134 using DV::reserve;
135 using DV::pop_back;
136 using DV::sort;
137 using DV::ownPolicy;
138 using DV::trackIndices;
139 using DV::testInsert;
140 using DV::getConstStore;
141 using DV::setStore;
142 using DV::setConstStore;
143 using DV::setNonConstStore;
144 using DV::cbegin;
145 using DV::cend;
146 using DV::crbegin;
147 using DV::crend;
148 using DV::shrink_to_fit;
149
150
154 using DV::begin;
155 using DV::end;
156 using DV::rbegin;
157 using DV::rend;
158 using DV::front;
159 using DV::back;
160 using DV::operator[];
161 using DV::at;
162
163
164 //========================================================================
167
168
177
178
185 template <typename... ARGS>
186 explicit ConstDataVector(SG::OwnershipPolicy ownPolicy, ARGS&&... args);
187
188
202
203
214 template <class InputIterator>
215 ConstDataVector(InputIterator first, InputIterator last,
217
218
225 // The copy constructor for derived classes is deliberately omitted,
226 // as otherwise we get warnings about not calling the copy constructors
227 // for base classes, which are problematic when we have virtual
228 // inheritance. Most of what needs doing is done in the base class anyway,
229 // except for setting @c m_isMostDerived. We arrange for these flags
230 // to all get set to false; they'll get set correctly when
231 // @c testInsert is called.
232 // Need this to get the default copy ctor defined when a move
233 // ctor is also present.
235
236
244
245
255 ConstDataVector(std::initializer_list<value_type> l,
257
258
265 template <class CONTAINER>
266 ConstDataVector (const std::vector<ElementLink<CONTAINER> >& v);
267
268
282
283
291
292
303 ConstDataVector& operator= (std::initializer_list<value_type> l);
304
305
315 template <class InputIterator>
316 void assign(InputIterator first, InputIterator last);
317
318
327 void assign(std::initializer_list<value_type> l);
328
329
336 template <class CONTAINER>
337 void assign (const std::vector<ElementLink<CONTAINER> >& v);
338
339
341 //========================================================================
344
345
356
357
368
369
379
380
390
391
393 //========================================================================
396
397
407 iterator begin() noexcept;
408
409
419 iterator end() noexcept;
420
421
432
433
444
445
447 //========================================================================
450
451
465
466
482
483
497
498
515
516
529 template <class InputIterator>
530 void insert(iterator position, InputIterator first, InputIterator last);
531
532
545
546
559
560
572 void insert(iterator position, std::initializer_list<value_type> l);
573
574
576 //========================================================================
579
580
590
591
604
605
613 // cppcheck-suppress duplInheritedMember
614 void clear();
615
616
618 //========================================================================
621
622
634
635
641 static void iter_swap (iterator a, iterator b);
642
643
645 //========================================================================
648
649
650
669
670
688 void swapElement(iterator pos, value_type newElem, reference oldElem);
689
690
713
714
737
738
739public:
744
745
752 static
754
755
763 void resortAux (iterator /*beg*/, iterator /*end*/);
764
765
775 // cppcheck-suppress duplInheritedMember
776 void clear (SG::OwnershipPolicy ownPolicy);
777
778
790 // cppcheck-suppress duplInheritedMember
791 void clear (SG::OwnershipPolicy ownPolicy,
792 SG::IndexTrackingPolicy trackIndices);
793
794
801 const SG::AuxVectorBase& auxbase() const;
802
803
805 //========================================================================
808
809
820 bool operator< (const ConstDataVector& b) const;
821
823 bool operator> (const ConstDataVector& b) const;
824
826 bool operator<= (const ConstDataVector& b) const;
827
829 bool operator>= (const ConstDataVector& b) const;
830
831
841 bool operator== (const ConstDataVector& b) const;
842
844 bool operator!= (const ConstDataVector& b) const;
845
846
847
848private:
850 //========================================================================
853
854
858
859
868 void assignElement (typename BaseContainer::iterator pos, value_type newElem);
869
870
881
882
891 void
893 typename BaseContainer::value_type newElem);
894
895
901 static
903
904
911
912
919
920
922};
923
924
925#ifndef XAOD_STANDALONE
926
928
933template <class DV>
935 : public ClassID_traits<DV>
936{
937public:
938 static constexpr bool s_isConst = true;
939};
940
941
942namespace SG {
943
944
954template <class DV>
972
973
981template <class DV, class U>
983{
985 static void init() { DV::dvlinfo(); }
986};
987
988
993template <class DV>
995 : public BaseInfo<DV>
996{
997};
998
999
1000} // namespace SG
1001
1002
1003#endif // not XAOD_STANDALONE
1004
1005
1007
1008
1009#endif // not ATHCONTAINERS_CONSTDATAVECTOR_H
a traits class that associates a CLID to a type T It also detects whether T inherits from Gaudi DataO...
An STL vector of pointers that by default owns its pointed-to elements.
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
static Double_t a
DataVector adapter that acts like it holds const pointers.
DV::size_type size_type
Basic types, forwarded from the base.
reverse_iterator rbegin() noexcept
friend void test2_assignelement1a()
DV::const_value_type * pointer
friend void test2_assignelement1()
void resortAux(iterator, iterator)
value_type push_back(value_type pElem)
DV::base_value_type base_value_type
ConstDataVector(ConstDataVector &&rhs)
Move constructor.
ElementProxy front()
Access the first element in the collection as an lvalue.
DataVector< base_value_type > base_data_vector
ConstDataVector(SG::OwnershipPolicy ownPolicy=SG::OWN_ELEMENTS)
Default constructor.
iterator begin() noexcept
Return an iterator pointing at the beginning of the collection.
iterator end() noexcept
iterator to_my_iterator(typename T::iterator it)
ConstDataVector(SG::OwnershipPolicy ownPolicy, ARGS &&... args)
Constructor with argument forwarding.
ElementProxy at(size_type n)
Access an element, as an lvalue.
DataModel_detail::ElementProxy< ConstDataVector > ElementProxy
This type is used to proxy lvalue accesses to DataVector elements, in order to handle ownership.
std::true_type isSequence
DV::DVL_BASE DVL_BASE
ConstDataVector(std::initializer_list< value_type > l, SG::OwnershipPolicy ownPolicy=SG::VIEW_ELEMENTS)
Constructor from an initializer list.
std::unique_ptr< const base_value_type > unique_type
Type of a unique_ptr that can be used to insert elements into this container.
ElementProxy to_element_proxy(typename BaseContainer::iterator i)
static const bool has_virtual
iterator erase(iterator position)
value_type emplace_back(value_type pElem)
static const ConstDataVector * fromDataVector(const T *dv)
DV::const_value_type value_type
These types get modified so that the base's const_value_type becomes our value_type.
static T::iterator to_base_iterator(iterator it)
void assignElement(typename BaseContainer::iterator pos, value_type newElem)
iterator insert(iterator position, value_type pElem)
void swapElement(size_type index, value_type newElem, reference oldElem)
const SG::AuxVectorBase & auxbase() const
ElementProxy back()
Access the last element in the collection as an lvalue.
reverse_iterator rend() noexcept
const T * asDataVector() const
DV::const_iterator const_iterator
DV::allocator_type allocator_type
void assign(std::initializer_list< value_type > l)
Assign from an initializer list.
DV::BaseContainer BaseContainer
ConstDataVector(size_type n, SG::OwnershipPolicy ownPolicy=SG::OWN_ELEMENTS)
Sized constructor.
static constexpr bool must_own
ConstDataVector(InputIterator first, InputIterator last, SG::OwnershipPolicy ownPolicy=SG::VIEW_ELEMENTS)
Constructor from iterators.
DataModel_detail::iterator< ConstDataVector > iterator
The iterator for this type.
ElementProxy operator[](size_type n)
Access an element, as an lvalue.
void assign(InputIterator first, InputIterator last)
Assign from iterators.
ConstDataVector(const ConstDataVector &)=default
Copy constructor.
DV::const_value_type const & const_reference
DV::const_value_type const * const_pointer
DV::const_reverse_iterator const_reverse_iterator
std::reverse_iterator< iterator > reverse_iterator
Standard reverse_iterator.
ConstDataVector & operator=(const ConstDataVector &rhs)
Assignment operator.
ConstDataVector(const std::vector< ElementLink< CONTAINER > > &v)
Constructor from a vector of ElementLinks.
void swap(ConstDataVector &rhs)
void assign(const std::vector< ElementLink< CONTAINER > > &v)
Assign from a vector of ElementLinks.
static void iter_swap(iterator a, iterator b)
DV::difference_type difference_type
void assignBaseElement(typename BaseContainer::iterator pos, typename BaseContainer::value_type newElem)
DV::const_value_type const_value_type
DV::const_value_type & reference
iterator emplace(iterator position, value_type pElem)
Proxy for lvalue access to DataVector/DataList elements.
(Non-const) Iterator class for DataVector/DataList.
Derived DataVector<T>.
Definition DataVector.h:795
Provide an interface for finding inheritance information at run time.
DataBucket class for ConstDataVector.
DVLConstDataVectorBucket(ConstDataVector< DV > *data)
Constructor from a payload object.
DVLConstDataVectorBucket(std::unique_ptr< ConstDataVector< DV > > data)
Constructor from a payload object.
STL class.
Forward declaration.
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.
Default, invalid implementation of ClassID_traits.
SG::DVLConstDataVectorBucket< DV > type
Metafunction to find the proper DataBucket class for T.
#define private