GSE++ library: reading and writing GSE waveforms

◆ operator()()

intT GSE2::waveform::TDAT2read::operator() ( std::istream &  is)
inherited

get another value from the stream

Definition at line 122 of file gsexx_TDAT2.cc.

References GSE2::waveform::TDAT2sum::add(), GSE2::waveform::TDAT2sum::checksum(), GSE2::waveform::TDAT2read::convert(), GSE2::waveform::TDAT2sum::hot(), GSE2::waveform::TDAT2sum::nread(), GSE2::waveform::TCHK2::read(), GSE2::Terror::silent, and GSE2::waveform::TCHK2::value().

123 {
124  intT retval;
125  // check for DAT2 line
126  if (this->TDAT2sum::nread() == 0)
127  {
128  std::string lineID;
129  is >> lineID;
130  if (!GSEIDmatch<TDAT2sum>(lineID)) throw
131  Terror("ERROR (TDAT2::read): missing DAT2 line!");
132  char c=' ';
133  while (c != '\n') { is.get(c); }
134  }
135 
136  if (!this->TDAT2sum::hot()) throw
137  Terror("ERROR (TDAT2::read): requesting more samples than specified!");
138  retval=convert(is);
139  this->TDAT2sum::add(retval);
140 
141  // check checksum
142  if (!TDAT2sum::hot()) {
143  TCHK2 checksum;
144  checksum.read(is);
145  if (this->TDAT2sum::checksum().value()!=checksum.value())
146  {
147  if (!Terror::silent)
148  {
149  std::cerr << "checksum read: " << checksum.value()
150  << " calculated: " << this->TDAT2sum::checksum().value()
151  << std::endl;
152  }
153  throw
154  Terror("ERROR (TDAT2::read): conflicting checksum in CHK2 line!");
155  }
156  }
157  return(retval);
158 }
virtual intT convert(std::istream &is)=0
get from stream: user must define
int intT
All GSE2 waveform data is based on 4 byte integers.
Definition: gsexx.h:89
void read(std::istream &is)
read CHK2 line from istream
void add(const intT &value)
count a sample
Definition: gsexx.h:322
bool hot() const
return true if not all samples are processed
Definition: gsexx.h:304
const TCHK2 & checksum() const
return the checksum
Definition: gsexx.h:298
intT nread() const
return the number of samples read
Definition: gsexx.h:300
intT value() const
Return the checksum value.
Definition: gsexx.h:181
static bool silent
be silent?
Definition: gsexx.h:77
Here is the call graph for this function: