OPAL (Object Oriented Parallel Accelerator Library)  2021.1.99
OPAL
LineTemplate.h
Go to the documentation of this file.
1 //
2 // Class LineTemplate
3 //
4 // An ``archetype'' for a OPAL beam line with arguments.
5 // The model is stored in form of a MacroStream. A call to the macro line
6 // is expanded by first replacing the arguments, and then parsing the
7 // resulting stream as a LINE definition.
8 //
9 // Copyright (c) 2008 - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland
10 //
11 // All rights reserved
12 //
13 // This file is part of OPAL.
14 //
15 // OPAL is free software: you can redistribute it and/or modify
16 // it under the terms of the GNU General Public License as published by
17 // the Free Software Foundation, either version 3 of the License, or
18 // (at your option) any later version.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with OPAL. If not, see <https://www.gnu.org/licenses/>.
22 //
23 
24 #ifndef OPAL_LineTemplate_HH
25 #define OPAL_LineTemplate_HH
26 
27 #include "OpalParser/Macro.h"
28 #include "OpalParser/MacroStream.h"
29 
30 class Line;
31 class Statement;
32 class TokenStream;
33 
34 class LineTemplate: public Macro {
35 
36  friend class Line;
37 
38 public:
39 
40  LineTemplate();
41  virtual ~LineTemplate();
42 
44  // Throw OpalException, since the template cannot be cloned.
45  virtual LineTemplate *clone(const std::string &name);
46 
48  // The instance gets the name [b]name[/b], and its actual arguments
49  // are read from [b]stat[/b]. The parser is ignored.
50  virtual Object *makeInstance
51  (const std::string &name, Statement &stat, const Parser *);
52 
54  // Return NULL, since one cannot make a template from a template.
55  virtual Object *makeTemplate(const std::string &, TokenStream &, Statement &);
56 
58  // Read the actual arguments from [b]stat[/b]. [b]is[/b] is not used.
59  void parseTemplate(TokenStream &is, Statement &stat);
60 
61 private:
62 
63  // Not implemented.
65  void operator=(const LineTemplate &);
66 
67  // Clone constructor.
68  LineTemplate(const std::string &name, Object *parent);
69 
70  // The contained beam line element list.
72 };
73 
74 #endif // OPAL_LineTemplate_HH
const std::string name
The base class for all OPAL objects.
Definition: Object.h:48
Interface for abstract language parser.
Definition: Parser.h:31
Interface for statements.
Definition: Statement.h:38
Abstract interface for a stream of input tokens.
Definition: TokenStream.h:33
Definition: Line.h:32
MacroStream body
Definition: LineTemplate.h:71
virtual ~LineTemplate()
LineTemplate(const LineTemplate &)
void parseTemplate(TokenStream &is, Statement &stat)
Parse the line template.
virtual Object * makeInstance(const std::string &name, Statement &stat, const Parser *)
Make line instance.
virtual LineTemplate * clone(const std::string &name)
Make clone.
void operator=(const LineTemplate &)
virtual Object * makeTemplate(const std::string &, TokenStream &, Statement &)
Make a line template.
Abstract base class for macros.
Definition: Macro.h:34
An input buffer for macro commands.
Definition: MacroStream.h:31