OPAL (Object Oriented Parallel Accelerator Library) 2022.1
OPAL
Attributes.cpp
Go to the documentation of this file.
1// ------------------------------------------------------------------------
2// $RCSfile: Attributes.cpp,v $
3// ------------------------------------------------------------------------
4// $Revision: 1.2 $
5// ------------------------------------------------------------------------
6// Copyright: see Copyright.readme
7// ------------------------------------------------------------------------
8//
9// Namespace Attributes
10//
11// ------------------------------------------------------------------------
12//
13// $Date: 2002/01/17 22:18:36 $
14// $Author: jsberg $
15//
16// ------------------------------------------------------------------------
17
19
21#include "Attributes/Bool.h"
23#include "Attributes/Place.h"
24#include "Attributes/Range.h"
25#include "Attributes/Real.h"
28#include "Attributes/String.h"
33#include "Attributes/TableRow.h"
36#include "Expressions/AValue.h"
38#include "Expressions/SValue.h"
40
43#include "Utilities/Util.h"
44
45#include <boost/regex.hpp>
46
47using namespace Expressions;
48
49namespace {
50 std::string stringifyVariable(Object *obj) {
51 ValueDefinition *value = dynamic_cast<ValueDefinition*>(obj);
52
53 if (value) {
54 std::ostringstream valueStream;
55 try {
56 double real = value->getReal();
57 valueStream << real;
58 return valueStream.str();
59 } catch (OpalException const& e) {
60 }
61 try {
62 std::string str = value->getString();
63 valueStream << str;
64 return valueStream.str();
65 } catch (OpalException const& e) {
66 }
67
68 try {
69 bool boolean = value->getBool();
70 valueStream << std::boolalpha << boolean;
71 return Util::toUpper(valueStream.str());
72 } catch (OpalException const&) {
73 }
74 }
75
76 throw OpalException("Attributes::stringifyVariable",
77 "The variable '" + obj->getOpalName() + "' isn't of type REAL, STRING or BOOL");
78 return "";
79 }
80}
81
82// Namespace Attributes.
83// ------------------------------------------------------------------------
84
85namespace Attributes {
86
87 // ----------------------------------------------------------------------
88 // Boolean value.
89
90 Attribute makeBool(const std::string &name, const std::string &help) {
91 return Attribute(new Bool(name, help), nullptr);
92 }
93
94
95 Attribute makeBool(const std::string &name, const std::string &help, bool ini) {
96 return Attribute(new Bool(name, help), new SValue<bool>(ini));
97 }
98
99
100 bool getBool(const Attribute &attr) {
101 if(attr.isBaseAllocated()) {
102 AttributeBase *base = &attr.getBase();
103 if(dynamic_cast<Bool *>(&attr.getHandler())) {
104 return dynamic_cast<SValue<bool> *>(base)->evaluate();
105 } else if(SValue<SRefAttr<bool> > *ref =
106 dynamic_cast<SValue<SRefAttr<bool> > *>(base)) {
107 const SRefAttr<bool> &value = ref->evaluate();
108 return value.evaluate();
109 } else {
110 throw OpalException("Attributes::getBool()", "Attribute \"" +
111 attr.getName() + "\" is not logical.");
112 }
113 } else {
114 return false;
115 }
116 }
117
118
119 void setBool(Attribute &attr, bool val) {
121 if(dynamic_cast<const Bool *>(&attr.getHandler())) {
122 attr.set(new SValue<bool>(val));
123 } else if((attr.isBaseAllocated() == true) &&
124 (ref = dynamic_cast<SValue<SRefAttr<bool> >*>(&attr.getBase()))) {
125 const SRefAttr<bool> &value = ref->evaluate();
126 value.set(val);
127 } else {
128 throw OpalException("Attributes::setBool()", "Attribute \"" +
129 attr.getName() + "\" is not logical.");
130 }
131 }
132
133
134 // ----------------------------------------------------------------------
135 // Boolean array value.
136 Attribute makeBoolArray(const std::string &name, const std::string &help) {
137 return Attribute(new BoolArray(name, help), nullptr);
138 }
139
140
141 std::vector<bool> getBoolArray(const Attribute &attr) {
142 if(attr.isBaseAllocated()) {
143 AttributeBase *base = &attr.getBase();
144 if(AValue<bool> *value =
145 dynamic_cast<AValue<bool>*>(base)) {
146 return value->evaluate();
147 } else {
148 throw OpalException("Attributes::getBoolArray()", "Attribute \"" +
149 attr.getName() + "\" is not a logical array.");
150 }
151 } else {
152 return std::vector<bool>();
153 }
154 }
155
156
157 void setBoolArray(Attribute &attr, const std::vector<bool> &value) {
158 if(dynamic_cast<const BoolArray *>(&attr.getHandler())) {
159 // Use ADeferred here, since a component may be overridden later
160 // by an expression.
161 attr.set(new ADeferred<bool>(value));
162 } else {
163 throw OpalException("Attributes::setBoolArray()", "Attribute \"" +
164 attr.getName() + "\" is not a logical array");
165 }
166 }
167
168
169 // ----------------------------------------------------------------------
170 // Place value.
171
172 Attribute makePlace(const std::string &name, const std::string &help) {
173 return Attribute(new Place(name, help),
174 new SValue<PlaceRep>(PlaceRep("#S")));
175 }
176
177
179 if(attr.isBaseAllocated()) {
180 if(SValue<PlaceRep> *place =
181 dynamic_cast<SValue<PlaceRep> *>(&attr.getBase())) {
182 return place->evaluate();
183 } else {
184 throw OpalException("Attributes::getPlace()", "Attribute \"" +
185 attr.getName() + "\" is not a place reference.");
186 }
187 } else {
188 return PlaceRep();
189 }
190 }
191
192
193 void setPlace(Attribute &attr, const PlaceRep &rep) {
194 if(dynamic_cast<const Place *>(&attr.getHandler())) {
195 attr.set(new SValue<PlaceRep>(rep));
196 } else {
197 throw OpalException("Attributes::setPlace()", "Attribute \"" +
198 attr.getName() + "\" is not a place reference.");
199 }
200 }
201
202
203 // ----------------------------------------------------------------------
204 // Range value.
205
206 Attribute makeRange(const std::string &name, const std::string &help) {
207 return Attribute(new Range(name, help),
209 }
210
211
213 if(attr.isBaseAllocated()) {
214 if(SValue<RangeRep> *range =
215 dynamic_cast<SValue<RangeRep> *>(&attr.getBase())) {
216 return range->evaluate();
217 } else {
218 throw OpalException("Attributes::getRange()", "Attribute \"" +
219 attr.getName() + "\" is not a range reference.");
220 }
221 } else {
222 return RangeRep();
223 }
224 }
225
226
227 void setRange(Attribute &attr, const RangeRep &rep) {
228 if(dynamic_cast<const Range *>(&attr.getHandler())) {
229 attr.set(new SValue<RangeRep>(rep));
230 } else {
231 throw OpalException("Attributes::setRange()", "Attribute \"" +
232 attr.getName() + "\" is not a range reference.");
233 }
234 }
235
236
237 // ----------------------------------------------------------------------
238 // Real value.
239
240 Attribute makeReal(const std::string &name, const std::string &help) {
241 return Attribute(new Real(name, help), nullptr);
242 }
243
244
246 makeReal(const std::string &name, const std::string &help, double initial) {
247 return Attribute(new Real(name, help),
248 new SValue<double>(initial));
249 }
250
251
252 double getReal(const Attribute &attr) {
253 if(attr.isBaseAllocated()) {
254 AttributeBase *base = &attr.getBase();
255 if(dynamic_cast<Real *>(&attr.getHandler())) {
256 return dynamic_cast<SValue<double> *>(base)->evaluate();
257 } else if(SValue<SRefAttr<double> > *ref =
258 dynamic_cast<SValue<SRefAttr<double> > *>(base)) {
259 const SRefAttr<double> &value = ref->evaluate();
260 return value.evaluate();
261 } else {
262 throw OpalException("Attributes::getReal()", "Attribute \"" +
263 attr.getName() + "\" is not real.");
264 }
265 } else {
266 return 0.0;
267 }
268 }
269
270
271 void setReal(Attribute &attr, double val) {
273 if(dynamic_cast<const Real *>(&attr.getHandler())) {
274 attr.set(new SValue<double>(val));
275 } else if((attr.isBaseAllocated() == true) &&
276 (ref = dynamic_cast<SValue<SRefAttr<double> >*>(&attr.getBase()))) {
277 const SRefAttr<double> &value = ref->evaluate();
278 value.set(val);
279 } else {
280 throw OpalException("Attributes::setReal()", "Attribute \"" +
281 attr.getName() + "\" is not real.");
282 }
283 }
284
285
286 // ----------------------------------------------------------------------
287 // Real array value.
288
289 Attribute makeRealArray(const std::string &name, const std::string &help) {
290 return Attribute(new RealArray(name, help), nullptr);
291 }
292
293
294 std::vector<double> getRealArray(const Attribute &attr) {
295 if(attr.isBaseAllocated()) {
296 if(dynamic_cast<RealArray *>(&attr.getHandler())) {
297 AttributeBase *base = &attr.getBase();
298 return dynamic_cast<AValue<double>*>(base)->evaluate();
299 } else {
300 throw OpalException("Attributes::getRealArray()", "Attribute \"" +
301 attr.getName() + "\" is not a real array.");
302 }
303 } else {
304 return std::vector<double>();
305 }
306 }
307
308
309 void setRealArray(Attribute &attr, const std::vector<double> &value) {
310 if(dynamic_cast<const RealArray *>(&attr.getHandler())) {
311 // Use ADeferred here, since a component may be overridden later
312 // by an expression.
313 attr.set(new ADeferred<double>(value));
314 } else {
315 throw OpalException("Attributes::setRealArray()", "Attribute \"" +
316 attr.getName() + "\" is not a real array.");
317 }
318 }
319
320
321 // ----------------------------------------------------------------------
322 // Reference value.
323
324 Attribute makeReference(const std::string &name, const std::string &help) {
325 return Attribute(new Reference(name, help), nullptr);
326 }
327
328
329 // ----------------------------------------------------------------------
330 // String value.
331
332 Attribute makeString(const std::string &name, const std::string &help) {
333 return Attribute(new String(name, help), nullptr);
334 }
335
336
338 makeString(const std::string &name, const std::string &help, const std::string &initial) {
339 return Attribute(new String(name, help), new SValue<std::string>(initial));
340 }
341
342
343 std::string getString(const Attribute &attr) {
344 if(attr.isBaseAllocated()) {
345 AttributeBase *base = &attr.getBase();
346 std::string expr;
347 if(dynamic_cast<String *>(&attr.getHandler())
348 || dynamic_cast<UpperCaseString *>(&attr.getHandler())
349 || dynamic_cast<PredefinedString *>(&attr.getHandler())) {
350 expr = dynamic_cast<SValue<std::string> *>(base)->evaluate();
351 } else if(SValue<SRefAttr<std::string> > *ref =
352 dynamic_cast<SValue<SRefAttr<std::string> > *>(base)) {
353 const SRefAttr<std::string> &value = ref->evaluate();
354 expr = value.evaluate();
355 } else {
356 throw OpalException("Attributes::getString()", "Attribute \"" +
357 attr.getName() + "\" is not string.");
358 }
359
360 auto opal = OpalData::getInstance();
361
362 boost::regex variableRE("\\$\\{(.*?)\\}");
363 boost::smatch what;
364
365 std::string exprDeref;
366 std::string::const_iterator start = expr.begin();
367 std::string::const_iterator end = expr.end();
368
369 while (boost::regex_search(start, end, what, variableRE, boost::match_default)) {
370 exprDeref += std::string(start, what[0].first);
371 std::string variable = Util::toUpper(std::string(what[1].first, what[1].second));
372
373 if (Object *obj = opal->find(variable)) {
374 exprDeref += ::stringifyVariable(obj);
375 } else {
376 throw OpalException("Attributes::getString",
377 "Can't find variable '" + variable + "' in string \"" + expr + "\"");
378 }
379
380 start = what[0].second;
381 }
382 exprDeref += std::string(start, end);
383
384 return exprDeref;
385 } else {
386 return std::string();
387 }
388 }
389
390
391 void setString(Attribute &attr, const std::string &val) {
393 if(dynamic_cast<const String *>(&attr.getHandler())) {
394 attr.set(new SValue<std::string>(val));
395 } else if((attr.isBaseAllocated() == true) &&
396 (ref = dynamic_cast<SValue<SRefAttr<std::string> >*>(&attr.getBase()))) {
397 const SRefAttr<std::string> &value = ref->evaluate();
398 value.set(val);
399 } else {
400 throw OpalException("Attributes::setString()", "Attribute \"" +
401 attr.getName() + "\" is not a string.");
402 }
403 }
404
405
406 // ----------------------------------------------------------------------
407 // Predefined string value.
408
410 const std::string &help,
411 const std::initializer_list<std::string>& predefinedStrings) {
412 return Attribute(new PredefinedString(name, help, predefinedStrings), nullptr);
413 }
414
415
417 makePredefinedString(const std::string &name,
418 const std::string &help,
419 const std::initializer_list<std::string>& predefinedStrings,
420 const std::string &initial) {
421 return Attribute(new PredefinedString(name, help, predefinedStrings, initial),
422 new SValue<std::string>(Util::toUpper(initial)));
423 }
424
425
426 void setPredefinedString(Attribute &attr, const std::string &val) {
428 std::string upperCaseVal = Util::toUpper(val);
429 if(dynamic_cast<const PredefinedString *>(&attr.getHandler())) {
430 attr.set(new SValue<std::string>(upperCaseVal));
431 } else if((attr.isBaseAllocated() == true) &&
432 (ref = dynamic_cast<SValue<SRefAttr<std::string> >*>(&attr.getBase()))) {
433 const SRefAttr<std::string> &value = ref->evaluate();
434 value.set(upperCaseVal);
435 } else {
436 throw OpalException("Attributes::setPredefinedString()", "Attribute \"" +
437 attr.getName() + "\" is not a supported string.");
438 }
439 }
440
441
442 // ----------------------------------------------------------------------
443 // Upper case string value.
444
445 Attribute makeUpperCaseString(const std::string &name, const std::string &help) {
446 return Attribute(new UpperCaseString(name, help), nullptr);
447 }
448
449
451 makeUpperCaseString(const std::string &name, const std::string &help, const std::string &initial) {
452 return Attribute(new UpperCaseString(name, help), new SValue<std::string>(Util::toUpper(initial)));
453 }
454
455
456 void setUpperCaseString(Attribute &attr, const std::string &val) {
458 if(dynamic_cast<const UpperCaseString *>(&attr.getHandler())) {
459 attr.set(new SValue<std::string>(Util::toUpper(val)));
460 } else if((attr.isBaseAllocated() == true) &&
461 (ref = dynamic_cast<SValue<SRefAttr<std::string> >*>(&attr.getBase()))) {
462 const SRefAttr<std::string> &value = ref->evaluate();
463 value.set(Util::toUpper(val));
464 } else {
465 throw OpalException("Attributes::setUpperCaseString()", "Attribute \"" +
466 attr.getName() + "\" is not an upper case string.");
467 }
468 }
469
470
471 // ----------------------------------------------------------------------
472 // String array value.
473 Attribute makeStringArray(const std::string &name, const std::string &help) {
474 return Attribute(new StringArray(name, help), nullptr);
475 }
476
477
478 std::vector<std::string> getStringArray(const Attribute &attr) {
479 if(attr.isBaseAllocated()) {
480 AttributeBase *base = &attr.getBase();
481 if(dynamic_cast<StringArray *>(&attr.getHandler())
482 || dynamic_cast<UpperCaseStringArray *>(&attr.getHandler())) {
483 auto opal = OpalData::getInstance();
484
485 boost::regex variableRE("\\$\\{(.*?)\\}");
486 boost::smatch what;
487
488 std::vector<std::string> value = dynamic_cast<AValue<std::string>*>(base)->evaluate();
489 for (auto expr: value) {
490 std::string exprDeref;
491 std::string::const_iterator start = expr.begin();
492 std::string::const_iterator end = expr.end();
493
494 while (boost::regex_search(start, end, what, variableRE, boost::match_default)) {
495 exprDeref += std::string(start, what[0].first);
496 std::string variable = Util::toUpper(std::string(what[1].first, what[1].second));
497
498 if (Object *obj = opal->find(variable)) {
499 std::ostringstream value;
500
501 RealVariable *real = static_cast<RealVariable*>(obj);
502 real->printValue(value);
503 exprDeref += value.str();
504 } else {
505 exprDeref += std::string(what[0].first, what[0].second);
506 }
507
508 start = what[0].second;
509 }
510 expr = exprDeref + std::string(start, end);
511 }
512
513 return value;
514 } else {
515 throw OpalException("Attributes::getStringArray()", "Attribute \"" +
516 attr.getName() + "\" is not a string array.");
517 }
518 } else {
519 return std::vector<std::string>();
520 }
521 }
522
523
524 void setStringArray(Attribute &attr, const std::vector<std::string> &value) {
525 if(dynamic_cast<const StringArray *>(&attr.getHandler())) {
526 // Strings are never expressions, so AValue will do here.
527 attr.set(new AValue<std::string>(value));
528 } else {
529 throw OpalException("Attributes::setStringArray()", "Attribute \"" +
530 attr.getName() + "\" is not a string array.");
531 }
532 }
533
534 // ----------------------------------------------------------------------
535 // Upper case string array value.
536 Attribute makeUpperCaseStringArray(const std::string &name, const std::string &help) {
537 return Attribute(new UpperCaseStringArray(name, help), nullptr);
538 }
539
540 void setUpperCaseStringArray(Attribute &attr, const std::vector<std::string> &value) {
541 if(dynamic_cast<const UpperCaseStringArray *>(&attr.getHandler())) {
542 // Strings are never expressions, so AValue will do here.
543 std::vector<std::string> uppercase(value.size());
544 std::transform(value.begin(), value.end(), uppercase.begin(),
545 [](std::string val) -> std::string { return Util::toUpper(val); });
546 attr.set(new AValue<std::string>(uppercase));
547 } else {
548 throw OpalException("Attributes::setUpperCaseStringArray()", "Attribute \"" +
549 attr.getName() + "\" is not an upper case string array.");
550 }
551 }
552
553
554 // ----------------------------------------------------------------------
555 // Table row reference value.
556
557 Attribute makeTableRow(const std::string &name, const std::string &help) {
558 return Attribute(new TableRow(name, help), nullptr);
559 }
560
561
563 if(attr.isBaseAllocated()) {
564 if(SValue<TableRowRep> *row =
565 dynamic_cast<SValue<TableRowRep> *>(&attr.getBase())) {
566 return row->evaluate();
567 } else {
568 throw OpalException("Attributes::getTableRow()", "Attribute \"" +
569 attr.getName() +
570 "\" is not a table row reference.");
571 }
572 } else {
573 return TableRowRep();
574 }
575 }
576
577
578 void setTableRow(Attribute &attr, const TableRowRep &rep) {
579 if(dynamic_cast<const TableRow *>(&attr.getHandler())) {
580 attr.set(new SValue<TableRowRep>(rep));
581 } else {
582 throw OpalException("Attributes::setTableRow()", "Attribute \"" +
583 attr.getName() +
584 "\" is not a table row reference.");
585 }
586 }
587
588
589 // ----------------------------------------------------------------------
590 // Token list value.
591
592 Attribute makeTokenList(const std::string &name, const std::string &help) {
593 return Attribute(new TokenList(name, help), nullptr);
594 }
595
596
597 std::list<Token> getTokenList(const Attribute &attr) {
598 if(attr.isBaseAllocated()) {
599 AttributeBase *base = &attr.getBase();
600 if(dynamic_cast<TokenList *>(&attr.getHandler())) {
601 return dynamic_cast<SValue<std::list<Token> > *>(base)->evaluate();
602 } else {
603 throw OpalException("Attributes::getTokenList()", "Attribute \"" +
604 attr.getName() + "\" is not a token list.");
605 }
606 } else {
607 return std::list<Token>();
608 }
609 }
610
611
612 void setTokenList(Attribute &attr, const std::list<Token> &val) {
613 if(dynamic_cast<const TokenList *>(&attr.getHandler())) {
614 attr.set(new SValue<std::list<Token> >(val));
615 } else {
616 throw OpalException("Attributes::setTokenList()", "Attribute \"" + attr.getName() +
617 "\" is not a token list.");
618 }
619 }
620
621
622 // ----------------------------------------------------------------------
623 // Token list array value.
624
625 Attribute makeTokenListArray(const std::string &name, const std::string &help) {
626 return Attribute(new TokenListArray(name, help), nullptr);
627 }
628
629
630 std::vector<std::list<Token> > getTokenListArray(const Attribute &attr) {
631 if(attr.isBaseAllocated()) {
632 AttributeBase *base = &attr.getBase();
633 if(dynamic_cast<TokenListArray *>(&attr.getHandler())) {
634 return dynamic_cast<AValue<std::list<Token> > *>(base)->evaluate();
635 } else {
636 throw OpalException("Attributes::getTokenListArray()", "Attribute \"" +
637 attr.getName() + "\" is not a token list array.");
638 }
639 } else {
640 return std::vector<std::list<Token> >();
641 }
642 }
643
644
645 void
647 const std::vector<std::list<Token> > &value) {
648 // Token lists are never expressions, so AValue will do here.
649 attr.set(new AValue<std::list<Token> >(value));
650 }
651}
FLieGenerator< T, N > real(const FLieGenerator< std::complex< T >, N > &)
Take real part of a complex generator.
PartBunchBase< T, Dim >::ConstIterator end(PartBunchBase< T, Dim > const &bunch)
const std::string name
Representation objects and parsers for attribute expressions.
Definition: Expressions.h:64
A collection of routines to construct object Attributes and retrieve.
Definition: Attributes.cpp:85
Attribute makePlace(const std::string &name, const std::string &help)
Create a place attribute.
Definition: Attributes.cpp:172
Attribute makeBool(const std::string &name, const std::string &help)
Make logical attribute.
Definition: Attributes.cpp:90
double getReal(const Attribute &attr)
Return real value.
Definition: Attributes.cpp:252
void setBoolArray(Attribute &attr, const std::vector< bool > &value)
Set logical array value.
Definition: Attributes.cpp:157
void setUpperCaseStringArray(Attribute &attr, const std::vector< std::string > &value)
Set upper case string array value.
Definition: Attributes.cpp:540
Attribute makeUpperCaseStringArray(const std::string &name, const std::string &help)
Make uppercase string array attribute.
Definition: Attributes.cpp:536
void setRealArray(Attribute &attr, const std::vector< double > &value)
Set array value.
Definition: Attributes.cpp:309
void setBool(Attribute &attr, bool val)
Set logical value.
Definition: Attributes.cpp:119
std::list< Token > getTokenList(const Attribute &attr)
Return token list value.
Definition: Attributes.cpp:597
void setTableRow(Attribute &attr, const TableRowRep &rep)
Set table row value.
Definition: Attributes.cpp:578
Attribute makeUpperCaseString(const std::string &name, const std::string &help)
Make uppercase string attribute.
Definition: Attributes.cpp:445
Attribute makeStringArray(const std::string &name, const std::string &help)
Create a string array attribute.
Definition: Attributes.cpp:473
void setUpperCaseString(Attribute &attr, const std::string &val)
Set uppercase string value.
Definition: Attributes.cpp:456
Attribute makePredefinedString(const std::string &name, const std::string &help, const std::initializer_list< std::string > &predefinedStrings)
Make predefined string attribute.
Definition: Attributes.cpp:409
Attribute makeReal(const std::string &name, const std::string &help)
Make real attribute.
Definition: Attributes.cpp:240
Attribute makeTableRow(const std::string &name, const std::string &help)
Create a table row attribute.
Definition: Attributes.cpp:557
Attribute makeReference(const std::string &name, const std::string &help)
Create a reference attribute.
Definition: Attributes.cpp:324
void setRange(Attribute &attr, const RangeRep &rep)
Set range value.
Definition: Attributes.cpp:227
void setString(Attribute &attr, const std::string &val)
Set string value.
Definition: Attributes.cpp:391
Attribute makeRange(const std::string &name, const std::string &help)
Create a range attribute.
Definition: Attributes.cpp:206
Attribute makeTokenListArray(const std::string &name, const std::string &help)
Make token list attribute.
Definition: Attributes.cpp:625
std::vector< bool > getBoolArray(const Attribute &attr)
Get logical array value.
Definition: Attributes.cpp:141
bool getBool(const Attribute &attr)
Return logical value.
Definition: Attributes.cpp:100
TableRowRep getTableRow(const Attribute &attr)
Get table row value.
Definition: Attributes.cpp:562
Attribute makeTokenList(const std::string &name, const std::string &help)
Make token list attribute.
Definition: Attributes.cpp:592
void setTokenListArray(Attribute &attr, const std::vector< std::list< Token > > &value)
Set token list array value.
Definition: Attributes.cpp:646
void setReal(Attribute &attr, double val)
Set real value.
Definition: Attributes.cpp:271
Attribute makeRealArray(const std::string &name, const std::string &help)
Create real array attribute.
Definition: Attributes.cpp:289
void setStringArray(Attribute &attr, const std::vector< std::string > &value)
Set string array value.
Definition: Attributes.cpp:524
PlaceRep getPlace(const Attribute &attr)
Get place value.
Definition: Attributes.cpp:178
std::vector< double > getRealArray(const Attribute &attr)
Get array value.
Definition: Attributes.cpp:294
std::vector< std::string > getStringArray(const Attribute &attr)
Get string array value.
Definition: Attributes.cpp:478
void setPredefinedString(Attribute &attr, const std::string &val)
Set predefined string value.
Definition: Attributes.cpp:426
std::string getString(const Attribute &attr)
Get string value.
Definition: Attributes.cpp:343
Attribute makeBoolArray(const std::string &name, const std::string &help)
Create a logical array attribute.
Definition: Attributes.cpp:136
std::vector< std::list< Token > > getTokenListArray(const Attribute &attr)
Return token list array value.
Definition: Attributes.cpp:630
void setTokenList(Attribute &attr, const std::list< Token > &val)
Set token list value.
Definition: Attributes.cpp:612
Attribute makeString(const std::string &name, const std::string &help)
Make string attribute.
Definition: Attributes.cpp:332
RangeRep getRange(const Attribute &attr)
Get range value.
Definition: Attributes.cpp:212
void setPlace(Attribute &attr, const PlaceRep &rep)
Set place value.
Definition: Attributes.cpp:193
constexpr double e
The value of.
Definition: Physics.h:39
std::string toUpper(const std::string &str)
Definition: Util.cpp:146
A representation of an Object attribute.
Definition: Attribute.h:52
AttributeBase & getBase() const
Return reference to polymorphic value.
Definition: Attribute.cpp:69
const std::string & getName() const
Return the attribute name.
Definition: Attribute.cpp:92
void set(AttributeBase *newBase)
Define new value.
Definition: Attribute.cpp:139
bool isBaseAllocated() const
Definition: Attribute.cpp:73
AttributeHandler & getHandler() const
Return a reference to the parser.
Definition: Attribute.cpp:77
Abstract base class for attribute values of different types.
Definition: AttributeBase.h:32
An attribute defined as a reference to a scalar.
Definition: SRefAttr.h:48
virtual void set(const T &) const
Store new value.
Definition: SRefAttr.h:205
virtual T evaluate() const
Evaluate.
Definition: SRefAttr.h:144
The base class for all OPAL objects.
Definition: Object.h:48
const std::string & getOpalName() const
Return object name.
Definition: Object.cpp:310
static OpalData * getInstance()
Definition: OpalData.cpp:196
Representation of a place within a beam line or sequence.
Definition: PlaceRep.h:41
Representation of a range within a beam line or sequence.
Definition: RangeRep.h:34
Representation of a table row reference.
Definition: TableRowRep.h:36
The base class for all OPAL value definitions.
virtual double getReal() const
Return real value.
virtual bool getBool() const
Return logical value.
virtual std::string getString() const
Return string value.
Parser for attribute of type logical.
Definition: Bool.h:31
Parser for an attribute of type logical array.
Definition: BoolArray.h:32
Parser for an attribute of type place reference.
Definition: Place.h:32
Parser for an attribute of type string.
Parser for an attribute of type range definition.
Definition: Range.h:32
Parser for an attribute of type real.
Definition: Real.h:31
Parser for an attribute of type real array.
Definition: RealArray.h:32
Parser for an attribute of type attribute reference.
Definition: Reference.h:33
Parser for an attribute of type string.
Definition: String.h:31
Parser for an attribute of type string array.
Definition: StringArray.h:32
Parser for an attribute of type table row reference.
Definition: TableRow.h:34
Parser for an attribute of type token list.
Definition: TokenList.h:36
Parser for an attribute of type token list array.
Parser for an attribute of type string.
Parser for an attribute of type string array.
Object attribute with a `‘deferred’' array value.
Definition: ADeferred.h:40
Object attribute with a constant array value.
Definition: AValue.h:35
Object attribute with a constant scalar value.
Definition: SValue.h:34
The base class for all OPAL exceptions.
Definition: OpalException.h:28