OPAL (Object Oriented Parallel Accelerator Library)  2021.1.99
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 
25 // Class ARow
26 // ------------------------------------------------------------------------
27 
28 namespace Expressions {
29 
30  ARow::ARow(const ARow &rhs):
31  OArray<double>(rhs), tabName(rhs.tabName), position(rhs.position),
32  columns(rhs.columns)
33  {}
34 
35 
36  ARow::ARow(const std::string &tName, const PlaceRep &row,
37  const std::vector<std::string> &cols):
38  OArray<double>(), tabName(tName), position(row), columns(cols)
39  {}
40 
41 
43  {}
44 
45 
47  return new ARow(*this);
48  }
49 
50 
51  std::vector<double> ARow::evaluate() const {
52  Table *table = Table::find(tabName);
53  table->fill();
54  return table->getRow(position, columns);
55  }
56 
57 
58  void ARow::print(std::ostream &os, int) const {
59  os << "ROW(" << tabName << ',' << position << ",{";
60  std::vector<std::string>::const_iterator i = columns.begin();
61 
62  while(i != columns.end()) {
63  os << '"' << *i << '"';
64  if(++i == columns.end()) break;
65  os << ',';
66  }
67  os << "})";
68  }
69 
70 }
Representation objects and parsers for attribute expressions.
Definition: Expressions.h:64
An array expression.
Definition: Expressions.h:142
Representation of a place within a beam line or sequence.
Definition: PlaceRep.h:41
The base class for all OPAL tables.
Definition: Table.h:42
virtual void fill()=0
Refill the buffer.
virtual std::vector< double > getRow(const PlaceRep &, const std::vector< std::string > &)=0
Return a table row.
static Table * find(const std::string &name)
Find named Table.
Definition: Table.cpp:41
An array expression defined as a table row.
Definition: ARow.h:35
virtual OArray< double > * clone() const
Make clone.
Definition: ARow.cpp:46
const std::string tabName
Definition: ARow.h:65
PlaceRep position
Definition: ARow.h:68
virtual void print(std::ostream &os, int precedence=99) const
Print expression.
Definition: ARow.cpp:58
virtual std::vector< double > evaluate() const
Evaluate.
Definition: ARow.cpp:51
const std::vector< std::string > columns
Definition: ARow.h:71