OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
Sequence.h
Go to the documentation of this file.
1 #ifndef OPAL_Sequence_HH
2 #define OPAL_Sequence_HH
3 
4 // ------------------------------------------------------------------------
5 // $RCSfile: Sequence.h,v $
6 // ------------------------------------------------------------------------
7 // $Revision: 1.1.1.1 $
8 // ------------------------------------------------------------------------
9 // Copyright: see Copyright.readme
10 // ------------------------------------------------------------------------
11 //
12 // Class: Sequence
13 //
14 // ------------------------------------------------------------------------
15 //
16 // $Date: 2000/03/27 09:33:43 $
17 // $Author: Andreas Adelmann $
18 //
19 // ------------------------------------------------------------------------
20 
23 #include "Beamlines/TBeamline.h"
24 #include "Lines/SequenceMember.h"
26 #include <list>
27 
28 class TokenStream;
29 
30 
31 // Class Sequence
32 // ------------------------------------------------------------------------
34 // A Sequence contains a CLASSIC TBeamline<SequenceMember> which represents
35 // the sequence of elements in the line and their positions. The sequence
36 // definition is parsed in collaboration with a SequenceParser.
37 
38 class Sequence: public BeamSequence {
39 
40  friend class Edit;
41  friend class SequenceParser;
42  friend class SequenceTemplate;
43 
44 public:
45 
48 
50  Sequence();
51 
52  virtual ~Sequence();
53 
55  // The new object is an empty sequence, it will be filled in by the parser.
56  virtual Sequence *clone(const std::string &name);
57 
59  virtual Sequence *copy(const std::string &name);
60 
62  virtual double getLength() const;
63 
65  virtual double getEntrance(ReferenceType) const;
66 
68  virtual double getExit(ReferenceType) const;
69 
71  // "ENTRY", "CENTRE", or "EXIT".
73 
75  // Arguments:
76  // [ol]
77  // [li] Name to be given to the template.
78  // [li] Token stream to be read for the sequence line.
79  // [li] Statement to be read for the arguments.
80  // [/ol]
81  virtual Object *makeTemplate(const std::string &, TokenStream &, Statement &);
82 
84  virtual void parse(Statement &);
85 
87  virtual void print(std::ostream &) const;
88 
90  virtual void replace(Object *oldObject, Object *newObject);
91 
93  // Recompute drift lengths.
94  virtual void update();
95 
97  // The result it the ideal line.
98  virtual TLine *fetchLine() const;
99 
101  // Assign to the underlying ideal line and re-insert the drifts.
102  void storeLine(TLine &line);
103 
104 private:
105 
106  // Not implemented.
107  Sequence(const Sequence &);
108  void operator=(const Sequence &);
109 
110  // Clone constructor.
111  Sequence(const std::string &name, Sequence *parent);
112 
113  // Add the top-level begin and end markers.
114  void addEndMarkers(TLine &line) const;
115 
116  // Compute drift length for a generated drift.
117  double findDriftLength(TLine::iterator drift) const;
118 
119  // Find named position in sequence line.
120  TLine::iterator findNamedPosition(TLine &, const std::string &) const;
121 
122  // Insert the top-level drift spaces.
123  void insertDrifts(TLine &line);
124 
125  // Recompute drift lengths for a given sequence or sub-sequence.
126  static void updateList(Sequence *, TLine *);
127 
128  // The reference code.
130 
131  // The reference point.
132  std::string itsRefPoint;
133 };
134 
135 #endif // OPAL_Sequence_HH
double findDriftLength(TLine::iterator drift) const
Definition: Sequence.cpp:326
virtual ~Sequence()
Definition: Sequence.cpp:94
virtual void print(std::ostream &) const
Print sequence.
Definition: Sequence.cpp:219
virtual TLine * fetchLine() const
Return the embedded CLASSIC beam line.
Definition: Sequence.cpp:279
Abstract interface for a stream of input tokens.
Definition: TokenStream.h:33
Sequence()
Exemplar constructor.
Definition: Sequence.cpp:53
An ``archetype&#39;&#39; for a SEQUENCE with arguments.
virtual void parse(Statement &)
Parse sequence.
Definition: Sequence.cpp:207
TLine::iterator findNamedPosition(TLine &, const std::string &) const
Definition: Sequence.cpp:125
void insertDrifts(TLine &line)
Definition: Sequence.cpp:369
virtual double getEntrance(ReferenceType) const
Return the arc length from origin to entrance.
Definition: Sequence.cpp:156
virtual void replace(Object *oldObject, Object *newObject)
Replace references to elements.
Definition: Sequence.cpp:260
ReferenceType getReference() const
Return the reference type flag.
Definition: Sequence.cpp:178
Template class for beam lines.
Definition: TBeamline.h:40
void operator=(const Sequence &)
ReferenceType
Reference for element positioning.
Definition: Element.h:52
ReferenceType itsCode
Definition: Sequence.h:129
void addEndMarkers(TLine &line) const
Definition: Sequence.cpp:313
Interface for statements.
Definition: Statement.h:38
static void updateList(Sequence *, TLine *)
Definition: Sequence.cpp:384
void storeLine(TLine &line)
Store sequence line.
Definition: Sequence.cpp:284
The SEQUENCE definition.
Definition: Sequence.h:38
The parser for SEQUENCE members.
virtual Sequence * clone(const std::string &name)
Make clone.
Definition: Sequence.cpp:98
virtual double getExit(ReferenceType) const
Return the arc length from origin to exit.
Definition: Sequence.cpp:167
TBeamline< SequenceMember > TLine
The type of a sequence line.
Definition: Sequence.h:47
The base class for all OPAL beam lines and sequences.
Definition: BeamSequence.h:32
virtual Sequence * copy(const std::string &name)
Make copy of the sequence line.
Definition: Sequence.cpp:103
This class contains all data for the sequence editor.
Definition: Edit.h:38
virtual double getLength() const
Return sequence length.
Definition: Sequence.cpp:151
The base class for all OPAL objects.
Definition: Object.h:48
const std::string name
std::string itsRefPoint
Definition: Sequence.h:132
std::string::iterator iterator
Definition: MSLang.h:16
virtual void update()
Update the embedded CLASSIC beam line.
Definition: Sequence.cpp:273
virtual Object * makeTemplate(const std::string &, TokenStream &, Statement &)
Make a sequence template.
Definition: Sequence.cpp:193