CustomPhysicsFactory.hh
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 /// \file CustomPhysicsFactory.h
3 //
4 ////////////////////////////////////////////////////////////////////////
5 #ifndef CUSTOMPHYSICSFACTORY_hh
6 #define CUSTOMPHYSICSFACTORY_hh
7 
8 #include "Geant4/G4VPhysicsConstructor.hh"
9 
10 #ifndef CUSTOMPHYSICSTABLE_hh
11 namespace gar {
12  namespace garg4 { class CustomPhysicsTable; }
13 }
14 #endif
15 
16 namespace gar {
17  namespace garg4 {
19  {
20  public:
23 
24  virtual bool Registered() = 0;
25  virtual std::string GetName() = 0;
26  virtual G4VPhysicsConstructor * Build() = 0;
27  };
28 
29  template<class T>
31  {
32  public:
35  virtual ~CustomPhysicsFactory() {};
36  bool Registered ()
37  {return registered;}
39  { return myName;}
40  virtual G4VPhysicsConstructor * Build();
41 
42 
43  private:
45  bool registered;
46  bool verbose;
47  };
48  }
49 }
50 
52 
53 namespace gar {
54  namespace garg4 {
55 
56  template<class T> G4VPhysicsConstructor * CustomPhysicsFactory<T>::Build()
57  {
58  return new T();
59  }
60 
62  {
63 
64  // For debugging.
65  verbose=true;
66 
67  if(Name!="")
68  myName=Name;
69  else
70  std::cerr<<"CustomPhysicsFactory Error : Physics registered with no name!"<<std::endl;
71 
72  // register self in physics table - note, factory is actually registered
73  // in static TheCustomPhysicsTable, not the instance created below
74  // which just acts to pass information along
75  new CustomPhysicsTable(this);
76  registered=true;
77  }
78 
79 
80 
82  {
83  registered=false;
84  }
85 
86  }
87 } // gar
88 
89 #endif
90 
91 
92 // Sept 2009 - Ben Jones, MIT
std::string string
Definition: nybbler.cc:12
ChannelGroupService::Name Name
virtual G4VPhysicsConstructor * Build()
verbose
Definition: train.py:477
General GArSoft Utilities.
QTextStream & endl(QTextStream &s)