CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ParticleTable.h
Go to the documentation of this file.
1 #ifndef FastSimulation_Particle_ParticleTable_H
2 #define FastSimulation_Particle_ParticleTable_H
3 
4 // HepPDT header
6 #include <memory>
7 
9 
11 
12 public:
13  struct Sentry{
16  }
17  ~Sentry() {
18  ParticleTable::instance()->set(nullptr);
19  }
20  };
21 
23  }
24 
27  return pdt_;
28  }
29 
30  static ParticleTable* const instance() {
31  if( !myself ) myself = new ParticleTable();
32  return myself;
33  }
34 
35 private:
36 
37  ParticleTable(const HepPDT::ParticleDataTable* pdt=nullptr) : pdt_(pdt) {}
38  void set( const HepPDT::ParticleDataTable* pdt) { pdt_ = pdt; }
39  static thread_local ParticleTable* myself;
40 
42 
43  friend struct Sentry;
44 };
45 
46 
47 
48 #endif // FastSimulation_Particle_ParticleTable_H
HepPDT::ParticleDataTable ParticleDataTable
Sentry(const HepPDT::ParticleDataTable *pdt)
Definition: ParticleTable.h:14
static ParticleTable *const instance()
Definition: ParticleTable.h:30
static thread_local ParticleTable * myself
Definition: ParticleTable.h:39
const HepPDT::ParticleDataTable * theTable() const
Get the pointer to the particle data table.
Definition: ParticleTable.h:26
void set(const HepPDT::ParticleDataTable *pdt)
Definition: ParticleTable.h:38
ParticleTable(const HepPDT::ParticleDataTable *pdt=nullptr)
Definition: ParticleTable.h:37
const HepPDT::ParticleDataTable * pdt_
Definition: ParticleTable.h:41