OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
ARow.cpp
Go to the documentation of this file.
1 // ------------------------------------------------------------------------
2 // $RCSfile: ARow.cpp,v $
3 // ------------------------------------------------------------------------
4 // $Revision: 1.3 $
5 // ------------------------------------------------------------------------
6 // Copyright: see Copyright.readme
7 // ------------------------------------------------------------------------
8 //
9 // Class: ARow
10 // Expression class. Generates a list of values from a TABLE() function.
11 //
12 // ------------------------------------------------------------------------
13 //
14 // $Date: 2002/01/22 15:16:02 $
15 // $Author: jsberg $
16 //
17 // ------------------------------------------------------------------------
18 
19 #include "Expressions/ARow.h"
20 #include "AbstractObjects/Table.h"
21 
22 #include <iostream>
23 
24 using namespace std;
25 
26 // Class ARow
27 // ------------------------------------------------------------------------
28 
29 namespace Expressions {
30 
31  ARow::ARow(const ARow &rhs):
32  OArray<double>(rhs), tabName(rhs.tabName), position(rhs.position),
33  columns(rhs.columns)
34  {}
35 
36 
37  ARow::ARow(const std::string &tName, const PlaceRep &row,
38  const std::vector<std::string> &cols):
39  OArray<double>(), tabName(tName), position(row), columns(cols)
40  {}
41 
42 
44  {}
45 
46 
48  return new ARow(*this);
49  }
50 
51 
52  std::vector<double> ARow::evaluate() const {
53  Table *table = Table::find(tabName);
54  table->fill();
55  return table->getRow(position, columns);
56  }
57 
58 
59  void ARow::print(std::ostream &os, int) const {
60  os << "ROW(" << tabName << ',' << position << ",{";
61  std::vector<std::string>::const_iterator i = columns.begin();
62 
63  while(i != columns.end()) {
64  os << '"' << *i << '"';
65  if(++i == columns.end()) break;
66  os << ',';
67  }
68  os << "})";
69  }
70 
71 }
virtual void fill()=0
Refill the buffer.
const std::vector< std::string > columns
Definition: ARow.h:71
const std::string tabName
Definition: ARow.h:65
Representation of a place within a beam line or sequence.
Definition: PlaceRep.h:41
virtual std::vector< double > evaluate() const
Evaluate.
Definition: ARow.cpp:52
static Table * find(const std::string &name)
Find named Table.
Definition: Table.cpp:41
virtual void print(std::ostream &os, int precedence=99) const
Print expression.
Definition: ARow.cpp:59
An array expression defined as a table row.
Definition: ARow.h:35
The base class for all OPAL tables.
Definition: Table.h:42
PlaceRep position
Definition: ARow.h:68
virtual OArray< double > * clone() const
Make clone.
Definition: ARow.cpp:47
An array expression.
Definition: Expressions.h:149
virtual std::vector< double > getRow(const PlaceRep &, const std::vector< std::string > &)=0
Return a table row.