OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
XMonitorRep.cpp
Go to the documentation of this file.
1 // ------------------------------------------------------------------------
2 // $RCSfile: XMonitorRep.cpp,v $
3 // ------------------------------------------------------------------------
4 // $Revision: 1.1.1.1 $
5 // ------------------------------------------------------------------------
6 // Copyright: see Copyright.readme
7 // ------------------------------------------------------------------------
8 //
9 // Class: XMonitorRep
10 // Defines a concrete representation for a horizontal orbit monitor.
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(XMonitorRep::*get)() const;
33  void (XMonitorRep::*set)(double);
34  };
35 
36  const Entry entries[] = {
37  {
38  "L",
41  },
42  { 0, 0, 0 }
43  };
44 }
45 
46 
47 // Class XMonitorRep
48 // ------------------------------------------------------------------------
49 
51  MonitorRep()
52 {}
53 
54 
56  MonitorRep(rhs)
57 {}
58 
59 
60 XMonitorRep::XMonitorRep(const std::string &name):
61  MonitorRep(name)
62 {}
63 
64 
66 {}
67 
68 
70  return new XMonitorRep(*this);
71 }
72 
73 
74 Channel *XMonitorRep::getChannel(const std::string &aKey, bool create) {
75  for(const Entry *entry = entries; entry->name != 0; ++entry) {
76  if(aKey == entry->name) {
77  return new IndirectChannel<XMonitorRep>(*this, entry->get, entry->set);
78  }
79  }
80 
81  return ElementBase::getChannel(aKey, create);
82 }
83 
84 
87 
88  for(const Entry *entry = entries; entry->name != 0; ++entry) {
89  image->setAttribute(entry->name, (this->*(entry->get))());
90  }
91 
92  return image;
93 }
94 
95 
97  return active ? X : OFF;
98 }
Interface for basic beam line object.
Definition: ElementBase.h:128
virtual Channel * getChannel(const std::string &aKey, bool=false)
Construct a read/write channel.
Definition: XMonitorRep.cpp:74
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.
Representation for a orbit position monitor.
Definition: XMonitorRep.h:31
Monitor acts on x-plane.
Definition: Monitor.h:50
Monitor is off (inactive).
Definition: Monitor.h:48
virtual ElementBase * clone() const
Return clone.
Definition: XMonitorRep.cpp:69
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.
virtual ~XMonitorRep()
Definition: XMonitorRep.cpp:65
virtual ElementImage * getImage() const
Construct an image.
Definition: XMonitorRep.cpp:85
Abstract interface for read/write access to variable.
Definition: Channel.h:32
const std::string name
Representation for an orbit position monitor.
Definition: MonitorRep.h:32
bool active
The active/inactive flag.
Definition: MonitorRep.h:94
virtual Plane getPlane() const
Get plane.
Definition: XMonitorRep.cpp:96
Plane
Plane selection.
Definition: Monitor.h:46
Access to a [b]double[/b] data member.