OPAL (Object Oriented Parallel Accelerator Library)  2021.1.99
OPAL
Line.h
Go to the documentation of this file.
1 //
2 // Class Line
3 // The LINE definition.
4 // A Line contains a CLASSIC TBeamline<FlaggedElmPtr> which represents the
5 // sequence of elements in the line. The line is always flat in the sense
6 // that nested anonymous lines are flattened.
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_Line_HH
22 #define OPAL_Line_HH
23 
28 
29 class TokenStream;
30 
31 
32 class Line: public BeamSequence {
33 
34  friend class LineTemplate;
35 
36 public:
37 
39  Line();
40 
41  virtual ~Line();
42 
44  // The new object is an empty line, it will be filled by the parser.
45  virtual Line *clone(const std::string &name);
46 
48  // Copy also the line list.
49  virtual Line *copy(const std::string &name);
50 
52  virtual double getLength() const;
53 
55  // The template gets the name [b]name[/b], [b]is[/b] is ignored,
56  // and the formals and the line list are read from [b]stat[/b].
57  virtual Object *makeTemplate
58  (const std::string &name, TokenStream &is, Statement &stat);
59 
61  // Read the definition from [b]stat[/b].
62  virtual void parse(Statement &stat);
63 
65  virtual void print(std::ostream &stream) const;
66 
67 private:
68 
69  // Not implemented.
70  Line(const Line &);
71  void operator=(const Line &);
72 
73  // Clone constructor.
74  Line(const std::string &name, Line *parent);
75 
76  // Return the embedded CLASSIC beam line.
77  // The result it the ideal line.
78  virtual FlaggedBeamline *fetchLine() const;
79 
80  // Parse sub-list.
81  void parseList(Statement &);
82 
83  // Replace references to elements.
84  virtual void replace(Object *oldObject, Object *newObject);
85 };
86 
87 #endif // OPAL_Line_HH
const std::string name
The base class for all OPAL beam lines and sequences.
Definition: BeamSequence.h:32
The base class for all OPAL objects.
Definition: Object.h:48
Interface for statements.
Definition: Statement.h:38
Abstract interface for a stream of input tokens.
Definition: TokenStream.h:33
Definition: Line.h:32
virtual void replace(Object *oldObject, Object *newObject)
Replace references.
Definition: Line.cpp:361
void operator=(const Line &)
virtual void parse(Statement &stat)
Parse the line object.
Definition: Line.cpp:150
virtual FlaggedBeamline * fetchLine() const
Return the embedded CLASSIC beam line.
Definition: Line.cpp:289
virtual void print(std::ostream &stream) const
Print the line.
Definition: Line.cpp:267
virtual Line * copy(const std::string &name)
Make complete copy.
Definition: Line.cpp:122
virtual double getLength() const
Return line length.
Definition: Line.cpp:130
virtual ~Line()
Definition: Line.cpp:113
virtual Object * makeTemplate(const std::string &name, TokenStream &is, Statement &stat)
Make a line template.
Definition: Line.cpp:136
void parseList(Statement &)
Definition: Line.cpp:294
Line()
Exemplar constructor.
Definition: Line.cpp:65
Line(const Line &)
virtual Line * clone(const std::string &name)
Make clone.
Definition: Line.cpp:117