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