OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
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
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.") {
36 itsAttr[0] = Attributes::makeString("FILE", "Name of file to be read", "CALL");
37
39}
40
41Call::Call(const std::string& name, Call* parent) : Action(name, parent) {}
42
44
45Call* Call::clone(const std::string& name) { return new Call(name, this); }
46
48 std::string file = Attributes::getString(itsAttr[0]);
49
50 if (Options::info && ippl::Comm->rank() == 0) {
51 *gmsg << "* Reading input stream '" << file << "' from \"CALL\" command.\n" << endl;
52 }
53
54 OpalParser().run(new FileStream(file));
55}
56
57void Call::parse(Statement& statement) { parseShortcut(statement); }
Inform * gmsg
Definition changes.cpp:7
Inform * gmsg
Definition changes.cpp:7
The base class for all OPAL actions.
Definition Action.h:29
Definition Call.h:23
Call()
Exemplar constructor.
Definition Call.cpp:32
virtual void parse(Statement &)
Parse command (special for one-attribute command).
Definition Call.cpp:57
virtual void execute()
Execute the command.
Definition Call.cpp:47
virtual Call * clone(const std::string &name)
Make clone.
Definition Call.cpp:45
virtual ~Call()
Definition Call.cpp:43
A stream of input tokens.
Definition FileStream.h:31
virtual void parseShortcut(Statement &, bool eval=true)
Parser for single-attribute commands.
Definition Object.cpp:113
void registerOwnership(const AttributeHandler::OwnerType &itsClass) const
Definition Object.cpp:169
std::vector< Attribute > itsAttr
The object attributes.
Definition Object.h:210
The default parser for OPAL-9.
Definition OpalParser.h:43
virtual void run() const
Read current stream.
Interface for statements.
Definition Statement.h:37
std::string getString(const Attribute &attr)
Get string value.
Attribute makeString(const std::string &name, const std::string &help)
Make string attribute.
bool info
Info flag.
Definition Options.cpp:28