OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
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
21namespace {
22 struct Entry {
23 const char* name;
24 double (DriftRep::*get)() const;
25 void (DriftRep::*set)(double);
26 };
27
28 const Entry entries[] = {
30} // namespace
31
32DriftRep::DriftRep() : Drift(), geometry(0.0) {}
33
34DriftRep::DriftRep(const DriftRep& right) : Drift(right), geometry(right.geometry) {}
35
36DriftRep::DriftRep(const std::string& name) : Drift(name), geometry() {}
37
39
40ElementBase* DriftRep::clone() const { return new DriftRep(*this); }
41
42Channel* DriftRep::getChannel(const std::string& aKey, bool create) {
43 for (const Entry* entry = entries; entry->name != 0; ++entry) {
44 if (aKey == entry->name) {
45 return new IndirectChannel<DriftRep>(*this, entry->get, entry->set);
46 }
47 }
48
49 return ElementBase::getChannel(aKey, create);
50}
51
53
54const NullField& DriftRep::getField() const { return field; }
55
57
Abstract interface for read/write access to variable.
Definition Channel.h:30
virtual ElementBase * clone() const
Return clone.
Definition DriftRep.cpp:40
virtual Channel * getChannel(const std::string &aKey, bool=false)
Construct a read/write channel.
Definition DriftRep.cpp:42
virtual StraightGeometry & getGeometry()
Get geometry.
Definition DriftRep.cpp:56
virtual NullField & getField()
Get field.
Definition DriftRep.cpp:52
NullField field
The zero magnetic field.
Definition DriftRep.h:65
StraightGeometry geometry
The geometry.
Definition DriftRep.h:68
virtual ~DriftRep()
Definition DriftRep.cpp:38
Interface for drift space.
Definition Drift.h:31
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 a [b]double[/b] data member.
A zero electromagnetic field.
Definition NullField.h:29
A geometry representing a straight line.