45#ifndef G4TAtomicHitsMap_h
46#define G4TAtomicHitsMap_h 1
48#include "G4THitsCollection.hh"
49#include "G4THitsMap.hh"
52#include "G4Threading.hh"
53#include "G4AutoLock.hh"
72 static_assert(std::is_fundamental<T>::value,
73 "G4TAtomicHitsMap must use fundamental type");
79 typedef typename container_type::iterator
iterator;
108 inline G4int
add(
const G4int& key, T& aHit)
const;
112 inline G4int
set(
const G4int& key, T& aHit)
const;
158 for(
auto itr = theCollection->begin(); itr != theCollection->end(); itr++)
161 delete theCollection;
167 return (collectionName ==
right.collectionName);
174 for(
auto itr = rhs.
GetMap()->begin(); itr != rhs.
GetMap()->end(); itr++)
175 add(itr->first, *(itr->second));
184 for(
auto itr = rhs.GetMap()->begin(); itr != rhs.GetMap()->end(); itr++)
185 add(itr->first, *(itr->second));
195 if(theCollection->find(key) != theCollection->end())
196 return theCollection->find(key)->second;
199 G4AutoLock l(&fMutex);
200 if(theCollection->find(key) == theCollection->end())
203 (*theCollection)[key] = ptr;
207 return theCollection->find(key)->second;
214 if(theCollection->find(key) != theCollection->end())
215 *(*theCollection)[key] += *aHit;
218 G4AutoLock l(&fMutex);
219 (*theCollection)[key] = aHit;
221 G4AutoLock l(&fMutex);
222 return theCollection->size();
228 if(theCollection->find(key) != theCollection->end())
229 *(*theCollection)[key] += aHit;
234 G4AutoLock l(&fMutex);
235 (*theCollection)[key] = hit;
237 G4AutoLock l(&fMutex);
238 return theCollection->size();
244 if(theCollection->find(key) != theCollection->end())
245 delete(*theCollection)[key]->second;
247 (*theCollection)[key] = aHit;
248 G4AutoLock l(&fMutex);
249 return theCollection->size();
255 if(theCollection->find(key) != theCollection->end())
256 *(*theCollection)[key] = aHit;
261 (*theCollection)[key] = hit;
263 G4AutoLock l(&fMutex);
264 return theCollection->size();
274 G4cout <<
"G4TAtomicHitsMap " << SDname <<
" / " << collectionName <<
" --- "
275 << entries() <<
" entries" << G4endl;
281 G4AutoLock l(&fMutex);
283 for(
auto itr = theCollection->begin(); itr != theCollection->end(); itr++)
286 theCollection->clear();
Definition of the G4atomic class.
This is an implementation of G4THitsMap<T> where the underlying type is G4atomic<T>,...
container_type::const_iterator const_iterator
virtual size_t size() const
const_iterator begin() const
container_type * theCollection
virtual G4VHit * GetHit(size_t) const
virtual ~G4TAtomicHitsMap()
G4TAtomicHitsMap< T > & operator+=(const G4TAtomicHitsMap< T > &right) const
const_iterator cend() const
container_type * GetMap() const
virtual void DrawAllHits()
virtual size_t GetSize() const
std::map< G4int, mapped_type > container_type
G4bool operator==(const G4TAtomicHitsMap< T > &right) const
virtual void PrintAllHits()
container_type::iterator iterator
const_iterator cbegin() const
const_iterator end() const
G4int set(const G4int &key, value_type *&aHit) const
value_type * operator[](G4int key) const
G4int add(const G4int &key, value_type *&aHit) const
const_iterator find(G4int p) const