OPALX (Object Oriented Parallel Accelerator Library for Exascal) MINIorX
OPALX
DriftRep.cpp
Go to the documentation of this file.
1//
2// Class DriftRep
3// Representation for a drift space.
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//
20
21
22namespace {
23 struct Entry {
24 const char *name;
25 double(DriftRep::*get)() const;
26 void (DriftRep::*set)(double);
27 };
28
29 const Entry entries[] = {
30 {
31 "L",
34 },
35 { 0, 0, 0 }
36 };
37}
38
39
41 Drift(),
42 geometry(0.0)
43{}
44
45
47 Drift(right),
48 geometry(right.geometry)
49{}
50
51
52DriftRep::DriftRep(const std::string &name):
53 Drift(name),
54 geometry()
55{}
56
57
60
61
63 return new DriftRep(*this);
64}
65
66
67Channel *DriftRep::getChannel(const std::string &aKey, bool create) {
68 for(const Entry *entry = entries; entry->name != 0; ++entry) {
69 if(aKey == entry->name) {
70 return new IndirectChannel<DriftRep>(*this, entry->get, entry->set);
71 }
72 }
73
74 return ElementBase::getChannel(aKey, create);
75}
76
77
81
83 return field;
84}
85
86
90
92 return geometry;
93}
Drift(const std::string &name)
Constructor with given name.
Definition Drift.cpp:41
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.
ElementBase(const std::string &name)
Constructor with given name.
virtual ElementBase * clone() const
Return clone.
Definition DriftRep.cpp:62
virtual Channel * getChannel(const std::string &aKey, bool=false)
Construct a read/write channel.
Definition DriftRep.cpp:67
virtual StraightGeometry & getGeometry()
Get geometry.
Definition DriftRep.cpp:87
virtual NullField & getField()
Get field.
Definition DriftRep.cpp:78
NullField field
The zero magnetic field.
Definition DriftRep.h:69
StraightGeometry geometry
The geometry.
Definition DriftRep.h:72
virtual ~DriftRep()
Definition DriftRep.cpp:58
DriftRep(const std::string &name)
Constructor with given name.
Definition DriftRep.cpp:52
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