OPAL (Object Oriented Parallel Accelerator Library) 2022.1
OPAL
Call.cpp
Go to the documentation of this file.
1//
2// Class Call
3// The class for OPAL CALL command.
4//
5// Copyright (c) 2000 - 2021, Paul Scherrer Institut, Villigen PSI, Switzerland
6// All rights reserved
7//
8// This file is part of OPAL.
9//
10// OPAL is free software: you can redistribute it and/or modify
11// it under the terms of the GNU General Public License as published by
12// the Free Software Foundation, either version 3 of the License, or
13// (at your option) any later version.
14//
15// You should have received a copy of the GNU General Public License
16// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
17//
18#include "BasicActions/Call.h"
19
23#include "Parser/FileStream.h"
25#include "Utilities/Options.h"
26#include "Utility/IpplInfo.h"
27
28#include <iostream>
29
30extern Inform* gmsg;
31
33 Action(1, "CALL",
34 "The \"CALL\" statement switches input temporarily to the "
35 "named file.") {
37 ("FILE", "Name of file to be read", "CALL");
38
40}
41
42
43Call::Call(const std::string& name, Call* parent):
44 Action(name, parent)
45{}
46
47
49{}
50
51
52Call* Call::clone(const std::string& name) {
53 return new Call(name, this);
54}
55
56
58 std::string file = Attributes::getString(itsAttr[0]);
59
60 if (Options::info && Ippl::myNode() == 0) {
61 *gmsg << "* Reading input stream '" << file
62 << "' from \"CALL\" command.\n" << endl;
63 }
64
65 OpalParser().run(new FileStream(file));
66}
67
68
69void Call::parse(Statement& statement) {
70 parseShortcut(statement);
71}
Inform * gmsg
Definition: Main.cpp:61
Inform & endl(Inform &inf)
Definition: Inform.cpp:42
const std::string name
std::string getString(const Attribute &attr)
Get string value.
Definition: Attributes.cpp:343
Attribute makeString(const std::string &name, const std::string &help)
Make string attribute.
Definition: Attributes.cpp:332
bool info
Info flag.
Definition: Options.cpp:28
The base class for all OPAL actions.
Definition: Action.h:30
virtual void parseShortcut(Statement &, bool eval=true)
Parser for single-attribute commands.
Definition: Object.cpp:129
void registerOwnership(const AttributeHandler::OwnerType &itsClass) const
Definition: Object.cpp:191
std::vector< Attribute > itsAttr
The object attributes.
Definition: Object.h:216
Definition: Call.h:24
Call()
Exemplar constructor.
Definition: Call.cpp:32
virtual void parse(Statement &)
Parse command (special for one-attribute command).
Definition: Call.cpp:69
virtual void execute()
Execute the command.
Definition: Call.cpp:57
virtual Call * clone(const std::string &name)
Make clone.
Definition: Call.cpp:52
virtual ~Call()
Definition: Call.cpp:48
A stream of input tokens.
Definition: FileStream.h:32
Interface for statements.
Definition: Statement.h:38
The default parser for OPAL-9.
Definition: OpalParser.h:44
virtual void run() const
Read current stream.
Definition: OpalParser.cpp:602
Definition: Inform.h:42
static int myNode()
Definition: IpplInfo.cpp:691