OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
StringConstant.cpp
Go to the documentation of this file.
1//
2// Class StringConstant
3// The STRING CONSTANT definition.
4//
5// Copyright (c) 2000 - 2021, 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
22#include "Utilities/Util.h"
23
24#include <iostream>
25
26#define CREATE_STRINGCONSTANT(x) opal->create(new StringConstant(x, this, x));
27
30 1, "STRING_CONSTANT",
31 "The \"STRING CONSTANT\" statement defines a global "
32 "string constant:\n"
33 "\tSTRING CONSTANT <name> = <String-expression>;\n") {
34 itsAttr[0] = Attributes::makeString("VALUE", "The constant value");
35
37
39 opal->create(new StringConstant("GITREVISION", this, Util::getGitRevision()));
40
41 // NOTE: Strings that contain a hyphen can't be written without quotes and
42 // no string constant should be defined for them
43
44 // Element / TYPE
46 CREATE_STRINGCONSTANT("CARBONCYCL");
47 CREATE_STRINGCONSTANT("CYCIAE");
48 CREATE_STRINGCONSTANT("AVFEQ");
50 CREATE_STRINGCONSTANT("BANDRF");
51 CREATE_STRINGCONSTANT("SYNCHROCYCLOTRON");
52 CREATE_STRINGCONSTANT("SINGLEGAP");
53 CREATE_STRINGCONSTANT("STANDING");
54 CREATE_STRINGCONSTANT("TEMPORAL");
55 CREATE_STRINGCONSTANT("SPATIAL");
56 // Beam / PARTICLE
57 CREATE_STRINGCONSTANT("PHOTON");
58 CREATE_STRINGCONSTANT("ELECTRON");
59 CREATE_STRINGCONSTANT("PROTON");
60 CREATE_STRINGCONSTANT("POSITRON");
61 CREATE_STRINGCONSTANT("ANTIPROTON");
62 CREATE_STRINGCONSTANT("CARBON");
63 CREATE_STRINGCONSTANT("HMINUS");
64 CREATE_STRINGCONSTANT("URANIUM");
67 CREATE_STRINGCONSTANT("DEUTERON");
68 CREATE_STRINGCONSTANT("XENON");
70 CREATE_STRINGCONSTANT("ALPHA");
71 // Distribution / TYPE
72 CREATE_STRINGCONSTANT("FROMFILE");
73 CREATE_STRINGCONSTANT("EMITTEDFROMFILE");
74 CREATE_STRINGCONSTANT("GAUSS");
75 CREATE_STRINGCONSTANT("MULTIVARIATEGAUSS");
76 CREATE_STRINGCONSTANT("BINOMIAL");
77 CREATE_STRINGCONSTANT("FLATTOP");
78 CREATE_STRINGCONSTANT("OPALFLATTOP");
79 CREATE_STRINGCONSTANT("MULTIGAUSS");
80 CREATE_STRINGCONSTANT("GUNGAUSSFLATTOPTH");
81 CREATE_STRINGCONSTANT("ASTRAFLATTOPTH");
82 CREATE_STRINGCONSTANT("GAUSSMATCHED");
83
84 // Distribution / INPUTMOUNITS
86 CREATE_STRINGCONSTANT("EVOVERC");
87
88 // Distribution / EMISSIONMODEL
89 CREATE_STRINGCONSTANT("ASTRA");
90 CREATE_STRINGCONSTANT("NONEQUIL");
91 // additionally: NONE
92
93 // TrimCoil / TYPE
94 // CREATE_STRINGCONSTANT("PSI-BFIELD");
95 // CREATE_STRINGCONSTANT("PSI-PHASE");
96 // CREATE_STRINGCONSTANT("PSI-BFIELD-MIRRORED");
97
98 // OptimizeCmd / CROSSOVER
99 CREATE_STRINGCONSTANT("BLEND");
100 CREATE_STRINGCONSTANT("NAIVEONEPOINT");
101 CREATE_STRINGCONSTANT("NAIVEUNIFORM");
102 CREATE_STRINGCONSTANT("SIMULATEDBINARY");
103
104 // OptimizeCmd / MUTATION
105 CREATE_STRINGCONSTANT("ONEBIT");
106 CREATE_STRINGCONSTANT("INDEPENDENTBIT");
107
108 // OpalSample / TYPE
109 CREATE_STRINGCONSTANT("UNIFORM");
110 CREATE_STRINGCONSTANT("UNIFORM_INT");
111 CREATE_STRINGCONSTANT("GAUSSIAN");
112 CREATE_STRINGCONSTANT("LATIN_HYPERCUBE");
113 CREATE_STRINGCONSTANT("RANDOM_SEQUENCE_UNIFORM_INT");
114 CREATE_STRINGCONSTANT("RANDOM_SEQUENCE_UNIFORM");
115
116 // Option / RNGTYPE
117 CREATE_STRINGCONSTANT("RANDOM");
118 CREATE_STRINGCONSTANT("HALTON");
119 CREATE_STRINGCONSTANT("SOBOL");
120 CREATE_STRINGCONSTANT("NIEDERREITER");
121
122 // OpalWake / TYPE
123 // CREATE_STRINGCONSTANT("1D-CSR");
124 // CREATE_STRINGCONSTANT("1D-CSR-IGF");
125 // CREATE_STRINGCONSTANT("LONG-SHORT-RANGE");
126 // CREATE_STRINGCONSTANT("TRANSV-SHORT-RANGE");
127
128 // OpalWake / CONDUCT
131
132 // ParticleMatterInteraction / TYPE
133 CREATE_STRINGCONSTANT("SCATTERING");
134 CREATE_STRINGCONSTANT("BEAMSTRIPPING");
135
136 // FieldSolver / FSTYPE
139 // CREATE_STRINGCONSTANT("OPEN"); // already exists as BC!
141 // additionally: NONE
142
143 // Binning / PARAMETER
144 CREATE_STRINGCONSTANT("VELOCITYZ");
145 CREATE_STRINGCONSTANT("POSITIONZ");
147 CREATE_STRINGCONSTANT("GAMMAZ");
148
149 // FieldSolver / BCFFT
150 CREATE_STRINGCONSTANT("OPEN");
151 CREATE_STRINGCONSTANT("DIRICHLET");
152 CREATE_STRINGCONSTANT("PERIODIC");
153
154 // FieldSolver / GREENSF
155 CREATE_STRINGCONSTANT("STANDARD");
156 CREATE_STRINGCONSTANT("INTEGRATED");
157
158 // FieldSolver / INTERPL
159 CREATE_STRINGCONSTANT("CONSTANT");
160 CREATE_STRINGCONSTANT("LINEAR");
161 CREATE_STRINGCONSTANT("QUADRATIC");
162
163 // FieldSolver / PRECMODE
165 CREATE_STRINGCONSTANT("HIERARCHY");
166 CREATE_STRINGCONSTANT("REUSE");
167
168 // Option / PSDUMPFRAME
169 CREATE_STRINGCONSTANT("GLOBAL");
170 CREATE_STRINGCONSTANT("BUNCH_MEAN");
171 CREATE_STRINGCONSTANT("REFERENCE");
172
173 // OpalFilter / TYPE
174 // CREATE_STRINGCONSTANT("SAVITZKY-GOLAY");
175 CREATE_STRINGCONSTANT("FIXEDFFTLOWPASS");
176 CREATE_STRINGCONSTANT("RELATIVEFFTLOWPASS");
177 CREATE_STRINGCONSTANT("STENCIL");
178
179 // TrackRun / METHOD
180 CREATE_STRINGCONSTANT("PARALLEL");
181
182 // TrackRun / MBMODE
183 CREATE_STRINGCONSTANT("FORCE");
184 CREATE_STRINGCONSTANT("AUTO");
185
186 // TrackRun / MB_BINNING
187 CREATE_STRINGCONSTANT("GAMMA_BINNING");
188 CREATE_STRINGCONSTANT("BUNCH_BINNING");
189
190 // ParticleMatterInteraction / MATERIAL
192 CREATE_STRINGCONSTANT("ALUMINAAL2O3");
193 CREATE_STRINGCONSTANT("ALUMINUM");
194 CREATE_STRINGCONSTANT("BERYLLIUM");
195 CREATE_STRINGCONSTANT("BORONCARBIDE");
196 CREATE_STRINGCONSTANT("COPPER");
197 CREATE_STRINGCONSTANT("GOLD");
198 CREATE_STRINGCONSTANT("GRAPHITE");
199 CREATE_STRINGCONSTANT("GRAPHITER6710");
200 CREATE_STRINGCONSTANT("KAPTON");
201 CREATE_STRINGCONSTANT("MOLYBDENUM");
202 CREATE_STRINGCONSTANT("MYLAR");
203 CREATE_STRINGCONSTANT("TITANIUM");
204 CREATE_STRINGCONSTANT("WATER");
205
206 // TrackCmd / TIMEINTEGRATOR
210
211 // OpalVacuum / GAS
213 // additionally: AIR
214
215 // BoundaryGeometry / TOPO
216 CREATE_STRINGCONSTANT("RECTANGULAR");
217 CREATE_STRINGCONSTANT("BOXCORNER");
218 CREATE_STRINGCONSTANT("ELLIPTIC");
219
220 // DumpEMFields / COORDINATE_SYSTEM
221 CREATE_STRINGCONSTANT("CARTESIAN");
222 CREATE_STRINGCONSTANT("CYLINDRICAL");
223}
224
225StringConstant::StringConstant(const std::string& name, StringConstant* parent)
226 : ValueDefinition(name, parent) {}
227
229 const std::string& name, StringConstant* parent, const std::string& value)
230 : ValueDefinition(name, parent) {
232 itsAttr[0].setReadOnly(true);
233 builtin = true;
234}
235
237
238bool StringConstant::canReplaceBy(Object*) { return false; }
239
240StringConstant* StringConstant::clone(const std::string& name) {
241 return new StringConstant(name, this);
242}
243
244std::string StringConstant::getString() const { return Attributes::getString(itsAttr[0]); }
245
246void StringConstant::print(std::ostream& os) const {
247 os << "STRING " << getOpalName() << '=' << itsAttr[0] << ';';
248 os << std::endl;
249}
250
251void StringConstant::printValue(std::ostream& os) const { os << itsAttr[0]; }
#define CREATE_STRINGCONSTANT(x)
The base class for all OPAL objects.
Definition Object.h:45
void registerOwnership(const AttributeHandler::OwnerType &itsClass) const
Definition Object.cpp:169
const std::string & getOpalName() const
Return object name.
Definition Object.cpp:267
std::vector< Attribute > itsAttr
The object attributes.
Definition Object.h:210
bool builtin
Built-in flag.
Definition Object.h:226
The global OPAL structure.
Definition OpalData.h:45
void create(Object *newObject)
Create new object.
Definition OpalData.cpp:387
static OpalData * getInstance()
Definition OpalData.cpp:193
virtual std::string getString() const
Return value.
virtual StringConstant * clone(const std::string &name)
Make clone.
virtual void print(std::ostream &) const
Print the constant.
virtual ~StringConstant()
StringConstant()
Exemplar constructor.
virtual void printValue(std::ostream &os) const
Print its value.
virtual bool canReplaceBy(Object *object)
Test if object can be replaced.
The base class for all OPAL value definitions.
Attribute & value()
Return the attribute representing the value of the definition.
void setString(Attribute &attr, const std::string &val)
Set string value.
std::string getString(const Attribute &attr)
Get string value.
Attribute makeString(const std::string &name, const std::string &help)
Make string attribute.
std::string getGitRevision()
Definition Util.cpp:32