OPAL (Object Oriented Parallel Accelerator Library)  2021.1.99
OPAL
XCorrectorRep.cpp
Go to the documentation of this file.
1 //
2 // Class XCorrectorRep
3 // Representation for an orbit corrector.
4 // This derived class acts on the horizontal plane.
5 //
6 // Copyright (c) 200x - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland
7 // All rights reserved
8 //
9 // This file is part of OPAL.
10 //
11 // OPAL is free software: you can redistribute it and/or modify
12 // it under the terms of the GNU General Public License as published by
13 // the Free Software Foundation, either version 3 of the License, or
14 // (at your option) any later version.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with OPAL. If not, see <https://www.gnu.org/licenses/>.
18 //
21 
22 namespace {
23  struct Entry {
24  const char *name;
25  double(XCorrectorRep::*get)() const;
26  void (XCorrectorRep::*set)(double);
27  };
28 
29  const Entry entries[] = {
30  {
31  "L",
34  },
35  {
36  "BY",
39  },
40  { 0, 0, 0 }
41  };
42 }
43 
44 
46  CorrectorRep()
47 {}
48 
49 
51  CorrectorRep(rhs)
52 {}
53 
54 
55 XCorrectorRep::XCorrectorRep(const std::string &name):
57 {}
58 
59 
61 {}
62 
63 
65  return new XCorrectorRep(*this);
66 }
67 
68 
69 Channel *XCorrectorRep::getChannel(const std::string &aKey, bool create) {
70  for(const Entry *entry = entries; entry->name != 0; ++entry) {
71  if(aKey == entry->name) {
72  return new IndirectChannel<XCorrectorRep>(*this, entry->get, entry->set);
73  }
74  }
75 
76  return ElementBase::getChannel(aKey, create);
77 }
78 
80  return active ? X : OFF;
81 }
82 
83 
84 double XCorrectorRep::getBx() const {
85  return 0.0;
86 }
87 
88 
89 void XCorrectorRep::setBx(double) {
90  // Do nothing.
91 }
const std::string name
Plane
Plane selection.
Definition: Corrector.h:40
@ OFF
Corrector is off (inactive).
Definition: Corrector.h:42
@ X
Corrector acts on x-plane.
Definition: Corrector.h:44
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
virtual double getBy() const
Get vertical field component in Teslas.
bool active
The active/inactive flag.
Definition: CorrectorRep.h:92
virtual void setBy(double)
Set vertical field component in Teslas.
virtual void setBx(double)
Set field.
virtual Channel * getChannel(const std::string &aKey, bool=false)
Construct a read/write channel.
virtual Plane getPlane() const
Get plane of action.
virtual double getBx() const
Get field.
virtual ElementBase * clone() const
Return clone.
virtual ~XCorrectorRep()
Abstract interface for read/write access to variable.
Definition: Channel.h:32
Access to a [b]double[/b] data member.