OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
MonitorRep.cpp
Go to the documentation of this file.
1 // ------------------------------------------------------------------------
2 // $RCSfile: MonitorRep.cpp,v $
3 // ------------------------------------------------------------------------
4 // $Revision: 1.1.1.1 $
5 // ------------------------------------------------------------------------
6 // Copyright: see Copyright.readme
7 // ------------------------------------------------------------------------
8 //
9 // Class: MonitorRep
10 // Defines a concrete representation for an orbit monitor acting on
11 // both planes.
12 //
13 // ------------------------------------------------------------------------
14 // Class category: BeamlineCore
15 // ------------------------------------------------------------------------
16 //
17 // $Date: 2000/03/27 09:32:33 $
18 // $Author: fci $
19 //
20 // ------------------------------------------------------------------------
21 
25 
26 
27 // Attribute access table.
28 // ------------------------------------------------------------------------
29 
30 namespace {
31  struct Entry {
32  const char *name;
33  double(MonitorRep::*get)() const;
34  void (MonitorRep::*set)(double);
35  };
36 
37  const Entry entries[] = {
38  {
39  "L",
42  },
43  { 0, 0, 0 }
44  };
45 }
46 
47 
48 // Class MonitorRep
49 // ------------------------------------------------------------------------
50 
52  Monitor(), field(), geometry(), active(true)
53 {}
54 
55 
57  Monitor(right), field(), geometry(right.geometry), active(true)
58 {}
59 
60 
61 MonitorRep::MonitorRep(const std::string &name):
62  Monitor(name), field(), geometry(), active(true)
63 {}
64 
65 
67 {}
68 
69 
71  return new MonitorRep(*this);
72 }
73 
74 
75 Channel *MonitorRep::getChannel(const std::string &aKey, bool create) {
76  for(const Entry *entry = entries; entry->name != 0; ++entry) {
77  if(aKey == entry->name) {
78  return new IndirectChannel<MonitorRep>(*this, entry->get, entry->set);
79  }
80  }
81 
82  return ElementBase::getChannel(aKey, create);
83 }
84 
85 
87  return field;
88 }
89 
91  return field;
92 }
93 
94 
96  return geometry;
97 }
98 
100  return geometry;
101 }
102 
103 
106 
107  for(const Entry *entry = entries; entry->name != 0; ++entry) {
108  image->setAttribute(entry->name, (this->*(entry->get))());
109  }
110 
111  return image;
112 }
113 
114 
116  return active ? XY : OFF;
117 }
118 
119 
120 void MonitorRep::setActive(bool flag) {
121  active = flag;
122 }
Interface for basic beam line object.
Definition: ElementBase.h:128
NullField field
The zero magnetic field.
Definition: MonitorRep.h:88
virtual Channel * getChannel(const std::string &aKey, bool=false)
Construct a read/write channel.
Definition: MonitorRep.cpp:75
Interface for beam position monitors.
Definition: Monitor.h:41
virtual Plane getPlane() const
Get planes.
Definition: MonitorRep.cpp:115
virtual void setElementLength(double length)
Set design length.
Definition: ElementBase.h:515
virtual NullField & getField()
Get field.
Definition: MonitorRep.cpp:86
virtual Channel * getChannel(const std::string &aKey, bool create=false)
Construct a read/write channel.
StraightGeometry geometry
The monitor geometry.
Definition: MonitorRep.h:91
Monitor acts on both planes.
Definition: Monitor.h:54
virtual StraightGeometry & getGeometry()
Get geometry.
Definition: MonitorRep.cpp:95
A zero electromagnetic field.
Definition: NullField.h:30
Monitor is off (inactive).
Definition: Monitor.h:48
virtual ElementImage * getImage() const
Construct an image.
Definition: MonitorRep.cpp:104
virtual double getElementLength() const
Get design length.
Definition: ElementBase.h:511
An image of an element.
Definition: ElementImage.h:35
virtual ElementImage * getImage() const
Construct an image.
void setAttribute(const std::string &aKey, double val)
Set value of an attribute.
A geometry representing a straight line.
Abstract interface for read/write access to variable.
Definition: Channel.h:32
const std::string name
virtual ~MonitorRep()
Definition: MonitorRep.cpp:66
Representation for an orbit position monitor.
Definition: MonitorRep.h:32
virtual ElementBase * clone() const
Return clone.
Definition: MonitorRep.cpp:70
bool active
The active/inactive flag.
Definition: MonitorRep.h:94
virtual void setActive(bool=true)
Set active flag.
Definition: MonitorRep.cpp:120
Plane
Plane selection.
Definition: Monitor.h:46
Access to a [b]double[/b] data member.