OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
PSystem.cpp
Go to the documentation of this file.
1 // ------------------------------------------------------------------------
2 // $RCSfile: PSystem.cpp,v $
3 // ------------------------------------------------------------------------
4 // $Revision: 1.2 $
5 // ------------------------------------------------------------------------
6 // Copyright: see Copyright.readme
7 // ------------------------------------------------------------------------
8 //
9 // Class: PSystem
10 // The class for the OPAL SYSTEM command.
11 //
12 // ------------------------------------------------------------------------
13 //
14 // $Date: 2002/01/17 22:18:36 $
15 // $Author: jsberg $
16 //
17 // ------------------------------------------------------------------------
18 
19 #include "BasicActions/PSystem.h"
20 
21 #include "Ippl.h"
22 #include "Attributes/Attributes.h"
23 
24 #include <cstdlib>
25 // Class PSystem
26 // ------------------------------------------------------------------------
27 
29  Action(1, "PSYSTEM",
30  "The \"PSYSTEM\" statement sends a command string to the "
31  "operating system from all nodes.") {
33  ("CMD", "A system command to be executed");
34 
36 }
37 
38 
39 PSystem::PSystem(const std::string &name, PSystem *parent):
40  Action(name, parent)
41 {}
42 
43 
45 {}
46 
47 
48 PSystem *PSystem::clone(const std::string &name) {
49  return new PSystem(name, this);
50 }
51 
52 
54  std::string command = Attributes::getString(itsAttr[0]);
55 
56  int res = system(command.c_str());
57  if (res!=0)
58  ERRORMSG("SYSTEM call failed" << endl);
59 }
60 
61 void PSystem::parse(Statement &statement) {
62  parseShortcut(statement);
63 }
virtual ~PSystem()
Definition: PSystem.cpp:44
virtual void parseShortcut(Statement &)
Parser for single-attribute commands.
Definition: Object.cpp:132
The base class for all OPAL actions.
Definition: Action.h:30
#define ERRORMSG(msg)
Definition: IpplInfo.h:399
std::vector< Attribute > itsAttr
The object attributes (see Attribute.hh).
Definition: Object.h:214
virtual void execute()
Execute the command.
Definition: PSystem.cpp:53
Interface for statements.
Definition: Statement.h:38
void registerOwnership(const AttributeHandler::OwnerType &itsClass) const
Definition: Object.cpp:194
virtual PSystem * clone(const std::string &name)
Make clone.
Definition: PSystem.cpp:48
const std::string name
PSystem()
Exemplar constructor.
Definition: PSystem.cpp:28
The SYSTEM command.
Definition: PSystem.h:28
virtual void parse(Statement &)
Parse command (special for one-attribute command).
Definition: PSystem.cpp:61
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