OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
SequenceParser.h
Go to the documentation of this file.
1 #ifndef OPAL_SequenceParser_HH
2 #define OPAL_SequenceParser_HH
3 
4 // ------------------------------------------------------------------------
5 // $RCSfile: SequenceParser.h,v $
6 // ------------------------------------------------------------------------
7 // $Revision: 1.1.1.1 $
8 // ------------------------------------------------------------------------
9 // Copyright: see Copyright.readme
10 // ------------------------------------------------------------------------
11 //
12 // Class: SequenceParser
13 //
14 // ------------------------------------------------------------------------
15 //
16 // $Date: 2000/03/27 09:33:43 $
17 // $Author: Andreas Adelmann $
18 //
19 // ------------------------------------------------------------------------
20 
21 #include "OpalParser/OpalParser.h"
22 #include "Lines/Sequence.h"
23 #include <list>
24 
25 class Element;
26 class Sequence;
27 class SequenceMember;
28 class Statement;
29 
30 
31 // Class SequenceParser
32 // ------------------------------------------------------------------------
34 // Recognises the format for all possible SEQUENCE members.
35 // The SequenceParser is instantiated when a SEQUENCE header is seen.
36 // It takes over parsing for the members of the sequence and returns
37 // when it sees ENDSEQUENCE. Before returning it makes sure that all
38 // sequence members are placed correctly.
39 
40 class SequenceParser: public OpalParser {
41 
42 public:
43 
45  // Assign the current sequence being parsed.
47 
48  virtual ~SequenceParser();
49 
51  virtual void parse(Statement &) const;
52 
53 private:
54 
55  // The data structure for relative position definitions.
56  struct Reference {
58  { fromPosition = 0; }
59 
60  Reference(std::string name, SequenceMember *member): fromName(name)
61  { fromPosition = 0; itsList.push_back(member); }
62 
64  { }
65 
66  std::string fromName;
68  std::list<SequenceMember *> itsList;
69  };
70 
71  typedef std::list<Reference> RefList;
72 
73  // The type of CLASSIC beamline embedded in a Sequence.
75 
76  // Not implemented.
79  void operator=(const SequenceParser &);
80 
81  // Fill in relative positions and convert to absolute.
82  void fillPositions() const;
83 
84  // Find positions of elements named in "FROM" clauses.
85  void findFromPositions() const;
86 
87  // Find positions of neighbour elements in sequence line.
88  void findNeighbourPositions() const;
89 
90  // Parse single member.
91  void parseMember(Statement &) const;
92 
93  // Parse element position.
94  void parsePosition(Statement &, Object &, bool defined) const;
95 
96  // The sequence being parsed.
98 
99  // Flag for success.
100  mutable bool okFlag;
101 
102  // The relative positions to be filled in.
104 
105  // The sequence being parsed.
106  mutable TLine itsLine;
107 };
108 
109 #endif // OPAL_SequenceParser_HH
std::list< SequenceMember * > itsList
std::list< Reference > RefList
void parsePosition(Statement &, Object &, bool defined) const
Sequence::TLine TLine
void operator=(const SequenceParser &)
virtual ~SequenceParser()
The default parser for OPAL-9.
Definition: OpalParser.h:44
void findNeighbourPositions() const
void findFromPositions() const
Template class for beam lines.
Definition: TBeamline.h:40
The base class for all OPAL elements.
Definition: Element.h:46
Interface for statements.
Definition: Statement.h:38
The SEQUENCE definition.
Definition: Sequence.h:38
The parser for SEQUENCE members.
SequenceMember * fromPosition
Reference(std::string name, SequenceMember *member)
Sequence * itsSequence
The base class for all OPAL objects.
Definition: Object.h:48
const std::string name
void fillPositions() const
void parseMember(Statement &) const
virtual void parse(Statement &) const
Parse sequence member.
A member of a SEQUENCE.