OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
Material.cpp
Go to the documentation of this file.
1 #include "Physics/Material.h"
2 #include "Physics/Air.h"
3 #include "Physics/AluminaAL2O3.h"
4 #include "Physics/Aluminum.h"
5 #include "Physics/Beryllium.h"
6 #include "Physics/BoronCarbide.h"
7 #include "Physics/Copper.h"
8 #include "Physics/Gold.h"
9 #include "Physics/Graphite.h"
10 #include "Physics/GraphiteR6710.h"
11 #include "Physics/Kapton.h"
12 #include "Physics/Molybdenum.h"
13 #include "Physics/Mylar.h"
14 #include "Physics/Titanium.h"
15 #include "Physics/Water.h"
17 #include "Utilities/Util.h"
18 
19 #include <iostream>
20 
21 using namespace Physics;
22 
23 std::map<std::string, std::shared_ptr<Material> > Material::protoTable_sm;
24 
25 std::shared_ptr<Material> Material::addMaterial(const std::string &name,
26  std::shared_ptr<Material> mat_ptr) {
27  std::string nameUp = Util::toUpper(name);
28  if (protoTable_sm.find(nameUp) != protoTable_sm.end())
29  return protoTable_sm[nameUp];
30 
31  protoTable_sm.insert(std::make_pair(nameUp, mat_ptr));
32 
33  return mat_ptr;
34 }
35 
36 std::shared_ptr<Material> Material::getMaterial(const std::string &name) {
37  std::string nameUp = Util::toUpper(name);
38  if (protoTable_sm.find(nameUp) != protoTable_sm.end()) return protoTable_sm[nameUp];
39 
40  throw GeneralClassicException("Material::getMaterial", "Unknown material '" + name + "'");
41 }
42 
43 namespace {
44  auto air = Material::addMaterial("Air",
45  std::shared_ptr<Material>(new Air()));
46  auto aluminaal2o3 = Material::addMaterial("AluminaAL2O3",
47  std::shared_ptr<Material>(new AluminaAL2O3()));
48  auto aluminum = Material::addMaterial("Aluminum",
49  std::shared_ptr<Material>(new Aluminum()));
50  auto beryllium = Material::addMaterial("Beryllium",
51  std::shared_ptr<Material>(new Beryllium()));
52  auto berilium = Material::addMaterial("Berilium",
53  beryllium);
54  auto boroncarbide = Material::addMaterial("BoronCarbide",
55  std::shared_ptr<Material>(new BoronCarbide()));
56  auto copper = Material::addMaterial("Copper",
57  std::shared_ptr<Material>(new Copper()));
58  auto gold = Material::addMaterial("Gold",
59  std::shared_ptr<Material>(new Gold()));
60  auto graphite = Material::addMaterial("Graphite",
61  std::shared_ptr<Material>(new Graphite()));
62  auto graphiter6710 = Material::addMaterial("GraphiteR6710",
63  std::shared_ptr<Material>(new GraphiteR6710()));
64  auto kapton = Material::addMaterial("Kapton",
65  std::shared_ptr<Material>(new Kapton()));
66  auto molybdenum = Material::addMaterial("Molybdenum",
67  std::shared_ptr<Material>(new Molybdenum()));
68  auto mylar = Material::addMaterial("Mylar",
69  std::shared_ptr<Material>(new Mylar()));
70  auto titanium = Material::addMaterial("Titanium",
71  std::shared_ptr<Material>(new Titanium()));
72  auto titan = Material::addMaterial("Titan",
73  titanium);
74  auto water = Material::addMaterial("Water",
75  std::shared_ptr<Material>(new Water()));
76 }
std::string toUpper(const std::string &str)
Definition: Util.cpp:130
static std::map< std::string, std::shared_ptr< Material > > protoTable_sm
Definition: Material.h:46
static std::shared_ptr< Material > addMaterial(const std::string &name, std::shared_ptr< Material > mat_ptr)
Definition: Material.cpp:25
static std::shared_ptr< Material > getMaterial(const std::string &name)
Definition: Material.cpp:36
const std::string name