OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
Value.cpp
Go to the documentation of this file.
1 // ------------------------------------------------------------------------
2 // $RCSfile: Value.cpp,v $
3 // ------------------------------------------------------------------------
4 // $Revision: 1.1.1.1 $
5 // ------------------------------------------------------------------------
6 // Copyright: see Copyright.readme
7 // ------------------------------------------------------------------------
8 //
9 // Class: Value
10 // The class for the OPAL VALUE command.
11 //
12 // ------------------------------------------------------------------------
13 //
14 // $Date: 2000/03/27 09:33:37 $
15 // $Author: Andreas Adelmann $
16 //
17 // ------------------------------------------------------------------------
18 
19 #include "BasicActions/Value.h"
20 #include "Attributes/Attributes.h"
21 #include <iomanip>
22 #include <iostream>
23 #include <vector>
24 
25 
26 // Class Value
27 // ------------------------------------------------------------------------
28 
29 extern Inform *gmsg;
30 
32  Action(1, "VALUE",
33  "The \"VALUE\" statement prints a list of expressions and "
34  "their values.") {
36  ("VALUE", "The values to be evaluated");
37 
39 }
40 
41 
42 Value::Value(const std::string &name, Value *parent):
43  Action(name, parent)
44 {}
45 
46 
48 {}
49 
50 
51 Value *Value::clone(const std::string &name) {
52  return new Value(name, this);
53 }
54 
55 
57  *gmsg << "\nvalue: " << itsAttr[0] << "={";
58  // std::streamsize old_prec = *gmsg.precision(12);
59  const std::vector<double> array = Attributes::getRealArray(itsAttr[0]);
60  std::vector<double>::const_iterator i = array.begin();
61 
62  while(i != array.end()) {
63  *gmsg << *i++;
64  if(i == array.end()) break;
65  *gmsg << ",";
66  }
67 
68  *gmsg << "}\n" << endl;
69  // *gmsg.precision(old_prec);
70 }
71 
72 
73 void Value::parse(Statement &statement) {
74  parseShortcut(statement);
75 }
Value()
Exemplar constructor.
Definition: Value.cpp:31
virtual void parseShortcut(Statement &)
Parser for single-attribute commands.
Definition: Object.cpp:132
The base class for all OPAL actions.
Definition: Action.h:30
The VALUE command.
Definition: Value.h:28
Inform * gmsg
Definition: Main.cpp:21
std::vector< Attribute > itsAttr
The object attributes (see Attribute.hh).
Definition: Object.h:214
virtual void execute()
Execute the command.
Definition: Value.cpp:56
Interface for statements.
Definition: Statement.h:38
void registerOwnership(const AttributeHandler::OwnerType &itsClass) const
Definition: Object.cpp:194
std::vector< double > getRealArray(const Attribute &attr)
Get array value.
Definition: Attributes.cpp:258
virtual Value * clone(const std::string &name)
Make clone.
Definition: Value.cpp:51
virtual ~Value()
Definition: Value.cpp:47
const std::string name
Attribute makeRealArray(const std::string &name, const std::string &help)
Create real array attribute.
Definition: Attributes.cpp:253
Definition: Inform.h:41
virtual void parse(Statement &)
Parse command (special for one-attribute command).
Definition: Value.cpp:73
Inform & endl(Inform &inf)
Definition: Inform.cpp:42