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