Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4AttDefStore Namespace Reference

Functions

std::map< G4String, G4AttDef > * GetInstance (const G4String &storeKey, G4bool &isNew)
 
G4bool GetStoreKey (const std::map< G4String, G4AttDef > *definitions, G4String &key)
 

Variables

std::map< G4String, std::map< G4String, G4AttDef > * > * m_defsmaps = nullptr
 
G4Mutex mutex = G4MUTEX_INITIALIZER
 

Function Documentation

◆ GetInstance()

std::map< G4String, G4AttDef > * G4AttDefStore::GetInstance ( const G4String & storeKey,
G4bool & isNew )

Definition at line 40 of file G4AttDefStore.cc.

41{
42 G4AutoLock al(&mutex);
43
44 if (m_defsmaps == nullptr)
45 m_defsmaps = new std::map<G4String,std::map<G4String,G4AttDef>*>;
46
47 // Allocate the new map if not existing already
48 // and return it to the caller
49 //
50 std::map<G4String,G4AttDef>* definitions;
51
52 // NOLINTNEXTLINE(modernize-use-auto): Explicitly want a const_iterator
53 std::map<G4String,std::map<G4String,G4AttDef>*>::const_iterator iDefinitions =
54 m_defsmaps->find(storeKey);
55
56 if (iDefinitions == m_defsmaps->end())
57 {
58 isNew = true;
59 definitions = new std::map<G4String,G4AttDef>;
60 (*m_defsmaps)[storeKey] = definitions;
61 }
62 else
63 {
64 isNew = false;
65 definitions = iDefinitions->second;
66 }
67 return definitions;
68}
std::map< G4String, std::map< G4String, G4AttDef > * > * m_defsmaps

Referenced by G4PhysicalVolumeModel::GetAttDefs(), G4RichTrajectory::GetAttDefs(), G4RichTrajectoryPoint::GetAttDefs(), G4SmoothTrajectory::GetAttDefs(), G4SmoothTrajectoryPoint::GetAttDefs(), G4TrajectoriesModel::GetAttDefs(), G4Trajectory::GetAttDefs(), and G4TrajectoryPoint::GetAttDefs().

◆ GetStoreKey()

G4bool G4AttDefStore::GetStoreKey ( const std::map< G4String, G4AttDef > * definitions,
G4String & key )

Definition at line 70 of file G4AttDefStore.cc.

72{
73 G4AutoLock al(&mutex);
74
75 if (m_defsmaps == nullptr)
76 m_defsmaps = new std::map<G4String,std::map<G4String,G4AttDef>*>;
77 std::map<G4String,std::map<G4String,G4AttDef>*>::const_iterator i;
78 for (i = m_defsmaps->begin(); i != m_defsmaps->end(); ++i)
79 {
80 if (i->second == definitions)
81 {
82 key = i->first;
83 return true;
84 }
85 }
86
87 return false;
88}

Referenced by operator<<().

Variable Documentation

◆ m_defsmaps

std::map< G4String, std::map< G4String, G4AttDef > * > * G4AttDefStore::m_defsmaps = nullptr

Definition at line 35 of file G4AttDefStore.cc.

Referenced by GetInstance(), and GetStoreKey().

◆ mutex

G4Mutex G4AttDefStore::mutex = G4MUTEX_INITIALIZER

Definition at line 37 of file G4AttDefStore.cc.