OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
SeptumRep.cpp
Go to the documentation of this file.
1 // ------------------------------------------------------------------------
2 // $RCSfile: SeptumRep.cpp,v $
3 // ------------------------------------------------------------------------
4 // $Revision: 1.1.1.1 $
5 // ------------------------------------------------------------------------
6 // Copyright: see Copyright.readme
7 // ------------------------------------------------------------------------
8 //
9 // Class: SeptumRep
10 // Defines a representation for a septa.
11 //
12 // ------------------------------------------------------------------------
13 // Class category: BeamlineCore
14 // ------------------------------------------------------------------------
15 //
16 // $Date: 2009/09/21 10:26:06 $
17 // $Author: bi $
18 //
19 // ------------------------------------------------------------------------
20 
21 #include "BeamlineCore/SeptumRep.h"
24 
25 
26 // Attribute access table.
27 // ------------------------------------------------------------------------
28 
29 namespace {
30  struct Entry {
31  const char *name;
32  double(SeptumRep::*get)() const;
33  void (SeptumRep::*set)(double);
34  };
35 
36  static const Entry entries[] = {
37  {
38  "L",
41  },
42  { 0, 0, 0 }
43  };
44 }
45 
46 
47 // Class SeptumRep
48 // ------------------------------------------------------------------------
49 
51  Septum(), field(), geometry(), active(true)
52 {}
53 
54 
56  Septum(right), field(), geometry(right.geometry), active(true)
57 {}
58 
59 
60 SeptumRep::SeptumRep(const std::string &name):
61  Septum(name), field(), geometry(), active(true)
62 {}
63 
64 
66 {}
67 
68 
70  return new SeptumRep(*this);
71 }
72 
73 
74 Channel *SeptumRep::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<SeptumRep>(*this, entry->get, entry->set);
78  }
79  }
80 
81  return ElementBase::getChannel(aKey, create);
82 }
83 
85  return field;
86 }
87 
89  return field;
90 }
91 
93  return geometry;
94 }
95 
97  return geometry;
98 }
99 
100 
103 
104  for(const Entry *entry = entries; entry->name != 0; ++entry) {
105  image->setAttribute(entry->name, (this->*(entry->get))());
106  }
107 
108  return image;
109 }
110 
111 void SeptumRep::setActive(bool flag) {
112  active = flag;
113 }
virtual ElementBase * clone() const
Return clone.
Definition: SeptumRep.cpp:69
StraightGeometry geometry
The septa&#39;s geometry.
Definition: SeptumRep.h:87
Interface for basic beam line object.
Definition: ElementBase.h:128
Interface for septum magnet.
Definition: Septum.h:11
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.
virtual void setActive(bool=true)
Set active flag.
Definition: SeptumRep.cpp:111
A zero electromagnetic field.
Definition: NullField.h:30
NullField field
The zero magnetic field.
Definition: SeptumRep.h:84
virtual ~SeptumRep()
Definition: SeptumRep.cpp:65
virtual StraightGeometry & getGeometry()
Get geometry.
Definition: SeptumRep.cpp:92
virtual ElementImage * getImage() const
Construct an image.
Definition: SeptumRep.cpp:101
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
virtual Channel * getChannel(const std::string &aKey, bool=false)
Construct a read/write channel.
Definition: SeptumRep.cpp:74
Representation for Septum.
Definition: SeptumRep.h:31
const std::string name
bool active
The active/inactive flag.
Definition: SeptumRep.h:90
virtual NullField & getField()
Get field.
Definition: SeptumRep.cpp:84
Access to a [b]double[/b] data member.