00001
00002
00060 #ifndef ATHCONTAINERS_CONSTDATAVECTOR_H
00061 #define ATHCONTAINERS_CONSTDATAVECTOR_H
00062
00063 #include "AthContainers/DataVector.h"
00064 #if __cplusplus > 201100
00065 #include <initializer_list>
00066 #endif
00067
00068
00072 template <class DV>
00073 class ConstDataVector
00074 : private DV
00075 {
00076 public:
00078 typedef typename DV::size_type size_type;
00079 typedef typename DV::difference_type difference_type;
00080 typedef typename DV::allocator_type allocator_type;
00081 typedef typename DV::base_value_type base_value_type;
00082 typedef typename DV::BaseContainer BaseContainer;
00083 typedef typename DV::DVL_BASE DVL_BASE;
00084 typedef typename DV::const_iterator const_iterator;
00085 typedef typename DV::const_reverse_iterator const_reverse_iterator;
00086
00087
00088 typedef DataVector<base_value_type> base_data_vector;
00089
00092 typedef typename DV::const_value_type value_type;
00093 typedef typename DV::const_value_type const_value_type;
00094 typedef typename DV::const_value_type & reference;
00095 typedef typename DV::const_value_type const & const_reference;
00096 typedef typename DV::const_value_type * pointer;
00097 typedef typename DV::const_value_type const * const_pointer;
00098
00100 static const bool has_virtual = DV::has_virtual;
00101
00104 typedef DataModel_detail::ElementProxy<ConstDataVector> ElementProxy;
00105
00107 typedef typename DataModel_detail::iterator<ConstDataVector> iterator;
00108
00111 typedef typename std::reverse_iterator<iterator>
00112 reverse_iterator;
00113
00116 using DV::size;
00117 using DV::max_size;
00118 using DV::resize;
00119 using DV::capacity;
00120 using DV::empty;
00121 using DV::reserve;
00122 using DV::pop_back;
00123 using DV::sort;
00124 using DV::ownPolicy;
00125 using DV::trackIndices;
00126 using DV::testInsert;
00127 using DV::getConstStore;
00128 using DV::setStore;
00129 using DV::setConstStore;
00130 using DV::setNonConstStore;
00131 using DV::cbegin;
00132 using DV::cend;
00133 using DV::crbegin;
00134 using DV::crend;
00135 #if __cplusplus > 201100
00136 using DV::shrink_to_fit;
00137 #endif
00138
00139
00143 using DV::begin;
00144 using DV::end;
00145 using DV::rbegin;
00146 using DV::rend;
00147 using DV::front;
00148 using DV::back;
00149 using DV::operator[];
00150 using DV::at;
00151
00152
00153
00156
00157
00165 explicit ConstDataVector(SG::OwnershipPolicy ownPolicy = SG::OWN_ELEMENTS);
00166
00167
00179 explicit ConstDataVector(size_type n,
00180 SG::OwnershipPolicy ownPolicy = SG::OWN_ELEMENTS);
00181
00182
00193 template <class InputIterator>
00194 ConstDataVector(InputIterator first, InputIterator last,
00195 SG::OwnershipPolicy ownPolicy = SG::VIEW_ELEMENTS);
00196
00197
00204
00205
00206
00207
00208
00209
00210
00211 #if __cplusplus > 201100
00212
00213
00214 ConstDataVector (const ConstDataVector&) = default;
00215 #endif
00216
00217
00218 #if __cplusplus > 201100
00219
00225 ConstDataVector (ConstDataVector&& rhs);
00226
00227
00237 ConstDataVector(std::initializer_list<value_type> l,
00238 SG::OwnershipPolicy ownPolicy = SG::VIEW_ELEMENTS);
00239 #endif
00240
00241
00254 ConstDataVector& operator= (const ConstDataVector& rhs) ;
00255
00256
00257 #if __cplusplus > 201100
00258
00264 ConstDataVector& operator= (ConstDataVector&& rhs);
00265
00266
00277 ConstDataVector& operator= (std::initializer_list<value_type> l);
00278 #endif
00279
00280
00290 template <class InputIterator>
00291 void assign(InputIterator first, InputIterator last);
00292
00293
00294 #if __cplusplus > 201100
00295
00303 void assign(std::initializer_list<value_type> l);
00304 #endif
00305
00306
00308
00311
00312
00322 ElementProxy operator[] (size_type n);
00323
00324
00334 ElementProxy at (size_type n);
00335
00336
00345 ElementProxy front ();
00346
00347
00356 ElementProxy back ();
00357
00358
00360
00363
00364
00374 iterator begin();
00375
00376
00386 iterator end();
00387
00388
00398 reverse_iterator rbegin();
00399
00400
00410 reverse_iterator rend();
00411
00412
00414
00417
00418
00429 void push_back(value_type pElem);
00430
00431
00445 void emplace_back(value_type pElem);
00446
00447
00460 iterator insert(iterator position, value_type pElem);
00461
00462
00478 iterator emplace(iterator position, value_type pElem);
00479
00480
00493 template <class InputIterator>
00494 void insert(iterator position, InputIterator first, InputIterator last);
00495
00496
00497 #if __cplusplus > 201100
00498 #ifndef __REFLEX__
00499
00508 void push_back(std::unique_ptr<const base_value_type> pElem);
00509
00510
00522 iterator insert(iterator position, std::unique_ptr<const base_value_type> pElem);
00523 #endif
00524
00525
00537 void insert(iterator position, std::initializer_list<value_type> l);
00538 #endif
00539
00540
00542
00545
00546
00555 iterator erase(iterator position);
00556
00557
00569 iterator erase(iterator first, iterator last);
00570
00571
00579 void clear();
00580
00581
00583
00586
00587
00598 void swap(ConstDataVector& rhs);
00599
00600
00606 static void iter_swap (iterator a, iterator b);
00607
00608
00610
00613
00614
00615
00633 void swapElement(size_type index, value_type newElem, reference oldElem);
00634
00635
00653 void swapElement(iterator pos, value_type newElem, reference oldElem);
00654
00655
00656 #if __cplusplus > 201100
00657 #ifndef __REFLEX__
00658
00677 void swapElement(size_type index,
00678 std::unique_ptr<const base_value_type> newElem,
00679 std::unique_ptr<const base_value_type>& oldElem);
00680
00681
00701 void swapElement(iterator pos,
00702 std::unique_ptr<const base_value_type> newElem,
00703 std::unique_ptr<const base_value_type>& oldElem);
00704 #endif
00705 #endif
00706
00707
00708 public:
00712 const DV* asDataVector() const;
00713
00714
00722 void resortAux (iterator , iterator );
00723
00724
00734 void clear (SG::OwnershipPolicy ownPolicy);
00735
00736
00743 const SG::AuxVectorBase& auxbase() const;
00744
00745
00747
00750
00751
00763 bool operator< (const ConstDataVector& b) const;
00764
00766 bool operator> (const ConstDataVector& b) const;
00767
00769 bool operator<= (const ConstDataVector& b) const;
00770
00772 bool operator>= (const ConstDataVector& b) const;
00773
00774
00785 bool operator== (const ConstDataVector& b) const;
00786
00788 bool operator!= (const ConstDataVector& b) const;
00789
00790
00791
00792 private:
00794
00797
00798
00799 friend class DataModel_detail::ElementProxy<ConstDataVector>;
00800 friend void test2_assignelement1<ConstDataVector>();
00801
00802
00811 void assignElement (typename BaseContainer::iterator pos, value_type newElem);
00812
00813
00814 #if __cplusplus > 201100
00815 #ifndef __REFLEX__
00816
00824 void assignElement (typename BaseContainer::iterator pos,
00825 std::unique_ptr<const base_value_type> newElem);
00826 #endif
00827 #endif
00828
00829
00838 void
00839 assignBaseElement (typename BaseContainer::iterator pos,
00840 typename BaseContainer::value_type newElem);
00841
00842
00848 static
00849 typename DV::iterator to_base_iterator (iterator it);
00850
00851
00857 iterator to_my_iterator (typename DV::iterator it);
00858
00859
00865 ElementProxy to_element_proxy (typename BaseContainer::iterator i);
00866
00867
00869 };
00870
00871
00872 #ifndef XAOD_STANDALONE
00873
00874 #include "SGTools/ClassID_traits.h"
00875
00880 template <class DV>
00881 struct ClassID_traits<ConstDataVector<DV> >
00882 : public ClassID_traits<DV>
00883 {
00884 public:
00885 BOOST_STATIC_CONSTANT(bool, s_isConst = true);
00886 };
00887
00888
00889 namespace SG {
00890
00891
00901 template <class DV>
00902 class DVLConstDataVectorBucket
00903 : public DVLDataBucket<DV>
00904 {
00905 public:
00910 DVLConstDataVectorBucket (ConstDataVector<DV>* data);
00911
00912
00913 #if __cplusplus > 201100
00914
00918 DVLConstDataVectorBucket (std::unique_ptr<ConstDataVector<DV> > data);
00919 #endif
00920 };
00921
00922
00930 template <class DV, class U>
00931 struct DataBucketTrait<ConstDataVector<DV>, U>
00932 {
00933 typedef SG::DVLConstDataVectorBucket<DV> type;
00934 static void init() { DV::dvlinfo(); }
00935 };
00936
00937
00942 template <class DV>
00943 class BaseInfo<ConstDataVector<DV> >
00944 : public BaseInfo<DV>
00945 {
00946 };
00947
00948
00949 }
00950
00951
00952 #endif // not XAOD_STANDALONE
00953
00954
00955 #include "AthContainers/ConstDataVector.icc"
00956
00957
00958 #endif // not ATHCONTAINERS_CONSTDATAVECTOR_H