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

#include <IdentifiableValueContainer.h>

Inheritance diagram for IdentifiableValueContainer< T >:
Collaboration diagram for IdentifiableValueContainer< T >:

Public Types

typedef T value_type
 
typedef IdentifiableValueCache< T > Cache
 

Public Member Functions

 IdentifiableValueContainer (const IdentifiableValueContainer< T > &)=delete
 
IdentifiableValueContaineroperator= (const IdentifiableValueContainer &)=delete
 
 ~IdentifiableValueContainer ()
 
 IdentifiableValueContainer (size_t maxSize, T defaultValue)
 Self Owning Constructor Pass the maximum hash to size the cache and the defaultValue which will be interpreted as an empty value. More...
 
 IdentifiableValueContainer (IdentifiableValueCache< T > *ptr)
 External Cache Constructor Pass the external cache to set up a view specific view interface. More...
 
const T & emptyValue () const
 Return the empty value that is interpreted as an empty entry. More...
 
bool present (size_t i) const
 Is the value for this has set and also accepted in the mask. More...
 
bool setOrDrop (size_t i, const T &value)
 Set the value for the given hash. More...
 
size_t maxSize () const
 Return the maxSize of the collection. More...
 
size_t numberSet () const
 Return the number of entries set and accessible according to the mask. More...
 
bool tryAddFromCache (size_t i)
 Returns true if the value is also in the external cache, sets mask to true if it is. More...
 
retrieve (size_t i) const
 Retrieve the value of the hash, if accessible according to the mask. More...
 
std::vector< std::pair< size_t, T > > getAll () const
 Make a vector of hashes and values, convenient for iteration and other uses. More...
 
const std::vector< std::atomic< T > > & wholeEventReadAccess () const
 Get read only access to the whole external cache. This could be useful for special situations. More...
 
const Cachecache () const
 Obtain const access to the cache. More...
 
const std::set< size_t > & getMask () const
 

Private Attributes

std::set< size_t > m_mask
 
Cachem_cache
 
bool m_own
 

Detailed Description

template<class T>
class IdentifiableValueContainer< T >

Definition at line 21 of file IdentifiableValueContainer.h.

Member Typedef Documentation

◆ Cache

template<class T >
typedef IdentifiableValueCache<T> IdentifiableValueContainer< T >::Cache

Definition at line 25 of file IdentifiableValueContainer.h.

◆ value_type

template<class T >
typedef T IdentifiableValueContainer< T >::value_type

Definition at line 24 of file IdentifiableValueContainer.h.

Constructor & Destructor Documentation

◆ IdentifiableValueContainer() [1/3]

◆ ~IdentifiableValueContainer()

template<class T >
IdentifiableValueContainer< T >::~IdentifiableValueContainer ( )
inline

Definition at line 31 of file IdentifiableValueContainer.h.

31 { if(m_own) delete m_cache; }

◆ IdentifiableValueContainer() [2/3]

template<class T >
IdentifiableValueContainer< T >::IdentifiableValueContainer ( size_t  maxSize,
defaultValue 
)
inline

Self Owning Constructor Pass the maximum hash to size the cache and the defaultValue which will be interpreted as an empty value.

Definition at line 35 of file IdentifiableValueContainer.h.

35  : m_own(true)
36  {
37  m_cache = new IdentifiableValueCache<T>(maxSize, std::move(defaultValue));
38  }

◆ IdentifiableValueContainer() [3/3]

template<class T >
IdentifiableValueContainer< T >::IdentifiableValueContainer ( IdentifiableValueCache< T > *  ptr)
inline

External Cache Constructor Pass the external cache to set up a view specific view interface.

Definition at line 42 of file IdentifiableValueContainer.h.

42  :
43  m_cache(ptr), m_own(false)
44  {}

Member Function Documentation

◆ cache()

template<class T >
const Cache* IdentifiableValueContainer< T >::cache ( ) const
inline

Obtain const access to the cache.

Definition at line 77 of file IdentifiableValueContainer.h.

77 { return m_cache; }

◆ emptyValue()

template<class T >
const T& IdentifiableValueContainer< T >::emptyValue ( ) const
inline

Return the empty value that is interpreted as an empty entry.

Definition at line 48 of file IdentifiableValueContainer.h.

48 { return m_cache->emptyValue(); }

◆ getAll()

template<class T >
std::vector< std::pair< size_t, T > > IdentifiableValueContainer< T >::getAll

Make a vector of hashes and values, convenient for iteration and other uses.

Definition at line 93 of file IdentifiableValueContainer.h.

93  {
94  std::vector<std::pair<size_t, T>> list;
95  list.reserve(m_mask.size());
96  const auto& raw = m_cache->rawReadAccess();
97  for(size_t i : m_mask){
98  list.emplace_back(i, raw[i].load(std::memory_order_relaxed));
99  }
100  return list;
101 }

◆ getMask()

template<class T >
const std::set<size_t>& IdentifiableValueContainer< T >::getMask ( ) const
inline

Definition at line 79 of file IdentifiableValueContainer.h.

79 { return m_mask; }

◆ maxSize()

template<class T >
size_t IdentifiableValueContainer< T >::maxSize ( ) const
inline

Return the maxSize of the collection.

Definition at line 58 of file IdentifiableValueContainer.h.

58 { return m_cache->maxSize(); }

◆ numberSet()

template<class T >
size_t IdentifiableValueContainer< T >::numberSet

