OPAL (Object Oriented Parallel Accelerator Library)  2021.1.99
OPAL
SeptumRep.cpp
Go to the documentation of this file.
1 //
2 // Class SeptumRep
3 // Representation for Septum.
4 //
5 // Copyright (c) 200x - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland
6 // All rights reserved
7 //
8 // This file is part of OPAL.
9 //
10 // OPAL is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with OPAL. If not, see <https://www.gnu.org/licenses/>.
17 //
18 #include "BeamlineCore/SeptumRep.h"
20 
21 namespace {
22  struct Entry {
23  const char *name;
24  double(SeptumRep::*get)() const;
25  void (SeptumRep::*set)(double);
26  };
27 
28  static const Entry entries[] = {
29  {
30  "L",
33  },
34  { 0, 0, 0 }
35  };
36 }
37 
38 
40  Septum(), field(), geometry(), active(true)
41 {}
42 
43 
45  Septum(right), field(), geometry(right.geometry), active(true)
46 {}
47 
48 
49 SeptumRep::SeptumRep(const std::string &name):
50  Septum(name), field(), geometry(), active(true)
51 {}
52 
53 
55 {}
56 
57 
59  return new SeptumRep(*this);
60 }
61 
62 
63 Channel *SeptumRep::getChannel(const std::string &aKey, bool create) {
64  for(const Entry *entry = entries; entry->name != 0; ++entry) {
65  if(aKey == entry->name) {
66  return new IndirectChannel<SeptumRep>(*this, entry->get, entry->set);
67  }
68  }
69 
70  return ElementBase::getChannel(aKey, create);
71 }
72 
74  return field;
75 }
76 
78  return field;
79 }
80 
82  return geometry;
83 }
84 
86  return geometry;
87 }
88 
89 
90 void SeptumRep::setActive(bool flag) {
91  active = flag;
92 }
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
Definition: Septum.h:23
virtual StraightGeometry & getGeometry()
Get geometry.
Definition: SeptumRep.cpp:81
NullField field
The zero magnetic field.
Definition: SeptumRep.h:73
StraightGeometry geometry
The septa's geometry.
Definition: SeptumRep.h:76
virtual void setActive(bool=true)
Set active flag.
Definition: SeptumRep.cpp:90
bool active
The active/inactive flag.
Definition: SeptumRep.h:79
virtual ElementBase * clone() const
Return clone.
Definition: SeptumRep.cpp:58
virtual NullField & getField()
Get field.
Definition: SeptumRep.cpp:73
virtual ~SeptumRep()
Definition: SeptumRep.cpp:54
virtual Channel * getChannel(const std::string &aKey, bool=false)
Construct a read/write channel.
Definition: SeptumRep.cpp:63
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