OPAL (Object Oriented Parallel Accelerator Library)  2021.1.99
OPAL
MacroCmd.h
Go to the documentation of this file.
1 //
2 // Class MacroCmd
3 //
4 // This class parses the MACRO command.
5 // Encapsulate the buffer for the ``archetypes'' of all macros.
6 // The macro is stored as a MacroStream. For execution, first the
7 // parameters are replaced, then the resulting stream is sent to the parser.
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 #ifndef CLASSIC_MacroCmd_HH
24 #define CLASSIC_MacroCmd_HH
25 
26 #include "OpalParser/Macro.h"
27 #include "OpalParser/MacroStream.h"
29 #include <iosfwd>
30 #include <string>
31 
32 // Class MacroCmd
33 // ------------------------------------------------------------------------
34 
35 class MacroCmd: public Macro {
36 
37 public:
38 
39  MacroCmd();
40  MacroCmd(const std::string &name, MacroCmd *parent);
41  virtual ~MacroCmd();
42 
44  virtual void execute();
45 
47  // Expects parse pointer in the statement to be set on the first argument.
48  // The parser is used to determine the parse mode
49  // (normal, error, match, edit, track).
50  virtual Object *makeInstance
51  (const std::string &name, Statement &, const Parser *);
52 
54  // Expects parse pointer in the statement to be set on the first argument.
55  virtual Object *makeTemplate(const std::string &, TokenStream &, Statement &);
56 
57 private:
58 
59  // Not implemented.
60  MacroCmd(const MacroCmd &);
61  void operator=(const MacroCmd &);
62 
63  // The stream of tokens representing the macro command.
65 
66  // Pointer to the parser to be used in execution.
67  const Parser *itsParser;
68 };
69 
70 #endif // CLASSIC_MacroCmd_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
Abstract base class for macros.
Definition: Macro.h:34
virtual Object * makeInstance(const std::string &name, Statement &, const Parser *)
Make a macro instance.
Definition: MacroCmd.cpp:59
virtual Object * makeTemplate(const std::string &, TokenStream &, Statement &)
Make a macro template.
Definition: MacroCmd.cpp:102
void operator=(const MacroCmd &)
Pointer< MacroStream > body
Definition: MacroCmd.h:64
const Parser * itsParser
Definition: MacroCmd.h:67
virtual ~MacroCmd()
Definition: MacroCmd.cpp:48
virtual void execute()
Execute the macro command.
Definition: MacroCmd.cpp:52
MacroCmd()
Definition: MacroCmd.cpp:34
MacroCmd(const MacroCmd &)