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.");
139 }
else if(
ref ==
"CENTRE" ||
ref ==
"") {
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;
186 ref.fromPosition = &(*j);
198 ref.fromPosition = &(*j);
210 ref.fromPosition = &(*j);
266 throw ParseError(
"SequenceParser::parseMember()",
267 "You cannot redefine \"" + objName +
268 "\" within the sequence of the same name.");
270 throw ParseError(
"SequenceParser::parseMember()",
271 "You cannot refer to \"" + objName +
272 "\" within the sequence of the same name.");
274 throw ParseError(
"SequenceParser::parseMember()",
275 "You cannot redefine \"" + objName +
276 "\" within a sequence.");
282 copy = line->copy(objName);
284 copy = obj->
clone(objName);
310 throw ParseError(
"SequenceParser::parseMember()",
"Object \"" +
311 objName +
"\" is not an element.");
314 throw ParseError(
"SequenceParser::parseMember()",
315 "Element class name \"" + clsName +
"\" is unknown.");
323 double position = 0.0;
324 std::string fromName;
334 flag |= (flag & 0x0001) ? 0x0008 : 0x0001;
335 }
else if(
name ==
"DRIFT") {
338 flag |= (flag & 0x0002) ? 0x0008 : 0x0002;
339 }
else if(
name ==
"FROM") {
347 throw ParseError(
"SequenceParser::parsePosition()",
348 "Expected 'S' or 'E'.");
352 (stat,
"Expected <name>, \"#S\", or \"#E\".");
354 flag |= (flag & 0x0004) ? 0x0008 : 0x0004;
359 attr->parse(stat,
true);
361 attr->parse(stat,
false);
363 throw ParseError(
"SequenceParser::parsePosition()",
364 "Delimiter \"=\" or \":=\" expected.");
367 throw ParseError(
"SequenceParser::parsePosition()",
369 "\" has no attribute \"" +
name +
"\".");
372 throw ParseError(
"SequenceParser::parsePosition()",
373 "Overriding attributes not permitted here.");
403 if(fromName ==
"PREVIOUS") {
406 }
else if(fromName ==
"NEXT") {
409 }
else if(fromName ==
"#S") {
412 }
else if(fromName ==
"#E") {
422 if(i->fromName == fromName) {
424 i->itsList.push_back(&member);
431 ref.fromName = fromName;
432 ref.itsList.push_back(&member);
439 throw ParseError(
"SequenceParser:parsePosition()",
440 "Conflicting keywords.");
std::string parseString(Statement &, const char msg[])
Parse string value.
void parseDelimiter(Statement &stat, char delim)
Test for one-character delimiter.
double parseRealConst(Statement &)
Parse real constant.
double getReal(const Attribute &attr)
Return real value.
std::string getString(const Attribute &attr)
Get string value.
std::string::iterator iterator
boost::function< boost::tuple< double, bool >arguments_t)> type
A representation of an Object attribute.
The base class for all OPAL beam lines and sequences.
virtual double getLength() const =0
Return element length.
static Element * find(const std::string &name)
Find named Element.
ReferenceType
Reference for element positioning.
The base class for all OPAL objects.
virtual Object * makeInstance(const std::string &name, Statement &, const Parser *)
Macro handler function.
const std::string & getOpalName() const
Return object name.
virtual Object * clone(const std::string &name)=0
Return a clone.
virtual Attribute * findAttribute(const std::string &name)
Find an attribute by name.
void makeDirty(Object *object)
Invalidate expressions.
static OpalData * getInstance()
void define(Object *newObject)
Define a new object.
virtual ElementBase * copyStructure()
Make a structural copy.
void setElement(ElementBase *)
Set the element pointer.
void setReflectionFlag(bool flag) const
Set reflection flag.
Reference-counted pointer.
Interface for statements.
bool keyword(const char *s)
Test for keyword.
bool delimiter(char c)
Test for delimiter.
void start()
Return to start.
void insertDrifts(TLine &line)
TLine::iterator findNamedPosition(TLine &, const std::string &) const
void storeLine(TLine &line)
Store sequence line.
void addEndMarkers(TLine &line) const
MemberType itsType
Type word.
Pointer< Element > OpalElement
double itsPosition
The position attribute ("AT" or "DRIFT").
PositionType itsFlag
Flag word.
void findFromPositions() const
void fillPositions() const
void parseMember(Statement &) const
virtual ~SequenceParser()
void findNeighbourPositions() const
virtual void parse(Statement &) const
Parse sequence member.
void parsePosition(Statement &, Object &, bool defined) const
virtual void parseEnd(Statement &) const
Check for end of statement.
virtual Object * find(const std::string &) const
Find object by name in the main directory.
void stop() const
Set stop flag.
The base class for all OPAL exceptions.