ATLAS Offline Software
Loading...
Searching...
No Matches
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
IdentifiableValueContainer & operator= (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.
 IdentifiableValueContainer (IdentifiableValueCache< T > *ptr)
 External Cache Constructor Pass the external cache to set up a view specific view interface.
const T & emptyValue () const
 Return the empty value that is interpreted as an empty entry.
bool present (size_t i) const
 Is the value for this has set and also accepted in the mask.
bool setOrDrop (size_t i, const T &value)
 Set the value for the given hash.
size_t maxSize () const
 Return the maxSize of the collection.
size_t numberSet () const
 Return the number of entries set and accessible according to the mask.
bool tryAddFromCache (size_t i)
 Returns true if the value is also in the external cache, sets mask to true if it is.
T retrieve (size_t i) const
 Retrieve the value of the hash, if accessible according to the mask.
std::vector< std::pair< size_t, T > > getAll () const
 Make a vector of hashes and values, convenient for iteration and other uses.
const std::vector< std::atomic< T > > & wholeEventReadAccess () const
 Get read only access to the whole external cache. This could be useful for special situations.
const Cache * cache () const
 Obtain const access to the cache.
const std::set< size_t > & getMask () const

Private Attributes

std::set< size_t > m_mask
Cache * m_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]

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

◆ ~IdentifiableValueContainer()

◆ IdentifiableValueContainer() [2/3]

template<class T>
IdentifiableValueContainer< T >::IdentifiableValueContainer ( size_t maxSize,
T 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.

◆ 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 ( ) const

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

Definition at line 93 of file IdentifiableValueContainer.h.

93 {
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 ( ) const

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}
bool present(size_t i) const
Is the value for this has set and also accepted in the mask.
const Cache * cache() const
Obtain const access to the cache.
IdentifiableValueCache< T > Cache

◆ 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: