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;
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.");
281 }
else if(
BeamSequence *line = dynamic_cast<BeamSequence *>(obj)) {
282 copy = line->copy(objName);
284 copy = obj->
clone(objName);
293 if(
Element *elem = dynamic_cast<Element *>(&*copy)) {
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") {
421 i != references.end(); ++i) {
422 if(i->fromName == fromName) {
424 i->itsList.push_back(&member);
432 ref.
itsList.push_back(&member);
433 references.push_back(ref);
439 throw ParseError(
"SequenceParser:parsePosition()",
440 "Conflicting keywords.");
std::list< SequenceMember * > itsList
double parseRealConst(Statement &)
Parse real constant.
bool keyword(const char *s)
Test for keyword.
Interface for basic beam line object.
void define(Object *newObject)
Define a new object.
void parsePosition(Statement &, Object &, bool defined) const
The base class for all OPAL exceptions.
virtual Attribute * findAttribute(const std::string &name)
Find an attribute by name.
virtual ~SequenceParser()
TLine::iterator findNamedPosition(TLine &, const std::string &) const
double itsPosition
The position attribute ("AT" or "DRIFT").
void findNeighbourPositions() const
void insertDrifts(TLine &line)
void stop() const
Set stop flag.
void findFromPositions() const
void parseDelimiter(Statement &stat, char delim)
Test for one-character delimiter.
static OpalData * getInstance()
const std::string & getOpalName() const
Return object name.
MemberType itsType
Type word.
The base class for all OPAL elements.
A representation of an Object attribute.
ReferenceType
Reference for element positioning.
void addEndMarkers(TLine &line) const
Interface for statements.
Reference-counted pointer.
void storeLine(TLine &line)
Store sequence line.
void start()
Return to start.
virtual Object * makeInstance(const std::string &name, Statement &, const Parser *)
Macro handler function.
virtual ElementBase * copyStructure()
Make a structural copy.
The base class for all OPAL beam lines and sequences.
static Element * find(const std::string &name)
Find named Element.
virtual double getLength() const =0
Return element length.
SequenceMember * fromPosition
The base class for all OPAL objects.
virtual void parseEnd(Statement &) const
Check for end of statement.
virtual Object * clone(const std::string &name)=0
Return a clone.
PositionType itsFlag
Flag word.
void fillPositions() const
std::string::iterator iterator
double getReal(const Attribute &attr)
Return real value.
std::string parseString(Statement &, const char msg[])
Parse string value.
bool delimiter(char c)
Test for delimiter.
void parseMember(Statement &) const
virtual void parse(Statement &) const
Parse sequence member.
void makeDirty(Object *object)
Invalidate expressions.
Pointer< Element > OpalElement
void setElement(ElementBase *)
Set the element pointer.
virtual Object * find(const std::string &) const
Find object by name in the main directory.
std::string getString(const Attribute &attr)
Get string value.
void setReflectionFlag(bool flag) const
Set reflection flag.