OPAL (Object Oriented Parallel Accelerator Library)  2021.1.99
OPAL
MonitorRep.cpp
Go to the documentation of this file.
1 //
2 // Class MonitorRep
3 // Representation for an orbit position monitor.
4 // The base class observes both planes.
5 //
6 // Copyright (c) 200x - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland
7 // All rights reserved
8 //
9 // This file is part of OPAL.
10 //
11 // OPAL is free software: you can redistribute it and/or modify
12 // it under the terms of the GNU General Public License as published by
13 // the Free Software Foundation, either version 3 of the License, or
14 // (at your option) any later version.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with OPAL. If not, see <https://www.gnu.org/licenses/>.
18 //
21 
22 namespace {
23  struct Entry {
24  const char *name;
25  double(MonitorRep::*get)() const;
26  void (MonitorRep::*set)(double);
27  };
28 
29  const Entry entries[] = {
30  {
31  "L",
34  },
35  { 0, 0, 0 }
36  };
37 }
38 
39 
41  Monitor(), field(), geometry(), active(true)
42 {}
43 
44 
46  Monitor(right), field(), geometry(right.geometry), active(true)
47 {}
48 
49 
50 MonitorRep::MonitorRep(const std::string &name):
51  Monitor(name), field(), geometry(), active(true)
52 {}
53 
54 
56 {}
57 
58 
60  return new MonitorRep(*this);
61 }
62 
63 
64 Channel *MonitorRep::getChannel(const std::string &aKey, bool create) {
65  for(const Entry *entry = entries; entry->name != 0; ++entry) {
66  if(aKey == entry->name) {
67  return new IndirectChannel<MonitorRep>(*this, entry->get, entry->set);
68  }
69  }
70 
71  return ElementBase::getChannel(aKey, create);
72 }
73 
74 
76  return field;
77 }
78 
80  return field;
81 }
82 
83 
85  return geometry;
86 }
87 
89  return geometry;
90 }
91 
92 
94  return active ? XY : OFF;
95 }
96 
97 
98 void MonitorRep::setActive(bool flag) {
99  active = flag;
100 }
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
Plane
Plane selection.
Definition: Monitor.h:37
@ XY
Monitor acts on both planes.
Definition: Monitor.h:45
@ OFF
Monitor is off (inactive).
Definition: Monitor.h:39
NullField field
The zero magnetic field.
Definition: MonitorRep.h:77
virtual Channel * getChannel(const std::string &aKey, bool=false)
Construct a read/write channel.
Definition: MonitorRep.cpp:64
virtual ElementBase * clone() const
Return clone.
Definition: MonitorRep.cpp:59
virtual NullField & getField()
Get field.
Definition: MonitorRep.cpp:75
StraightGeometry geometry
The monitor geometry.
Definition: MonitorRep.h:80
virtual StraightGeometry & getGeometry()
Get geometry.
Definition: MonitorRep.cpp:84
virtual Plane getPlane() const
Get planes.
Definition: MonitorRep.cpp:93
virtual void setActive(bool=true)
Set active flag.
Definition: MonitorRep.cpp:98
bool active
The active/inactive flag.
Definition: MonitorRep.h:83
virtual ~MonitorRep()
Definition: MonitorRep.cpp:55
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 zero electromagnetic field.
Definition: NullField.h:30