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