OPAL (Object Oriented Parallel Accelerator Library)  2021.1.99
OPAL
SolenoidRep.cpp
Go to the documentation of this file.
1 //
2 // Class SolenoidRep
3 // Representation for a solenoid magnet.
4 //
5 // Copyright (c) 200x - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland
6 // All rights reserved
7 //
8 // This file is part of OPAL.
9 //
10 // OPAL is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with OPAL. If not, see <https://www.gnu.org/licenses/>.
17 //
20 
21 namespace {
22  struct Entry {
23  const char *name;
24  double(SolenoidRep::*get)() const;
25  void (SolenoidRep::*set)(double);
26  };
27 
28  const Entry entries[] = {
29  {
30  "L",
33  },
34  {
35  "BZ",
38  },
39  { 0, 0, 0 }
40  };
41 }
42 
43 
45  Solenoid(),
46  geometry(),
47  field()
48 {}
49 
50 
52  Solenoid(right),
53  geometry(right.geometry),
54  field(right.field)
55 {}
56 
57 
58 SolenoidRep::SolenoidRep(const std::string &name):
59  Solenoid(name), geometry(), field()
60 {}
61 
62 
64 {}
65 
66 
68  return new SolenoidRep(*this);
69 }
70 
71 
72 Channel *SolenoidRep::getChannel(const std::string &aKey, bool create) {
73  for(const Entry *entry = entries; entry->name != 0; ++entry) {
74  if(aKey == entry->name) {
75  return new IndirectChannel<SolenoidRep>(*this, entry->get, entry->set);
76  }
77  }
78 
79  return ElementBase::getChannel(aKey, create);
80 }
81 
82 
84  return field;
85 }
86 
88  return field;
89 }
90 
91 
93  return geometry;
94 }
95 
97  return geometry;
98 }
99 
100 
101 double SolenoidRep::getBz() const {
102  return field.getBz();
103 }
104 
105 
106 void SolenoidRep::setBz(double Bz) {
107  field.setBz(Bz);
108 }
const std::string name
virtual Channel * getChannel(const std::string &aKey, bool create=false)
Construct a read/write channel.
virtual double getElementLength() const
Get design length.
Definition: ElementBase.h:432
virtual void setElementLength(double length)
Set design length.
Definition: ElementBase.h:436
Interface for solenoids.
Definition: Solenoid.h:36
virtual Channel * getChannel(const std::string &aKey, bool=false)
Construct a read/write channel.
Definition: SolenoidRep.cpp:72
virtual StraightGeometry & getGeometry()
Get geometry.
Definition: SolenoidRep.cpp:92
virtual ElementBase * clone() const
Return clone.
Definition: SolenoidRep.cpp:67
ConstBzField field
The solenoid field.
Definition: SolenoidRep.h:80
StraightGeometry geometry
The solenoid geometry.
Definition: SolenoidRep.h:77
virtual ~SolenoidRep()
Definition: SolenoidRep.cpp:63
virtual double getBz() const
Get field.
virtual void setBz(double Bz)
Set field.
virtual ConstBzField & getField()
Get field.
Definition: SolenoidRep.cpp:83
A geometry representing a straight line.
Abstract interface for read/write access to variable.
Definition: Channel.h:32
Access to a [b]double[/b] data member.
A homogeneous magnetostatic field in z-direction.
Definition: ConstBzField.h:30
virtual double getBz() const
Get component.
virtual void setBz(double Bz)
Set component.