CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ColumnBuffer.cc
Go to the documentation of this file.
1 #include "Alignment/Geners/interface/ColumnBuffer.hh"
2 #include "Alignment/Geners/interface/streamposIO.hh"
3 
4 namespace gs {
5  namespace Private {
6  bool ColumnBuffer::write(std::ostream& os) const
7  {
8  write_pod(os, firstrow);
9  write_pod(os, lastrowp1);
10  const unsigned char isPod = (podsize ? 1 : 0);
11  write_pod(os, isPod);
12  if (isPod)
13  write_pod(os, podsize);
14  else
15  write_pod_vector(os, offsets);
16  return !os.fail() && buf.write(os);
17  }
18 
19  void ColumnBuffer::restore(const ClassId& id, const ClassId& bufId,
20  std::istream& is, ColumnBuffer* obj)
21  {
22  assert(obj);
23  obj->classId().ensureSameId(id);
24 
25  read_pod(is, &obj->firstrow);
26  read_pod(is, &obj->lastrowp1);
27  unsigned char isPod;
28  read_pod(is, &isPod);
29  if (isPod)
30  {
31  obj->offsets.clear();
32  read_pod(is, &obj->podsize);
33  }
34  else
35  {
36  obj->podsize = 0;
37  read_pod_vector(is, &obj->offsets);
38  }
39  if (is.fail()) throw IOReadFailure(
40  "In gs::Private::ColumnBuffer::restore: input stream failure");
41 
42  // Size of a POD object can not be zero
43  if (isPod && !obj->podsize) throw IOInvalidData(
44  "In gs::Private::ColumnBuffer::restore: corrupted record");
45 
46  CharBuffer::restore(bufId, is, &obj->buf);
47  }
48 
49  bool ColumnBuffer::operator==(const ColumnBuffer& r) const
50  {
51  return firstrow == r.firstrow &&
52  lastrowp1 == r.lastrowp1 &&
53  podsize == r.podsize &&
54  offsets == r.offsets &&
55  buf == r.buf;
56  }
57 
58  const ClassId& ColumnBuffer::static_classId()
59  {
60  static const ClassId classId_(ClassId(classname(), version()));
61  return classId_;
62  }
63  }
64 }
bool operator==(const QGLikelihoodParameters &lhs, const QGLikelihoodCategory &rhs)
Test if parameters are compatible with category.