Return the number of entries set and accessible according to the mask.

This is not a trivial function do not repeatedly call.

Definition at line 124 of file IdentifiableValueContainer.h.

124  {
125  return m_mask.size();
126 }

◆ operator=()

template<class T >
IdentifiableValueContainer& IdentifiableValueContainer< T >::operator= ( const IdentifiableValueContainer< T > &  )
delete

◆ present()

template<class T >
bool IdentifiableValueContainer< T >::present ( size_t  i) const

Is the value for this has set and also accepted in the mask.

Definition at line 87 of file IdentifiableValueContainer.h.

88 {
89  return m_mask.count(i);
90 }

◆ retrieve()

template<class T >
T IdentifiableValueContainer< T >::retrieve ( size_t  i) const

Retrieve the value of the hash, if accessible according to the mask.

Definition at line 104 of file IdentifiableValueContainer.h.

104  {
106  auto r = cache->retrieve(i);
107  //Should be quicker to establish empty cache than empty mask with a std::set
108  //So the cache is checked first
109  if(r!= cache->emptyValue() && present(i)) return r;
110  else return cache->emptyValue();
111 }

◆ setOrDrop()

template<class T >
bool IdentifiableValueContainer< T >::setOrDrop ( size_t  i,
const T &  value 
)

Set the value for the given hash.

Definition at line 129 of file IdentifiableValueContainer.h.

129  {
130  bool b = m_cache->setOrDrop(i, value);
131  m_mask.emplace(i);
132  return b;
133 }

◆ tryAddFromCache()

template<class T >
bool IdentifiableValueContainer< T >::tryAddFromCache ( size_t  i)

Returns true if the value is also in the external cache, sets mask to true if it is.

Definition at line 114 of file IdentifiableValueContainer.h.

114  {
115  if(i >= maxSize()) return false;
116  bool b = m_cache->present(i);
117  if(b) m_mask.emplace(i);
118  return b;
119 }

◆ wholeEventReadAccess()

template<class T >
const std::vector<std::atomic<T> >& IdentifiableValueContainer< T >::wholeEventReadAccess ( ) const
inline

Get read only access to the whole external cache. This could be useful for special situations.

Definition at line 74 of file IdentifiableValueContainer.h.

74 { return m_cache->rawReadAccess(); }

Member Data Documentation

◆ m_cache

template<class T >
Cache* IdentifiableValueContainer< T >::m_cache
private

Definition at line 82 of file IdentifiableValueContainer.h.

◆ m_mask

template<class T >
std::set<size_t> IdentifiableValueContainer< T >::m_mask
private

Definition at line 81 of file IdentifiableValueContainer.h.

◆ m_own

template<class T >
bool IdentifiableValueContainer< T >::m_own
private

Definition at line 83 of file IdentifiableValueContainer.h.


The documentation for this class was generated from the following file:
beamspotman.r
def r
Definition: beamspotman.py:676
IdentifiableValueContainer::maxSize
size_t maxSize() const
Return the maxSize of the collection.
Definition: IdentifiableValueContainer.h:58
IdentifiableValueCache::setOrDrop
bool setOrDrop(size_t i, const T &value)
Set the given hash to the value.
Definition: IdentifiableValueCache.h:90
athena.value
value
Definition: athena.py:124
IdentifiableValueCache::rawReadAccess
const std::vector< std::atomic< T > > & rawReadAccess() const
Definition: IdentifiableValueCache.h:66
IdentifiableValueCache::emptyValue
const T & emptyValue() const
Return the empty value that is interpreted as an empty entry.
Definition: IdentifiableValueCache.h:26
dbg::ptr
void * ptr(T *p)
Definition: SGImplSvc.cxx:74
IdentifiableValueContainer::cache
const Cache * cache() const
Obtain const access to the cache.
Definition: IdentifiableValueContainer.h:77
IdentifiableValueCache::retrieve
T retrieve(size_t i)
Retrieve the Value stored in that hash.
Definition: IdentifiableValueCache.h:49
IdentifiableValueContainer::m_own
bool m_own
Definition: IdentifiableValueContainer.h:83
IdentifiableValueContainer::m_mask
std::set< size_t > m_mask
Definition: IdentifiableValueContainer.h:81
IdentifiableValueContainer::m_cache
Cache * m_cache
Definition: IdentifiableValueContainer.h:82
IdentifiableValueCache::present
bool present(size_t i)
Returns true if the value is set to anything but the emptyValue.
Definition: IdentifiableValueCache.h:55
lumiFormat.i
int i
Definition: lumiFormat.py:85
IdentifiableValueContainer::Cache
IdentifiableValueCache< T > Cache
Definition: IdentifiableValueContainer.h:25
histSizes.list
def list(name, path='/')
Definition: histSizes.py:38
IdentifiableValueContainer::present
bool present(size_t i) const
Is the value for this has set and also accepted in the mask.
Definition: IdentifiableValueContainer.h:87
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
IdentifiableValueCache::maxSize
size_t maxSize() const
Return the maxSize of the collection.
Definition: IdentifiableValueCache.h:44
ATLAS_THREAD_SAFE
#define ATLAS_THREAD_SAFE
Definition: checker_macros.h:211
python.root_pickle.load
def load(f, use_proxy=1, key=None)
Definition: root_pickle.py:476
IdentifiableValueCache
This class is to provide an event wide MT container for concurrent storing of basic types,...
Definition: IdentifiableValueCache.h:19