CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DualAxis.cc
Go to the documentation of this file.
2 
3 #include "Alignment/Geners/interface/binaryIO.hh"
4 #include "Alignment/Geners/interface/IOException.hh"
5 #include "Alignment/Geners/interface/CPP11_auto_ptr.hh"
6 
7 namespace npstat {
8  bool DualAxis::write(std::ostream& of) const
9  {
10  unsigned char c = uniform_;
11  gs::write_pod(of, c);
12  if (uniform_)
13  return !of.fail() && u_.classId().write(of) && u_.write(of);
14  else
15  return !of.fail() && a_.classId().write(of) && a_.write(of);
16  }
17 
18  DualAxis* DualAxis::read(const gs::ClassId& id, std::istream& in)
19  {
20  static const gs::ClassId current(gs::ClassId::makeId<DualAxis>());
21  current.ensureSameId(id);
22 
23  unsigned char c;
24  gs::read_pod(in, &c);
25  gs::ClassId clid(in, 1);
26  if (in.fail())
27  throw gs::IOReadFailure("In npstat::DualAxis::read: "
28  "input stream failure");
29  if (c)
30  {
31  CPP11_auto_ptr<UniformAxis> axis(UniformAxis::read(clid, in));
32  return new DualAxis(*axis);
33  }
34  else
35  {
36  CPP11_auto_ptr<GridAxis> axis(GridAxis::read(clid, in));
37  return new DualAxis(*axis);
38  }
39  }
40 }
gs::ClassId classId() const
Definition: GridAxis.h:115
Represent both equidistant and non-uniform coordinate sets for rectangular grids. ...
UniformAxis u_
Definition: DualAxis.h:120
bool write(std::ostream &of) const
Definition: UniformAxis.cc:108
GridAxis a_
Definition: DualAxis.h:119
static DualAxis * read(const gs::ClassId &id, std::istream &in)
Definition: DualAxis.cc:18
static UniformAxis * read(const gs::ClassId &id, std::istream &in)
Definition: UniformAxis.cc:117
bool write(std::ostream &of) const
Definition: DualAxis.cc:8
static GridAxis * read(const gs::ClassId &id, std::istream &in)
Definition: GridAxis.cc:154
bool write(std::ostream &of) const
Definition: GridAxis.cc:144
gs::ClassId classId() const
Definition: UniformAxis.h:78