OPAL (Object Oriented Parallel Accelerator Library)  2021.1.99
OPAL
VacuumRep.cpp
Go to the documentation of this file.
1 //
2 // Class VacuumRep
3 // Defines a concrete representation for vacuum conditions.
4 //
5 // Copyright (c) 2018-2021, Pedro Calvo, CIEMAT, Spain
6 // All rights reserved
7 //
8 // Implemented as part of the PhD thesis
9 // "Optimizing the radioisotope production of the novel AMIT
10 // superconducting weak focusing cyclotron"
11 //
12 // This file is part of OPAL.
13 //
14 // OPAL is free software: you can redistribute it and/or modify
15 // it under the terms of the GNU General Public License as published by
16 // the Free Software Foundation, either version 3 of the License, or
17 // (at your option) any later version.
18 //
19 // You should have received a copy of the GNU General Public License
20 // along with OPAL. If not, see <https://www.gnu.org/licenses/>.
21 //
22 #include "BeamlineCore/VacuumRep.h"
23 
25 
26 
27 namespace {
28  struct Entry {
29  const char *name;
30  double(VacuumRep::*get)() const;
31  void (VacuumRep::*set)(double);
32  };
33  const Entry entries[] = {
34  {
35  "p",
38  },
39  { 0, 0, 0 }
40  };
41 }
42 
43 
44 // Class VacuumRep
45 // ------------------------------------------------------------------------
46 
48  Vacuum(),
49  geometry(0.0, 0.0)
50 {}
51 
53  Vacuum(right),
54  geometry(0.0, 0.0)
55 {}
56 
57 VacuumRep::VacuumRep(const std::string &name):
58  Vacuum(name),
59  geometry(0.0, 0.0)
60 {}
61 
63 {}
64 
65 
67  return new VacuumRep(*this);
68 }
69 
70 
71 Channel *VacuumRep::getChannel(const std::string &aKey, bool create) {
72  for(const Entry *entry = entries; entry->name != 0; ++entry) {
73  if(aKey == entry->name) {
74  return new IndirectChannel<VacuumRep>(*this, entry->get, entry->set);
75  }
76  }
77  return ElementBase::getChannel(aKey, create);
78 }
79 
80 
82  return field;
83 }
84 
86  return field;
87 }
88 
89 
91  return geometry;
92 }
93 
95  return geometry;
96 }
const std::string name
virtual Channel * getChannel(const std::string &aKey, bool create=false)
Construct a read/write channel.
Definition: Vacuum.h:67
double getPressure() const
Definition: Vacuum.cpp:97
void setPressure(double pressure)
Definition: Vacuum.cpp:93
virtual Channel * getChannel(const std::string &aKey, bool=false)
Construct a read/write channel.
Definition: VacuumRep.cpp:71
virtual ~VacuumRep()
Definition: VacuumRep.cpp:62
PlanarArcGeometry geometry
Definition: VacuumRep.h:78
NullField field
Definition: VacuumRep.h:75
virtual ElementBase * clone() const
Return clone.
Definition: VacuumRep.cpp:66
virtual PlanarArcGeometry & getGeometry()
Get geometry.
Definition: VacuumRep.cpp:90
virtual NullField & getField()
Get field.
Definition: VacuumRep.cpp:81
A simple arc in the XZ plane.
Abstract interface for read/write access to variable.
Definition: Channel.h:32
Access to a [b]double[/b] data member.
A zero electromagnetic field.
Definition: NullField.h:30