OPAL (Object Oriented Parallel Accelerator Library)  2021.1.99
OPAL
StripperRep.cpp
Go to the documentation of this file.
1 //
2 // Class StripperRep
3 // Representation for Stripper
4 //
5 // Copyright (c) 2011, Jianjun Yang,
6 // Paul Scherrer Institut, Villigen PSI, Switzerland
7 // All rights reserved
8 //
9 // Implemented as part of the PhD thesis
10 // "Beam dynamics in high intensity cyclotrons including neighboring bunch effects"
11 // and the paper
12 // "Beam dynamics in high intensity cyclotrons including neighboring bunch effects:
13 // Model, implementation, and application"
14 // (https://journals.aps.org/prab/pdf/10.1103/PhysRevSTAB.13.064201)
15 //
16 // This file is part of OPAL.
17 //
18 // OPAL is free software: you can redistribute it and/or modify
19 // it under the terms of the GNU General Public License as published by
20 // the Free Software Foundation, either version 3 of the License, or
21 // (at your option) any later version.
22 //
23 // You should have received a copy of the GNU General Public License
24 // along with OPAL. If not, see <https://www.gnu.org/licenses/>.
25 //
28 
29 
30 // Attribute access table.
31 // ------------------------------------------------------------------------
32 
33 namespace {
34  struct Entry {
35  const char *name;
36  double(StripperRep::*get)() const;
37  void (StripperRep::*set)(double);
38  };
39 
40  static const Entry entries[] = {
41  {
42  "L",
45  },
46  { 0, 0, 0 }
47  };
48 }
49 
50 
51 // Class StripperRep
52 // ------------------------------------------------------------------------
53 
55  Stripper(), field(), geometry(), active(true)
56 {}
57 
58 
60  Stripper(right), field(), geometry(right.geometry), active(true)
61 {}
62 
63 
64 StripperRep::StripperRep(const std::string &name):
65  Stripper(name), field(), geometry(), active(true)
66 {}
67 
68 
70 {}
71 
72 
74  return new StripperRep(*this);
75 }
76 
77 
78 Channel *StripperRep::getChannel(const std::string &aKey, bool create) {
79  for(const Entry *entry = entries; entry->name != 0; ++entry) {
80  if(aKey == entry->name) {
81  return new IndirectChannel<StripperRep>(*this, entry->get, entry->set);
82  }
83  }
84 
85  return ElementBase::getChannel(aKey, create);
86 }
87 
89  return field;
90 }
91 
93  return field;
94 }
95 
97  return geometry;
98 }
99 
101  return geometry;
102 }
103 
104 void StripperRep::setActive(bool flag) {
105  active = flag;
106 }
const std::string name
virtual Channel * getChannel(const std::string &aKey, bool create=false)
Construct a read/write channel.
virtual double getElementLength() const
Get design length.
Definition: ElementBase.h:432
virtual void setElementLength(double length)
Set design length.
Definition: ElementBase.h:436
NullField field
The zero magnetic field.
Definition: StripperRep.h:81
virtual StraightGeometry & getGeometry()
Get geometry.
Definition: StripperRep.cpp:96
virtual ~StripperRep()
Definition: StripperRep.cpp:69
virtual void setActive(bool=true)
Set active flag.
bool active
The active/inactive flag.
Definition: StripperRep.h:87
virtual ElementBase * clone() const
Return clone.
Definition: StripperRep.cpp:73
StraightGeometry geometry
The septa's geometry.
Definition: StripperRep.h:84
virtual Channel * getChannel(const std::string &aKey, bool=false)
Construct a read/write channel.
Definition: StripperRep.cpp:78
virtual NullField & getField()
Get field.
Definition: StripperRep.cpp:88
A geometry representing a straight line.
Abstract interface for read/write access to variable.
Definition: Channel.h:32
Access to a [b]double[/b] data member.
A zero electromagnetic field.
Definition: NullField.h:30