OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
DegraderRep.cpp
Go to the documentation of this file.
1 // ------------------------------------------------------------------------
2 // $RCSfile: DegraderRep.cpp,v $
3 // ------------------------------------------------------------------------
4 // $Revision: 1.1.1.1 $
5 // ------------------------------------------------------------------------
6 // Copyright: see Copyright.readme
7 // ------------------------------------------------------------------------
8 //
9 // Class: DegraderRep
10 // Defines a concrete collimator representation.
11 //
12 // ------------------------------------------------------------------------
13 // Class category: BeamlineCore
14 // ------------------------------------------------------------------------
15 //
16 // $Date: 2000/03/27 09:32:33 $
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(DegraderRep::*get)() const;
33  void (DegraderRep::*set)(double);
34  };
35 
36  const Entry entries[] = {
37  {
38  "L",
41  },
42  { 0, 0, 0 }
43  };
44 }
45 
46 
47 // Class DegraderRep
48 // ------------------------------------------------------------------------
49 
51  Degrader(),
52  geometry(0.0)
53 {}
54 
55 
57  Degrader(right),
58  geometry(right.geometry)
59 {}
60 
61 
62 DegraderRep::DegraderRep(const std::string &name):
63  Degrader(name),
64  geometry()
65 {}
66 
67 
69 {}
70 
71 
73  return new DegraderRep(*this);
74 }
75 
76 
77 Channel *DegraderRep::getChannel(const std::string &aKey, bool create) {
78  for(const Entry *entry = entries; entry->name != 0; ++entry) {
79  if(aKey == entry->name) {
80  return new IndirectChannel<DegraderRep>(*this, entry->get, entry->set);
81  }
82  }
83 
84  return ElementBase::getChannel(aKey, create);
85 }
86 
87 
89  return field;
90 }
91 
93  return field;
94 }
95 
96 
98  return geometry;
99 }
100 
102  return geometry;
103 }
104 
105 
108 
109  for(const Entry *entry = entries; entry->name != 0; ++entry) {
110  image->setAttribute(entry->name, (this->*(entry->get))());
111  }
112 
113  return image;
114 }
virtual StraightGeometry & getGeometry()
Get geometry.
Definition: DegraderRep.cpp:97
virtual NullField & getField()
Get field.
Definition: DegraderRep.cpp:88
virtual Channel * getChannel(const std::string &aKey, bool=false)
Construct a read/write channel.
Definition: DegraderRep.cpp:77
Interface for basic beam line object.
Definition: ElementBase.h:128
StraightGeometry geometry
Definition: DegraderRep.h:96
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.
NullField field
Definition: DegraderRep.h:93
A zero electromagnetic field.
Definition: NullField.h:30
virtual ElementBase * clone() const
Return clone.
Definition: DegraderRep.cpp:72
virtual ~DegraderRep()
Definition: DegraderRep.cpp:68
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.
Representation for a collimator.
Definition: DegraderRep.h:32
void setAttribute(const std::string &aKey, double val)
Set value of an attribute.
virtual ElementImage * getImage() const
Construct an image.
A geometry representing a straight line.
Abstract interface for read/write access to variable.
Definition: Channel.h:32
Abstract collimator.
Definition: Degrader.h:37
const std::string name
Access to a [b]double[/b] data member.