OPAL (Object Oriented Parallel Accelerator Library)  2021.1.99
OPAL
Echo.cpp
Go to the documentation of this file.
1 //
2 // Class Echo
3 // The class for OPAL ECHO 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/Echo.h"
19 
20 #include "Attributes/Attributes.h"
21 #include "Utility/IpplInfo.h"
22 
23 #include <iostream>
24 
25 
27  Action(1, "ECHO",
28  "The \"ECHO\" statement sends a message to the ECHO file.") {
29  itsAttr[0] = Attributes::makeString("MESSAGE", "The message to be sent.");
30 
32 }
33 
34 
35 Echo::Echo(const std::string& name, Echo* parent):
36  Action(name, parent)
37 {}
38 
39 
41 {}
42 
43 
44 Echo* Echo::clone(const std::string& name) {
45  return new Echo(name, this);
46 }
47 
48 
49 void Echo::execute() {
50  if (Ippl::myNode() == 0)
51  std::cerr << Attributes::getString(itsAttr[0]) << std::endl;
52 }
53 
54 
55 void Echo::parse(Statement& statement) {
56  parseShortcut(statement);
57 }
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
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: Echo.h:24
virtual ~Echo()
Definition: Echo.cpp:40
virtual void execute()
Execute the command.
Definition: Echo.cpp:49
virtual Echo * clone(const std::string &name)
Make clone.
Definition: Echo.cpp:44
Echo()
Exemplar constructor.
Definition: Echo.cpp:26
virtual void parse(Statement &)
Parse command (special for one-attribute command).
Definition: Echo.cpp:55
Interface for statements.
Definition: Statement.h:38
static int myNode()
Definition: IpplInfo.cpp:691