OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
SCell.cpp
Go to the documentation of this file.
1 // ------------------------------------------------------------------------
2 // $RCSfile: SCell.cpp,v $
3 // ------------------------------------------------------------------------
4 // $Revision: 1.3 $
5 // ------------------------------------------------------------------------
6 // Copyright: see Copyright.readme
7 // ------------------------------------------------------------------------
8 //
9 // Template class SCell:
10 // Reference to a table cell.
11 //
12 // ------------------------------------------------------------------------
13 //
14 // $Date: 2002/01/22 15:16:02 $
15 // $Author: jsberg $
16 //
17 // ------------------------------------------------------------------------
18 
19 #include "Expressions/SCell.h"
20 #include "AbstractObjects/Table.h"
21 #include "Channels/ConstChannel.h"
22 
23 #include <iostream>
24 
25 using namespace std;
26 
27 // Class SCell
28 // ------------------------------------------------------------------------
29 
30 
31 namespace Expressions {
32 
33  SCell::SCell
34  (const std::string &tab, const PlaceRep &place, const std::string &col):
35  tab_name(tab), position(place), col_name(col), itsChannel(0)
36  {}
37 
38 
39  SCell::~SCell() {
40  delete itsChannel;
41  }
42 
43 
44  Scalar<double> *SCell::clone() const {
45  return new SCell(tab_name, position, col_name);
46  }
47 
48 
49  double SCell::evaluate() const {
50  // Define table pointer and refill the table if required.
51  Table *table = Table::find(tab_name);
52  table->fill();
53 
54  // Return value of table cell.
55  return table->getCell(position, col_name);
56  }
57 
58 
59  void SCell::print(std::ostream &os, int) const {
60  os << tab_name << "->" << position;
61  os << "->" << col_name;
62  return;
63  }
64 
65 }
virtual void fill()=0
Refill the buffer.
Representation of a place within a beam line or sequence.
Definition: PlaceRep.h:41
A scalar expression referring to a table cell.
Definition: SCell.h:36
static Table * find(const std::string &name)
Find named Table.
Definition: Table.cpp:41
virtual double getCell(const PlaceRep &row, const std::string &col)=0
Return value in selected table cell.
The base class for all OPAL tables.
Definition: Table.h:42