39 itsSequence(seq), okFlag(true), itsLine()
48 if (stat.
keyword(
"ENDSEQUENCE")) {
95 if (i->fromPosition != 0 &&
98 j != i->itsList.end(); ++j) {
99 (*j)->itsPosition += i->fromPosition->itsPosition;
112 "Circular \"FROM\" clauses.");
123 i->fromPosition = &(*pos);
126 "Not all FROM clauses resolved.");
137 if (ref ==
"ENTRY") {
139 }
else if (ref ==
"CENTRE" || ref.empty()) {
141 }
else if (ref ==
"EXIT") {
144 throw OpalException(
"SequenceParser::findNeighbourPositions()",
145 "Unknown reference flag \"" + ref +
146 "\" in <sequence> \"" +
158 std::string
name = i->getElement()->getName();
163 i->itsPosition += length / 2.0;
165 i->itsPosition += length;
173 std::string
name = j->getElement()->getName();
178 i->itsPosition += length;
180 i->itsPosition += length / 2.0;
265 throw ParseError(
"SequenceParser::parseMember()",
266 "You cannot redefine \"" + objName +
267 "\" within the sequence of the same name.");
269 throw ParseError(
"SequenceParser::parseMember()",
270 "You cannot refer to \"" + objName +
271 "\" within the sequence of the same name.");
273 throw ParseError(
"SequenceParser::parseMember()",
274 "You cannot redefine \"" + objName +
275 "\" within a sequence.");
280 }
else if (
BeamSequence *line = dynamic_cast<BeamSequence *>(obj)) {
281 copy = line->copy(objName);
283 copy = obj->
clone(objName);
292 if (
Element *elem = dynamic_cast<Element *>(&*copy)) {
309 throw ParseError(
"SequenceParser::parseMember()",
"Object \"" +
310 objName +
"\" is not an element.");
313 throw ParseError(
"SequenceParser::parseMember()",
314 "Element class name \"" + clsName +
"\" is unknown.");
322 double position = 0.0;
323 std::string fromName;
333 flag |= (flag & 0x0001) ? 0x0008 : 0x0001;
334 }
else if (name ==
"DRIFT") {
337 flag |= (flag & 0x0002) ? 0x0008 : 0x0002;
338 }
else if (name ==
"FROM") {
343 }
else if (stat.
keyword(
"E")) {
346 throw ParseError(
"SequenceParser::parsePosition()",
347 "Expected 'S' or 'E'.");
351 (stat,
"Expected <name>, \"#S\", or \"#E\".");
353 flag |= (flag & 0x0004) ? 0x0008 : 0x0004;
354 }
else if (defined) {
358 attr->parse(stat,
true);
360 attr->parse(stat,
false);
362 throw ParseError(
"SequenceParser::parsePosition()",
363 "Delimiter \"=\" or \":=\" expected.");
366 throw ParseError(
"SequenceParser::parsePosition()",
368 "\" has no attribute \"" + name +
"\".");
371 throw ParseError(
"SequenceParser::parsePosition()",
372 "Overriding attributes not permitted here.");
402 if (fromName ==
"PREVIOUS") {
405 }
else if (fromName ==
"NEXT") {
408 }
else if (fromName ==
"#S") {
411 }
else if (fromName ==
"#E") {
420 i != references.end(); ++i) {
421 if (i->fromName == fromName) {
423 i->itsList.push_back(&member);
431 ref.
itsList.push_back(&member);
432 references.push_back(ref);
438 throw ParseError(
"SequenceParser:parsePosition()",
439 "Conflicting keywords.");
SequenceMember * fromPosition
static OpalData * getInstance()
and give any other recipients of the Program a copy of this License along with the Program You may charge a fee for the physical act of transferring a copy
The base class for all OPAL objects.
Reference-counted pointer.
std::string getString(const Attribute &attr)
Get string value.
void parseDelimiter(Statement &stat, char delim)
Test for one-character delimiter.
void start()
Return to start.
void insertDrifts(TLine &line)
void define(Object *newObject)
Define a new object.
PositionType itsFlag
Flag word.
void makeDirty(Object *object)
Invalidate expressions.
ReferenceType
Reference for element positioning.
Pointer< Element > OpalElement
void fillPositions() const
void addEndMarkers(TLine &line) const
std::list< SequenceMember * > itsList
virtual ~SequenceParser()
std::string::iterator iterator
void storeLine(TLine &line)
Store sequence line.
TLine::iterator findNamedPosition(TLine &, const std::string &) const
The base class for all OPAL exceptions.
The base class for all OPAL beam lines and sequences.
void setReflectionFlag(bool flag) const
Set reflection flag.
Interface for statements.
void findFromPositions() const
void parsePosition(Statement &, Object &, bool defined) const
bool delimiter(char c)
Test for delimiter.
void findNeighbourPositions() const
std::string parseString(Statement &, const char msg[])
Parse string value.
const std::string & getOpalName() const
Return object name.
virtual Object * makeInstance(const std::string &name, Statement &, const Parser *)
Macro handler function.
MemberType itsType
Type word.
static Element * find(const std::string &name)
Find named Element.
virtual ElementBase * copyStructure()
Make a structural copy.
virtual void parse(Statement &) const
Parse sequence member.
double parseRealConst(Statement &)
Parse real constant.
double getReal(const Attribute &attr)
Return real value.
void stop() const
Set stop flag.
bool keyword(const char *s)
Test for keyword.
virtual double getLength() const =0
Return element length.
void setElement(ElementBase *)
Set the element pointer.
virtual Attribute * findAttribute(const std::string &name)
Find an attribute by name.
void parseMember(Statement &) const
double itsPosition
The position attribute ("AT" or "DRIFT").
virtual Object * find(const std::string &) const
Find object by name in the main directory.
virtual Object * clone(const std::string &name)=0
Return a clone.
virtual void parseEnd(Statement &) const
Check for end of statement.
A representation of an Object attribute.