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