OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
MultipoleRep.cpp
Go to the documentation of this file.
1//
2// Class MultipoleRep
3// Representation for a general multipole.
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//
19#include <cctype>
22
23// Attribute access table.
24// ------------------------------------------------------------------------
25
26namespace {
27 struct Entry {
28 const char* name;
29 double (MultipoleRep::*get)() const;
30 void (MultipoleRep::*set)(double);
31 };
32
33 const Entry entries[] = {
35} // namespace
36
37MultipoleRep::MultipoleRep() : Multipole(), geometry(), field() {}
38
40 : Multipole(multipole), geometry(multipole.geometry), field(multipole.field) {}
41
42MultipoleRep::MultipoleRep(const std::string& name) : Multipole(name), geometry(), field() {}
43
45
46ElementBase* MultipoleRep::clone() const { return new MultipoleRep(*this); }
47
48Channel* MultipoleRep::getChannel(const std::string& aKey, bool create) {
49 if (aKey[0] == 'A' || aKey[0] == 'B') {
50 int n = 0;
51
52 for (std::string::size_type k = 1; k < aKey.length(); k++) {
53 if (isdigit(aKey[k])) {
54 n = 10 * n + aKey[k] - '0';
55 } else {
56 return 0;
57 }
58 }
59
60 if (aKey[0] == 'B') {
63 } else {
66 }
67 } else {
68 for (const Entry* entry = entries; entry->name != 0; ++entry) {
69 if (aKey == entry->name) {
70 return new IndirectChannel<MultipoleRep>(*this, entry->get, entry->set);
71 }
72 }
73
74 return ElementBase::getChannel(aKey, create);
75 }
76}
77
79
81
83
85
86void MultipoleRep::setField(const BMultipoleField& aField) { field = aField; }
The magnetic field of a multipole.
Abstract interface for read/write access to variable.
Definition Channel.h:30
virtual Channel * getChannel(const std::string &aKey, bool create=false)
Construct a read/write channel.
virtual double getElementLength() const
Get design length.
virtual void setElementLength(double length)
Set design length.
Access to an indexed [b]double[/b] data member.
Access to a [b]double[/b] data member.
virtual ElementBase * clone() const
Return clone.
virtual Channel * getChannel(const std::string &aKey, bool=false)
Construct a read/write channel.
StraightGeometry geometry
Multipole geometry.
virtual ~MultipoleRep()
virtual BMultipoleField & getField()
Get field.
BMultipoleField field
Multipole field.
virtual void setField(const BMultipoleField &field)
Set mulitpole field.
virtual StraightGeometry & getGeometry()
Get geometry.
Interface for general multipole.
Definition Multipole.h:30
void setSkewComponent(int n, double)
Definition Multipole.h:216
void setNormalComponent(int n, double)
Definition Multipole.h:214
double getSkewComponent(int n) const
Gets the n-th skew component of the multipole expansion.
double getNormalComponent(int n) const
Gets the n-th normal component of the multipole expansion.
A geometry representing a straight line.