ATLAS Offline Software
Public Member Functions | Private Types | Private Attributes | List of all members
TransformMap< T, X > Class Template Reference

Generic class to outsource the cache of transformations, Vectors, etc, from the core class instance. More...

#include <TransformMap.h>

Collaboration diagram for TransformMap< T, X >:

Public Member Functions

 TransformMap ()=default
 : Default constructor More...
 
 TransformMap (const TransformMap &other)=default
 
TransformMapoperator= (const TransformMap &other)=default
 : Copy assignment operator More...
 
 ~TransformMap ()=default
 
bool setTransform (const T *obj, const X &xf) const
 : Adds a transform object to the map. More...
 
bool setTransform (const T *obj, const X &xf)
 
bool setTransform (const T *obj, std::shared_ptr< const X > xf) const
 : Adds a transform object to the map. More...
 
bool setTransform (const T *obj, std::shared_ptr< const X > xf)
 
const X * getTransform (const T *obj) const
 : Returns the transform that's associated with input object. More...
 
bool append (const TransformMap &other)
 : Copies all key value pairs from the external map and appends it to this map instance. More...
 
void clear ()
 : Clear the transform cache map More...
 
void lock ()
 : Lock the map which switches off the mutex protection mechanism. More...
 
std::vector< const T * > getStoredKeys () const
 : Returns a vector of all objects that have been parsed to the map More...
 

Private Types

using ConCurrentMap_t = CxxUtils::ConcurrentToValMap< const T *, std::shared_ptr< const X >, CxxUtils::SimpleUpdater >
 
using ConCurrentMap_ptr = std::unique_ptr< ConCurrentMap_t >
 
using CanonicalMap_t = std::unordered_map< const T *, std::shared_ptr< const X > >
 
using CanonicalMap_ptr = std::unique_ptr< CanonicalMap_t >
 

Private Attributes

CanonicalMap_t m_container ATLAS_THREAD_SAFE {}
 
bool m_locked ATLAS_THREAD_SAFE {false}
 
std::shared_mutex m_mutex ATLAS_THREAD_SAFE {}
 
ConCurrentMap_ptr m_mutableCont ATLAS_THREAD_SAFE
 

Detailed Description

template<typename T, typename X>
class TransformMap< T, X >

Generic class to outsource the cache of transformations, Vectors, etc, from the core class instance.

The pointer to the class instance serves as access key to the map. The cache can be filled on-the fly and hence does not require an initialization step.

Definition at line 21 of file TransformMap.h.

Member Typedef Documentation

◆ CanonicalMap_ptr

template<typename T , typename X >
using TransformMap< T, X >::CanonicalMap_ptr = std::unique_ptr<CanonicalMap_t>
private

Definition at line 71 of file TransformMap.h.

◆ CanonicalMap_t

template<typename T , typename X >
using TransformMap< T, X >::CanonicalMap_t = std::unordered_map<const T*, std::shared_ptr<const X> >
private

Definition at line 70 of file TransformMap.h.

◆ ConCurrentMap_ptr

template<typename T , typename X >
using TransformMap< T, X >::ConCurrentMap_ptr = std::unique_ptr<ConCurrentMap_t>
private

Definition at line 69 of file TransformMap.h.

◆ ConCurrentMap_t

template<typename T , typename X >
using TransformMap< T, X >::ConCurrentMap_t = CxxUtils::ConcurrentToValMap<const T*, std::shared_ptr<const X>, CxxUtils::SimpleUpdater>
private

Definition at line 68 of file TransformMap.h.

Constructor & Destructor Documentation

◆ TransformMap() [1/2]

template<typename T , typename X >
TransformMap< T, X >::TransformMap ( )
default

: Default constructor

◆ TransformMap() [2/2]

template<typename T , typename X >
TransformMap< T, X >::TransformMap ( const TransformMap< T, X > &  other)
default

◆ ~TransformMap()

template<typename T , typename X >
TransformMap< T, X >::~TransformMap ( )
default

Member Function Documentation

◆ append()

template<typename T , typename X >
bool TransformMap< T, X >::append ( const TransformMap< T, X > &  other)

: Copies all key value pairs from the external map and appends it to this map instance.

Returns false if the second map partially overlaps with this map.

Parameters
otherOther map in memory to copy from

◆ clear()

template<typename T , typename X >
void TransformMap< T, X >::clear ( )

: Clear the transform cache map

◆ getStoredKeys()

template<typename T , typename X >
std::vector<const T*> TransformMap< T, X >::getStoredKeys ( ) const

: Returns a vector of all objects that have been parsed to the map

◆ getTransform()

template<typename T , typename X >
const X* TransformMap< T, X >::getTransform ( const T *  obj) const

: Returns the transform that's associated with input object.

If the object has not been added via the setTransform method, a nullptr is returned

Parameters
objPointer to the class instance which associated transform shall be fetched

◆ lock()

template<typename T , typename X >
void TransformMap< T, X >::lock ( )

: Lock the map which switches off the mutex protection mechanism.

Any attempt to const modify the container afterwards leads to exceptions.

◆ operator=()

template<typename T , typename X >
TransformMap& TransformMap< T, X >::operator= ( const TransformMap< T, X > &  other)
default

: Copy assignment operator

◆ setTransform() [1/4]

template<typename T , typename X >
bool TransformMap< T, X >::setTransform ( const T *  obj,
const X &  xf 
)

◆ setTransform() [2/4]

template<typename T , typename X >
bool TransformMap< T, X >::setTransform ( const T *  obj,
const X &  xf 
) const

: Adds a transform object to the map.

Returns false if a transform has been already associated before with the object. The object is turned into a shared pointer to allow sharing of the same memory in cases where multiple TransformMaps are around in memory and the transform remains constant across the maps.

Parameters
objPointer to the class instance to which the transform shall be associated.
xfTransform object to cache

◆ setTransform() [3/4]

template<typename T , typename X >
bool TransformMap< T, X >::setTransform ( const T *  obj,
std::shared_ptr< const X >  xf 
)

◆ setTransform() [4/4]

template<typename T , typename X >
bool TransformMap< T, X >::setTransform ( const T *  obj,
std::shared_ptr< const X >  xf 
) const

: Adds a transform object to the map.

Returns false if a transform has been already associated before with the object

Parameters
objPointer to the class instance to which the transform shall be associated.
xfShared pointer of the transform object to cache

Member Data Documentation

◆ ATLAS_THREAD_SAFE [1/4]

template<typename T , typename X >
CanonicalMap_t m_container TransformMap< T, X >::ATLAS_THREAD_SAFE {}
mutableprivate

Definition at line 74 of file TransformMap.h.

◆ ATLAS_THREAD_SAFE [2/4]

template<typename T , typename X >
bool m_locked TransformMap< T, X >::ATLAS_THREAD_SAFE {false}
mutableprivate

Definition at line 75 of file TransformMap.h.

◆ ATLAS_THREAD_SAFE [3/4]

template<typename T , typename X >
std::shared_mutex m_mutex TransformMap< T, X >::ATLAS_THREAD_SAFE {}
mutableprivate

Definition at line 76 of file TransformMap.h.

◆ ATLAS_THREAD_SAFE [4/4]

template<typename T , typename X >
ConCurrentMap_ptr m_mutableCont TransformMap< T, X >::ATLAS_THREAD_SAFE
mutableprivate
Initial value:
{
std::make_unique<ConCurrentMap_t>(typename ConCurrentMap_t::Updater_t())}

Definition at line 77 of file TransformMap.h.


The documentation for this class was generated from the following file: