OPAL (Object Oriented Parallel Accelerator Library) 2024.2
OPAL
Attributes.h
Go to the documentation of this file.
1#ifndef OPAL_Attributes_HH
2#define OPAL_Attributes_HH
3
4// ------------------------------------------------------------------------
5// $RCSfile: Attributes.h,v $
6// ------------------------------------------------------------------------
7// $Revision: 1.1.1.1 $
8// ------------------------------------------------------------------------
9// Copyright: see Copyright.readme
10// ------------------------------------------------------------------------
11//
12// Namespace Attributes
13//
14// ------------------------------------------------------------------------
15//
16// $Date: 2000/03/27 09:33:37 $
17// $Author: Andreas Adelmann $
18//
19// ------------------------------------------------------------------------
20
22#include "Parser/Token.h"
23
24#include <initializer_list>
25#include <list>
26#include <string>
27#include <vector>
28
29class PlaceRep;
30class RangeRep;
31class TableRowRep;
32
33// Namespace Attributes.
34// ------------------------------------------------------------------------
36// their values.
37// Each exemplar constructor must use these functions to fill in the
38// attribute handlers for all command attributes.
39// This namespace is part of the interface to the class Attribute,
40// used to store object attributes.
41
42namespace Attributes {
43
45 // Initial value undefined.
46 extern Attribute makeBool(const std::string &name, const std::string &help);
47
49 // Initial value defined.
50 extern Attribute
51 makeBool(const std::string &name, const std::string &help, bool initial);
52
54 // Evaluate any expression and return value.
55 // If the expression is non-deferred, the value is cached.
56 // Re-evaluation takes place only if a new definition has been read.
57 bool getBool(const Attribute &);
58
60 extern void setBool(Attribute &, bool);
61
62
64 // Initial value is empty array.
65 extern Attribute makeBoolArray(const std::string &name, const std::string &help);
66
68 extern std::vector<bool> getBoolArray(const Attribute &);
69
71 extern void setBoolArray(Attribute &, const std::vector<bool> &);
72
73
75 // Initial value is "#S".
76 extern Attribute makePlace(const std::string &name, const std::string &help);
77
79 extern PlaceRep getPlace(const Attribute &);
80
82 extern void setPlace(Attribute &, const PlaceRep &);
83
84
86 // Initial value is "FULL".
87 extern Attribute makeRange(const std::string &name, const std::string &help);
88
90 extern RangeRep getRange(const Attribute &);
91
93 extern void setRange(Attribute &, const RangeRep &);
94
95
97 // Initial value is undefined.
98 extern Attribute
99 makeReal(const std::string &name, const std::string &help);
100
102 // Initial value is defined.
103 extern Attribute
104 makeReal(const std::string &name, const std::string &help, double initial);
105
107 extern double getReal(const Attribute &attr);
108
110 extern void setReal(Attribute &attr, double val);
111
112
114 // Initial value is empty array.
115 extern Attribute makeRealArray(const std::string &name, const std::string &help);
116
118 extern std::vector<double> getRealArray(const Attribute &);
119
121 extern void setRealArray(Attribute &, const std::vector<double> &);
122
123
125 // Initial value is undefined.
126 extern Attribute makeReference(const std::string &name, const std::string &help);
127
128
130 // Initial value undefined.
131 extern Attribute makeString(const std::string &name, const std::string &help);
132
134 // Initial value is defined.
135 extern Attribute
136 makeString(const std::string &name, const std::string &help, const std::string &initial);
137
139 extern std::string getString(const Attribute &attr);
140
142 extern void setString(Attribute &attr, const std::string &val);
143
145 // Initial value undefined.
146 extern Attribute makePredefinedString(const std::string &name,
147 const std::string &help,
148 const std::initializer_list<std::string>& predefinedStrings);
149
151 // Initial value is defined.
152 extern Attribute
153 makePredefinedString(const std::string &name,
154 const std::string &help,
155 const std::initializer_list<std::string>& predefinedStrings,
156 const std::string &initial);
157
159 extern void setPredefinedString(Attribute &attr, const std::string &val);
160
162 // Initial value undefined.
163 extern Attribute makeUpperCaseString(const std::string &name, const std::string &help);
164
166 // Initial value is defined.
167 extern Attribute
168 makeUpperCaseString(const std::string &name, const std::string &help, const std::string &initial);
169
171 extern void setUpperCaseString(Attribute &attr, const std::string &val);
172
174 // Initial value is empty array.
175 extern Attribute makeStringArray(const std::string &name, const std::string &help);
176
178 extern std::vector<std::string> getStringArray(const Attribute &);
179
181 extern void setStringArray(Attribute &, const std::vector<std::string> &);
182
184 // Initial value is empty array.
185 extern Attribute makeUpperCaseStringArray(const std::string &name, const std::string &help);
186
188 extern void setUpperCaseStringArray(Attribute &, const std::vector<std::string> &);
189
191 // Initial value is undefined.
192 extern Attribute makeTableRow(const std::string &name, const std::string &help);
193
195 extern TableRowRep getTableRow(const Attribute &);
196
198 extern void setTableRow(Attribute &, const TableRowRep &);
199
200
202 // Initial value is empty list.
203 extern Attribute makeTokenList(const std::string &name, const std::string &help);
204
206 extern std::list<Token> getTokenList(const Attribute &attr);
207
209 extern void setTokenList(Attribute &attr, const std::list<Token> &);
210
211
213 // Initial value is empty array.
214 extern Attribute makeTokenListArray(const std::string &name, const std::string &help);
215
217 extern std::vector<std::list<Token> >
218 getTokenListArray(const Attribute &attr);
219
221 extern void
222 setTokenListArray(Attribute &attr, const std::vector<std::list<Token> > &);
223
224};
225
226#endif // OPAL_Attributes_HH
const std::string name
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.
A representation of an Object attribute.
Definition Attribute.h:52
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