OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
Echo.cpp
Go to the documentation of this file.
1 // ------------------------------------------------------------------------
2 // $RCSfile: Echo.cpp,v $
3 // ------------------------------------------------------------------------
4 // $Release$
5 // ------------------------------------------------------------------------
6 // Copyright: see Copyright.readme
7 // ------------------------------------------------------------------------
8 //
9 // Class: Echo
10 // The class for OPAL ECHO commands.
11 //
12 // ------------------------------------------------------------------------
13 //
14 // $Date: 2000/03/27 09:33:37 $
15 // $Author: Andreas Adelmann $
16 //
17 // ------------------------------------------------------------------------
18 
19 #include "BasicActions/Echo.h"
20 #include "Attributes/Attributes.h"
21 #include "Utility/IpplInfo.h"
22 #include <iostream>
23 
24 
25 // Class Echo
26 // ------------------------------------------------------------------------
27 
29  Action(1, "ECHO",
30  "The \"ECHO\" statement sends a message to the ECHO file.") {
31  itsAttr[0] = Attributes::makeString("MESSAGE", "The message to be sent.");
32 
34 }
35 
36 
37 Echo::Echo(const std::string &name, Echo *parent):
38  Action(name, parent)
39 {}
40 
41 
43 {}
44 
45 
46 Echo *Echo::clone(const std::string &name) {
47  return new Echo(name, this);
48 }
49 
50 
51 void Echo::execute() {
52  if (Ippl::myNode() == 0)
53  std::cerr << Attributes::getString(itsAttr[0]) << std::endl;
54 }
55 
56 
57 void Echo::parse(Statement &statement) {
58  parseShortcut(statement);
59 }
virtual Echo * clone(const std::string &name)
Make clone.
Definition: Echo.cpp:46
virtual void parseShortcut(Statement &)
Parser for single-attribute commands.
Definition: Object.cpp:132
virtual void execute()
Execute the command.
Definition: Echo.cpp:51
The base class for all OPAL actions.
Definition: Action.h:30
static int myNode()
Definition: IpplInfo.cpp:794
std::vector< Attribute > itsAttr
The object attributes (see Attribute.hh).
Definition: Object.h:214
Interface for statements.
Definition: Statement.h:38
void registerOwnership(const AttributeHandler::OwnerType &itsClass) const
Definition: Object.cpp:194
virtual void parse(Statement &)
Parse command (special for one-attribute command).
Definition: Echo.cpp:57
const std::string name
The ECHO command.
Definition: Echo.h:28
virtual ~Echo()
Definition: Echo.cpp:42
Echo()
Exemplar constructor.
Definition: Echo.cpp:28
Attribute makeString(const std::string &name, const std::string &help)
Make string attribute.
Definition: Attributes.cpp:296
Inform & endl(Inform &inf)
Definition: Inform.cpp:42
std::string getString(const Attribute &attr)
Get string value.
Definition: Attributes.cpp:307