OPALX (Object Oriented Parallel Accelerator Library for Exascal) MINIorX
OPALX
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("ELECTRON");
58 CREATE_STRINGCONSTANT("PROTON");
59 CREATE_STRINGCONSTANT("POSITRON");
60 CREATE_STRINGCONSTANT("ANTIPROTON");
61 CREATE_STRINGCONSTANT("CARBON");
62 CREATE_STRINGCONSTANT("HMINUS");
63 CREATE_STRINGCONSTANT("URANIUM");
65 CREATE_STRINGCONSTANT("DEUTERON");
66 CREATE_STRINGCONSTANT("XENON");
68 CREATE_STRINGCONSTANT("ALPHA");
69 // Distribution / TYPE
70 CREATE_STRINGCONSTANT("FROMFILE");
71 CREATE_STRINGCONSTANT("GAUSS");
72 CREATE_STRINGCONSTANT("MULTIVARIATEGAUSS");
73 CREATE_STRINGCONSTANT("BINOMIAL");
74 CREATE_STRINGCONSTANT("FLATTOP");
75 CREATE_STRINGCONSTANT("MULTIGAUSS");
76 CREATE_STRINGCONSTANT("GUNGAUSSFLATTOPTH");
77 CREATE_STRINGCONSTANT("ASTRAFLATTOPTH");
78 CREATE_STRINGCONSTANT("GAUSSMATCHED");
79
80 // Distribution / INPUTMOUNITS
82 CREATE_STRINGCONSTANT("EVOVERC");
83
84 // Distribution / EMISSIONMODEL
85 CREATE_STRINGCONSTANT("ASTRA");
86 CREATE_STRINGCONSTANT("NONEQUIL");
87 // additionally: NONE
88
89 // TrimCoil / TYPE
90 // CREATE_STRINGCONSTANT("PSI-BFIELD");
91 // CREATE_STRINGCONSTANT("PSI-PHASE");
92 // CREATE_STRINGCONSTANT("PSI-BFIELD-MIRRORED");
93
94 // OptimizeCmd / CROSSOVER
95 CREATE_STRINGCONSTANT("BLEND");
96 CREATE_STRINGCONSTANT("NAIVEONEPOINT");
97 CREATE_STRINGCONSTANT("NAIVEUNIFORM");
98 CREATE_STRINGCONSTANT("SIMULATEDBINARY");
99
100 // OptimizeCmd / MUTATION
101 CREATE_STRINGCONSTANT("ONEBIT");
102 CREATE_STRINGCONSTANT("INDEPENDENTBIT");
103
104 // OpalSample / TYPE
105 CREATE_STRINGCONSTANT("UNIFORM");
106 CREATE_STRINGCONSTANT("UNIFORM_INT");
107 CREATE_STRINGCONSTANT("GAUSSIAN");
108 CREATE_STRINGCONSTANT("LATIN_HYPERCUBE");
109 CREATE_STRINGCONSTANT("RANDOM_SEQUENCE_UNIFORM_INT");
110 CREATE_STRINGCONSTANT("RANDOM_SEQUENCE_UNIFORM");
111
112 // Option / RNGTYPE
113 CREATE_STRINGCONSTANT("RANDOM");
114 CREATE_STRINGCONSTANT("HALTON");
115 CREATE_STRINGCONSTANT("SOBOL");
116 CREATE_STRINGCONSTANT("NIEDERREITER");
117
118 // OpalWake / TYPE
119 // CREATE_STRINGCONSTANT("1D-CSR");
120 // CREATE_STRINGCONSTANT("1D-CSR-IGF");
121 // CREATE_STRINGCONSTANT("LONG-SHORT-RANGE");
122 // CREATE_STRINGCONSTANT("TRANSV-SHORT-RANGE");
123
124 // OpalWake / CONDUCT
127
128 // ParticleMatterInteraction / TYPE
129 CREATE_STRINGCONSTANT("SCATTERING");
130 CREATE_STRINGCONSTANT("BEAMSTRIPPING");
131
132 // FieldSolver / FSTYPE
134 CREATE_STRINGCONSTANT("FFTPERIODIC");
135 // additionally: NONE
136
137 // FieldSolver / BCFFT
138 CREATE_STRINGCONSTANT("OPEN");
139 CREATE_STRINGCONSTANT("DIRICHLET");
140 CREATE_STRINGCONSTANT("PERIODIC");
141
142 // FieldSolver / GREENSF
143 CREATE_STRINGCONSTANT("STANDARD");
144 CREATE_STRINGCONSTANT("INTEGRATED");
145
146 // FieldSolver / INTERPL
147 CREATE_STRINGCONSTANT("CONSTANT");
148 CREATE_STRINGCONSTANT("LINEAR");
149 CREATE_STRINGCONSTANT("QUADRATIC");
150
151 // FieldSolver / PRECMODE
153 CREATE_STRINGCONSTANT("HIERARCHY");
154 CREATE_STRINGCONSTANT("REUSE");
155
156 // Option / PSDUMPFRAME
157 CREATE_STRINGCONSTANT("GLOBAL");
158 CREATE_STRINGCONSTANT("BUNCH_MEAN");
159 CREATE_STRINGCONSTANT("REFERENCE");
160
161 // OpalFilter / TYPE
162 // CREATE_STRINGCONSTANT("SAVITZKY-GOLAY");
163 CREATE_STRINGCONSTANT("FIXEDFFTLOWPASS");
164 CREATE_STRINGCONSTANT("RELATIVEFFTLOWPASS");
165 CREATE_STRINGCONSTANT("STENCIL");
166
167 // TrackRun / METHOD
168 CREATE_STRINGCONSTANT("PARALLEL");
169
170 // TrackRun / MBMODE
171 CREATE_STRINGCONSTANT("FORCE");
172 CREATE_STRINGCONSTANT("AUTO");
173
174 // TrackRun / MB_BINNING
175 CREATE_STRINGCONSTANT("GAMMA_BINNING");
176 CREATE_STRINGCONSTANT("BUNCH_BINNING");
177
178 // ParticleMatterInteraction / MATERIAL
180 CREATE_STRINGCONSTANT("ALUMINAAL2O3");
181 CREATE_STRINGCONSTANT("ALUMINUM");
182 CREATE_STRINGCONSTANT("BERYLLIUM");
183 CREATE_STRINGCONSTANT("BORONCARBIDE");
184 CREATE_STRINGCONSTANT("COPPER");
185 CREATE_STRINGCONSTANT("GOLD");
186 CREATE_STRINGCONSTANT("GRAPHITE");
187 CREATE_STRINGCONSTANT("GRAPHITER6710");
188 CREATE_STRINGCONSTANT("KAPTON");
189 CREATE_STRINGCONSTANT("MOLYBDENUM");
190 CREATE_STRINGCONSTANT("MYLAR");
191 CREATE_STRINGCONSTANT("TITANIUM");
192 CREATE_STRINGCONSTANT("WATER");
193
194 // TrackCmd / TIMEINTEGRATOR
198
199 // OpalVacuum / GAS
201 // additionally: AIR
202
203 // BoundaryGeometry / TOPO
204 CREATE_STRINGCONSTANT("RECTANGULAR");
205 CREATE_STRINGCONSTANT("BOXCORNER");
206 CREATE_STRINGCONSTANT("ELLIPTIC");
207
208 // DumpEMFields / COORDINATE_SYSTEM
209 CREATE_STRINGCONSTANT("CARTESIAN");
210 CREATE_STRINGCONSTANT("CYLINDRICAL");
211}
212
213StringConstant::StringConstant(const std::string& name, StringConstant* parent)
214 : ValueDefinition(name, parent) {
215}
216
218 const std::string& name, StringConstant* parent, const std::string& value)
219 : ValueDefinition(name, parent) {
221 itsAttr[0].setReadOnly(true);
222 builtin = true;
223}
224
227
229 return false;
230}
231
232StringConstant* StringConstant::clone(const std::string& name) {
233 return new StringConstant(name, this);
234}
235
236std::string StringConstant::getString() const {
238}
239
240void StringConstant::print(std::ostream& os) const {
241 os << "STRING " << getOpalName() << '=' << itsAttr[0] << ';';
242 os << std::endl;
243}
244
245void StringConstant::printValue(std::ostream& os) const {
246 os << itsAttr[0];
247}
#define CREATE_STRINGCONSTANT(x)
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
void registerOwnership(const AttributeHandler::OwnerType &itsClass) const
Definition Object.cpp:189
const std::string & getOpalName() const
Return object name.
Definition Object.cpp:308
Object(int size, const char *name, const char *help)
Constructor for exemplars.
Definition Object.cpp:354
std::vector< Attribute > itsAttr
The object attributes.
Definition Object.h:216
bool builtin
Built-in flag.
Definition Object.h:233
The global OPAL structure.
Definition OpalData.h:45
void create(Object *newObject)
Create new object.
Definition OpalData.cpp:473
static OpalData * getInstance()
Definition OpalData.cpp:195
ValueDefinition(int size, const char *name, const char *help)
Constructor for exemplars.
Attribute & value()
Return the attribute representing the value of the definition.
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.