CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Attributes
LayerHitMapCache::SimpleCache Class Reference

Public Types

using KeyType = int
 
using ValueType = RecHitsSortedInPhi
 

Public Member Functions

void add (KeyType key, ValueType *value)
 add object to cache. It is caller responsibility to check that object is not yet there. More...
 
void clear ()
 emptify cache, delete values associated to Key More...
 
void extend (const SimpleCache &other)
 
const ValueTypeget (KeyType key) const
 
SimpleCacheoperator= (const SimpleCache &)=delete
 
SimpleCacheoperator= (SimpleCache &&)=default
 
void resize (int size)
 
 SimpleCache (const SimpleCache &)=delete
 
 SimpleCache (SimpleCache &&)=default
 
 SimpleCache (unsigned int initSize)
 
 ~SimpleCache ()
 

Private Attributes

std::vector< mayown_ptr< ValueType > > theContainer
 

Detailed Description

Definition at line 16 of file LayerHitMapCache.h.

Member Typedef Documentation

◆ KeyType

Definition at line 19 of file LayerHitMapCache.h.

◆ ValueType

Definition at line 18 of file LayerHitMapCache.h.

Constructor & Destructor Documentation

◆ SimpleCache() [1/3]

LayerHitMapCache::SimpleCache::SimpleCache ( unsigned int  initSize)
inline

Definition at line 20 of file LayerHitMapCache.h.

20 : theContainer(initSize) {}

◆ SimpleCache() [2/3]

LayerHitMapCache::SimpleCache::SimpleCache ( const SimpleCache )
delete

◆ SimpleCache() [3/3]

LayerHitMapCache::SimpleCache::SimpleCache ( SimpleCache &&  )
default

◆ ~SimpleCache()

LayerHitMapCache::SimpleCache::~SimpleCache ( )
inline

Definition at line 25 of file LayerHitMapCache.h.

25 { clear(); }

References clear().

Member Function Documentation

◆ add()

void LayerHitMapCache::SimpleCache::add ( KeyType  key,
ValueType value 
)
inline

add object to cache. It is caller responsibility to check that object is not yet there.

Definition at line 29 of file LayerHitMapCache.h.

29  {
30  if (key >= int(theContainer.size()))
31  resize(key + 1);
32  theContainer[key].reset(value);
33  }

References crabWrapper::key, resize(), and theContainer.

Referenced by LayerHitMapCache::add(), and counter.Counter::register().

◆ clear()

void LayerHitMapCache::SimpleCache::clear ( void  )
inline

emptify cache, delete values associated to Key

Definition at line 51 of file LayerHitMapCache.h.

51  {
52  for (auto& v : theContainer) {
53  v.reset();
54  }
55  }

References theContainer, and findQualityFiles::v.

Referenced by LayerHitMapCache::clear(), and ~SimpleCache().

◆ extend()

void LayerHitMapCache::SimpleCache::extend ( const SimpleCache other)
inline

Definition at line 34 of file LayerHitMapCache.h.

34  {
35  // N.B. Here we assume that the lifetime of 'other' is longer than of 'this'.
36  if (other.theContainer.size() > theContainer.size())
37  resize(other.theContainer.size());
38 
39  for (size_t i = 0, size = other.theContainer.size(); i != size; ++i) {
40  assert(get(i) == nullptr); // We don't want to override any existing value
41  auto v = other.get(i);
42  if (v) {
43  // pass by reference to denote that we don't own it
44  theContainer[i].reset(*(other.get(i)));
45  } else {
46  theContainer[i].reset();
47  }
48  }
49  }

References cms::cuda::assert(), get(), mps_fire::i, trackingPlots::other, resize(), findQualityFiles::size, theContainer, and findQualityFiles::v.

Referenced by MatrixUtil.WF::__init__(), and LayerHitMapCache::extend().

◆ get()

const ValueType* LayerHitMapCache::SimpleCache::get ( KeyType  key) const
inline

◆ operator=() [1/2]

SimpleCache& LayerHitMapCache::SimpleCache::operator= ( const SimpleCache )
delete

◆ operator=() [2/2]

SimpleCache& LayerHitMapCache::SimpleCache::operator= ( SimpleCache &&  )
default

◆ resize()

void LayerHitMapCache::SimpleCache::resize ( int  size)
inline

Definition at line 26 of file LayerHitMapCache.h.

26 { theContainer.resize(size); }

References findQualityFiles::size, and theContainer.

Referenced by add(), and extend().

Member Data Documentation

◆ theContainer

std::vector<mayown_ptr<ValueType> > LayerHitMapCache::SimpleCache::theContainer
private

Definition at line 58 of file LayerHitMapCache.h.

Referenced by add(), clear(), extend(), get(), and resize().

mps_fire.i
i
Definition: mps_fire.py:428
LayerHitMapCache::SimpleCache::theContainer
std::vector< mayown_ptr< ValueType > > theContainer
Definition: LayerHitMapCache.h:58
cms::cuda::assert
assert(be >=bs)
findQualityFiles.v
v
Definition: findQualityFiles.py:179
LayerHitMapCache::SimpleCache::clear
void clear()
emptify cache, delete values associated to Key
Definition: LayerHitMapCache.h:51
trackingPlots.other
other
Definition: trackingPlots.py:1467
value
Definition: value.py:1
LayerHitMapCache::SimpleCache::resize
void resize(int size)
Definition: LayerHitMapCache.h:26
LayerHitMapCache::SimpleCache::get
const ValueType * get(KeyType key) const
Definition: LayerHitMapCache.h:27
crabWrapper.key
key
Definition: crabWrapper.py:19
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443