OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
SourceRep.cpp
Go to the documentation of this file.
4 
5 
6 // Attribute access table.
7 // ------------------------------------------------------------------------
8 
9 namespace {
10  struct Entry {
11  const char *name;
12  double(SourceRep::*get)() const;
13  void (SourceRep::*set)(double);
14  };
15 
16  const Entry entries[] = {
17  {
18  "L",
21  },
22  { 0, 0, 0 }
23  };
24 }
25 
26 
27 // Class SourceRep
28 // ------------------------------------------------------------------------
29 
31  Source(),
32  geometry()
33 {}
34 
35 
37  Source(right),
38  geometry(right.geometry)
39 {}
40 
41 
42 SourceRep::SourceRep(const std::string &name):
43  Source(name), geometry()
44 {}
45 
46 
48 {}
49 
50 
52  return new SourceRep(*this);
53 }
54 
55 
56 Channel *SourceRep::getChannel(const std::string &aKey, bool create) {
57  for(const Entry *entry = entries; entry->name != 0; ++entry) {
58  if(aKey == entry->name) {
59  return new IndirectChannel<SourceRep>(*this, entry->get, entry->set);
60  }
61  }
62 
63  return ElementBase::getChannel(aKey, create);
64 }
65 
67  return field;
68 }
69 
71  return field;
72 }
73 
75  return geometry;
76 }
77 
79  return geometry;
80 }
81 
82 
85 
86  for(const Entry *entry = entries; entry->name != 0; ++entry) {
87  image->setAttribute(entry->name, (this->*(entry->get))());
88  }
89 
90  return image;
91 }
Definition: Source.h:12
Interface for basic beam line object.
Definition: ElementBase.h:128
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.
A zero electromagnetic field.
Definition: NullField.h:30
virtual StraightGeometry & getGeometry()
Get geometry.
Definition: SourceRep.cpp:74
virtual double getElementLength() const
Get design length.
Definition: ElementBase.h:511
virtual NullField & getField()
Get field.
Definition: SourceRep.cpp:66
virtual ElementBase * clone() const
Return clone.
Definition: SourceRep.cpp:51
An image of an element.
Definition: ElementImage.h:35
virtual ElementImage * getImage() const
Construct an image.
StraightGeometry geometry
The solenoid geometry.
Definition: SourceRep.h:83
void setAttribute(const std::string &aKey, double val)
Set value of an attribute.
NullField field
Definition: SourceRep.h:80
A geometry representing a straight line.
virtual ElementImage * getImage() const
Construct an image.
Definition: SourceRep.cpp:83
Abstract interface for read/write access to variable.
Definition: Channel.h:32
const std::string name
virtual Channel * getChannel(const std::string &aKey, bool=false)
Construct a read/write channel.
Definition: SourceRep.cpp:56
Tepresentation for a solenoid magnet.
Definition: SourceRep.h:32
virtual ~SourceRep()
Definition: SourceRep.cpp:47
Access to a [b]double[/b] data member.