OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
LineTemplate.h
Go to the documentation of this file.
1 #ifndef OPAL_LineTemplate_HH
2 #define OPAL_LineTemplate_HH
3 
4 // ------------------------------------------------------------------------
5 // $RCSfile: LineTemplate.h,v $
6 // ------------------------------------------------------------------------
7 // $Revision: 1.2 $
8 // ------------------------------------------------------------------------
9 // Copyright: see Copyright.readme
10 // ------------------------------------------------------------------------
11 //
12 // Class: LineTemplate
13 //
14 // ------------------------------------------------------------------------
15 //
16 // $Date: 2000/03/29 10:41:40 $
17 // $Author: opal $
18 //
19 // ------------------------------------------------------------------------
20 
21 #include "OpalParser/Macro.h"
22 #include "OpalParser/MacroStream.h"
23 
24 class Line;
25 class Statement;
26 class TokenStream;
27 
28 
29 // Class LineTemplate
30 // ------------------------------------------------------------------------
32 // The model is stored in form of a MacroStream. A call to the macro line
33 // is expanded by first replacing the arguments, and then parsing the
34 // resulting stream as a LINE definition.
35 
36 class LineTemplate: public Macro {
37 
38  friend class Line;
39 
40 public:
41 
42  LineTemplate();
43  virtual ~LineTemplate();
44 
46  // Throw OpalException, since the template cannot be cloned.
47  virtual LineTemplate *clone(const std::string &name);
48 
50  // The instance gets the name [b]name[/b], and its actual arguments
51  // are read from [b]stat[/b]. The parser is ignored.
52  virtual Object *makeInstance
53  (const std::string &name, Statement &stat, const Parser *);
54 
56  // Return NULL, since one cannot make a template from a template.
57  virtual Object *makeTemplate(const std::string &, TokenStream &, Statement &);
58 
60  // Read the actual arguments from [b]stat[/b]. [b]is[/b] is not used.
61  void parseTemplate(TokenStream &is, Statement &stat);
62 
63 private:
64 
65  // Not implemented.
66  LineTemplate(const LineTemplate &);
67  void operator=(const LineTemplate &);
68 
69  // Clone constructor.
70  LineTemplate(const std::string &name, Object *parent);
71 
72  // The contained beam line element list.
74 };
75 
76 #endif // OPAL_LineTemplate_HH
virtual ~LineTemplate()
void operator=(const LineTemplate &)
Abstract interface for a stream of input tokens.
Definition: TokenStream.h:33
virtual Object * makeInstance(const std::string &name, Statement &stat, const Parser *)
Make line instance.
Interface for abstract language parser.
Definition: Parser.h:31
Interface for statements.
Definition: Statement.h:38
virtual Object * makeTemplate(const std::string &, TokenStream &, Statement &)
Make a line template.
An input buffer for macro commands.
Definition: MacroStream.h:31
void parseTemplate(TokenStream &is, Statement &stat)
Parse the line template.
Abstract base class for macros.
Definition: Macro.h:34
An ``archetype'' for a OPAL beam line with arguments.
Definition: LineTemplate.h:36
The base class for all OPAL objects.
Definition: Object.h:48
const std::string name
MacroStream body
Definition: LineTemplate.h:73
The LINE definition.
Definition: Line.h:36
virtual LineTemplate * clone(const std::string &name)
Make clone.