00001
00002
00011 #ifndef ATHCONTAINERS_AUXELEMENTBASE_H
00012 #define ATHCONTAINERS_AUXELEMENTBASE_H
00013
00014
00015 #include "AthContainersInterfaces/IAuxElement.h"
00016 #include "AthContainersInterfaces/IConstAuxStore.h"
00017 #include "AthContainersInterfaces/IAuxStore.h"
00018 #include "AthLinks/DataLink.h"
00019 #include "AthContainers/AuxTypeRegistry.h"
00020 #include "AthContainers/AuxVectorData.h"
00021 #include "AthContainers/tools/AuxDataTraits.h"
00022 #include "AthContainers/exceptions.h"
00023 #include "AthContainers/tools/likely.h"
00024 #include <cstddef>
00025
00026
00027
00028 namespace SG {
00029
00030
00031 class AuxElementData;
00032 class AuxElementStandaloneData;
00033 class AuxVectorData_test;
00034 class AuxVectorBase;
00035 class AuxVectorBase_test;
00036
00037
00173 class AuxElement
00174 : public SG::IAuxElement
00175 {
00176 public:
00178 AuxElement();
00179
00180
00191 AuxElement (const AuxElement& other);
00192
00193
00203 AuxElement& operator= (const AuxElement& other);
00204
00205
00211 ~AuxElement();
00212
00213
00217 SG::AuxVectorData* container();
00218
00219
00223 const SG::AuxVectorData* container() const;
00224
00225
00229 size_t index() const;
00230
00231
00243 class TypelessConstAccessor
00244 {
00245 public:
00252 TypelessConstAccessor (const std::string& name);
00253
00254
00262 TypelessConstAccessor (const std::type_info& ti,
00263 const std::string& name);
00264
00265
00273 TypelessConstAccessor (const std::string& name,
00274 const std::string& clsname);
00275
00276
00285 TypelessConstAccessor (const std::type_info& ti,
00286 const std::string& name,
00287 const std::string& clsname);
00288
00289
00294 const void* operator() (const AuxElement& e) const;
00295
00296
00306 const void* operator() (const AuxVectorData& container, size_t index) const;
00307
00308
00313 const void* getDataArray (const AuxVectorData& container) const;
00314
00315
00320 bool isAvailable (const AuxElement& e) const;
00321
00322
00326 SG::auxid_t auxid() const;
00327
00328
00329 protected:
00331 SG::auxid_t m_auxid;
00332
00334 size_t m_eltSize;
00335 };
00336
00337
00357 template <class T>
00358 class ConstAccessor
00359 {
00360 public:
00362 typedef typename AuxDataTraits<T>::const_reference_type
00363 const_reference_type;
00364
00366 typedef typename AuxDataTraits<T>::const_container_pointer_type
00367 const_container_pointer_type;
00368
00375 ConstAccessor (const std::string& name);
00376
00377
00385 ConstAccessor (const std::string& name, const std::string& clsname);
00386
00387
00392 const_reference_type operator() (const AuxElement& e) const;
00393
00394
00404 const_reference_type
00405 operator() (const AuxVectorData& container, size_t index) const;
00406
00407
00412 const_container_pointer_type
00413 getDataArray (const AuxVectorData& container) const;
00414
00415
00420 bool isAvailable (const AuxElement& e) const;
00421
00422
00426 SG::auxid_t auxid() const;
00427
00428
00429 protected:
00431 SG::auxid_t m_auxid;
00432 };
00433
00434
00464 template <class T>
00465 class Accessor
00466 : public ConstAccessor<T>
00467 {
00468 public:
00470 typedef typename AuxDataTraits<T>::reference_type
00471 reference_type;
00472
00474 typedef typename AuxDataTraits<T>::element_type
00475 element_type;
00476
00478 typedef typename AuxDataTraits<T>::container_pointer_type
00479 container_pointer_type;
00480
00481 using ConstAccessor<T>::operator();
00482 using ConstAccessor<T>::getDataArray;
00483
00484
00491 Accessor (const std::string& name);
00492
00493
00501 Accessor (const std::string& name, const std::string& clsname);
00502
00503
00508 reference_type operator() (AuxElement& e) const;
00509
00510
00520 reference_type operator() (AuxVectorData& container, size_t index) const;
00521
00522
00528 void set (AuxElement& e, const element_type& x) const;
00529
00530
00535 container_pointer_type getDataArray (AuxVectorData& container) const;
00536
00537
00542 bool isAvailableWritable (const AuxElement& e) const;
00543 };
00544
00545
00569 template <class T>
00570 class Decorator
00571 {
00572 public:
00574 typedef typename AuxDataTraits<T>::reference_type
00575 reference_type;
00576
00578 typedef typename AuxDataTraits<T>::element_type
00579 element_type;
00580
00582 typedef typename AuxDataTraits<T>::container_pointer_type
00583 container_pointer_type;
00584 typedef typename AuxDataTraits<T>::const_container_pointer_type
00585 const_container_pointer_type;
00586
00587
00594 Decorator (const std::string& name);
00595
00596
00604 Decorator (const std::string& name, const std::string& clsname);
00605
00606
00615 reference_type operator() (const AuxElement& e) const;
00616
00617
00631 reference_type
00632 operator() (const AuxVectorData& container, size_t index) const;
00633
00634
00640 void set (const AuxElement& e, const element_type& x) const;
00641
00642
00651 const_container_pointer_type getDataArray (const AuxVectorData& container) const;
00652
00653
00658 bool isAvailable (const AuxElement& e) const;
00659
00660
00665 bool isAvailableWritable (const AuxElement& e) const;
00666
00667
00671 SG::auxid_t auxid() const;
00672
00673
00674 private:
00676 SG::auxid_t m_auxid;
00677 };
00678
00679
00689 template <class T>
00690 typename AuxDataTraits<T>::reference_type
00691 auxdata (const std::string& name);
00692
00693
00704 template <class T>
00705 typename AuxDataTraits<T>::reference_type
00706 auxdata (const std::string& name,
00707 const std::string& clsname);
00708
00709
00719 template <class T>
00720 typename AuxDataTraits<T>::const_reference_type
00721 auxdata (const std::string& name) const;
00722
00723
00734 template <class T>
00735 typename AuxDataTraits<T>::const_reference_type
00736 auxdata (const std::string& name,
00737 const std::string& clsname) const;
00738
00739
00749 template <class T>
00750 typename AuxDataTraits<T>::const_reference_type
00751 auxdataConst (const std::string& name) const;
00752
00753
00764 template <class T>
00765 typename AuxDataTraits<T>::const_reference_type
00766 auxdataConst (const std::string& name,
00767 const std::string& clsname) const;
00768
00769
00780 template <class T>
00781 bool isAvailable (const std::string& name,
00782 const std::string& clsname = "") const;
00783
00784
00795 template <class T>
00796 bool isAvailableWritable (const std::string& name,
00797 const std::string& clsname = "") const;
00798
00799
00810 template <class T>
00811 bool isAvailableWritableAsDecoration (const std::string& name,
00812 const std::string& clsname = "") const;
00813
00814
00828 template <class T>
00829 typename AuxDataTraits<T>::reference_type
00830 auxdecor (const std::string& name) const;
00831
00832
00847 template <class T>
00848 typename AuxDataTraits<T>::reference_type
00849 auxdecor (const std::string& name,
00850 const std::string& clsname) const;
00851
00852
00859 void makePrivateStore();
00860
00861
00872 template <class U1>
00873 void makePrivateStore (const U1& other);
00874
00875
00886 template <class U1>
00887 void makePrivateStore (const U1* other);
00888
00889
00896 void releasePrivateStore();
00897
00898
00907 void setStore (const SG::IConstAuxStore* store);
00908
00909
00918 void setStore (SG::IAuxStore* store);
00919
00920
00929 void setStore (const DataLink< SG::IConstAuxStore >& store);
00930
00931
00936 void setConstStore (const SG::IConstAuxStore* store);
00937
00938
00943 void setNonConstStore (SG::IAuxStore* store);
00944
00945
00949 bool usingPrivateStore() const;
00950
00951
00955 bool usingStandaloneStore() const;
00956
00957
00965 const SG::IConstAuxStore* getConstStore() const;
00966
00967
00974 SG::IAuxStore* getStore() const;
00975
00976
00983 void clearCache();
00984
00985
00995 const SG::auxid_set_t& getAuxIDs() const;
00996
00997
01003 bool hasStore() const;
01004
01005
01011 bool hasNonConstStore() const;
01012
01013
01020 void clearDecorations() const;
01021
01022
01023 private:
01024 friend class SG::AuxVectorBase;
01025 friend class SG::AuxVectorBase_test;
01026
01027
01035 AuxElement (SG::AuxVectorData* container, size_t index);
01036
01037
01038
01044 void releasePrivateStoreForDtor();
01045
01046
01060 void setIndex (size_t index, SG::AuxVectorData* container);
01061
01062
01072 bool setIndexPrivate (size_t index, SG::AuxVectorData* container);
01073
01074
01084 void makePrivateStore1 (const void*);
01085
01086
01096 void makePrivateStore1 (const AuxElement* other);
01097
01098
01106 AuxElementStandaloneData* setStore1 (const SG::IConstAuxStore* store);
01107
01108
01115 void clearAux();
01116
01117
01130 void copyAux (const AuxElement& other);
01131
01132
01136 bool privateDataValid() const;
01137
01138
01141 size_t m_index;
01142
01147 SG::AuxVectorData* m_container;
01148
01158 SG::AuxElementData* m_privateData;
01159
01164 static SG::AuxElementData* s_privatePlaceholder;
01165 };
01166
01167
01168 }
01169
01170
01171 #include "AthContainers/AuxElement.icc"
01172
01173
01174 #endif // not ATHCONTAINERS_AUXELEMENTBASE_H