00001
00002
00011 #ifndef ATHCONTAINERS_AUXVECTORDATA_H
00012 #define ATHCONTAINERS_AUXVECTORDATA_H
00013
00014
00015 #include "AthContainersInterfaces/AuxTypes.h"
00016 #include "AthContainersInterfaces/IConstAuxStore.h"
00017 #include "AthContainersInterfaces/AuxDataOption.h"
00018 #include "AthContainers/tools/AuxDataTraits.h"
00019 #include "AthLinks/DataLink.h"
00020 #ifndef XAOD_STANDALONE
00021 # include "AthenaKernel/ILockable.h"
00022 # include "AthenaKernel/IThinningSvc.h"
00023 #endif // not XAOD_STANDALONE
00024 #include "CxxUtils/override.h"
00025 #include <vector>
00026 #include <utility>
00027 #include <cstdlib>
00028
00029 #include "AthContainers/tools/likely.h"
00030 #include "AthContainers/tools/assume.h"
00031 #include "AthContainers/tools/threading.h"
00032
00033
00034 namespace SG {
00035
00036
00037 class AuxElement;
00038 class IAuxStore;
00039 class AuxDataOption;
00040
00041
00162 class AuxVectorData
00163 #ifndef XAOD_STANDALONE
00164 : public ILockable
00165 #endif // not XAOD_STANDALONE
00166 {
00167 public:
00169 AuxVectorData();
00170
00171
00172 #if __cplusplus > 201100
00173
00177 AuxVectorData (AuxVectorData&& rhs);
00178
00179
00184 AuxVectorData& operator= (AuxVectorData&& rhs);
00185 #endif
00186
00187
00189 virtual ~AuxVectorData();
00190
00191
00197 virtual size_t size_v() const = 0;
00198
00199
00205 virtual size_t capacity_v() const = 0;
00206
00207
00208
00211
00212
00219 const SG::IConstAuxStore* getConstStore() const;
00220
00221
00227 SG::IAuxStore* getStore() const;
00228
00229
00233 bool hasStore() const;
00234
00235
00239 bool hasNonConstStore() const;
00240
00241
00251 bool setOption (auxid_t id, const AuxDataOption& option);
00252
00253
00263 bool setOption (const std::string& name,
00264 const AuxDataOption& option);
00265
00266
00277 bool setOption (const std::string& name,
00278 const std::string& clsname,
00279 const AuxDataOption& option);
00280
00281
00292 template <class T>
00293 bool setOption (auxid_t id, const std::string& optname, T arg);
00294
00295
00306 bool setOption (const std::string& name,
00307 const std::string& optname,
00308 int arg);
00309 bool setOption (const std::string& name,
00310 const std::string& optname,
00311 float arg);
00312 bool setOption (const std::string& name,
00313 const std::string& optname,
00314 double arg);
00315
00316
00328 template <class T>
00329 bool setOption (const std::string& name,
00330 const std::string& clsname,
00331 const std::string& optname,
00332 T arg);
00333
00334
00335
00336 protected:
00337
00338
00339
00340
00341
00349 void setStore (const SG::IConstAuxStore* store);
00350
00351
00359 void setStore (SG::IAuxStore* store);
00360
00361
00369 void setStore (const DataLink< SG::IConstAuxStore >& store);
00370
00371
00373
00376 public:
00377
00378
00387 const SG::auxid_set_t& getAuxIDs() const;
00388
00389
00398 const SG::auxid_set_t& getWritableAuxIDs() const;
00399
00400
00405 bool isAvailable (auxid_t id) const;
00406
00407
00413 template <class T>
00414 bool isAvailable (const std::string& name,
00415 const std::string& clsname = "") const;
00416
00417
00422 bool isAvailableWritable (auxid_t id) const;
00423
00424
00430 template <class T>
00431 bool isAvailableWritable (const std::string& name,
00432 const std::string& clsname = "") const;
00433
00434
00439 bool isAvailableWritableAsDecoration (auxid_t id) const;
00440
00441
00447 template <class T>
00448 bool isAvailableWritableAsDecoration (const std::string& name,
00449 const std::string& clsname = "") const;
00450
00451
00464 template <class T>
00465 typename AuxDataTraits<T>::reference_type
00466 getData (SG::auxid_t auxid, size_t ndx);
00467
00468
00480 template <class T>
00481 typename AuxDataTraits<T>::const_reference_type
00482 getData (SG::auxid_t auxid, size_t ndx) const;
00483
00484
00504 template <class T>
00505 typename AuxDataTraits<T>::reference_type
00506 getDecoration (SG::auxid_t auxid, size_t ndx) const;
00507
00508
00517 const void* getDataArray (SG::auxid_t auxid) const;
00518
00519
00528 const void* getDataArrayAllowMissing (SG::auxid_t auxid) const;
00529
00530
00531 protected:
00540 void* getDataArray (SG::auxid_t auxid);
00541
00542
00557 void* getDecorationArray (SG::auxid_t auxid) const;
00558
00559
00562 static size_t s_minCacheLen;
00563
00564
00566
00569 public:
00570
00571
00576 void swap (AuxVectorData& other);
00577
00578
00585 void clearCache();
00586
00587
00594 #ifndef XAOD_STANDALONE
00595 virtual
00596 #endif // not XAOD_STANDALONE
00597 void lock()
00598 #ifndef XAOD_STANDALONE
00599 ATH_OVERRIDE
00600 #endif // not XAOD_STANDALONE
00601 ;
00602
00603
00610 void clearDecorations() const;
00611
00612
00614
00615
00616
00617 private:
00624 class Cache
00625 {
00626 public:
00630 Cache();
00631
00632
00633 #if __cplusplus > 201100
00634
00638 Cache (Cache&& rhs);
00639
00640
00645 Cache& operator= (Cache&& rhs);
00646 #endif
00647
00648
00652 ~Cache();
00653
00654
00659 void* cachePtr (SG::auxid_t auxid);
00660
00661
00671 void* getDataArray (SG::auxid_t auxid, AuxVectorData& parent);
00672
00673
00683 const void* getDataArray (SG::auxid_t auxid, const AuxVectorData& parent);
00684
00685
00695 const void* getDataArrayAllowMissing (SG::auxid_t auxid,
00696 const AuxVectorData& parent);
00697
00698
00714 void* getDecorationArray (SG::auxid_t auxid, const AuxVectorData& parent);
00715
00716
00721 void swap (Cache& other);
00722
00723
00727 void clear();
00728
00729
00735 void store (SG::auxid_t auxid, void* ptr);
00736
00737
00741 void** m_cache[2];
00742
00744 size_t m_cache_len;
00745
00747
00748
00749
00750 std::vector<void**> m_allcache;
00751
00752
00753 private:
00754 Cache (const Cache&);
00755 Cache& operator= (const Cache&);
00756 };
00757
00758 friend class Cache;
00759
00760
00762 AuxVectorData (const AuxVectorData&);
00763 AuxVectorData& operator= (const AuxVectorData&);
00764
00765
00766 friend class SG::AuxElement;
00767
00768
00773 bool isAvailableOol (auxid_t id) const;
00774
00775
00780 bool isAvailableWritableOol (auxid_t id) const;
00781
00782
00787 bool isAvailableWritableAsDecorationOol (auxid_t id) const;
00788
00789
00800 void* getDataOol (SG::auxid_t auxid, bool allowMissing);
00801
00802
00813 const void* getDataOol (SG::auxid_t auxid, bool allowMissing) const;
00814
00815
00830 void* getDecorationOol (SG::auxid_t auxid) const;
00831
00832
00834 mutable Cache m_cache;
00835
00837 mutable Cache m_constCache;
00838
00840 mutable Cache m_decorCache;
00841
00842
00844 SG::IAuxStore* m_store;
00845
00846
00848 const SG::IConstAuxStore* m_constStore;
00849
00850
00852 DataLink< SG::IConstAuxStore > m_constStoreLink;
00853
00854
00856 typedef AthContainers_detail::mutex mutex_t;
00857 typedef AthContainers_detail::lock_guard<mutex_t> guard_t;
00858 mutable mutex_t m_mutex;
00859
00861 static SG::auxid_set_t s_emptySet;
00862 };
00863
00864
00865 }
00866
00867
00868 #ifndef XAOD_STANDALONE
00869
00870
00883 StatusCode thinningHook (const SG::AuxVectorData* in,
00884 IThinningSvc* svc,
00885 const IThinningSvc::Filter_t& filter,
00886 const IThinningSvc::Operator::Type op );
00887
00888
00889 #endif
00890
00891
00892 #include "AthContainers/AuxVectorData.icc"
00893
00894
00895 #endif // not ATHCONTAINERS_AUXVECTORDATA_H