ATLAS Offline Software
TransformMap.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef GEOMODELUTILITIES_TRANSFORMMAP_H
6 #define GEOMODELUTILITIES_TRANSFORMMAP_H
7 
10 
11 #include <memory>
12 #include <unordered_map>
13 #include <shared_mutex>
14 
21 template <typename T, typename X> class TransformMap {
22 public:
24  TransformMap() =default;
25  /*** @brief: Copy constructor from an existing map*/
26  TransformMap(const TransformMap& other) = default;
29 
30  ~TransformMap() = default;
38  bool setTransform(const T *obj, const X &xf) const;
39  bool setTransform(const T* obj, const X& xf);
45  bool setTransform(const T *obj, std::shared_ptr<const X> xf) const;
46  bool setTransform(const T* obj, std::shared_ptr<const X> xf);
47 
52  const X *getTransform(const T *obj) const;
53 
58  bool append(const TransformMap &other);
60  void clear();
63  void lock();
65  std::vector<const T*> getStoredKeys() const;
66 
67 private:
68  using ConCurrentMap_t = CxxUtils::ConcurrentToValMap<const T*, std::shared_ptr<const X>, CxxUtils::SimpleUpdater>;
69  using ConCurrentMap_ptr = std::unique_ptr<ConCurrentMap_t>;
70  using CanonicalMap_t = std::unordered_map<const T*, std::shared_ptr<const X>>;
71  using CanonicalMap_ptr = std::unique_ptr<CanonicalMap_t>;
72 
73 
74  mutable CanonicalMap_t m_container ATLAS_THREAD_SAFE{};
75  mutable bool m_locked ATLAS_THREAD_SAFE{false};
76  mutable std::shared_mutex m_mutex ATLAS_THREAD_SAFE{};
77  mutable ConCurrentMap_ptr m_mutableCont ATLAS_THREAD_SAFE{
78  std::make_unique<ConCurrentMap_t>(typename ConCurrentMap_t::Updater_t())};
79 
80 
81 };
83 #endif
TransformMap::ConCurrentMap_ptr
std::unique_ptr< ConCurrentMap_t > ConCurrentMap_ptr
Definition: TransformMap.h:69
CxxUtils::SimpleUpdater
Simple (non-deleting) Updater implementation.
Definition: SimpleUpdater.h:37
TransformMap::TransformMap
TransformMap(const TransformMap &other)=default
TransformMap::setTransform
bool setTransform(const T *obj, const X &xf) const
: Adds a transform object to the map.
ConcurrentToValMap.h
Hash map from pointers/integers to arbitrary objects allowing concurrent, lockless reads.
TransformMap::clear
void clear()
: Clear the transform cache map
TransformMap::operator=
TransformMap & operator=(const TransformMap &other)=default
: Copy assignment operator
TransformMap::getStoredKeys
std::vector< const T * > getStoredKeys() const
: Returns a vector of all objects that have been parsed to the map
TransformMap::setTransform
bool setTransform(const T *obj, std::shared_ptr< const X > xf)
TransformMap::getTransform
const X * getTransform(const T *obj) const
: Returns the transform that's associated with input object.
Monitored::X
@ X
Definition: HistogramFillerUtils.h:24
TransformMap::ATLAS_THREAD_SAFE
CanonicalMap_t m_container ATLAS_THREAD_SAFE
Definition: TransformMap.h:74
TransformMap::append
bool append(const TransformMap &other)
: Copies all key value pairs from the external map and appends it to this map instance.
TransformMap
Generic class to outsource the cache of transformations, Vectors, etc, from the core class instance.
Definition: TransformMap.h:21
TransformMap::setTransform
bool setTransform(const T *obj, std::shared_ptr< const X > xf) const
: Adds a transform object to the map.
TransformMap::ConCurrentMap_t
CxxUtils::ConcurrentToValMap< const T *, std::shared_ptr< const X >, CxxUtils::SimpleUpdater > ConCurrentMap_t
Definition: TransformMap.h:68
TransformMap::~TransformMap
~TransformMap()=default
TransformMap.icc
TransformMap::setTransform
bool setTransform(const T *obj, const X &xf)
TransformMap::CanonicalMap_ptr
std::unique_ptr< CanonicalMap_t > CanonicalMap_ptr
Definition: TransformMap.h:71
TransformMap::CanonicalMap_t
std::unordered_map< const T *, std::shared_ptr< const X > > CanonicalMap_t
Definition: TransformMap.h:70
InDetDD::other
@ other
Definition: InDetDD_Defs.h:16
SimpleUpdater.h
Simple (non-deleting) Updater implementation.
TransformMap::TransformMap
TransformMap()=default
: Default constructor
python.PyAthena.obj
obj
Definition: PyAthena.py:132
TransformMap::lock
void lock()
: Lock the map which switches off the mutex protection mechanism.
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35