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