OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
SolenoidRep.cpp
Go to the documentation of this file.
1 // ------------------------------------------------------------------------
2 // $RCSfile: SolenoidRep.cpp,v $
3 // ------------------------------------------------------------------------
4 // $Revision: 1.1.1.1 $
5 // ------------------------------------------------------------------------
6 // Copyright: see Copyright.readme
7 // ------------------------------------------------------------------------
8 //
9 // Class: SolenoidRep
10 // Defines a concrete representation for a solenoid.
11 //
12 // ------------------------------------------------------------------------
13 // Class category: BeamlineCore
14 // ------------------------------------------------------------------------
15 //
16 // $Date: 2000/03/27 09:32:34 $
17 // $Author: fci $
18 //
19 // ------------------------------------------------------------------------
20 
24 
25 
26 // Attribute access table.
27 // ------------------------------------------------------------------------
28 
29 namespace {
30  struct Entry {
31  const char *name;
32  double(SolenoidRep::*get)() const;
33  void (SolenoidRep::*set)(double);
34  };
35 
36  const Entry entries[] = {
37  {
38  "L",
41  },
42  {
43  "BZ",
46  },
47  { 0, 0, 0 }
48  };
49 }
50 
51 
52 // Class SolenoidRep
53 // ------------------------------------------------------------------------
54 
56  Solenoid(),
57  geometry(),
58  field()
59 {}
60 
61 
63  Solenoid(right),
64  geometry(right.geometry),
65  field(right.field)
66 {}
67 
68 
69 SolenoidRep::SolenoidRep(const std::string &name):
70  Solenoid(name), geometry(), field()
71 {}
72 
73 
75 {}
76 
77 
79  return new SolenoidRep(*this);
80 }
81 
82 
83 Channel *SolenoidRep::getChannel(const std::string &aKey, bool create) {
84  for(const Entry *entry = entries; entry->name != 0; ++entry) {
85  if(aKey == entry->name) {
86  return new IndirectChannel<SolenoidRep>(*this, entry->get, entry->set);
87  }
88  }
89 
90  return ElementBase::getChannel(aKey, create);
91 }
92 
93 
95  return field;
96 }
97 
99  return field;
100 }
101 
102 
104  return geometry;
105 }
106 
108  return geometry;
109 }
110 
111 
114 
115  for(const Entry *entry = entries; entry->name != 0; ++entry) {
116  image->setAttribute(entry->name, (this->*(entry->get))());
117  }
118 
119  return image;
120 }
121 
122 
123 double SolenoidRep::getBz() const {
124  return field.getBz();
125 }
126 
127 
128 void SolenoidRep::setBz(double Bz) {
129  field.setBz(Bz);
130 }
virtual Channel * getChannel(const std::string &aKey, bool=false)
Construct a read/write channel.
Definition: SolenoidRep.cpp:83
Interface for basic beam line object.
Definition: ElementBase.h:128
virtual ElementImage * getImage() const
Construct an image.
virtual void setBz(double Bz)
Set field.
virtual void setElementLength(double length)
Set design length.
Definition: ElementBase.h:515
virtual Channel * getChannel(const std::string &aKey, bool create=false)
Construct a read/write channel.
virtual double getElementLength() const override
Get design length.
Definition: Solenoid.cpp:256
virtual ConstBzField & getField()
Get field.
Definition: SolenoidRep.cpp:94
Tepresentation for a solenoid magnet.
Definition: SolenoidRep.h:32
StraightGeometry geometry
The solenoid geometry.
Definition: SolenoidRep.h:88
An image of an element.
Definition: ElementImage.h:35
virtual ElementImage * getImage() const
Construct an image.
ConstBzField field
The solenoid field.
Definition: SolenoidRep.h:91
void setAttribute(const std::string &aKey, double val)
Set value of an attribute.
Interface for solenoids.
Definition: Solenoid.h:36
virtual ElementBase * clone() const
Return clone.
Definition: SolenoidRep.cpp:78
A geometry representing a straight line.
virtual double getBz() const
Get component.
Abstract interface for read/write access to variable.
Definition: Channel.h:32
virtual double getBz() const
Get field.
const std::string name
A homogeneous magnetostatic field in z-direction.
Definition: ConstBzField.h:30
virtual StraightGeometry & getGeometry()
Get geometry.
virtual void setBz(double Bz)
Set component.
virtual ~SolenoidRep()
Definition: SolenoidRep.cpp:74
Access to a [b]double[/b] data member.