00001
00002
00011 #ifndef ATHCONTAINERS_AUXVECTORBASE_H
00012 #define ATHCONTAINERS_AUXVECTORBASE_H
00013
00014
00015 #include "AthContainers/AuxVectorData.h"
00016 #include "AthContainers/OwnershipPolicy.h"
00017 #include "AthContainers/IndexTrackingPolicy.h"
00018 #include "AthContainers/AuxElement.h"
00019 #include "AthContainers/AuxTypeRegistry.h"
00020 #include "AthContainers/exceptions.h"
00021 #include "AthContainers/tools/ATHCONTAINERS_ASSERT.h"
00022 #include "AthContainersInterfaces/IAuxStore.h"
00023 #include "AthContainersInterfaces/AuxStore_traits.h"
00024 #include <vector>
00025
00026
00027 namespace SG {
00028
00029
00092 class AuxVectorBase
00093 : public AuxVectorData
00094 {
00095 public:
00105 AuxVectorBase();
00106
00107
00108 #if __cplusplus > 201100
00109
00113 AuxVectorBase (AuxVectorBase&& rhs);
00114
00115
00120 AuxVectorBase& operator= (AuxVectorBase&& rhs);
00121 #endif
00122
00123
00127 virtual ~AuxVectorBase();
00128
00129
00133 bool trackIndices() const;
00134
00135
00146 void setStore (const SG::IConstAuxStore* store);
00147
00148
00159 void setStore (SG::IAuxStore* store);
00160
00161
00172 void setStore (const DataLink< SG::IConstAuxStore >& store);
00173
00174
00179 void setConstStore (const SG::IConstAuxStore* store);
00180
00181
00186 void setNonConstStore (SG::IAuxStore* store);
00187
00188
00189 protected:
00203 template <class DVL>
00204 void initAuxVectorBase (SG::OwnershipPolicy ownPolicy,
00205 SG::IndexTrackingPolicy indexTrackingPolicy);
00206
00207
00212 void swap (AuxVectorBase& other);
00213
00214
00227 template <class ForwardIterator>
00228 void setIndices (ForwardIterator beg,
00229 ForwardIterator end,
00230 size_t first = 0);
00231
00232
00240 template <class ForwardIterator>
00241 void clearIndex (ForwardIterator elt);
00242
00243
00252 template <class ForwardIterator>
00253 void clearIndices (ForwardIterator beg, ForwardIterator end);
00254
00255
00262 template <class DVL>
00263 void resize (size_t size);
00264
00265
00272 template <class DVL>
00273 void reserve (size_t size);
00274
00275
00301 template <class DVL>
00302 void shift (DVL& cont, size_t pos, ptrdiff_t offs);
00303
00304
00316 void moveAux (size_t index, SG::AuxElement* p, bool clear = false);
00317
00318
00328 void moveAux (size_t index, const void* p, bool clear = false);
00329
00330
00345 template <class ForwardIterator>
00346 void moveAux (size_t index, ForwardIterator beg, ForwardIterator end);
00347
00348
00362 void swapElementsAux (size_t aindex,
00363 size_t bindex,
00364 SG::AuxElement* a,
00365 SG::AuxElement* b,
00366 AuxVectorBase* bcont);
00367
00368
00381 void swapElementsAux (size_t aindex,
00382 size_t bindex,
00383 const void* a,
00384 const void* b,
00385 AuxVectorBase* bcont);
00386
00387
00402 template <class ForwardIterator>
00403 void resortAux (size_t index,
00404 ForwardIterator beg,
00405 ForwardIterator end);
00406
00407
00408 private:
00418 void initAuxVectorBase1 (const SG_STD_OR_BOOST::false_type&,
00419 SG::OwnershipPolicy ,
00420 SG::IndexTrackingPolicy );
00421
00422
00432 void initAuxVectorBase1 (const SG_STD_OR_BOOST::true_type&,
00433 SG::OwnershipPolicy ownPolicy,
00434 SG::IndexTrackingPolicy indexTrackingPolicy);
00435
00436
00446 template <class ForwardIterator>
00447 void setIndices1 (const SG_STD_OR_BOOST::false_type&,
00448 ForwardIterator beg,
00449 ForwardIterator end,
00450 size_t first);
00451
00452
00463 template <class ForwardIterator>
00464 void setIndices1 (const SG_STD_OR_BOOST::true_type&,
00465 ForwardIterator beg,
00466 ForwardIterator end,
00467 size_t first);
00468
00469
00477 template <class ForwardIterator>
00478 void clearIndex1 (const SG_STD_OR_BOOST::false_type&, ForwardIterator elt);
00479
00480
00487 template <class ForwardIterator>
00488 void clearIndex1 (const SG_STD_OR_BOOST::true_type&, ForwardIterator elt);
00489
00490
00498 template <class ForwardIterator>
00499 void clearIndices1 (const SG_STD_OR_BOOST::false_type&,
00500 ForwardIterator,
00501 ForwardIterator);
00502
00503
00511 template <class ForwardIterator>
00512 void clearIndices1 (const SG_STD_OR_BOOST::true_type&,
00513 ForwardIterator beg,
00514 ForwardIterator end);
00515
00516
00517
00524 void resize1 (const SG_STD_OR_BOOST::false_type&, size_t size);
00525
00526
00533 void resize1 (const SG_STD_OR_BOOST::true_type&, size_t size);
00534
00535
00542 void reserve1 (const SG_STD_OR_BOOST::false_type&, size_t size);
00543
00544
00551 void reserve1 (const SG_STD_OR_BOOST::true_type&, size_t size);
00552
00553
00562 template <class DVL>
00563 void shift1 (const SG_STD_OR_BOOST::false_type&,
00564 DVL& cont, size_t pos, ptrdiff_t offs);
00565
00566
00594 template <class DVL>
00595 void shift1 (const SG_STD_OR_BOOST::true_type&,
00596 DVL& cont, size_t pos, ptrdiff_t offs);
00597
00598
00607 template <class ForwardIterator>
00608 void moveAux1 (const SG_STD_OR_BOOST::false_type&,
00609 size_t index,
00610 ForwardIterator beg,
00611 ForwardIterator end);
00612
00613
00627 template <class ForwardIterator>
00628 void moveAux1 (const SG_STD_OR_BOOST::true_type&,
00629 size_t index,
00630 ForwardIterator beg,
00631 ForwardIterator end);
00632
00633
00642 template <class ForwardIterator>
00643 void resortAux1 (const SG_STD_OR_BOOST::false_type&,
00644 size_t index,
00645 ForwardIterator beg,
00646 ForwardIterator end);
00647
00648
00662 template <class ForwardIterator>
00663 void resortAux1 (const SG_STD_OR_BOOST::true_type&,
00664 size_t index,
00665 ForwardIterator a,
00666 ForwardIterator b);
00667
00668
00669 private:
00675 class ResortAuxHelper
00676 {
00677 public:
00678 ResortAuxHelper (size_t sz, size_t index, AuxVectorBase& vec);
00679 void resortElement (size_t idx, SG::AuxElement* elt);
00680
00681 private:
00682 AuxVectorBase& m_vec;
00683 size_t m_index;
00684 std::vector<size_t> m_imap;
00685 std::vector<size_t> m_rmap;
00686 std::vector<void*> m_auxdata;
00687 std::vector<SG::auxid_t> m_auxids;
00688 SG::AuxTypeRegistry::lock_t m_lock;
00689
00690 ResortAuxHelper();
00691 };
00692 void* getDataArrayForResort (SG::auxid_t auxid);
00693 void setIndexForResort (SG::AuxElement* elt, size_t idx);
00694 friend class ResortAuxHelper;
00695
00696
00698 bool m_trackIndices;
00699 };
00700
00701
00702 }
00703
00704
00705 #include "AthContainers/AuxVectorBase.icc"
00706
00707
00708 #endif // not DATAMODEL_AUXVECTORBASE_H