OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
Sequence.h
Go to the documentation of this file.
1//
2// Class Sequence
3// The SEQUENCE definition.
4// A Sequence contains an OPALX TBeamline<SequenceMember> which represents
5// the sequence of elements in the line and their positions. The sequence
6// definition is parsed in collaboration with a SequenceParser.
7//
8// Copyright (c) 200x - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland
9// All rights reserved
10//
11// This file is part of OPAL.
12//
13// OPAL is free software: you can redistribute it and/or modify
14// it under the terms of the GNU General Public License as published by
15// the Free Software Foundation, either version 3 of the License, or
16// (at your option) any later version.
17//
18// You should have received a copy of the GNU General Public License
19// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
20//
21#ifndef OPAL_Sequence_HH
22#define OPAL_Sequence_HH
23
24#include <list>
25#include <memory>
28#include "Beamlines/TBeamline.h"
30
31class TokenStream;
32
33class Sequence : public BeamSequence {
34 friend class Edit;
35 friend class SequenceParser;
36 friend class SequenceTemplate;
37
38public:
41
43 Sequence();
44
45 virtual ~Sequence();
46
48 // The new object is an empty sequence, it will be filled in by the parser.
49 virtual Sequence* clone(const std::string& name);
50
52 virtual Sequence* copy(const std::string& name);
53
55 virtual double getLength() const;
56
58 virtual double getEntrance(ReferenceType) const;
59
61 virtual double getExit(ReferenceType) const;
62
64 // "ENTRY", "CENTRE", or "EXIT".
66
68 // Arguments:
69 // [ol]
70 // [li] Name to be given to the template.
71 // [li] Token stream to be read for the sequence line.
72 // [li] Statement to be read for the arguments.
73 // [/ol]
74 virtual Object* makeTemplate(const std::string&, TokenStream&, Statement&);
75
77 virtual void parse(Statement&);
78
80 virtual void print(std::ostream&) const;
81
83 virtual void replace(Object* oldObject, Object* newObject);
84
86 // Recompute drift lengths.
87 virtual void update();
88
90 // The result it the ideal line.
91 virtual TLine* fetchLine() const;
92
94 // Assign to the underlying ideal line and re-insert the drifts.
95 void storeLine(TLine& line);
96
97private:
98 // Not implemented.
100 void operator=(const Sequence&);
101
102 // Clone constructor.
103 Sequence(const std::string& name, Sequence* parent);
104
105 // Add the top-level begin and end markers.
106 void addEndMarkers(TLine& line) const;
107
108 // Compute drift length for a generated drift.
109 double findDriftLength(TLine::iterator drift) const;
110
111 // Find named position in sequence line.
112 TLine::iterator findNamedPosition(TLine&, const std::string&) const;
113
114 // Insert the top-level drift spaces.
115 void insertDrifts(TLine& line);
116
117 // Recompute drift lengths for a given sequence or sub-sequence.
118 static void updateList(Sequence*, TLine*);
119
120 // The reference code.
122
123 // The reference point.
124 std::string itsRefPoint;
125};
126
127#endif // OPAL_Sequence_HH
The base class for all OPAL beam lines and sequences.
ReferenceType
Reference for element positioning.
Definition Element.h:43
The base class for all OPAL objects.
Definition Object.h:45
The parser for SEQUENCE members.
virtual double getLength() const
Return sequence length.
Definition Sequence.cpp:142
TBeamline< SequenceMember > TLine
The type of a sequence line.
Definition Sequence.h:40
virtual void print(std::ostream &) const
Print sequence.
Definition Sequence.cpp:200
std::string itsRefPoint
Definition Sequence.h:124
ReferenceType itsCode
Definition Sequence.h:121
friend class Edit
Definition Sequence.h:34
virtual Object * makeTemplate(const std::string &, TokenStream &, Statement &)
Make a sequence template.
Definition Sequence.cpp:177
void insertDrifts(TLine &line)
Definition Sequence.cpp:336
Sequence()
Exemplar constructor.
Definition Sequence.cpp:52
virtual double getExit(ReferenceType) const
Return the arc length from origin to exit.
Definition Sequence.cpp:154
virtual double getEntrance(ReferenceType) const
Return the arc length from origin to entrance.
Definition Sequence.cpp:144
virtual void update()
Update the embedded OPALX beam line.
Definition Sequence.cpp:248
TLine::iterator findNamedPosition(TLine &, const std::string &) const
Definition Sequence.cpp:116
void operator=(const Sequence &)
virtual TLine * fetchLine() const
Return the embedded OPALX beam line.
Definition Sequence.cpp:253
Sequence(const Sequence &)
virtual Sequence * clone(const std::string &name)
Make clone.
Definition Sequence.cpp:93
void storeLine(TLine &line)
Store sequence line.
Definition Sequence.cpp:255
virtual void replace(Object *oldObject, Object *newObject)
Replace references to elements.
Definition Sequence.cpp:238
virtual Sequence * copy(const std::string &name)
Make copy of the sequence line.
Definition Sequence.cpp:95
void addEndMarkers(TLine &line) const
Definition Sequence.cpp:283
virtual void parse(Statement &)
Parse sequence.
Definition Sequence.cpp:190
ReferenceType getReference() const
Return the reference type flag.
Definition Sequence.cpp:164
virtual ~Sequence()
Definition Sequence.cpp:91
double findDriftLength(TLine::iterator drift) const
Definition Sequence.cpp:295
static void updateList(Sequence *, TLine *)
Definition Sequence.cpp:350
Interface for statements.
Definition Statement.h:37
Abstract interface for a stream of input tokens.
Definition TokenStream.h:30