ATLAS Offline Software
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 */
62 #ifndef ATHCONTAINERS_CONSTDATAVECTOR_H
63 #define ATHCONTAINERS_CONSTDATAVECTOR_H
64 
66 #include "AthLinks/ElementLink.h"
67 #include <initializer_list>
68 
69 
73 template <class DV>
75  : private DV
76 {
77 public:
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 boost::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.
234  ConstDataVector (const ConstDataVector&) = default;
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 
443  reverse_iterator rend() noexcept;
444 
445 
447  //========================================================================
450 
451 
465 
466 
482 
483 
496  iterator insert(iterator position, value_type pElem);
497 
498 
515 
516 
529  template <class InputIterator>
530  void insert(iterator position, InputIterator first, InputIterator last);
531 
532 
544  value_type push_back(std::unique_ptr<const base_value_type> pElem);
545 
546 
558  iterator insert(iterator position, std::unique_ptr<const base_value_type> pElem);
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 
633  void swap(ConstDataVector& rhs);
634 
635 
641  static void iter_swap (iterator a, iterator b);
642 
643 
645  //========================================================================
648 
649 
650 
668  void swapElement(size_type index, value_type newElem, reference oldElem);
669 
670 
688  void swapElement(iterator pos, value_type newElem, reference oldElem);
689 
690 
711  std::unique_ptr<const base_value_type> newElem,
712  std::unique_ptr<const base_value_type>& oldElem);
713 
714 
735  std::unique_ptr<const base_value_type> newElem,
736  std::unique_ptr<const base_value_type>& oldElem);
737 
738 
739 public:
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 
848 private:
850  //========================================================================
853 
854 
858 
859 
869 
870 
880  std::unique_ptr<const base_value_type> newElem);
881 
882 
891  void
894 
895 
901  static
903 
904 
911 
912 
919 
920 
922 };
923 
924 
925 #ifndef XAOD_STANDALONE
926 
928 
933 template <class DV>
935  : public ClassID_traits<DV>
936 {
937 public:
938  BOOST_STATIC_CONSTANT(bool, s_isConst = true);
939 };
940 
941 
942 namespace SG {
943 
944 
954 template <class DV>
956  : public DVLDataBucket<DV>
957 {
958 public:
964 
965 
971 };
972 
973 
981 template <class DV, class U>
983 {
985  static void init() { DV::dvlinfo(); }
986 };
987 
988 
993 template <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
ConstDataVector::auxbase
const SG::AuxVectorBase & auxbase() const
Convert to AuxVectorBase.
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
ConstDataVector::ConstDataVector
ConstDataVector(size_type n, SG::OwnershipPolicy ownPolicy=SG::OWN_ELEMENTS)
Sized constructor.
ConstDataVector::assign
void assign(InputIterator first, InputIterator last)
Assign from iterators.
ConstDataVector::difference_type
DV::difference_type difference_type
Definition: ConstDataVector.h:80
ConstDataVector::at
ElementProxy at(size_type n)
Access an element, as an lvalue.
ConstDataVector::const_reverse_iterator
DV::const_reverse_iterator const_reverse_iterator
Definition: ConstDataVector.h:86
ConstDataVector::has_virtual
static const bool has_virtual
This needs to be forwarded from the base as well.
Definition: ConstDataVector.h:102
PlotCalibFromCool.dv
dv
Definition: PlotCalibFromCool.py:762
SG
Forward declaration.
Definition: CaloCellPacker_400_500.h:32
ConstDataVector::DVL_BASE
DV::DVL_BASE DVL_BASE
Definition: ConstDataVector.h:84
ConstDataVector::iterator
DataModel_detail::iterator< ConstDataVector > iterator
The iterator for this type.
Definition: ConstDataVector.h:113
ConstDataVector::to_base_iterator
static DV::iterator to_base_iterator(iterator it)
Convert a ConstDataVector::iterator to an iterator of the base DataVector.
ConstDataVector::pointer
DV::const_value_type * pointer
Definition: ConstDataVector.h:97
SG::VIEW_ELEMENTS
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Definition: OwnershipPolicy.h:18
ConstDataVector::end
iterator end() noexcept
Return an iterator pointing past the end of the collection.
ConstDataVector::to_my_iterator
iterator to_my_iterator(typename DV::iterator it)
Convert an iterator of the base DataVector to a ConstDataVector::iterator.
index
Definition: index.py:1
ConstDataVector::reference
DV::const_value_type & reference
Definition: ConstDataVector.h:95
ConstDataVector::must_own
static constexpr bool must_own
If true, then this type must own its contents.
Definition: ConstDataVector.h:124
ConstDataVector::swapElement
void swapElement(size_type index, value_type newElem, reference oldElem)
Swap one element out of the container.
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
skel.it
it
Definition: skel.GENtoEVGEN.py:396
taskman.template
dictionary template
Definition: taskman.py:317
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:158
reference
Definition: hcg.cxx:437
const
bool const RAWDATA *ch2 const
Definition: LArRodBlockPhysicsV0.cxx:560
SG::DVLConstDataVectorBucket
DataBucket class for ConstDataVector.
Definition: ConstDataVector.h:957
ConstDataVector::assign
void assign(const std::vector< ElementLink< CONTAINER > > &v)
Assign from a vector of ElementLinks.
ConstDataVector::ElementProxy
DataModel_detail::ElementProxy< ConstDataVector > ElementProxy
This type is used to proxy lvalue accesses to DataVector elements, in order to handle ownership.
Definition: ConstDataVector.h:110
ConstDataVector::asDataVector
const DV * asDataVector() const
Return a pointer to this object, as a const DataVector.
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
ConstDataVector::front
ElementProxy front()
Access the first element in the collection as an lvalue.
SG::OwnershipPolicy
OwnershipPolicy
describes the possible element ownership policies (see e.g. DataVector)
Definition: OwnershipPolicy.h:16
SG::DVLConstDataVectorBucket::DVLConstDataVectorBucket
DVLConstDataVectorBucket(std::unique_ptr< ConstDataVector< DV > > data)
Constructor from a payload object.
ConstDataVector::BaseContainer
DV::BaseContainer BaseContainer
Definition: ConstDataVector.h:83
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
ConstDataVector::clear
void clear()
Erase all the elements in the collection.
ConstDataVector::base_data_vector
DataVector< base_value_type > base_data_vector
Definition: ConstDataVector.h:89
DataModel_detail::iterator
(Non-const) Iterator class for DataVector/DataList.
Definition: DVLIterator.h:184
lumiFormat.i
int i
Definition: lumiFormat.py:85
SG::OWN_ELEMENTS
@ OWN_ELEMENTS
this data object owns its elements
Definition: OwnershipPolicy.h:17
ClassID_traits.h
a traits class that associates a CLID to a type T It also detects whether T inherits from Gaudi DataO...
beamspotman.n
n
Definition: beamspotman.py:731
ConstDataVector::swap
void swap(ConstDataVector &rhs)
Swap this collection with another.
ConstDataVector::back
ElementProxy back()
Access the last element in the collection as an lvalue.
ConstDataVector::assign
void assign(std::initializer_list< value_type > l)
Assign from an initializer list.
ConstDataVector::emplace
iterator emplace(iterator position, value_type pElem)
Add a new element to the collection.
ClassID_traits
Default, invalid implementation of ClassID_traits.
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:40
ConstDataVector::to_element_proxy
ElementProxy to_element_proxy(typename BaseContainer::iterator i)
Convert an iterator of the base vector to an ElementProxy for the ConstDataVector.
SG::BaseInfo
Provide an interface for finding inheritance information at run time.
Definition: Control/AthenaKernel/AthenaKernel/BaseInfo.h:751
ConstDataVector::test2_assignelement1a
friend void test2_assignelement1a()
SG::DataBucketTrait< ConstDataVector< DV >, U >::init
static void init()
Definition: ConstDataVector.h:985
ConstDataVector::ConstDataVector
ConstDataVector(const std::vector< ElementLink< CONTAINER > > &v)
Constructor from a vector of ElementLinks.
ConstDataVector::size_type
DV::size_type size_type
Basic types, forwarded from the base.
Definition: ConstDataVector.h:79
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
ConstDataVector::const_value_type
DV::const_value_type const_value_type
Definition: ConstDataVector.h:94
ConstDataVector::operator[]
ElementProxy operator[](size_type n)
Access an element, as an lvalue.
DataModel_detail
Definition: CompareAndPrint.h:15
ConstDataVector::const_reference
DV::const_value_type const & const_reference
Definition: ConstDataVector.h:96
SG::DataBucketTrait< ConstDataVector< DV >, U >::type
SG::DVLConstDataVectorBucket< DV > type
Definition: ConstDataVector.h:984
ConstDataVector::const_iterator
DV::const_iterator const_iterator
Definition: ConstDataVector.h:85
ConstDataVector::unique_type
std::unique_ptr< const base_value_type > unique_type
Type of a unique_ptr that can be used to insert elements into this container.
Definition: ConstDataVector.h:106
ConstDataVector::ConstDataVector
ConstDataVector(InputIterator first, InputIterator last, SG::OwnershipPolicy ownPolicy=SG::VIEW_ELEMENTS)
Constructor from iterators.
ConstDataVector::ConstDataVector
ConstDataVector(std::initializer_list< value_type > l, SG::OwnershipPolicy ownPolicy=SG::VIEW_ELEMENTS)
Constructor from an initializer list.
ConstDataVector::iter_swap
static void iter_swap(iterator a, iterator b)
Swap the referents of two DataVector iterators.
private
#define private
Definition: DetDescrConditionsDict_dict_fixes.cxx:13
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
ConstDataVector::ConstDataVector
ConstDataVector(const ConstDataVector &)=default
Copy constructor.
ConstDataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
ConstDataVector::ConstDataVector
ConstDataVector(SG::OwnershipPolicy ownPolicy, ARGS &&... args)
Constructor with argument forwarding.
python.Dumpers.typename
def typename(t)
Definition: Dumpers.py:194
ConstDataVector::rend
reverse_iterator rend() noexcept
Return a reverse_iterator pointing at the beginning of the collection.
ConstDataVector::assignElement
void assignElement(typename BaseContainer::iterator pos, value_type newElem)
Handle element assignment.
ConstDataVector::insert
iterator insert(iterator position, value_type pElem)
Add a new element to the collection.
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
python.PyAthena.v
v
Definition: PyAthena.py:154
ConstDataVector::allocator_type
DV::allocator_type allocator_type
Definition: ConstDataVector.h:81
ConstDataVector::ConstDataVector
ConstDataVector(ConstDataVector &&rhs)
Move constructor.
DataVector.h
An STL vector of pointers that by default owns its pointed-to elements.
ConstDataVector::assignBaseElement
void assignBaseElement(typename BaseContainer::iterator pos, typename BaseContainer::value_type newElem)
Handle element assignment from a base pointer.
a
TList * a
Definition: liststreamerinfos.cxx:10
SG::DVLDataBucket
A DataBucket specialized for DataVector/DataList.
Definition: DVLDataBucket.h:49
ConstDataVector::emplace_back
value_type emplace_back(value_type pElem)
Add an element to the end of the collection.
ConstDataVector::fromDataVector
static const ConstDataVector * fromDataVector(const DV *dv)
Cast from a DataVector to a ConstDataVector.
ConstDataVector
DataVector adapter that acts like it holds const pointers.
Definition: ConstDataVector.h:76
DeMoScan.first
bool first
Definition: DeMoScan.py:536
ConstDataVector::operator=
ConstDataVector & operator=(const ConstDataVector &rhs)
Assignment operator.
ConstDataVector::base_value_type
DV::base_value_type base_value_type
Definition: ConstDataVector.h:82
ConstDataVector::test2_assignelement1
friend void test2_assignelement1()
ConstDataVector::erase
iterator erase(iterator position)
Remove element at a given position.
ConstDataVector::rbegin
reverse_iterator rbegin() noexcept
Return a reverse_iterator pointing past the end of the collection.
SG::DVLConstDataVectorBucket::DVLConstDataVectorBucket
DVLConstDataVectorBucket(ConstDataVector< DV > *data)
Constructor from a payload object.
ClassID_traits< ConstDataVector< DV > >::BOOST_STATIC_CONSTANT
BOOST_STATIC_CONSTANT(bool, s_isConst=true)
ConstDataVector::const_pointer
DV::const_value_type const * const_pointer
Definition: ConstDataVector.h:98
DataModel_detail::ElementProxy
Proxy for lvalue access to DataVector/DataList elements.
Definition: ElementProxy.h:54
ConstDataVector::resortAux
void resortAux(iterator, iterator)
Reset indices / reorder aux data after elements have been permuted.
SG::DataBucketTrait
Metafunction to find the proper DataBucket class for T.
Definition: DataBucketTraitFwd.h:30
ConstDataVector::reverse_iterator
std::reverse_iterator< iterator > reverse_iterator
Standard reverse_iterator.
Definition: ConstDataVector.h:118
value_type
Definition: EDM_MasterSearch.h:11
ConstDataVector.icc
ConstDataVector::begin
iterator begin() noexcept
Return an iterator pointing at the beginning of the collection.
SG::IndexTrackingPolicy
IndexTrackingPolicy
Definition: IndexTrackingPolicy.h:37
xAOD::BaseContainer
DataVector< SG::AuxElement > BaseContainer
Definition: BaseContainer.h:7
ConstDataVector::ConstDataVector
ConstDataVector(SG::OwnershipPolicy ownPolicy=SG::OWN_ELEMENTS)
Default constructor.
python.CaloScaleNoiseConfig.args
args
Definition: CaloScaleNoiseConfig.py:80
ConstDataVector::value_type
DV::const_value_type value_type
These types get modified so that the base's const_value_type becomes our value_type.
Definition: ConstDataVector.h:93
ConstDataVector::isSequence
boost::true_type isSequence
Definition: ConstDataVector.h:120